CMS 3D CMS Logo

Public Member Functions | Properties | Private Member Functions | Private Attributes

Config::Process Class Reference

List of all members.

Public Member Functions

def __delattr__
def __init__
def __setattr__
def __setstate__
def add_
def analyzerNames
def analyzers_
def dumpConfig
def dumpPython
def endpaths_
def es_prefers_
def es_producers_
def es_sources_
def extend
def fillProcessDesc
def filterNames
def filters_
def globalReplace
def load
def looper_
def name_
def outputModules_
def pathNames
def paths_
def prefer
def producerNames
def producers_
def prune
def pruneModules
def pruneSequences
def psets_
def schedule_
def sequences_
def services_
def setLooper_
def setName_
def setPartialSchedule_
def setSchedule_
def setSource_
def setStrict
def setSubProcess_
def source_
def subProcess_
def validate
def vpsets_

Properties

 analyzers = property(analyzers_,doc="dictionary containing the analyzers for the process")
 endpaths = property(endpaths_,doc="dictionary containing the endpaths for the process")
 es_prefers = property(es_prefers_,doc="dictionary containing the es_prefers for the process")
 es_producers = property(es_producers_,doc="dictionary containing the es_producers for the process")
 es_sources = property(es_sources_,doc="dictionary containing the es_sources for the process")
 filters = property(filters_, doc="dictionary containing the filters for the process")
 looper = property(looper_,setLooper_,doc='the main looper or None if not set')
 outputModules = property(outputModules_,doc="dictionary containing the output_modules for the process")
 paths = property(paths_,doc="dictionary containing the paths for the process")
 process = property(name_,setName_, doc="name of the process")
 producers = property(producers_,doc="dictionary containing the producers for the process")
 psets = property(psets_,doc="dictionary containing the PSets for the process")
 schedule = property(schedule_,setSchedule_,doc='the schedule or None if not set')
 sequences = property(sequences_,doc="dictionary containing the sequences for the process")
 services = property(services_,doc="dictionary containing the services for the process")
 source = property(source_,setSource_,doc='the main source or None if not set')
 subProcess = property(subProcess_,setSubProcess_,doc='the SubProcess or None if not set')
 vpsets = property(vpsets_,doc="dictionary containing the PSets for the process")

Private Member Functions

def _dumpConfigESPrefers
def _dumpConfigNamedList
def _dumpConfigOptionallyNamedList
def _dumpConfigUnnamedList
def _dumpPython
def _dumpPythonList
def _findPreferred
def _insertInto
def _insertManyInto
def _insertOneInto
def _insertPaths
def _okToPlace
def _place
def _placeAnalyzer
def _placeEndPath
def _placeESPrefer
def _placeESProducer
def _placeESSource
def _placeFilter
def _placeLooper
def _placeOutputModule
def _placePath
def _placeProducer
def _placePSet
def _placeSequence
def _placeService
def _placeSource
def _placeSubProcess
def _placeVPSet
def _replaceInSequences
def _sequencesInDependencyOrder
def _validateSequence

Private Attributes

 __isStrict
 __processPSet
 __thelist

Detailed Description

Root class for a CMS configuration process

Definition at line 100 of file Config.py.


Constructor & Destructor Documentation

def Config::Process::__init__ (   self,
  name 
)

Definition at line 102 of file Config.py.

00103                            :
00104         self.__dict__['_Process__name'] = name
00105         self.__dict__['_Process__filters'] = {}
00106         self.__dict__['_Process__producers'] = {}
00107         self.__dict__['_Process__source'] = None
00108         self.__dict__['_Process__looper'] = None
00109         self.__dict__['_Process__subProcess'] = None
00110         self.__dict__['_Process__schedule'] = None
00111         self.__dict__['_Process__analyzers'] = {}
00112         self.__dict__['_Process__outputmodules'] = {}
00113         self.__dict__['_Process__paths'] = DictTypes.SortedKeysDict()    # have to keep the order
00114         self.__dict__['_Process__endpaths'] = DictTypes.SortedKeysDict() # of definition
00115         self.__dict__['_Process__sequences'] = {}
00116         self.__dict__['_Process__services'] = {}
00117         self.__dict__['_Process__essources'] = {}
00118         self.__dict__['_Process__esproducers'] = {}
00119         self.__dict__['_Process__esprefers'] = {}
00120         self.__dict__['_Process__psets']={}
00121         self.__dict__['_Process__vpsets']={}
00122         self.__dict__['_cloneToObjectDict'] = {}
00123         # policy switch to avoid object overwriting during extend/load
00124         self.__dict__['_Process__InExtendCall'] = False
00125         self.__dict__['_Process__partialschedules'] = {}
00126         self.__isStrict = False


Member Function Documentation

def Config::Process::__delattr__ (   self,
  name 
)

Definition at line 303 of file Config.py.

00304                               :
00305         if not hasattr(self,name):
00306             raise KeyError('process does not know about '+name)
00307         elif name.startswith('_Process__'):
00308             raise ValueError('this attribute cannot be deleted')
00309         else:
00310             # we have to remove it from all dictionaries/registries
00311             dicts = [item for item in self.__dict__.values() if (type(item)==dict or type(item)==DictTypes.SortedKeysDict)]
00312             for reg in dicts:
00313                 if reg.has_key(name): del reg[name]
00314             # if it was a labelable object, the label needs to be removed
00315             obj = getattr(self,name)
00316             if isinstance(obj,_Labelable):
00317                 getattr(self,name).setLabel(None)
00318             # now remove it from the process itself
00319             try:
00320                 del self.__dict__[name]
00321             except:
00322                 pass

