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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

187 def anyOf(listOfKeys,dict,opt=None):
188  for k in listOfKeys:
189  if k in dict:
190  toReturn=dict[k]
191  dict.pop(k)
192  return toReturn
193  if opt!=None:
194  return opt
195  else:
196  raise Exception("any of "+','.join(listOfKeys)+" are mandatory entries of --output options")
197 
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 95 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().

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

◆ filesFromDASQuery()

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

Definition at line 139 of file ConfigBuilder.py.

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

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

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

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

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

103 def filesFromList(fileName,s=None):
104  import os
105  import FWCore.ParameterSet.Config as cms
106  prim=[]
107  sec=[]
108  for line in open(fileName,'r'): 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 but keep the order
117  file_seen = set()
118  prim = [f for f in prim if not (f in file_seen or file_seen.add(f))]
119  file_seen = set()
120  sec = [f for f in sec if not (f in file_seen or file_seen.add(f))]
121  if s:
122  if not hasattr(s,"fileNames"):
123  s.fileNames=cms.untracked.vstring(prim)
124  else:
125  s.fileNames.extend(prim)
126  if len(sec)!=0:
127  if not hasattr(s,"secondaryFileNames"):
128  s.secondaryFileNames=cms.untracked.vstring(sec)
129  else:
130  s.secondaryFileNames.extend(sec)
131  print("found files: ",prim)
132  if len(prim)==0:
133  raise Exception("There are not files in input from the file list")
134  if len(sec)!=0:
135  print("found parent files:",sec)
136  return (prim,sec)
137 
138 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def filesFromList(fileName, s=None)