CMS 3D CMS Logo

Classes | Functions
ConfigBuilder Namespace Reference

Classes

class  ConfigBuilder
 
class  Options
 

Functions

def anyOf (listOfKeys, dict, opt=None)
 
def dumpPython (process, name)
 
def filesFromDASQuery (query, option="", s=None)
 
def filesFromList (fileName, s=None)
 

Function Documentation

◆ anyOf()

def ConfigBuilder.anyOf (   listOfKeys,
  dict,
  opt = None 
)

Definition at line 182 of file ConfigBuilder.py.

182 def anyOf(listOfKeys,dict,opt=None):
183  for k in listOfKeys:
184  if k in dict:
185  toReturn=dict[k]
186  dict.pop(k)
187  return toReturn
188  if opt!=None:
189  return opt
190  else:
191  raise Exception("any of "+','.join(listOfKeys)+" are mandatory entries of --output options")
192 

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

◆ dumpPython()

def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 92 of file ConfigBuilder.py.

92 def dumpPython(process,name):
93  theObject = getattr(process,name)
94  if isinstance(theObject,cms.Path) or isinstance(theObject,cms.EndPath) or isinstance(theObject,cms.Sequence):
95  return "process."+name+" = " + theObject.dumpPython()
96  elif isinstance(theObject,_Module) or isinstance(theObject,cms.ESProducer):
97  return "process."+name+" = " + theObject.dumpPython()+"\n"
98  else:
99  return "process."+name+" = " + theObject.dumpPython()+"\n"

Referenced by htmlCreator.create(), pdfCreator.create(), ConfigBuilder.ConfigBuilder.prepare(), SequenceTypes.TestModuleCommand.testCopyAndExclude(), Config.TestModuleCommand.testDelete(), MassReplace.TestModuleCommand.testMassReplaceInputTag(), MassReplace.TestModuleCommand.testMassReplaceParam(), Config.TestModuleCommand.testPrefers(), Config.TestModuleCommand.testProcessDumpPython(), Config.TestModuleCommand.testSecSource(), Config.TestModuleCommand.testSubProcess(), Config.TestModuleCommand.testTaskPlaceholder(), and DTWorkflow.DTWorkflow.write_pset_file().

◆ filesFromDASQuery()

def ConfigBuilder.filesFromDASQuery (   query,
  option = "",
  s = None 
)

Definition at line 134 of file ConfigBuilder.py.

134 def filesFromDASQuery(query,option="",s=None):
135  import os,time
136  import FWCore.ParameterSet.Config as cms
137  prim=[]
138  sec=[]
139  print("the query is",query)
140  eC=5
141  count=0
142  while eC!=0 and count<3:
143  if count!=0:
144  print('Sleeping, then retrying DAS')
145  time.sleep(100)
146  p = Popen('dasgoclient %s --query "%s"'%(option,query), stdout=PIPE,shell=True, universal_newlines=True)
147  pipe=p.stdout.read()
148  tupleP = os.waitpid(p.pid, 0)
149  eC=tupleP[1]
150  count=count+1
151  if eC==0:
152  print("DAS succeeded after",count,"attempts",eC)
153  else:
154  print("DAS failed 3 times- I give up")
155  for line in pipe.split('\n'):
156  if line.count(".root")>=2:
157  #two files solution...
158  entries=line.replace("\n","").split()
159  prim.append(entries[0])
160  sec.append(entries[1])
161  elif (line.find(".root")!=-1):
162  entry=line.replace("\n","")
163  prim.append(entry)
164  # remove any duplicates
165  prim = sorted(list(set(prim)))
166  sec = sorted(list(set(sec)))
167  if s:
168  if not hasattr(s,"fileNames"):
169  s.fileNames=cms.untracked.vstring(prim)
170  else:
171  s.fileNames.extend(prim)
172  if len(sec)!=0:
173  if not hasattr(s,"secondaryFileNames"):
174  s.secondaryFileNames=cms.untracked.vstring(sec)
175  else:
176  s.secondaryFileNames.extend(sec)
177  print("found files: ",prim)
178  if len(sec)!=0:
179  print("found parent files:",sec)
180  return (prim,sec)
181 

References print(), and submitPVValidationJobs.split().

Referenced by ConfigBuilder.ConfigBuilder.addSource(), ConfigBuilder.ConfigBuilder.addStandardSequences(), and ConfigBuilder.ConfigBuilder.prepare_DATAMIX().

◆ filesFromList()

def ConfigBuilder.filesFromList (   fileName,
  s = None 
)

Definition at line 100 of file ConfigBuilder.py.

100 def filesFromList(fileName,s=None):
101  import os
102  import FWCore.ParameterSet.Config as cms
103  prim=[]
104  sec=[]
105  for line in open(fileName,'r'):
106  if line.count(".root")>=2:
107  #two files solution...
108  entries=line.replace("\n","").split()
109  prim.append(entries[0])
110  sec.append(entries[1])
111  elif (line.find(".root")!=-1):
112  entry=line.replace("\n","")
113  prim.append(entry)
114  # remove any duplicates
115  prim = sorted(list(set(prim)))
116  sec = sorted(list(set(sec)))
117  if s:
118  if not hasattr(s,"fileNames"):
119  s.fileNames=cms.untracked.vstring(prim)
120  else:
121  s.fileNames.extend(prim)
122  if len(sec)!=0:
123  if not hasattr(s,"secondaryFileNames"):
124  s.secondaryFileNames=cms.untracked.vstring(sec)
125  else:
126  s.secondaryFileNames.extend(sec)
127  print("found files: ",prim)
128  if len(prim)==0:
129  raise Exception("There are not files in input from the file list")
130  if len(sec)!=0:
131  print("found parent files:",sec)
132  return (prim,sec)
133 

References print(), and submitPVValidationJobs.split().

Referenced by ConfigBuilder.ConfigBuilder.addSource(), ConfigBuilder.ConfigBuilder.addStandardSequences(), and ConfigBuilder.ConfigBuilder.prepare_DATAMIX().

join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
ConfigBuilder.filesFromList
def filesFromList(fileName, s=None)
Definition: ConfigBuilder.py:100
ConfigBuilder.filesFromDASQuery
def filesFromDASQuery(query, option="", s=None)
Definition: ConfigBuilder.py:134
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
ConfigBuilder.anyOf
def anyOf(listOfKeys, dict, opt=None)
Definition: ConfigBuilder.py:182
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:92