def Config::Process::__setattr__ (   self,
  name,
  value 
)

Definition at line 253 of file Config.py.

00254                                     :
00255         # check if the name is well-formed (only _ and alphanumerics are allowed)
00256         if not name.replace('_','').isalnum():
00257             raise ValueError('The label '+name+' contains forbiden characters')
00258 
00259         # private variable exempt from all this
00260         if name.startswith('_Process__'):
00261             self.__dict__[name]=value
00262             return
00263         if not isinstance(value,_ConfigureComponent):
00264             raise TypeError("can only assign labels to an object which inherits from '_ConfigureComponent'\n"
00265                             +"an instance of "+str(type(value))+" will not work")
00266         if not isinstance(value,_Labelable) and not isinstance(value,Source) and not isinstance(value,Looper) and not isinstance(value,Schedule):
00267             if name == value.type_():
00268                 self.add_(value)
00269                 return
00270             else:
00271                 raise TypeError("an instance of "+str(type(value))+" can not be assigned the label '"+name+"'.\n"+
00272                                 "Please either use the label '"+value.type_()+" or use the 'add_' method instead.")
00273         #clone the item
00274         if self.__isStrict:
00275             newValue =value.copy()
00276             try:
00277               newValue._filename = value._filename
00278             except:
00279               pass
00280             value.setIsFrozen()
00281         else:
00282             newValue =value
00283         if not self._okToPlace(name, value, self.__dict__):
00284             msg = "Trying to override definition of process."+name
00285             msg += "\n new object defined in: "+value._filename
00286             msg += "\n existing object defined in: "+getattr(self,name)._filename
00287             raise ValueError(msg)
00288         # remove the old object of the name (if there is one)
00289         if hasattr(self,name) and not (getattr(self,name)==newValue):
00290             # Allow items in sequences from load() statements to have
00291             # degeneratate names, but if the user overwrites a name in the
00292             # main config, replace it everywhere
00293             if not self.__InExtendCall and isinstance(newValue, _Sequenceable):
00294                 self._replaceInSequences(name, newValue)
00295             self.__delattr__(name)
00296         self.__dict__[name]=newValue
00297         if isinstance(newValue,_Labelable):
00298             newValue.setLabel(name)
00299             self._cloneToObjectDict[id(value)] = newValue
00300             self._cloneToObjectDict[id(newValue)] = newValue
00301         #now put in proper bucket
00302         newValue._place(name,self)

def Config::Process::__setstate__ (   self,
  pkldict 
)
Unpickling hook.

Since cloneToObjectDict stores a hash of objects by their
id() it needs to be updated when unpickling to use the
new object id values instantiated during the unpickle.

Definition at line 141 of file Config.py.

00142                                    :
00143         """
00144         Unpickling hook.
00145 
00146         Since cloneToObjectDict stores a hash of objects by their
00147         id() it needs to be updated when unpickling to use the
00148         new object id values instantiated during the unpickle.
00149 
00150         """
00151         self.__dict__.update(pkldict)
00152         tmpDict = {}
00153         for value in self._cloneToObjectDict.values():
00154             tmpDict[id(value)] = value
00155         self.__dict__['_cloneToObjectDict'] = tmpDict
00156 
00157 

def Config::Process::_dumpConfigESPrefers (   self,
  options 
) [private]

Definition at line 545 of file Config.py.

00546                                            :
00547         result = ''
00548         for item in self.es_prefers_().itervalues():
00549             result +=options.indentation()+'es_prefer '+item.targetLabel_()+' = '+item.dumpConfig(options)
        return result
def Config::Process::_dumpConfigNamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 470 of file Config.py.

00471                                                          :
00472         returnValue = ''
00473         for name,item in items:
00474             returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpConfigOptionallyNamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 480 of file Config.py.

00481                                                                    :
00482         returnValue = ''
00483         for name,item in items:
00484             if name == item.type_():
00485                 name = ''
00486             returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpConfigUnnamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 475 of file Config.py.

00476                                                            :
00477         returnValue = ''
00478         for name,item in items:
00479             returnValue +=options.indentation()+typeName+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpPython (   self,
  d,
  options 
) [private]

Definition at line 599 of file Config.py.

00600                                      :
00601         result = ''
00602         for name, value in d.iteritems():
00603            result += value.dumpPythonAs(name,options)+'\n'
        return result
def Config::Process::_dumpPythonList (   self,
  d,
  options 
) [private]

Definition at line 550 of file Config.py.

00551                                          :
00552         returnValue = ''
00553         if isinstance(d, DictTypes.SortedKeysDict):
00554             for name,item in d.items():
00555                 returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n'
00556         else:
00557             for name,item in sorted(d.items()):
00558                 returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n'
        return returnValue
def Config::Process::_findPreferred (   self,
  esname,
  d,
  args,
  kargs 
) [private]

Definition at line 806 of file Config.py.

00807                                                      :
00808         # is esname a name in the dictionary?
00809         if esname in d:
00810             typ = d[esname].type_()
00811             if typ == esname:
00812                 self.__setattr__( esname+"_prefer", ESPrefer(typ,*args,**kargs) )
00813             else:
00814                 self.__setattr__( esname+"_prefer", ESPrefer(typ, esname,*args,**kargs) )
00815             return True
00816         else:
00817             # maybe it's an unnamed ESModule?
00818             found = False
00819             for name, value in d.iteritems():
00820                if value.type_() == esname:
00821                   if found:
00822                       raise RuntimeError("More than one ES module for "+esname)
00823                   found = True
00824                   self.__setattr__(esname+"_prefer",  ESPrefer(d[esname].type_()) )
00825             return found

