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 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 _pruneModules
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 
)
The argument 'name' will be the name applied to this Process

Definition at line 102 of file Config.py.

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


Member Function Documentation

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

Definition at line 308 of file Config.py.

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

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

Definition at line 258 of file Config.py.

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

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

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

Definition at line 550 of file Config.py.

00551                                            :
00552         result = ''
00553         for item in self.es_prefers_().itervalues():
00554             result +=options.indentation()+'es_prefer '+item.targetLabel_()+' = '+item.dumpConfig(options)
        return result
def Config::Process::_dumpConfigNamedList (   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+' '+name+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpConfigOptionallyNamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 485 of file Config.py.

00486                                                                    :
00487         returnValue = ''
00488         for name,item in items:
00489             if name == item.type_():
00490                 name = ''
00491             returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpConfigUnnamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 480 of file Config.py.

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

Definition at line 604 of file Config.py.

00605                                      :
00606         result = ''
00607         for name, value in d.iteritems():
00608            result += value.dumpPythonAs(name,options)+'\n'
        return result
def Config::Process::_dumpPythonList (   self,
  d,
  options 
) [private]

Definition at line 555 of file Config.py.

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

Definition at line 832 of file Config.py.

00833                                                      :
00834         # is esname a name in the dictionary?
00835         if esname in d:
00836             typ = d[esname].type_()
00837             if typ == esname:
00838                 self.__setattr__( esname+"_prefer", ESPrefer(typ,*args,**kargs) )
00839             else:
00840                 self.__setattr__( esname+"_prefer", ESPrefer(typ, esname,*args,**kargs) )
00841             return True
00842         else:
00843             # maybe it's an unnamed ESModule?
00844             found = False
00845             for name, value in d.iteritems():
00846                if value.type_() == esname:
00847                   if found:
00848                       raise RuntimeError("More than one ES module for "+esname)
00849                   found = True
00850                   self.__setattr__(esname+"_prefer",  ESPrefer(d[esname].type_()) )
00851             return found

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

Definition at line 652 of file Config.py.

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

Definition at line 662 of file Config.py.

00663                                                                      :
00664         l = []
00665         for name,value in itemDict.iteritems():
00666           newLabel = value.nameInProcessDesc_(name)
00667           l.append(newLabel)
00668           value.insertInto(parameterSet, name)
00669         # alphabetical order is easier to compare with old language
00670         l.sort()
        parameterSet.addVString(tracked, label, l)
def Config::Process::_insertOneInto (   self,
  parameterSet,
  label,
  item,
  tracked 
) [private]

Definition at line 655 of file Config.py.

00656                                                                 :
00657         vitems = []
00658         if not item == None:
00659             newlabel = item.nameInProcessDesc_(label)
00660             vitems = [newlabel]
00661             item.insertInto(parameterSet, newlabel)
        parameterSet.addVString(tracked, label, vitems)
def Config::Process::_insertPaths (   self,
  processPSet 
) [private]

Definition at line 671 of file Config.py.

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

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

Definition at line 343 of file Config.py.

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

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

Definition at line 364 of file Config.py.

00365                                   :
00366         if self._okToPlace(name, mod, d):
00367             if self.__isStrict and isinstance(mod, _ModuleSequenceType):
00368                 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
00369             else:
00370                 d[name] = mod
00371             if isinstance(mod,_Labelable):
               mod.setLabel(name)
def Config::Process::_placeAnalyzer (   self,
  name,
  mod 
) [private]

Definition at line 378 of file Config.py.

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

Definition at line 387 of file Config.py.

00388                                     :
00389         self._validateSequence(mod, name)
00390         try:
00391             self._place(name, mod, self.__endpaths)
00392         except ModuleCloneError, msg:
00393             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 399 of file Config.py.

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

Definition at line 397 of file Config.py.

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

Definition at line 401 of file Config.py.

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

Definition at line 376 of file Config.py.

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

Definition at line 415 of file Config.py.

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

Definition at line 372 of file Config.py.

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

Definition at line 380 of file Config.py.

00381                                  :
00382         self._validateSequence(mod, name)
00383         try:
00384             self._place(name, mod, self.__paths)
00385         except ModuleCloneError, msg:
00386             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 374 of file Config.py.

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

Definition at line 403 of file Config.py.

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

Definition at line 394 of file Config.py.

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

Definition at line 425 of file Config.py.

00426                                         :
00427         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 407 of file Config.py.

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

Definition at line 420 of file Config.py.

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

Definition at line 405 of file Config.py.

00406                                   :
        self._place(name, mod, self.__vpsets)
def Config::Process::_pruneModules (   self,
  d,
  scheduledNames 
) [private]

Definition at line 757 of file Config.py.

00758                                               :
00759         moduleNames = set(d.keys())
00760         junk = moduleNames - scheduledNames
00761         for name in junk:
00762             delattr(self, name)

def Config::Process::_replaceInSequences (   self,
  label,
  new 
) [private]

Definition at line 637 of file Config.py.

00638                                              :
00639         old = getattr(self,label)
00640         #TODO - replace by iterator concatenation
00641         for sequenceable in self.sequences.itervalues():
00642             sequenceable.replace(old,new)
00643         for sequenceable in self.paths.itervalues():
00644             sequenceable.replace(old,new)
00645         for sequenceable in self.endpaths.itervalues():
            sequenceable.replace(old,new)
def Config::Process::_sequencesInDependencyOrder (   self) [private]

Definition at line 572 of file Config.py.

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

Definition at line 564 of file Config.py.

00565                                                 :
00566         # See if every module has been inserted into the process
00567         try:
00568             l = set()
00569             nameVisitor = NodeNameVisitor(l)
00570             sequence.visit(nameVisitor)
00571         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 328 of file Config.py.

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

def Config::Process::analyzerNames (   self)
Returns a string containing all the EDAnalyzer labels separated by a blank

Definition at line 136 of file Config.py.

00137                            :
00138         """Returns a string containing all the EDAnalyzer labels separated by a blank"""
        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 194 of file Config.py.

00195                         :
00196         """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 old configuration language

Definition at line 492 of file Config.py.

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

Definition at line 609 of file Config.py.

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

Definition at line 206 of file Config.py.

00207                        :
00208         """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 246 of file Config.py.

00247                          :
00248         """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 238 of file Config.py.

00239                            :
00240         """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 242 of file Config.py.

00243                          :
00244         """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 432 of file Config.py.

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

Definition at line 763 of file Config.py.

00764                                           :
00765         """Used by the framework to convert python to C++ objects"""
00766         class ServiceInjectorAdaptor(object):
00767             def __init__(self,ppset,thelist):
00768                 self.__thelist = thelist
00769                 self.__processPSet = ppset
00770             def addService(self,pset):
00771                 self.__thelist.append(pset)
00772             def newPSet(self):
00773                 return self.__processPSet.newPSet()
00774         self.validate()
00775         processPSet.addString(True, "@process_name", self.name_())
00776         all_modules = self.producers_().copy()
00777         all_modules.update(self.filters_())
00778         all_modules.update(self.analyzers_())
00779         all_modules.update(self.outputModules_())
00780         self._insertInto(processPSet, self.psets_())
00781         self._insertInto(processPSet, self.vpsets_())
00782         self._insertManyInto(processPSet, "@all_modules", all_modules, True)
00783         self._insertOneInto(processPSet,  "@all_sources", self.source_(), True)
00784         self._insertOneInto(processPSet,  "@all_loopers", self.looper_(), True)
00785         self._insertOneInto(processPSet,  "@all_subprocesses", self.subProcess_(), False)
00786         self._insertManyInto(processPSet, "@all_esmodules", self.es_producers_(), True)
00787         self._insertManyInto(processPSet, "@all_essources", self.es_sources_(), True)
00788         self._insertManyInto(processPSet, "@all_esprefers", self.es_prefers_(), True)
00789         self._insertPaths(processPSet)
00790         #handle services differently
00791         services = []
00792         for n in self.services_():
00793              getattr(self,n).insertInto(ServiceInjectorAdaptor(processPSet,services))
00794         processPSet.addVPSet(False,"services",services)
00795         return processPSet

def Config::Process::filterNames (   self)
Returns a string containing all the EDFilter labels separated by a blank

Definition at line 139 of file Config.py.

00140                          :
00141         """Returns a string containing all the EDFilter labels separated by a blank"""
        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 163 of file Config.py.

00164                       :
00165         """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 646 of file Config.py.

00647                                      :
00648         """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths"""
00649         if not hasattr(self,label):
00650             raise LookupError("process has no item of label "+label)
00651         self._replaceInSequences(label, new)
        setattr(self,label,new)
def Config::Process::load (   self,
  moduleName 
)

Definition at line 428 of file Config.py.

00429                               :
00430         moduleName = moduleName.replace("/",".")
00431         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 182 of file Config.py.

00183                      :
00184         """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 167 of file Config.py.

00168                    :
        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 198 of file Config.py.

00199                             :
00200         """returns a dict of the output modules which have been added to the Process"""
        return DictTypes.FixedKeysDict(self.__outputmodules)
def Config::Process::pathNames (   self)
Returns a string containing all the Path names separated by a blank

Definition at line 142 of file Config.py.

00143                        :
00144         """Returns a string containing all the Path names separated by a blank"""
00145         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 202 of file Config.py.

00203                     :
00204         """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 803 of file Config.py.

00804                                             :
00805         """Prefer this ES source or producer.  The argument can
00806            either be an object label, e.g.,
00807              process.prefer(process.juicerProducer) (not supported yet)
00808            or a name of an ESSource or ESProducer
00809              process.prefer("juicer")
00810            or a type of unnamed ESSource or ESProducer
00811              process.prefer("JuicerProducer")
00812            In addition, you can pass as a labelled arguments the name of the Record you wish to
00813            prefer where the type passed is a cms.vstring and that vstring can contain the
00814            name of the C++ types in the Record which are being preferred, e.g.,
00815               #prefer all data in record 'OrangeRecord' from 'juicer'
00816               process.prefer("juicer", OrangeRecord=cms.vstring())
00817            or
00818               #prefer only "Orange" data in "OrangeRecord" from "juicer"
00819               process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
00820            or
00821               #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
00822               ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))
00823         """
00824         # see if this refers to a named ESProducer
00825         if isinstance(esmodule, ESSource) or isinstance(esmodule, ESProducer):
00826             raise RuntimeError("Syntax of process.prefer(process.esmodule) not supported yet")
00827         elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs) or \
00828                 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
00829             pass
00830         else:
00831             raise RuntimeError("Cannot resolve prefer for "+repr(esmodule))

