CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
ConfigBuilder Namespace Reference

Classes

class  ConfigBuilder
 
class  Options
 

Functions

def anyOf
 
def dumpPython
 
def filesFromDASQuery
 
def filesFromList
 

Variables

string __source__ = "$Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v $"
 
string __version__ = "$Revision: 1.19 $"
 
tuple defaultOptions = Options()
 

Function Documentation

def ConfigBuilder.anyOf (   listOfKeys,
  dict,
  opt = None 
)

Definition at line 187 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")
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 95 of file ConfigBuilder.py.

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(), and Config.TestModuleCommand.testTaskPlaceholder().

95 
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:
return "process."+name+" = " + theObject.dumpPython()+"\n"
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().

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)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
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().

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'):
110  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)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

string ConfigBuilder.__source__ = "$Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v $"

Definition at line 5 of file ConfigBuilder.py.

string ConfigBuilder.__version__ = "$Revision: 1.19 $"

Definition at line 4 of file ConfigBuilder.py.

tuple ConfigBuilder.defaultOptions = Options()

Definition at line 23 of file ConfigBuilder.py.