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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

188 def anyOf(listOfKeys,dict,opt=None):
189  for k in listOfKeys:
190  if k in dict:
191  toReturn=dict[k]
192  dict.pop(k)
193  return toReturn
194  if opt!=None:
195  return opt
196  else:
197  raise Exception("any of "+','.join(listOfKeys)+" are mandatory entries of --output options")
198 
def anyOf(listOfKeys, dict, opt=None)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ dumpPython()

def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 96 of file ConfigBuilder.py.

Referenced by htmlCreator.create(), pdfCreator.create(), ConfigBuilder.ConfigBuilder.prepare(), Config.TestModuleCommand.testConditionalTaskPlaceholder(), 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().

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

◆ filesFromDASQuery()

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

Definition at line 140 of file ConfigBuilder.py.

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

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

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

◆ filesFromList()

def ConfigBuilder.filesFromList (   fileName,
  s = None 
)

Definition at line 104 of file ConfigBuilder.py.

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

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

104 def filesFromList(fileName,s=None):
105  import os
106  import FWCore.ParameterSet.Config as cms
107  prim=[]
108  sec=[]
109  for line in open(fileName,'r'): if line.count(".root")>=2:
110  #two files solution...
111  entries=line.replace("\n","").split()
112  prim.append(entries[0])
113  sec.append(entries[1])
114  elif (line.find(".root")!=-1):
115  entry=line.replace("\n","")
116  prim.append(entry)
117  # remove any duplicates but keep the order
118  file_seen = set()
119  prim = [f for f in prim if not (f in file_seen or file_seen.add(f))]
120  file_seen = set()
121  sec = [f for f in sec if not (f in file_seen or file_seen.add(f))]
122  if s:
123  if not hasattr(s,"fileNames"):
124  s.fileNames=cms.untracked.vstring(prim)
125  else:
126  s.fileNames.extend(prim)
127  if len(sec)!=0:
128  if not hasattr(s,"secondaryFileNames"):
129  s.secondaryFileNames=cms.untracked.vstring(sec)
130  else:
131  s.secondaryFileNames.extend(sec)
132  print("found files: ",prim)
133  if len(prim)==0:
134  raise Exception("There are not files in input from the file list")
135  if len(sec)!=0:
136  print("found parent files:",sec)
137  return (prim,sec)
138 
139 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def filesFromList(fileName, s=None)