def Config::Process::_insertInto (   self,
  parameterSet,
  itemDict 
) [private]

Definition at line 646 of file Config.py.

00647                                                  :
00648         for name,value in itemDict.iteritems():
            value.insertInto(parameterSet, name)
def Config::Process::_insertManyInto (   self,
  parameterSet,
  label,
  itemDict,
  tracked 
) [private]

Definition at line 656 of file Config.py.

00657                                                                      :
00658         l = []
00659         for name,value in itemDict.iteritems():
00660           newLabel = value.nameInProcessDesc_(name)
00661           l.append(newLabel)
00662           value.insertInto(parameterSet, name)
00663         # alphabetical order is easier to compare with old language
00664         l.sort()
        parameterSet.addVString(tracked, label, l)
def Config::Process::_insertOneInto (   self,
  parameterSet,
  label,
  item,
  tracked 
) [private]

Definition at line 649 of file Config.py.

00650                                                                 :
00651         vitems = []
00652         if not item == None:
00653             newlabel = item.nameInProcessDesc_(label)
00654             vitems = [newlabel]
00655             item.insertInto(parameterSet, newlabel)
        parameterSet.addVString(tracked, label, vitems)
def Config::Process::_insertPaths (   self,
  processPSet 
) [private]

Definition at line 665 of file Config.py.

00666                                        :
00667         scheduledPaths = []
00668         triggerPaths = []
00669         endpaths = []
00670         if self.schedule_() == None:
00671             # make one from triggerpaths & endpaths
00672             for name,value in self.paths_().iteritems():
00673                 scheduledPaths.append(name)
00674                 triggerPaths.append(name)
00675             for name,value in self.endpaths_().iteritems():
00676                 scheduledPaths.append(name)
00677                 endpaths.append(name)
00678         else:
00679             for path in self.schedule_():
00680                pathname = path.label_()
00681                scheduledPaths.append(pathname)
00682                if self.endpaths_().has_key(pathname):
00683                    endpaths.append(pathname)
00684                else:
00685                    triggerPaths.append(pathname)
00686         processPSet.addVString(True, "@end_paths", endpaths)
00687         processPSet.addVString(True, "@paths", scheduledPaths)
00688         # trigger_paths are a little different
00689         p = processPSet.newPSet()
00690         p.addVString(True, "@trigger_paths", triggerPaths)
00691         processPSet.addPSet(True, "@trigger_paths", p)
00692         # add all these paths
00693         pathValidator = PathValidator()
00694         endpathValidator = EndPathValidator()
00695         for triggername in triggerPaths:
00696             #self.paths_()[triggername].insertInto(processPSet, triggername, self.sequences_())
00697             pathValidator.setLabel(triggername)
00698             self.paths_()[triggername].visit(pathValidator)
00699             self.paths_()[triggername].insertInto(processPSet, triggername, self.__dict__)
00700         for endpathname in endpaths:
00701             #self.endpaths_()[endpathname].insertInto(processPSet, endpathname, self.sequences_())
00702             endpathValidator.setLabel(endpathname)
00703             self.endpaths_()[endpathname].visit(endpathValidator)
00704             self.endpaths_()[endpathname].insertInto(processPSet, endpathname, self.__dict__)
00705         processPSet.addVString(False, "@filters_on_endpaths", endpathValidator.filtersOnEndpaths)

def Config::Process::_okToPlace (   self,
  name,
  mod,
  d 
) [private]

Definition at line 338 of file Config.py.

00339                                       :
00340         if not self.__InExtendCall:
00341             # if going
00342             return True
00343         elif not self.__isStrict:
00344             return True
00345         elif name in d:
00346             # if there's an old copy, and the new one
00347             # hasn't been modified, we're done.  Still
00348             # not quite safe if something has been defined twice.
00349             #  Need to add checks
00350             if mod._isModified:
00351                 if d[name]._isModified:
00352                     return False
00353                 else:
00354                     return True
00355             else:
00356                 return True
00357         else:
00358             return True

def Config::Process::_place (   self,
  name,
  mod,
  d 
) [private]

Definition at line 359 of file Config.py.

00360                                   :
00361         if self._okToPlace(name, mod, d):
00362             if self.__isStrict and isinstance(mod, _ModuleSequenceType):
00363                 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
00364             else:
00365                 d[name] = mod
00366             if isinstance(mod,_Labelable):
               mod.setLabel(name)
def Config::Process::_placeAnalyzer (   self,
  name,
  mod 
) [private]

Definition at line 373 of file Config.py.

00374                                      :
        self._place(name, mod, self.__analyzers)
def Config::Process::_placeEndPath (   self,
  name,
  mod 
) [private]

Definition at line 382 of file Config.py.

