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

References join().

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

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

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

◆ filesFromDASQuery()

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

Definition at line 142 of file ConfigBuilder.py.

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

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

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

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

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

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