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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

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

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

◆ filesFromDASQuery()

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

Definition at line 141 of file ConfigBuilder.py.

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

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

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

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

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

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