00383                                     :
00384         self._validateSequence(mod, name)
00385         try:
00386             self._place(name, mod, self.__endpaths)
00387         except ModuleCloneError, msg:
00388             context = format_outerframe(4)
            raise Exception("%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
def Config::Process::_placeESPrefer (   self,
  name,
  mod 
) [private]

Definition at line 394 of file Config.py.

00395                                      :
        self._place(name, mod, self.__esprefers)
def Config::Process::_placeESProducer (   self,
  name,
  mod 
) [private]

Definition at line 392 of file Config.py.

00393                                        :
        self._place(name, mod, self.__esproducers)
def Config::Process::_placeESSource (   self,
  name,
  mod 
) [private]

Definition at line 396 of file Config.py.

00397                                      :
        self._place(name, mod, self.__essources)
def Config::Process::_placeFilter (   self,
  name,
  mod 
) [private]

Definition at line 371 of file Config.py.

00372                                    :
        self._place(name, mod, self.__filters)
def Config::Process::_placeLooper (   self,
  name,
  mod 
) [private]

Definition at line 410 of file Config.py.

00411                                    :
00412         if name != 'looper':
00413             raise ValueError("The label '"+name+"' can not be used for a Looper.  Only 'looper' is allowed.")
00414         self.__dict__['_Process__looper'] = mod
        self.__dict__[mod.type_()] = mod
def Config::Process::_placeOutputModule (   self,
  name,
  mod 
) [private]

Definition at line 367 of file Config.py.

00368                                          :
        self._place(name, mod, self.__outputmodules)
def Config::Process::_placePath (   self,
  name,
  mod 
) [private]

Definition at line 375 of file Config.py.

00376                                  :
00377         self._validateSequence(mod, name)
00378         try:
00379             self._place(name, mod, self.__paths)
00380         except ModuleCloneError, msg:
00381             context = format_outerframe(4)
            raise Exception("%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
def Config::Process::_placeProducer (   self,
  name,
  mod 
) [private]

Definition at line 369 of file Config.py.

00370                                      :
        self._place(name, mod, self.__producers)
def Config::Process::_placePSet (   self,
  name,
  mod 
) [private]

Definition at line 398 of file Config.py.

00399                                  :
        self._place(name, mod, self.__psets)
def Config::Process::_placeSequence (   self,
  name,
  mod 
) [private]

Definition at line 389 of file Config.py.

00390                                      :
00391         self._validateSequence(mod, name)
        self._place(name, mod, self.__sequences)
def Config::Process::_placeService (   self,
  typeName,
  mod 
) [private]

Definition at line 420 of file Config.py.

00421                                         :
00422         self._place(typeName, mod, self.__services)
        self.__dict__[typeName]=mod
def Config::Process::_placeSource (   self,
  name,
  mod 
) [private]
Allow the source to be referenced by 'source' or by type name

Definition at line 402 of file Config.py.

00403                                    :
00404         """Allow the source to be referenced by 'source' or by type name"""
00405         if name != 'source':
00406             raise ValueError("The label '"+name+"' can not be used for a Source.  Only 'source' is allowed.")
00407         if self.__dict__['_Process__source'] is not None :
00408             del self.__dict__[self.__dict__['_Process__source'].type_()]
00409         self.__dict__['_Process__source'] = mod
        self.__dict__[mod.type_()] = mod
def Config::Process::_placeSubProcess (   self,
  name,
  mod 
) [private]

Definition at line 415 of file Config.py.

00416                                        :
00417         if name != 'subProcess':
00418             raise ValueError("The label '"+name+"' can not be used for a SubProcess.  Only 'subProcess' is allowed.")
00419         self.__dict__['_Process__subProcess'] = mod
        self.__dict__[mod.type_()] = mod
def Config::Process::_placeVPSet (   self,
  name,
  mod 
) [private]

Definition at line 400 of file Config.py.

00401                                   :
        self._place(name, mod, self.__vpsets)
def Config::Process::_replaceInSequences (   self,
  label,
  new 
) [private]

Definition at line 631 of file Config.py.

00632                                              :
00633         old = getattr(self,label)
00634         #TODO - replace by iterator concatenation
00635         for sequenceable in self.sequences.itervalues():
00636             sequenceable.replace(old,new)
00637         for sequenceable in self.paths.itervalues():
00638             sequenceable.replace(old,new)
00639         for sequenceable in self.endpaths.itervalues():
            sequenceable.replace(old,new)
def Config::Process::_sequencesInDependencyOrder (   self) [private]

Definition at line 567 of file Config.py.

00568                                          :
00569         #for each sequence, see what other sequences it depends upon
00570         returnValue=DictTypes.SortedKeysDict()
00571         dependencies = {}
00572         for label,seq in self.sequences.iteritems():
00573             d = []
00574             v = SequenceVisitor(d)
00575             seq.visit(v)
00576             dependencies[label]=[dep.label_() for dep in d if dep.hasLabel_()]
00577         resolvedDependencies=True
00578         #keep looping until we can no longer get rid of all dependencies
00579         # if that happens it means we have circular dependencies
00580         iterCount = 0
00581         while resolvedDependencies:
00582             iterCount += 1
00583             resolvedDependencies = (0 != len(dependencies))
00584             oldDeps = dict(dependencies)
00585             for label,deps in oldDeps.iteritems():
00586                 # don't try too hard
00587                 if len(deps)==0 or iterCount > 100:
00588                     iterCount = 0
00589                     resolvedDependencies=True
00590                     returnValue[label]=self.sequences[label]
00591                     #remove this as a dependency for all other sequences
00592                     del dependencies[label]
00593                     for lb2,deps2 in dependencies.iteritems():
00594                         while deps2.count(label):
00595                             deps2.remove(label)
00596         if len(dependencies):
00597             raise RuntimeError("circular sequence dependency discovered \n"+
00598                                ",".join([label for label,junk in dependencies.iteritems()]))
        return returnValue
def Config::Process::_validateSequence (   self,
  sequence,
  label 
) [private]

Definition at line 559 of file Config.py.

00560                                                 :
00561         # See if every module has been inserted into the process
00562         try:
00563             l = set()
00564             nameVisitor = NodeNameVisitor(l)
00565             sequence.visit(nameVisitor)
00566         except:
            raise RuntimeError("An entry in sequence "+label + ' has no label')
def Config::Process::add_ (   self,
  value 
)
Allows addition of components which do not have to have a label, e.g. Services

Definition at line 323 of file Config.py.

00324                         :
00325         """Allows addition of components which do not have to have a label, e.g. Services"""
00326         if not isinstance(value,_ConfigureComponent):
00327             raise TypeError
00328         if not isinstance(value,_Unlabelable):
00329             raise TypeError
00330         #clone the item
00331         #clone the item
00332         if self.__isStrict:
00333             newValue =value.copy()
00334             value.setIsFrozen()
00335         else:
00336             newValue =value
00337         newValue._place('',self)

def Config::Process::analyzerNames (   self)

Definition at line 134 of file Config.py.

00135                            :
        return ' '.join(self.analyzers_().keys())
def Config::Process::analyzers_ (   self)
returns a dict of the analyzers which have been added to the Process

Definition at line 189 of file Config.py.

00190                         :
00191         """returns a dict of the analyzers which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__analyzers)
def Config::Process::dumpConfig (   self,
  options = PrintOptions() 
)
return a string containing the equivalent process defined using the configuration language

Definition at line 487 of file Config.py.

00488                                                 :
00489         """return a string containing the equivalent process defined using the configuration language"""
00490         config = "process "+self.__name+" = {\n"
00491         options.indent()
00492         if self.source_():
00493             config += options.indentation()+"source = "+self.source_().dumpConfig(options)
00494         if self.looper_():
00495             config += options.indentation()+"looper = "+self.looper_().dumpConfig(options)
00496         if self.subProcess_():
00497             config += options.indentation()+"subProcess = "+self.subProcess_().dumpConfig(options)
00498 
00499         config+=self._dumpConfigNamedList(self.producers_().iteritems(),
00500                                   'module',
00501                                   options)
00502         config+=self._dumpConfigNamedList(self.filters_().iteritems(),
00503                                   'module',
00504                                   options)
00505         config+=self._dumpConfigNamedList(self.analyzers_().iteritems(),
00506                                   'module',
00507                                   options)
00508         config+=self._dumpConfigNamedList(self.outputModules_().iteritems(),
00509                                   'module',
00510                                   options)
00511         config+=self._dumpConfigNamedList(self.sequences_().iteritems(),
00512                                   'sequence',
00513                                   options)
00514         config+=self._dumpConfigNamedList(self.paths_().iteritems(),
00515                                   'path',
00516                                   options)
00517         config+=self._dumpConfigNamedList(self.endpaths_().iteritems(),
00518                                   'endpath',
00519                                   options)
00520         config+=self._dumpConfigUnnamedList(self.services_().iteritems(),
00521                                   'service',
00522                                   options)
00523         config+=self._dumpConfigOptionallyNamedList(
00524             self.es_producers_().iteritems(),
00525             'es_module',
00526             options)
00527         config+=self._dumpConfigOptionallyNamedList(
00528             self.es_sources_().iteritems(),
00529             'es_source',
00530             options)
00531         config += self._dumpConfigESPrefers(options)
00532         for name,item in self.psets.iteritems():
00533             config +=options.indentation()+item.configTypeName()+' '+name+' = '+item.configValue(options)
00534         for name,item in self.vpsets.iteritems():
00535             config +=options.indentation()+'VPSet '+name+' = '+item.configValue(options)
00536         if self.schedule:
00537             pathNames = [p.label_() for p in self.schedule]
00538             config +=options.indentation()+'schedule = {'+','.join(pathNames)+'}\n'
00539 
00540 #        config+=self._dumpConfigNamedList(self.vpsets.iteritems(),
00541 #                                  'VPSet',
00542 #                                  options)
00543         config += "}\n"
00544         options.unindent()
        return config
def Config::Process::dumpPython (   self,
  options = PrintOptions() 
)
return a string containing the equivalent process defined using the configuration language

Definition at line 604 of file Config.py.

00605                                                 :
00606         """return a string containing the equivalent process defined using the configuration language"""
00607         result = "import FWCore.ParameterSet.Config as cms\n\n"
00608         result += "process = cms.Process(\""+self.__name+"\")\n\n"
00609         if self.source_():
00610             result += "process.source = "+self.source_().dumpPython(options)
00611         if self.looper_():
00612             result += "process.looper = "+self.looper_().dumpPython()
00613         if self.subProcess_():
00614             result += self.subProcess_().dumpPython(options)
00615         result+=self._dumpPythonList(self.producers_(), options)
00616         result+=self._dumpPythonList(self.filters_() , options)
00617         result+=self._dumpPythonList(self.analyzers_(), options)
00618         result+=self._dumpPythonList(self.outputModules_(), options)
00619         result+=self._dumpPythonList(self._sequencesInDependencyOrder(), options)
00620         result+=self._dumpPythonList(self.paths_(), options)
00621         result+=self._dumpPythonList(self.endpaths_(), options)
00622         result+=self._dumpPythonList(self.services_(), options)
00623         result+=self._dumpPythonList(self.es_producers_(), options)
00624         result+=self._dumpPythonList(self.es_sources_(), options)
00625         result+=self._dumpPython(self.es_prefers_(), options)
00626         result+=self._dumpPythonList(self.psets, options)
00627         result+=self._dumpPythonList(self.vpsets, options)
00628         if self.schedule:
00629             pathNames = ['process.'+p.label_() for p in self.schedule]
00630             result +='process.schedule = cms.Schedule('+','.join(pathNames)+')\n'
        return result
def Config::Process::endpaths_ (   self)
returns a dict of the endpaths which have been added to the Process

Definition at line 201 of file Config.py.

00202                        :
00203         """returns a dict of the endpaths which have been added to the Process"""
        return DictTypes.SortedAndFixedKeysDict(self.__endpaths)
def Config::Process::es_prefers_ (   self)
returns a dict of the es_prefers which have been added to the Process

Definition at line 241 of file Config.py.

00242                          :
00243         """returns a dict of the es_prefers which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__esprefers)
def Config::Process::es_producers_ (   self)
returns a dict of the esproducers which have been added to the Process

Definition at line 233 of file Config.py.

00234                            :
00235         """returns a dict of the esproducers which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__esproducers)
def Config::Process::es_sources_ (   self)
returns a the es_sources which have been added to the Process

Definition at line 237 of file Config.py.

00238                          :
00239         """returns a the es_sources which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__essources)
def Config::Process::extend (   self,
  other,
  items = () 
)
Look in other and find types which we can use

