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         if not name.isalnum():
00107             raise RuntimeError("Error: The process name is an empty string or contains non-alphanumeric characters")
00108         self.__dict__['_Process__filters'] = {}
00109         self.__dict__['_Process__producers'] = {}
00110         self.__dict__['_Process__source'] = None
00111         self.__dict__['_Process__looper'] = None
00112         self.__dict__['_Process__subProcess'] = None
00113         self.__dict__['_Process__schedule'] = None
00114         self.__dict__['_Process__analyzers'] = {}
00115         self.__dict__['_Process__outputmodules'] = {}
00116         self.__dict__['_Process__paths'] = DictTypes.SortedKeysDict()    # have to keep the order
00117         self.__dict__['_Process__endpaths'] = DictTypes.SortedKeysDict() # of definition
00118         self.__dict__['_Process__sequences'] = {}
00119         self.__dict__['_Process__services'] = {}
00120         self.__dict__['_Process__essources'] = {}
00121         self.__dict__['_Process__esproducers'] = {}
00122         self.__dict__['_Process__esprefers'] = {}
00123         self.__dict__['_Process__psets']={}
00124         self.__dict__['_Process__vpsets']={}
00125         self.__dict__['_cloneToObjectDict'] = {}
00126         # policy switch to avoid object overwriting during extend/load
00127         self.__dict__['_Process__InExtendCall'] = False
00128         self.__dict__['_Process__partialschedules'] = {}
00129         self.__isStrict = False


Member Function Documentation

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

Definition at line 312 of file Config.py.

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

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

Definition at line 262 of file Config.py.

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

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

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

Definition at line 554 of file Config.py.

00555                                            :
00556         result = ''
00557         for item in self.es_prefers_().itervalues():
00558             result +=options.indentation()+'es_prefer '+item.targetLabel_()+' = '+item.dumpConfig(options)
        return result
def Config::Process::_dumpConfigNamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 479 of file Config.py.

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

Definition at line 489 of file Config.py.

00490                                                                    :
00491         returnValue = ''
00492         for name,item in items:
00493             if name == item.type_():
00494                 name = ''
00495             returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpConfigUnnamedList (   self,
  items,
  typeName,
  options 
) [private]

Definition at line 484 of file Config.py.

00485                                                            :
00486         returnValue = ''
00487         for name,item in items:
00488             returnValue +=options.indentation()+typeName+' = '+item.dumpConfig(options)
        return returnValue
def Config::Process::_dumpPython (   self,
  d,
  options 
) [private]

Definition at line 608 of file Config.py.

00609                                      :
00610         result = ''
00611         for name, value in d.iteritems():
00612            result += value.dumpPythonAs(name,options)+'\n'
        return result
def Config::Process::_dumpPythonList (   self,
  d,
  options 
) [private]

Definition at line 559 of file Config.py.

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

Definition at line 836 of file Config.py.

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

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

Definition at line 656 of file Config.py.

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

Definition at line 666 of file Config.py.

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

Definition at line 659 of file Config.py.

00660                                                                 :
00661         vitems = []
00662         if not item == None:
00663             newlabel = item.nameInProcessDesc_(label)
00664             vitems = [newlabel]
00665             item.insertInto(parameterSet, newlabel)
        parameterSet.addVString(tracked, label, vitems)
def Config::Process::_insertPaths (   self,
  processPSet 
) [private]

Definition at line 675 of file Config.py.

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

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

Definition at line 347 of file Config.py.

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

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

Definition at line 368 of file Config.py.

00369                                   :
00370         if self._okToPlace(name, mod, d):
00371             if self.__isStrict and isinstance(mod, _ModuleSequenceType):
00372                 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
00373             else:
00374                 d[name] = mod
00375             if isinstance(mod,_Labelable):
               mod.setLabel(name)
def Config::Process::_placeAnalyzer (   self,
  name,
  mod 
) [private]

Definition at line 382 of file Config.py.

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

Definition at line 391 of file Config.py.

00392                                     :
00393         self._validateSequence(mod, name)
00394         try:
00395             self._place(name, mod, self.__endpaths)
00396         except ModuleCloneError, msg:
00397             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 403 of file Config.py.

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