def Config::Process::producerNames (   self)
Returns a string containing all the EDProducer labels separated by a blank

Definition at line 133 of file Config.py.

00134                            :
00135         """Returns a string containing all the EDProducer labels separated by a blank"""
        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 172 of file Config.py.

00173                         :
00174         """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:
tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths
not in the schedule will also be removed, along with an modules and sequences used only by
those removed Paths and EndPaths.

Definition at line 712 of file Config.py.

00713                    :
00714         """ Remove clutter from the process which we think is unnecessary:
00715         tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths
00716         not in the schedule will also be removed, along with an modules and sequences used only by
00717         those removed Paths and EndPaths."""
00718         for name in self.psets_():
00719             if getattr(self,name).isTracked():
00720                 delattr(self, name)
00721         for name in self.vpsets_():
00722             delattr(self, name)
00723         #first we need to resolve any SequencePlaceholders being used
00724         for x in self.paths.itervalues():
00725             x.resolve(self.__dict__)
00726         for x in self.endpaths.itervalues():
00727             x.resolve(self.__dict__)
00728         usedModules = set()
00729         if self.schedule_():
00730             usedModules=set(self.schedule_().moduleNames())
00731             #get rid of unused paths
00732             schedNames = set(( x.label_() for x in self.schedule_()))
00733             names = set(self.paths)
00734             names.update(set(self.endpaths))
00735             junk = names - schedNames
00736             for n in junk:
00737                 delattr(self,n)
00738         else:
00739             pths = list(self.paths.itervalues())
00740             pths.extend(self.endpaths.itervalues())
00741             temp = Schedule(*pths)
00742             usedModules=set(temp.moduleNames())
00743         self._pruneModules(self.producers_(), usedModules)
00744         self._pruneModules(self.filters_(), usedModules)
00745         self._pruneModules(self.analyzers_(), usedModules)
00746         #remove sequences that do not appear in remaining paths and endpaths
00747         seqs = list()
00748         sv = SequenceVisitor(seqs)
00749         for p in self.paths.itervalues():
00750             p.visit(sv)
00751         for p in self.endpaths.itervalues():
00752             p.visit(sv)
00753         keepSeqSet = set(( s for s in seqs if s.hasLabel_()))
00754         availableSeqs = set(self.sequences.itervalues())
00755         for s in availableSeqs-keepSeqSet:
00756             delattr(self,s.label_())
                
def Config::Process::psets_ (   self)
returns a dict of the PSets which have been added to the Process

Definition at line 250 of file Config.py.

00251                     :
00252         """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 214 of file Config.py.