Definition at line 427 of file Config.py.

00428                                    :
00429         """Look in other and find types which we can use"""
00430         # enable explicit check to avoid overwriting of existing objects
00431         self.__dict__['_Process__InExtendCall'] = True
00432 
00433         seqs = dict()
00434         labelled = dict()
00435         for name in dir(other):
00436             #'from XX import *' ignores these, and so should we.
00437             if name.startswith('_'):
00438                 continue
00439             item = getattr(other,name)
00440             if name == "source" or name == "looper" or name == "subProcess":
00441                 self.__setattr__(name,item)
00442             elif isinstance(item,_ModuleSequenceType):
00443                 seqs[name]=item
00444             elif isinstance(item,_Labelable):
00445                 self.__setattr__(name,item)
00446                 labelled[name]=item
00447                 try:
00448                     item.label_()
00449                 except:
00450                     item.setLabel(name)
00451                 continue
00452             elif isinstance(item,Schedule):
00453                 self.__setattr__(name,item)
00454             elif isinstance(item,_Unlabelable):
00455                 self.add_(item)
00456 
00457         #now create a sequence which uses the newly made items
00458         for name in seqs.iterkeys():
00459             seq = seqs[name]
00460             #newSeq = seq.copy()
00461             #
00462             if id(seq) not in self._cloneToObjectDict:
00463                 self.__setattr__(name,seq)
00464             else:
00465                 newSeq = self._cloneToObjectDict[id(seq)]
00466                 self.__dict__[name]=newSeq
00467                 newSeq.setLabel(name)
00468                 #now put in proper bucket
00469                 newSeq._place(name,self)
        self.__dict__['_Process__InExtendCall'] = False
