Public Member Functions | |
def | __delattr__ |
def | __init__ |
def | __setattr__ |
def | __setstate__ |
def | add_ |
def | aliases_ |
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 | |
aliases = property(aliases_,doc="dictionary containing the aliases for the process") | |
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 | __findFirstSequenceUsingModule |
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 | _placeAlias |
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 |
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__aliases'] = {} 00124 self.__dict__['_Process__psets']={} 00125 self.__dict__['_Process__vpsets']={} 00126 self.__dict__['_cloneToObjectDict'] = {} 00127 # policy switch to avoid object overwriting during extend/load 00128 self.__dict__['_Process__InExtendCall'] = False 00129 self.__dict__['_Process__partialschedules'] = {} 00130 self.__isStrict = False
def Config::Process::__delattr__ | ( | self, | |
name | |||
) |
Definition at line 356 of file Config.py.
00357 : 00358 if not hasattr(self,name): 00359 raise KeyError('process does not know about '+name) 00360 elif name.startswith('_Process__'): 00361 raise ValueError('this attribute cannot be deleted') 00362 else: 00363 # we have to remove it from all dictionaries/registries 00364 dicts = [item for item in self.__dict__.values() if (type(item)==dict or type(item)==DictTypes.SortedKeysDict)] 00365 for reg in dicts: 00366 if reg.has_key(name): del reg[name] 00367 # if it was a labelable object, the label needs to be removed 00368 obj = getattr(self,name) 00369 if isinstance(obj,_Labelable): 00370 getattr(self,name).setLabel(None) 00371 # now remove it from the process itself 00372 try: 00373 del self.__dict__[name] 00374 except: 00375 pass
def Config::Process::__findFirstSequenceUsingModule | ( | self, | |
seqs, | |||
mod | |||
) | [private] |
Given a container of sequences, find the first sequence containing mod and return the sequence. If no sequence is found, return None
Definition at line 345 of file Config.py.
00346 : 00347 """Given a container of sequences, find the first sequence containing mod 00348 and return the sequence. If no sequence is found, return None""" 00349 from FWCore.ParameterSet.SequenceTypes import ModuleNodeVisitor 00350 for sequenceable in seqs.itervalues(): 00351 l = list() 00352 v = ModuleNodeVisitor(l) 00353 sequenceable.visit(v) 00354 if mod in l: 00355 return sequenceable return None
def Config::Process::__setattr__ | ( | self, | |
name, | |||
value | |||
) |
Definition at line 267 of file Config.py.
00268 : 00269 # check if the name is well-formed (only _ and alphanumerics are allowed) 00270 if not name.replace('_','').isalnum(): 00271 raise ValueError('The label '+name+' contains forbiden characters') 00272 00273 # private variable exempt from all this 00274 if name.startswith('_Process__'): 00275 self.__dict__[name]=value 00276 return 00277 if not isinstance(value,_ConfigureComponent): 00278 raise TypeError("can only assign labels to an object which inherits from '_ConfigureComponent'\n" 00279 +"an instance of "+str(type(value))+" will not work") 00280 if not isinstance(value,_Labelable) and not isinstance(value,Source) and not isinstance(value,Looper) and not isinstance(value,Schedule): 00281 if name == value.type_(): 00282 self.add_(value) 00283 return 00284 else: 00285 raise TypeError("an instance of "+str(type(value))+" can not be assigned the label '"+name+"'.\n"+ 00286 "Please either use the label '"+value.type_()+" or use the 'add_' method instead.") 00287 #clone the item 00288 if self.__isStrict: 00289 newValue =value.copy() 00290 try: 00291 newValue._filename = value._filename 00292 except: 00293 pass 00294 value.setIsFrozen() 00295 else: 00296 newValue =value 00297 if not self._okToPlace(name, value, self.__dict__): 00298 newFile='top level config' 00299 if hasattr(value,'_filename'): 00300 newFile = value._filename 00301 oldFile='top level config' 00302 oldValue = getattr(self,name) 00303 if hasattr(oldValue,'_filename'): 00304 oldFile = oldValue._filename 00305 msg = "Trying to override definition of process."+name 00306 msg += "\n new object defined in: "+newFile 00307 msg += "\n existing object defined in: "+oldFile 00308 raise ValueError(msg) 00309 # remove the old object of the name (if there is one) 00310 if hasattr(self,name) and not (getattr(self,name)==newValue): 00311 # Compain if items in sequences from load() statements have 00312 # degeneratate names, but if the user overwrites a name in the 00313 # main config, replace it everywhere 00314 if isinstance(newValue, _Sequenceable): 00315 if not self.__InExtendCall: 00316 self._replaceInSequences(name, newValue) 00317 else: 00318 #should check to see if used in sequence before complaining 00319 newFile='top level config' 00320 if hasattr(value,'_filename'): 00321 newFile = value._filename 00322 oldFile='top level config' 00323 oldValue = getattr(self,name) 00324 if hasattr(oldValue,'_filename'): 00325 oldFile = oldValue._filename 00326 msg1 = "Trying to override definition of "+name+" while it is used by the sequence " 00327 msg2 = "\n new object defined in: "+newFile 00328 msg2 += "\n existing object defined in: "+oldFile 00329 s = self.__findFirstSequenceUsingModule(self.sequences,oldValue) 00330 if s is not None: 00331 raise ValueError(msg1+s.label_()+msg2) 00332 s = self.__findFirstSequenceUsingModule(self.paths,oldValue) 00333 if s is not None: 00334 raise ValueError(msg1+s.label_()+msg2) 00335 s = self.__findFirstSequenceUsingModule(self.endpaths,oldValue) 00336 if s is not None: 00337 raise ValueError(msg1+s.label_()+msg2) 00338 self.__delattr__(name) 00339 self.__dict__[name]=newValue 00340 if isinstance(newValue,_Labelable): 00341 newValue.setLabel(name) 00342 self._cloneToObjectDict[id(value)] = newValue 00343 self._cloneToObjectDict[id(newValue)] = newValue 00344 #now put in proper bucket 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 149 of file Config.py.
00150 : 00151 """ 00152 Unpickling hook. 00153 00154 Since cloneToObjectDict stores a hash of objects by their 00155 id() it needs to be updated when unpickling to use the 00156 new object id values instantiated during the unpickle. 00157 00158 """ 00159 self.__dict__.update(pkldict) 00160 tmpDict = {} 00161 for value in self._cloneToObjectDict.values(): 00162 tmpDict[id(value)] = value 00163 self.__dict__['_cloneToObjectDict'] = tmpDict 00164 00165
def Config::Process::_dumpConfigESPrefers | ( | self, | |
options | |||
) | [private] |
def Config::Process::_dumpConfigNamedList | ( | self, | |
items, | |||
typeName, | |||
options | |||
) | [private] |
def Config::Process::_dumpConfigOptionallyNamedList | ( | self, | |
items, | |||
typeName, | |||
options | |||
) | [private] |
def Config::Process::_dumpConfigUnnamedList | ( | self, | |
items, | |||
typeName, | |||
options | |||
) | [private] |
def Config::Process::_dumpPython | ( | self, | |
d, | |||
options | |||
) | [private] |
def Config::Process::_dumpPythonList | ( | self, | |
d, | |||
options | |||
) | [private] |
Definition at line 608 of file Config.py.
00609 : 00610 returnValue = '' 00611 if isinstance(d, DictTypes.SortedKeysDict): 00612 for name,item in d.items(): 00613 returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n' 00614 else: 00615 for name,item in sorted(d.items()): 00616 returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n' return returnValue
def Config::Process::_findPreferred | ( | self, | |
esname, | |||
d, | |||
args, | |||
kargs | |||
) | [private] |
Definition at line 896 of file Config.py.
00897 : 00898 # is esname a name in the dictionary? 00899 if esname in d: 00900 typ = d[esname].type_() 00901 if typ == esname: 00902 self.__setattr__( esname+"_prefer", ESPrefer(typ,*args,**kargs) ) 00903 else: 00904 self.__setattr__( esname+"_prefer", ESPrefer(typ, esname,*args,**kargs) ) 00905 return True 00906 else: 00907 # maybe it's an unnamed ESModule? 00908 found = False 00909 for name, value in d.iteritems(): 00910 if value.type_() == esname: 00911 if found: 00912 raise RuntimeError("More than one ES module for "+esname) 00913 found = True 00914 self.__setattr__(esname+"_prefer", ESPrefer(d[esname].type_()) ) 00915 return found
def Config::Process::_insertInto | ( | self, | |
parameterSet, | |||
itemDict | |||
) | [private] |
def Config::Process::_insertManyInto | ( | self, | |
parameterSet, | |||
label, | |||
itemDict, | |||
tracked | |||
) | [private] |
Definition at line 716 of file Config.py.
00717 : 00718 l = [] 00719 for name,value in itemDict.iteritems(): 00720 newLabel = value.nameInProcessDesc_(name) 00721 l.append(newLabel) 00722 value.insertInto(parameterSet, name) 00723 # alphabetical order is easier to compare with old language 00724 l.sort() parameterSet.addVString(tracked, label, l)
def Config::Process::_insertOneInto | ( | self, | |
parameterSet, | |||
label, | |||
item, | |||
tracked | |||
) | [private] |
def Config::Process::_insertPaths | ( | self, | |
processPSet | |||
) | [private] |
Definition at line 725 of file Config.py.
00726 : 00727 scheduledPaths = [] 00728 triggerPaths = [] 00729 endpaths = [] 00730 if self.schedule_() == None: 00731 # make one from triggerpaths & endpaths 00732 for name,value in self.paths_().iteritems(): 00733 scheduledPaths.append(name) 00734 triggerPaths.append(name) 00735 for name,value in self.endpaths_().iteritems(): 00736 scheduledPaths.append(name) 00737 endpaths.append(name) 00738 else: 00739 for path in self.schedule_(): 00740 pathname = path.label_() 00741 scheduledPaths.append(pathname) 00742 if self.endpaths_().has_key(pathname): 00743 endpaths.append(pathname) 00744 else: 00745 triggerPaths.append(pathname) 00746 processPSet.addVString(True, "@end_paths", endpaths) 00747 processPSet.addVString(True, "@paths", scheduledPaths) 00748 # trigger_paths are a little different 00749 p = processPSet.newPSet() 00750 p.addVString(True, "@trigger_paths", triggerPaths) 00751 processPSet.addPSet(True, "@trigger_paths", p) 00752 # add all these paths 00753 pathValidator = PathValidator() 00754 endpathValidator = EndPathValidator() 00755 for triggername in triggerPaths: 00756 #self.paths_()[triggername].insertInto(processPSet, triggername, self.sequences_()) 00757 pathValidator.setLabel(triggername) 00758 self.paths_()[triggername].visit(pathValidator) 00759 self.paths_()[triggername].insertInto(processPSet, triggername, self.__dict__) 00760 for endpathname in endpaths: 00761 #self.endpaths_()[endpathname].insertInto(processPSet, endpathname, self.sequences_()) 00762 endpathValidator.setLabel(endpathname) 00763 self.endpaths_()[endpathname].visit(endpathValidator) 00764 self.endpaths_()[endpathname].insertInto(processPSet, endpathname, self.__dict__) 00765 processPSet.addVString(False, "@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
def Config::Process::_okToPlace | ( | self, | |
name, | |||
mod, | |||
d | |||
) | [private] |
Definition at line 391 of file Config.py.
00392 : 00393 if not self.__InExtendCall: 00394 # if going 00395 return True 00396 elif not self.__isStrict: 00397 return True 00398 elif name in d: 00399 # if there's an old copy, and the new one 00400 # hasn't been modified, we're done. Still 00401 # not quite safe if something has been defined twice. 00402 # Need to add checks 00403 if mod._isModified: 00404 if d[name]._isModified: 00405 return False 00406 else: 00407 return True 00408 else: 00409 return True 00410 else: 00411 return True
def Config::Process::_place | ( | self, | |
name, | |||
mod, | |||
d | |||
) | [private] |
def Config::Process::_placeAlias | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeAnalyzer | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeEndPath | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeESPrefer | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeESProducer | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeESSource | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeFilter | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeLooper | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeOutputModule | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placePath | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeProducer | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placePSet | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeSequence | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeService | ( | self, | |
typeName, | |||
mod | |||
) | [private] |
def Config::Process::_placeSource | ( | self, | |
name, | |||
mod | |||
) | [private] |
Allow the source to be referenced by 'source' or by type name
Definition at line 457 of file Config.py.
00458 : 00459 """Allow the source to be referenced by 'source' or by type name""" 00460 if name != 'source': 00461 raise ValueError("The label '"+name+"' can not be used for a Source. Only 'source' is allowed.") 00462 if self.__dict__['_Process__source'] is not None : 00463 del self.__dict__[self.__dict__['_Process__source'].type_()] 00464 self.__dict__['_Process__source'] = mod self.__dict__[mod.type_()] = mod
def Config::Process::_placeSubProcess | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_placeVPSet | ( | self, | |
name, | |||
mod | |||
) | [private] |
def Config::Process::_pruneModules | ( | self, | |
d, | |||
scheduledNames | |||
) | [private] |
def Config::Process::_replaceInSequences | ( | self, | |
label, | |||
new | |||
) | [private] |
Definition at line 691 of file Config.py.
00692 : 00693 old = getattr(self,label) 00694 #TODO - replace by iterator concatenation 00695 for sequenceable in self.sequences.itervalues(): 00696 sequenceable.replace(old,new) 00697 for sequenceable in self.paths.itervalues(): 00698 sequenceable.replace(old,new) 00699 for sequenceable in self.endpaths.itervalues(): sequenceable.replace(old,new)
def Config::Process::_sequencesInDependencyOrder | ( | self | ) | [private] |
Definition at line 625 of file Config.py.
00626 : 00627 #for each sequence, see what other sequences it depends upon 00628 returnValue=DictTypes.SortedKeysDict() 00629 dependencies = {} 00630 for label,seq in self.sequences.iteritems(): 00631 d = [] 00632 v = SequenceVisitor(d) 00633 seq.visit(v) 00634 dependencies[label]=[dep.label_() for dep in d if dep.hasLabel_()] 00635 resolvedDependencies=True 00636 #keep looping until we can no longer get rid of all dependencies 00637 # if that happens it means we have circular dependencies 00638 iterCount = 0 00639 while resolvedDependencies: 00640 iterCount += 1 00641 resolvedDependencies = (0 != len(dependencies)) 00642 oldDeps = dict(dependencies) 00643 for label,deps in oldDeps.iteritems(): 00644 # don't try too hard 00645 if len(deps)==0 or iterCount > 100: 00646 iterCount = 0 00647 resolvedDependencies=True 00648 returnValue[label]=self.sequences[label] 00649 #remove this as a dependency for all other sequences 00650 del dependencies[label] 00651 for lb2,deps2 in dependencies.iteritems(): 00652 while deps2.count(label): 00653 deps2.remove(label) 00654 if len(dependencies): 00655 raise RuntimeError("circular sequence dependency discovered \n"+ 00656 ",".join([label for label,junk in dependencies.iteritems()])) return returnValue
def Config::Process::_validateSequence | ( | self, | |
sequence, | |||
label | |||
) | [private] |
def Config::Process::add_ | ( | self, | |
value | |||
) |
Allows addition of components which do not have to have a label, e.g. Services
Definition at line 376 of file Config.py.
00377 : 00378 """Allows addition of components which do not have to have a label, e.g. Services""" 00379 if not isinstance(value,_ConfigureComponent): 00380 raise TypeError 00381 if not isinstance(value,_Unlabelable): 00382 raise TypeError 00383 #clone the item 00384 #clone the item 00385 if self.__isStrict: 00386 newValue =value.copy() 00387 value.setIsFrozen() 00388 else: 00389 newValue =value 00390 newValue._place('',self)
def Config::Process::aliases_ | ( | self | ) |
def Config::Process::analyzerNames | ( | self | ) |
def Config::Process::analyzers_ | ( | self | ) |
def Config::Process::dumpConfig | ( | self, | |
options = PrintOptions() |
|||
) |
return a string containing the equivalent process defined using the old configuration language
Definition at line 542 of file Config.py.
00543 : 00544 """return a string containing the equivalent process defined using the old configuration language""" 00545 config = "process "+self.__name+" = {\n" 00546 options.indent() 00547 if self.source_(): 00548 config += options.indentation()+"source = "+self.source_().dumpConfig(options) 00549 if self.looper_(): 00550 config += options.indentation()+"looper = "+self.looper_().dumpConfig(options) 00551 if self.subProcess_(): 00552 config += options.indentation()+"subProcess = "+self.subProcess_().dumpConfig(options) 00553 00554 config+=self._dumpConfigNamedList(self.producers_().iteritems(), 00555 'module', 00556 options) 00557 config+=self._dumpConfigNamedList(self.filters_().iteritems(), 00558 'module', 00559 options) 00560 config+=self._dumpConfigNamedList(self.analyzers_().iteritems(), 00561 'module', 00562 options) 00563 config+=self._dumpConfigNamedList(self.outputModules_().iteritems(), 00564 'module', 00565 options) 00566 config+=self._dumpConfigNamedList(self.sequences_().iteritems(), 00567 'sequence', 00568 options) 00569 config+=self._dumpConfigNamedList(self.paths_().iteritems(), 00570 'path', 00571 options) 00572 config+=self._dumpConfigNamedList(self.endpaths_().iteritems(), 00573 'endpath', 00574 options) 00575 config+=self._dumpConfigUnnamedList(self.services_().iteritems(), 00576 'service', 00577 options) 00578 config+=self._dumpConfigNamedList(self.aliases_().iteritems(), 00579 'alias', 00580 options) 00581 config+=self._dumpConfigOptionallyNamedList( 00582 self.es_producers_().iteritems(), 00583 'es_module', 00584 options) 00585 config+=self._dumpConfigOptionallyNamedList( 00586 self.es_sources_().iteritems(), 00587 'es_source', 00588 options) 00589 config += self._dumpConfigESPrefers(options) 00590 for name,item in self.psets.iteritems(): 00591 config +=options.indentation()+item.configTypeName()+' '+name+' = '+item.configValue(options) 00592 for name,item in self.vpsets.iteritems(): 00593 config +=options.indentation()+'VPSet '+name+' = '+item.configValue(options) 00594 if self.schedule: 00595 pathNames = [p.label_() for p in self.schedule] 00596 config +=options.indentation()+'schedule = {'+','.join(pathNames)+'}\n' 00597 00598 # config+=self._dumpConfigNamedList(self.vpsets.iteritems(), 00599 # 'VPSet', 00600 # options) 00601 config += "}\n" 00602 options.unindent() return config
def Config::Process::dumpPython | ( | self, | |
options = PrintOptions() |
|||
) |
return a string containing the equivalent process defined using python
Definition at line 662 of file Config.py.
00663 : 00664 """return a string containing the equivalent process defined using python""" 00665 result = "import FWCore.ParameterSet.Config as cms\n\n" 00666 result += "process = cms.Process(\""+self.__name+"\")\n\n" 00667 if self.source_(): 00668 result += "process.source = "+self.source_().dumpPython(options) 00669 if self.looper_(): 00670 result += "process.looper = "+self.looper_().dumpPython() 00671 if self.subProcess_(): 00672 result += self.subProcess_().dumpPython(options) 00673 result+=self._dumpPythonList(self.producers_(), options) 00674 result+=self._dumpPythonList(self.filters_() , options) 00675 result+=self._dumpPythonList(self.analyzers_(), options) 00676 result+=self._dumpPythonList(self.outputModules_(), options) 00677 result+=self._dumpPythonList(self._sequencesInDependencyOrder(), options) 00678 result+=self._dumpPythonList(self.paths_(), options) 00679 result+=self._dumpPythonList(self.endpaths_(), options) 00680 result+=self._dumpPythonList(self.services_(), options) 00681 result+=self._dumpPythonList(self.es_producers_(), options) 00682 result+=self._dumpPythonList(self.es_sources_(), options) 00683 result+=self._dumpPython(self.es_prefers_(), options) 00684 result+=self._dumpPythonList(self.aliases_(), options) 00685 result+=self._dumpPythonList(self.psets, options) 00686 result+=self._dumpPythonList(self.vpsets, options) 00687 if self.schedule: 00688 pathNames = ['process.'+p.label_() for p in self.schedule] 00689 result +='process.schedule = cms.Schedule(*[ ' + ', '.join(pathNames) + ' ])\n' 00690 return result
def Config::Process::endpaths_ | ( | self | ) |
def Config::Process::es_prefers_ | ( | self | ) |
def Config::Process::es_producers_ | ( | self | ) |
def Config::Process::es_sources_ | ( | self | ) |
def Config::Process::extend | ( | self, | |
other, | |||
items = () |
|||
) |
Look in other and find types which we can use
Definition at line 482 of file Config.py.
00483 : 00484 """Look in other and find types which we can use""" 00485 # enable explicit check to avoid overwriting of existing objects 00486 self.__dict__['_Process__InExtendCall'] = True 00487 00488 seqs = dict() 00489 labelled = dict() 00490 for name in dir(other): 00491 #'from XX import *' ignores these, and so should we. 00492 if name.startswith('_'): 00493 continue 00494 item = getattr(other,name) 00495 if name == "source" or name == "looper" or name == "subProcess": 00496 self.__setattr__(name,item) 00497 elif isinstance(item,_ModuleSequenceType): 00498 seqs[name]=item 00499 elif isinstance(item,_Labelable): 00500 self.__setattr__(name,item) 00501 labelled[name]=item 00502 try: 00503 item.label_() 00504 except: 00505 item.setLabel(name) 00506 continue 00507 elif isinstance(item,Schedule): 00508 self.__setattr__(name,item) 00509 elif isinstance(item,_Unlabelable): 00510 self.add_(item) 00511 00512 #now create a sequence which uses the newly made items 00513 for name in seqs.iterkeys(): 00514 seq = seqs[name] 00515 #newSeq = seq.copy() 00516 # 00517 if id(seq) not in self._cloneToObjectDict: 00518 self.__setattr__(name,seq) 00519 else: 00520 newSeq = self._cloneToObjectDict[id(seq)] 00521 self.__dict__[name]=newSeq 00522 newSeq.setLabel(name) 00523 #now put in proper bucket 00524 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 826 of file Config.py.
00827 : 00828 """Used by the framework to convert python to C++ objects""" 00829 class ServiceInjectorAdaptor(object): 00830 def __init__(self,ppset,thelist): 00831 self.__thelist = thelist 00832 self.__processPSet = ppset 00833 def addService(self,pset): 00834 self.__thelist.append(pset) 00835 def newPSet(self): 00836 return self.__processPSet.newPSet() 00837 self.validate() 00838 processPSet.addString(True, "@process_name", self.name_()) 00839 all_modules = self.producers_().copy() 00840 all_modules.update(self.filters_()) 00841 all_modules.update(self.analyzers_()) 00842 all_modules.update(self.outputModules_()) 00843 self._insertInto(processPSet, self.psets_()) 00844 self._insertInto(processPSet, self.vpsets_()) 00845 self._insertManyInto(processPSet, "@all_modules", all_modules, True) 00846 self._insertOneInto(processPSet, "@all_sources", self.source_(), True) 00847 self._insertOneInto(processPSet, "@all_loopers", self.looper_(), True) 00848 self._insertOneInto(processPSet, "@all_subprocesses", self.subProcess_(), False) 00849 self._insertManyInto(processPSet, "@all_esmodules", self.es_producers_(), True) 00850 self._insertManyInto(processPSet, "@all_essources", self.es_sources_(), True) 00851 self._insertManyInto(processPSet, "@all_esprefers", self.es_prefers_(), True) 00852 self._insertManyInto(processPSet, "@all_aliases", self.aliases_(), True) 00853 self._insertPaths(processPSet) 00854 #handle services differently 00855 services = [] 00856 for n in self.services_(): 00857 getattr(self,n).insertInto(ServiceInjectorAdaptor(processPSet,services)) 00858 processPSet.addVPSet(False,"services",services) 00859 return processPSet
def Config::Process::filterNames | ( | self | ) |
def Config::Process::filters_ | ( | self | ) |
def Config::Process::globalReplace | ( | self, | |
label, | |||
new | |||
) |
Replace the item with label 'label' by object 'new' in the process and all sequences/paths
def Config::Process::load | ( | self, | |
moduleName | |||
) |
def Config::Process::looper_ | ( | self | ) |
def Config::Process::name_ | ( | self | ) |
def Config::Process::outputModules_ | ( | self | ) |
def Config::Process::pathNames | ( | self | ) |
def Config::Process::paths_ | ( | self | ) |
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 867 of file Config.py.
00868 : 00869 """Prefer this ES source or producer. The argument can 00870 either be an object label, e.g., 00871 process.prefer(process.juicerProducer) (not supported yet) 00872 or a name of an ESSource or ESProducer 00873 process.prefer("juicer") 00874 or a type of unnamed ESSource or ESProducer 00875 process.prefer("JuicerProducer") 00876 In addition, you can pass as a labelled arguments the name of the Record you wish to 00877 prefer where the type passed is a cms.vstring and that vstring can contain the 00878 name of the C++ types in the Record which are being preferred, e.g., 00879 #prefer all data in record 'OrangeRecord' from 'juicer' 00880 process.prefer("juicer", OrangeRecord=cms.vstring()) 00881 or 00882 #prefer only "Orange" data in "OrangeRecord" from "juicer" 00883 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 00884 or 00885 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 00886 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 00887 """ 00888 # see if this refers to a named ESProducer 00889 if isinstance(esmodule, ESSource) or isinstance(esmodule, ESProducer): 00890 raise RuntimeError("Syntax of process.prefer(process.esmodule) not supported yet") 00891 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs) or \ 00892 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs): 00893 pass 00894 else: 00895 raise RuntimeError("Cannot resolve prefer for "+repr(esmodule))
def Config::Process::producerNames | ( | self | ) |
def Config::Process::producers_ | ( | self | ) |
def Config::Process::prune | ( | self, | |
verbose = False |
|||
) |
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 766 of file Config.py.
00767 : 00768 """ Remove clutter from the process which we think is unnecessary: 00769 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 00770 not in the schedule will also be removed, along with an modules and sequences used only by 00771 those removed Paths and EndPaths.""" 00772 for name in self.psets_(): 00773 if getattr(self,name).isTracked(): 00774 delattr(self, name) 00775 for name in self.vpsets_(): 00776 delattr(self, name) 00777 #first we need to resolve any SequencePlaceholders being used 00778 for x in self.paths.itervalues(): 00779 x.resolve(self.__dict__) 00780 for x in self.endpaths.itervalues(): 00781 x.resolve(self.__dict__) 00782 usedModules = set() 00783 unneededPaths = set() 00784 if self.schedule_(): 00785 usedModules=set(self.schedule_().moduleNames()) 00786 #get rid of unused paths 00787 schedNames = set(( x.label_() for x in self.schedule_())) 00788 names = set(self.paths) 00789 names.update(set(self.endpaths)) 00790 unneededPaths = names - schedNames 00791 for n in unneededPaths: 00792 delattr(self,n) 00793 else: 00794 pths = list(self.paths.itervalues()) 00795 pths.extend(self.endpaths.itervalues()) 00796 temp = Schedule(*pths) 00797 usedModules=set(temp.moduleNames()) 00798 unneededModules = self._pruneModules(self.producers_(), usedModules) 00799 unneededModules.update(self._pruneModules(self.filters_(), usedModules)) 00800 unneededModules.update(self._pruneModules(self.analyzers_(), usedModules)) 00801 #remove sequences that do not appear in remaining paths and endpaths 00802 seqs = list() 00803 sv = SequenceVisitor(seqs) 00804 for p in self.paths.itervalues(): 00805 p.visit(sv) 00806 for p in self.endpaths.itervalues(): 00807 p.visit(sv) 00808 keepSeqSet = set(( s for s in seqs if s.hasLabel_())) 00809 availableSeqs = set(self.sequences.itervalues()) 00810 unneededSeqs = availableSeqs-keepSeqSet 00811 unneededSeqLabels = [] 00812 for s in unneededSeqs: 00813 unneededSeqLabels.append(s.label_()) 00814 delattr(self,s.label_()) 00815 if verbose: 00816 print "prune removed the following:" 00817 print " modules:"+",".join(unneededModules) 00818 print " sequences:"+",".join(unneededSeqLabels) print " paths/endpaths:"+",".join(unneededPaths)
def Config::Process::psets_ | ( | self | ) |
def Config::Process::schedule_ | ( | self | ) |
def Config::Process::sequences_ | ( | self | ) |
def Config::Process::services_ | ( | self | ) |
def Config::Process::setLooper_ | ( | self, | |
lpr | |||
) |
def Config::Process::setName_ | ( | self, | |
name | |||
) |
def Config::Process::setPartialSchedule_ | ( | self, | |
sch, | |||
label | |||
) |
def Config::Process::setSchedule_ | ( | self, | |
sch | |||
) |
Definition at line 227 of file Config.py.
00228 : 00229 # See if every module has been inserted into the process 00230 index = 0 00231 try: 00232 for p in sch: 00233 p.label_() 00234 index +=1 00235 except: 00236 raise RuntimeError("The path at index "+str(index)+" in the Schedule was not attached to the process.") 00237 self.__dict__['_Process__schedule'] = sch
def Config::Process::setSource_ | ( | self, | |
src | |||
) |
def Config::Process::setStrict | ( | self, | |
value | |||
) |
def Config::Process::setSubProcess_ | ( | self, | |
lpr | |||
) |
def Config::Process::source_ | ( | self | ) |
def Config::Process::subProcess_ | ( | self | ) |
def Config::Process::validate | ( | self | ) |
def Config::Process::vpsets_ | ( | self | ) |
Config::Process::__isStrict [private] |
Config::Process::__processPSet [private] |
Config::Process::__thelist [private] |
Config::Process::aliases = property(aliases_,doc="dictionary containing the aliases for the process") [static] |
Config::Process::analyzers = property(analyzers_,doc="dictionary containing the analyzers for the process") [static] |
Config::Process::endpaths = property(endpaths_,doc="dictionary containing the endpaths for the process") [static] |
Config::Process::es_prefers = property(es_prefers_,doc="dictionary containing the es_prefers for the process") [static] |
Config::Process::es_producers = property(es_producers_,doc="dictionary containing the es_producers for the process") [static] |
Config::Process::es_sources = property(es_sources_,doc="dictionary containing the es_sources for the process") [static] |
Config::Process::filters = property(filters_, doc="dictionary containing the filters for the process") [static] |
Config::Process::looper = property(looper_,setLooper_,doc='the main looper or None if not set') [static] |
Config::Process::outputModules = property(outputModules_,doc="dictionary containing the output_modules for the process") [static] |
Config::Process::paths = property(paths_,doc="dictionary containing the paths for the process") [static] |
Config::Process::process = property(name_,setName_, doc="name of the process") [static] |
Config::Process::producers = property(producers_,doc="dictionary containing the producers for the process") [static] |
Config::Process::psets = property(psets_,doc="dictionary containing the PSets for the process") [static] |
Config::Process::schedule = property(schedule_,setSchedule_,doc='the schedule or None if not set') [static] |
Config::Process::sequences = property(sequences_,doc="dictionary containing the sequences for the process") [static] |
Config::Process::services = property(services_,doc="dictionary containing the services for the process") [static] |
Config::Process::source = property(source_,setSource_,doc='the main source or None if not set') [static] |
Config::Process::subProcess = property(subProcess_,setSubProcess_,doc='the SubProcess or None if not set') [static] |