00215                        :
00216         """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 210 of file Config.py.

00211                         :
00212         """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 234 of file Config.py.

00235                        :
00236         """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 185 of file Config.py.

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

Definition at line 169 of file Config.py.

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

Definition at line 217 of file Config.py.

00218                                            :
00219         if label == "schedule":
00220             self.setSchedule_(sch)
00221         else:
            self._place(label, sch, self.__partialschedules)
def Config::Process::setSchedule_ (   self,
  sch 
)

Definition at line 222 of file Config.py.

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

Definition at line 179 of file Config.py.

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

Definition at line 128 of file Config.py.

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

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

Definition at line 191 of file Config.py.

00192                                 :
        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 176 of file Config.py.

00177                      :
00178         """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 188 of file Config.py.

00189                          :
00190         """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 796 of file Config.py.

00797                       :
00798         # check if there's some input
00799         # Breaks too many unit tests for now
00800         #if self.source_() == None and self.looper_() == None:
00801         #    raise RuntimeError("No input source was found for this process")
00802         pass

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

Definition at line 254 of file Config.py.

00255                      :
00256         """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 763 of file Config.py.

Definition at line 763 of file Config.py.


Property Documentation

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

Definition at line 197 of file Config.py.

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

Definition at line 209 of file Config.py.

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

Definition at line 249 of file Config.py.

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

Definition at line 241 of file Config.py.

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

Definition at line 245 of file Config.py.

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

Definition at line 166 of file Config.py.

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

Definition at line 187 of file Config.py.

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

Definition at line 201 of file Config.py.

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

Definition at line 205 of file Config.py.

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

Definition at line 171 of file Config.py.

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

Definition at line 175 of file Config.py.

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

Definition at line 253 of file Config.py.

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

Definition at line 233 of file Config.py.

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

Definition at line 213 of file Config.py.

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

Definition at line 237 of file Config.py.

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

Definition at line 181 of file Config.py.

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

Definition at line 193 of file Config.py.

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

Definition at line 257 of file Config.py.