def Config::Process::fillProcessDesc (   self,
  processPSet 
)

Definition at line 738 of file Config.py.

00739                                           :
00740         class ServiceInjectorAdaptor(object):
00741             def __init__(self,ppset,thelist):
00742                 self.__thelist = thelist
00743                 self.__processPSet = ppset
00744             def addService(self,pset):
00745                 self.__thelist.append(pset)
00746             def newPSet(self):
00747                 return self.__processPSet.newPSet()
00748         self.validate()
00749         processPSet.addString(True, "@process_name", self.name_())
00750         all_modules = self.producers_().copy()
00751         all_modules.update(self.filters_())
00752         all_modules.update(self.analyzers_())
00753         all_modules.update(self.outputModules_())
00754         self._insertInto(processPSet, self.psets_())
00755         self._insertInto(processPSet, self.vpsets_())
00756         self._insertManyInto(processPSet, "@all_modules", all_modules, True)
00757         self._insertOneInto(processPSet,  "@all_sources", self.source_(), True)
00758         self._insertOneInto(processPSet,  "@all_loopers", self.looper_(), True)
00759         self._insertOneInto(processPSet,  "@all_subprocesses", self.subProcess_(), False)
00760         self._insertManyInto(processPSet, "@all_esmodules", self.es_producers_(), True)
00761         self._insertManyInto(processPSet, "@all_essources", self.es_sources_(), True)
00762         self._insertManyInto(processPSet, "@all_esprefers", self.es_prefers_(), True)
00763         self._insertPaths(processPSet)
00764         #handle services differently
00765         services = []
00766         for n in self.services_():
00767              getattr(self,n).insertInto(ServiceInjectorAdaptor(processPSet,services))
00768         processPSet.addVPSet(False,"services",services)
00769         return processPSet

def Config::Process::filterNames (   self)

Definition at line 136 of file Config.py.

00137                          :
       return ' '.join(self.filters_().keys())
def Config::Process::filters_ (   self)
returns a dict of the filters which have been added to the Process

Definition at line 158 of file Config.py.

00159                       :
00160         """returns a dict of the filters which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__filters)
def Config::Process::globalReplace (   self,
  label,
  new 
)
Replace the item with label 'label' by object 'new' in the process and all sequences/paths

Definition at line 640 of file Config.py.

00641                                      :
00642         """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths"""
00643         if not hasattr(self,label):
00644             raise LookupError("process has no item of label "+label)
00645         self._replaceInSequences(label, new)
        setattr(self,label,new)
def Config::Process::load (   self,
  moduleName 
)

Definition at line 423 of file Config.py.

00424                               :
00425         moduleName = moduleName.replace("/",".")
00426         module = __import__(moduleName)
        self.extend(sys.modules[moduleName])
def Config::Process::looper_ (   self)
returns the looper which has been added to the Process or None if none have been added

Definition at line 177 of file Config.py.

00178                      :
00179         """returns the looper which has been added to the Process or None if none have been added"""
        return self.__looper
def Config::Process::name_ (   self)

Definition at line 162 of file Config.py.

00163                    :
        return self.__name
def Config::Process::outputModules_ (   self)
returns a dict of the output modules which have been added to the Process

Definition at line 193 of file Config.py.

00194                             :
00195         """returns a dict of the output modules which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__outputmodules)
def Config::Process::pathNames (   self)

