CMS 3D CMS Logo

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

Classes

class  ConfigBuilder
 
class  Options
 

Functions

def anyOf
 
def dumpPython
 
def filesFromDASQuery
 
def filesFromList
 
def MassReplaceInputTag
 

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

References join().

180 def anyOf(listOfKeys,dict,opt=None):
181  for k in listOfKeys:
182  if k in dict:
183  toReturn=dict[k]
184  dict.pop(k)
185  return toReturn
186  if opt!=None:
187  return opt
188  else:
189  raise Exception("any of "+','.join(listOfKeys)+" are mandatory entries of --output options")
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def ConfigBuilder.dumpPython (   process,
  name 
)

Definition at line 84 of file ConfigBuilder.py.

Referenced by EnablePSetHistory.new_recurseDumpModifications_(), and SequenceTypes.TestModuleCommand.testCopyAndExclude().

84 
85 def dumpPython(process,name):
86  theObject = getattr(process,name)
87  if isinstance(theObject,cms.Path) or isinstance(theObject,cms.EndPath) or isinstance(theObject,cms.Sequence):
88  return "process."+name+" = " + theObject.dumpPython("process")
89  elif isinstance(theObject,_Module) or isinstance(theObject,cms.ESProducer):
90  return "process."+name+" = " + theObject.dumpPython()+"\n"
91  else:
return "process."+name+" = " + theObject.dumpPython()+"\n"
def ConfigBuilder.filesFromDASQuery (   query,
  option = "",
  s = None 
)

Definition at line 126 of file ConfigBuilder.py.

References split.

Referenced by ConfigBuilder.ConfigBuilder.filesFromOption(), and ConfigBuilder.ConfigBuilder.prepare_DATAMIX().

127 def filesFromDASQuery(query,option="",s=None):
128  import os,time
129  import FWCore.ParameterSet.Config as cms
130  prim=[]
131  sec=[]
132  print "the query is",query
133  eC=5
134  count=0
135  while eC!=0 and count<3:
136  if count!=0:
137  print 'Sleeping, then retrying DAS'
138  time.sleep(100)
139  p = Popen('das_client %s --query "%s"'%(option,query), stdout=PIPE,shell=True)
140  pipe=p.stdout.read()
141  tupleP = os.waitpid(p.pid, 0)
142  eC=tupleP[1]
143  count=count+1
144  if eC==0:
145  print "DAS succeeded after",count,"attempts",eC
146  else:
147  print "DAS failed 3 times- I give up"
148  for line in pipe.split('\n'):
149  if line.count(".root")>=2:
150  #two files solution...
151  entries=line.replace("\n","").split()
152  if not entries[0] in prim:
153  prim.append(entries[0])
154  if not entries[1] in sec:
155  sec.append(entries[1])
156  elif (line.find(".root")!=-1):
157  entry=line.replace("\n","")
158  if not entry in prim:
159  prim.append(entry)
160  if s:
161  if not hasattr(s,"fileNames"):
162  s.fileNames=cms.untracked.vstring(prim)
163  else:
164  s.fileNames.extend(prim)
165  if len(sec)!=0:
166  if not hasattr(s,"secondaryFileNames"):
167  s.secondaryFileNames=cms.untracked.vstring(sec)
168  else:
169  s.secondaryFileNames.extend(sec)
170  print "found files: ",prim
171  if len(sec)!=0:
172  print "found parent files:",sec
173  return (prim,sec)
double split
Definition: MVATrainer.cc:139
def ConfigBuilder.filesFromList (   fileName,
  s = None 
)

Definition at line 92 of file ConfigBuilder.py.

References split.

Referenced by ConfigBuilder.ConfigBuilder.filesFromOption(), and ConfigBuilder.ConfigBuilder.prepare_DATAMIX().

92 
93 def filesFromList(fileName,s=None):
94  import os
95  import FWCore.ParameterSet.Config as cms
96  prim=[]
97  sec=[]
98  for line in open(fileName,'r'):
99  if line.count(".root")>=2:
100  #two files solution...
101  entries=line.replace("\n","").split()
102  if not entries[0] in prim:
103  prim.append(entries[0])
104  if not entries[1] in sec:
105  sec.append(entries[1])
106  elif (line.find(".root")!=-1):
107  entry=line.replace("\n","")
108  if not entry in prim:
109  prim.append(entry)
110  if s:
111  if not hasattr(s,"fileNames"):
112  s.fileNames=cms.untracked.vstring(prim)
113  else:
114  s.fileNames.extend(prim)
115  if len(sec)!=0:
116  if not hasattr(s,"secondaryFileNames"):
117  s.secondaryFileNames=cms.untracked.vstring(sec)
118  else:
119  s.secondaryFileNames.extend(sec)
120  print "found files: ",prim
121  if len(prim)==0:
122  raise Exception("There are not files in input from the file list")
123  if len(sec)!=0:
124  print "found parent files:",sec
125  return (prim,sec)
double split
Definition: MVATrainer.cc:139
def ConfigBuilder.MassReplaceInputTag (   aProcess,
  oldT = "rawDataCollector",
  newT = "rawDataRepacker" 
)

Definition at line 174 of file ConfigBuilder.py.

References relativeConstraints.keys, and helpers.massSearchReplaceAnyInputTag().

Referenced by customizeHLTforALL.customizeHLTforAll(), and customizeHLTforMC.customizeHLTforMC().

175 def MassReplaceInputTag(aProcess,oldT="rawDataCollector",newT="rawDataRepacker"):
176  from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
177  for s in aProcess.paths_().keys():
178  massSearchReplaceAnyInputTag(getattr(aProcess,s),oldT,newT)
def massSearchReplaceAnyInputTag
Definition: helpers.py:271

Variable Documentation

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

Definition at line 4 of file ConfigBuilder.py.

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

Definition at line 3 of file ConfigBuilder.py.

tuple ConfigBuilder.defaultOptions = Options()

Definition at line 17 of file ConfigBuilder.py.