Definition at line 401 of file Config.py.

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

Definition at line 405 of file Config.py.

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

Definition at line 380 of file Config.py.

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

Definition at line 419 of file Config.py.

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

Definition at line 376 of file Config.py.

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

Definition at line 384 of file Config.py.

00385                                  :
00386         self._validateSequence(mod, name)
00387         try:
00388             self._place(name, mod, self.__paths)
00389         except ModuleCloneError, msg:
00390             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 378 of file Config.py.

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

Definition at line 407 of file Config.py.

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

Definition at line 398 of file Config.py.

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

Definition at line 429 of file Config.py.

00430                                         :
00431         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 411 of file Config.py.

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

Definition at line 424 of file Config.py.

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

Definition at line 409 of file Config.py.

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

Definition at line 761 of file Config.py.

00762                                               :
00763         moduleNames = set(d.keys())
00764         junk = moduleNames - scheduledNames
00765         for name in junk:
00766             delattr(self, name)

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

Definition at line 641 of file Config.py.

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

Definition at line 576 of file Config.py.

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

Definition at line 568 of file Config.py.

00569                                                 :
00570         # See if every module has been inserted into the process
00571         try:
00572             l = set()
00573             nameVisitor = NodeNameVisitor(l)
00574             sequence.visit(nameVisitor)
00575         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 332 of file Config.py.

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

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

Definition at line 138 of file Config.py.

00139                            :
00140         """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 198 of file Config.py.

00199                         :
00200         """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 496 of file Config.py.

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

Definition at line 613 of file Config.py.

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

Definition at line 210 of file Config.py.

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

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

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

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

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

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

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

Definition at line 141 of file Config.py.

00142                          :
00143         """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 165 of file Config.py.

00166                       :
00167         """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 650 of file Config.py.

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

Definition at line 432 of file Config.py.

00433                               :
00434         moduleName = moduleName.replace("/",".")
00435         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 186 of file Config.py.

00187                      :
00188         """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 169 of file Config.py.

00170                    :
        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 202 of file Config.py.

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

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

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

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

00136                            :
00137         """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 176 of file Config.py.

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

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

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

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

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

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

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

Definition at line 171 of file Config.py.

00172                            :
00173         if not name.isalnum():
00174             raise RuntimeError("Error: The process name is an empty string or contains non-alphanumeric characters")
        self.__dict__['_Process__name'] = name
def Config::Process::setPartialSchedule_ (   self,
  sch,
  label 
)

Definition at line 221 of file Config.py.

00222                                            :
00223         if label == "schedule":
00224             self.setSchedule_(sch)
00225         else:
            self._place(label, sch, self.__partialschedules)
def Config::Process::setSchedule_ (   self,
  sch 
)

Definition at line 226 of file Config.py.

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

Definition at line 183 of file Config.py.

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

Definition at line 130 of file Config.py.

00131                               :
00132         self.__isStrict = value
00133         _Module.__isStrict__ = True

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

Definition at line 195 of file Config.py.

00196                                 :
        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 180 of file Config.py.

00181                      :
00182         """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 192 of file Config.py.

00193                          :
00194         """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 800 of file Config.py.

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

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

Definition at line 258 of file Config.py.

00259                      :
00260         """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 767 of file Config.py.

Definition at line 767 of file Config.py.


Property Documentation

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

Definition at line 201 of file Config.py.

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

Definition at line 213 of file Config.py.

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

Definition at line 253 of file Config.py.

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

Definition at line 245 of file Config.py.

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

Definition at line 249 of file Config.py.

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

Definition at line 168 of file Config.py.

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

Definition at line 191 of file Config.py.

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

Definition at line 205 of file Config.py.

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

Definition at line 209 of file Config.py.

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

Definition at line 175 of file Config.py.

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

Definition at line 179 of file Config.py.

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

Definition at line 257 of file Config.py.

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

Definition at line 237 of file Config.py.

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

Definition at line 217 of file Config.py.

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

Definition at line 241 of file Config.py.

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

Definition at line 185 of file Config.py.

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

Definition at line 197 of file Config.py.

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

Definition at line 261 of file Config.py.