Definition at line 138 of file Config.py.

00139                        :
00140        return ' '.join(self.paths_().keys())

def Config::Process::paths_ (   self)
returns a dict of the paths which have been added to the Process

Definition at line 197 of file Config.py.

00198                     :
00199         """returns a dict of the paths which have been added to the Process"""
        return DictTypes.SortedAndFixedKeysDict(self.__paths)
def Config::Process::prefer (   self,
  esmodule,
  args,
  kargs 
)
Prefer this ES source or producer.  The argument can
   either be an object label, e.g.,
     process.prefer(process.juicerProducer) (not supported yet)
   or a name of an ESSource or ESProducer
     process.prefer("juicer")
   or a type of unnamed ESSource or ESProducer
     process.prefer("JuicerProducer")
   In addition, you can pass as a labelled arguments the name of the Record you wish to
   prefer where the type passed is a cms.vstring and that vstring can contain the
   name of the C++ types in the Record which are being preferred, e.g.,
      #prefer all data in record 'OrangeRecord' from 'juicer'
      process.prefer("juicer", OrangeRecord=cms.vstring())
   or
      #prefer only "Orange" data in "OrangeRecord" from "juicer"
      process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
   or
      #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
      ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))

Definition at line 777 of file Config.py.

00778                                             :
00779         """Prefer this ES source or producer.  The argument can
00780            either be an object label, e.g.,
00781              process.prefer(process.juicerProducer) (not supported yet)
00782            or a name of an ESSource or ESProducer
00783              process.prefer("juicer")
00784            or a type of unnamed ESSource or ESProducer
00785              process.prefer("JuicerProducer")
00786            In addition, you can pass as a labelled arguments the name of the Record you wish to
00787            prefer where the type passed is a cms.vstring and that vstring can contain the
00788            name of the C++ types in the Record which are being preferred, e.g.,
00789               #prefer all data in record 'OrangeRecord' from 'juicer'
00790               process.prefer("juicer", OrangeRecord=cms.vstring())
00791            or
00792               #prefer only "Orange" data in "OrangeRecord" from "juicer"
00793               process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
00794            or
00795               #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
00796               ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))
00797         """
00798         # see if this refers to a named ESProducer
00799         if isinstance(esmodule, ESSource) or isinstance(esmodule, ESProducer):
00800             raise RuntimeError("Syntax of process.prefer(process.esmodule) not supported yet")
00801         elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs) or \
00802                 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
00803             pass
00804         else:
00805             raise RuntimeError("Cannot resolve prefer for "+repr(esmodule))

def Config::Process::producerNames (   self)

Definition at line 132 of file Config.py.

00133                            :
        return ' '.join(self.producers_().keys())
def Config::Process::producers_ (   self)
returns a dict of the producers which have been added to the Process

Definition at line 167 of file Config.py.

00168                         :
00169         """returns a dict of the producers which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__producers)
def Config::Process::prune (   self)
Remove clutter from the process which we think is unnecessary:
PSets, and unused modules.  Not working yet, because I need to remove
all unneeded sequences and paths that contain removed modules 

Definition at line 706 of file Config.py.

00707                    :
00708         """ Remove clutter from the process which we think is unnecessary:
00709         PSets, and unused modules.  Not working yet, because I need to remove
00710         all unneeded sequences and paths that contain removed modules """
00711         for name in self.psets_():
00712             delattr(self, name)
00713         for name in self.vpsets_():
00714             delattr(self, name)
00715 
00716         if self.schedule_():
00717             self.pruneSequences()
00718             scheduledNames = self.schedule_().moduleNames()
00719             self.pruneModules(self.producers_(), scheduledNames)
00720             self.pruneModules(self.filters_(), scheduledNames)
00721             self.pruneModules(self.analyzers_(), scheduledNames)

def Config::Process::pruneModules (   self,
  d,
  scheduledNames 
)

Definition at line 732 of file Config.py.

00733                                              :
00734         moduleNames = set(d.keys())
00735         junk = moduleNames - scheduledNames
00736         for name in junk:
00737             delattr(self, name)

def Config::Process::pruneSequences (   self)

Definition at line 722 of file Config.py.

00723                             :
00724         scheduledSequences = []
00725         visitor = SequenceVisitor(scheduledSequences)
00726         #self.schedule_()._seq.visit(visitor)
00727         #scheduledSequenceNames = set([seq.label_() for seq in scheduledSequences])
00728         #sequenceNames = set(self.sequences_().keys())
00729         #junk = sequenceNames - scheduledSequenceNames
00730         #for name in junk:
00731         #    delattr(self, name)

def Config::Process::psets_ (   self)
returns a dict of the PSets which have been added to the Process

Definition at line 245 of file Config.py.

00246                     :
00247         """returns a dict of the PSets which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__psets)
def Config::Process::schedule_ (   self)
returns the schedule which has been added to the Process or None if none have been added

Definition at line 209 of file Config.py.

00210                        :
00211         """returns the schedule which has been added to the Process or None if none have been added"""
        return self.__schedule
