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

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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

◆ dumpPython()

def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 93 of file ConfigBuilder.py.

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

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

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

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

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:101
ConfigBuilder.filesFromDASQuery
def filesFromDASQuery(query, option="", s=None)
Definition: ConfigBuilder.py:135
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:183
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:93