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 184 of file ConfigBuilder.py.

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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

◆ dumpPython()

def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 94 of file ConfigBuilder.py.

94 def dumpPython(process,name):
95  theObject = getattr(process,name)
96  if isinstance(theObject,cms.Path) or isinstance(theObject,cms.EndPath) or isinstance(theObject,cms.Sequence):
97  return "process."+name+" = " + theObject.dumpPython()
98  elif isinstance(theObject,_Module) or isinstance(theObject,cms.ESProducer):
99  return "process."+name+" = " + theObject.dumpPython()+"\n"
100  else:
101  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 136 of file ConfigBuilder.py.

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

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 102 of file ConfigBuilder.py.

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

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:102
ConfigBuilder.filesFromDASQuery
def filesFromDASQuery(query, option="", s=None)
Definition: ConfigBuilder.py:136
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:184
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:94