def Config::Process::sequences_ (   self)
returns a dict of the sequences which have been added to the Process

Definition at line 205 of file Config.py.

00206                         :
00207         """returns a dict of the sequences which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__sequences)
def Config::Process::services_ (   self)
returns a dict of the services which have been added to the Process

Definition at line 229 of file Config.py.

00230                        :
00231         """returns a dict of the services which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__services)
def Config::Process::setLooper_ (   self,
  lpr 
)

Definition at line 180 of file Config.py.

00181                             :
        self._placeLooper('looper',lpr)
def Config::Process::setName_ (   self,
  name 
)

Definition at line 164 of file Config.py.

00165                            :
        self.__dict__['_Process__name'] = name
def Config::Process::setPartialSchedule_ (   self,
  sch,
  label 
)

Definition at line 212 of file Config.py.

00213                                            :
00214         if label == "schedule":
00215             self.setSchedule_(sch)
00216         else:
            self._place(label, sch, self.__partialschedules)
def Config::Process::setSchedule_ (   self,
  sch 
)

Definition at line 217 of file Config.py.

00218                               :
00219                 # See if every module has been inserted into the process
00220         index = 0
00221         try:
00222             for p in sch:
00223                p.label_()
00224                index +=1
00225         except:
00226             raise RuntimeError("The path at index "+str(index)+" in the Schedule was not attached to the process.")
00227 
        self.__dict__['_Process__schedule'] = sch
def Config::Process::setSource_ (   self,
  src 
)

Definition at line 174 of file Config.py.

00175                             :
        self._placeSource('source',src)
def Config::Process::setStrict (   self,
  value 
)

Definition at line 127 of file Config.py.

00128                               :
00129         self.__isStrict = value
00130         _Module.__isStrict__ = True

def Config::Process::setSubProcess_ (   self,
  lpr 
)

Definition at line 186 of file Config.py.

00187                                 :
        self._placeSubProcess('subProcess',lpr)
def Config::Process::source_ (   self)
returns the source which has been added to the Process or None if none have been added

Definition at line 171 of file Config.py.

00172                      :
00173         """returns the source which has been added to the Process or None if none have been added"""
        return self.__source
def Config::Process::subProcess_ (   self)
returns the sub-process which has been added to the Process or None if none have been added

Definition at line 183 of file Config.py.

00184                          :
00185         """returns the sub-process which has been added to the Process or None if none have been added"""
        return self.__subProcess
def Config::Process::validate (   self)

Definition at line 770 of file Config.py.

00771                       :
00772         # check if there's some input
00773         # Breaks too many unit tests for now
00774         #if self.source_() == None and self.looper_() == None:
00775         #    raise RuntimeError("No input source was found for this process")
00776         pass

def Config::Process::vpsets_ (   self)
returns a dict of the VPSets which have been added to the Process

Definition at line 249 of file Config.py.

00250                      :
00251         """returns a dict of the VPSets which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__vpsets)

Member Data Documentation

Definition at line 102 of file Config.py.

Definition at line 738 of file Config.py.

Definition at line 738 of file Config.py.


Property Documentation

Config::Process::analyzers = property(analyzers_,doc="dictionary containing the analyzers for the process") [static]

Definition at line 192 of file Config.py.

Config::Process::endpaths = property(endpaths_,doc="dictionary containing the endpaths for the process") [static]

Definition at line 204 of file Config.py.

Config::Process::es_prefers = property(es_prefers_,doc="dictionary containing the es_prefers for the process") [static]

Definition at line 244 of file Config.py.

Config::Process::es_producers = property(es_producers_,doc="dictionary containing the es_producers for the process") [static]

Definition at line 236 of file Config.py.

Config::Process::es_sources = property(es_sources_,doc="dictionary containing the es_sources for the process") [static]

Definition at line 240 of file Config.py.

Config::Process::filters = property(filters_, doc="dictionary containing the filters for the process") [static]

Definition at line 161 of file Config.py.

Config::Process::looper = property(looper_,setLooper_,doc='the main looper or None if not set') [static]

Definition at line 182 of file Config.py.

Config::Process::outputModules = property(outputModules_,doc="dictionary containing the output_modules for the process") [static]

Definition at line 196 of file Config.py.

Config::Process::paths = property(paths_,doc="dictionary containing the paths for the process") [static]

Definition at line 200 of file Config.py.

Config::Process::process = property(name_,setName_, doc="name of the process") [static]

Definition at line 166 of file Config.py.

Config::Process::producers = property(producers_,doc="dictionary containing the producers for the process") [static]

Definition at line 170 of file Config.py.

Config::Process::psets = property(psets_,doc="dictionary containing the PSets for the process") [static]

Definition at line 248 of file Config.py.

Config::Process::schedule = property(schedule_,setSchedule_,doc='the schedule or None if not set') [static]

Definition at line 228 of file Config.py.

Config::Process::sequences = property(sequences_,doc="dictionary containing the sequences for the process") [static]

Definition at line 208 of file Config.py.

Config::Process::services = property(services_,doc="dictionary containing the services for the process") [static]

Definition at line 232 of file Config.py.

Config::Process::source = property(source_,setSource_,doc='the main source or None if not set') [static]

Definition at line 176 of file Config.py.

Config::Process::subProcess = property(subProcess_,setSubProcess_,doc='the SubProcess or None if not set') [static]

Definition at line 188 of file Config.py.

Config::Process::vpsets = property(vpsets_,doc="dictionary containing the PSets for the process") [static]

Definition at line 252 of file Config.py.