4 from Options
import Options
10 from Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
14 from Modules
import _Module
15 from SequenceTypes
import *
16 from SequenceTypes
import _ModuleSequenceType, _Sequenceable
17 from SequenceVisitors
import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
20 from ExceptionHandling
import *
23 if sys.getrecursionlimit()<5000:
24 sys.setrecursionlimit(5000)
28 Raise an exception if called by special config files. This checks 29 the call or import stack for the importing file. An exception is raised if 30 the importing module is not in allowedPatterns and if it is called too deeply: 31 minLevel = 2: inclusion by top lvel cfg only 32 minLevel = 1: No inclusion allowed 33 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 34 by any module in Module1 or Submodule1 40 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>']
41 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
45 for item
in inspect.stack():
49 for pattern
in CMSSWPath:
50 if item[1].
find(pattern) != -1:
53 if item[1].
find(
'/') == -1:
56 for pattern
in ignorePatterns:
57 if item[1].
find(pattern) != -1:
61 if inPath
and not ignore:
62 trueStack.append(item[1])
64 importedFile = trueStack[0]
66 if len(trueStack) > 1:
67 importedBy = trueStack[1]
69 for pattern
in allowedPatterns:
70 if importedBy.find(pattern) > -1:
73 if len(trueStack) <= minLevel:
76 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 80 """Look inside the module and find the Processes it contains""" 84 if isinstance(module,dict):
85 if 'process' in module:
89 if hasattr(module,
'process'):
90 if isinstance(module.process,Process):
91 process = module.process
93 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
95 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
99 """Root class for a CMS configuration process""" 101 """The argument 'name' will be the name applied to this Process 102 Can optionally pass as additional arguments cms.Modifier instances 103 that will be used to modify the Process as it is built 105 self.__dict__[
'_Process__name'] = name
106 if not name.isalnum():
107 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
108 self.__dict__[
'_Process__filters'] = {}
109 self.__dict__[
'_Process__producers'] = {}
110 self.__dict__[
'_Process__source'] =
None 111 self.__dict__[
'_Process__looper'] =
None 112 self.__dict__[
'_Process__subProcesses'] = []
113 self.__dict__[
'_Process__schedule'] =
None 114 self.__dict__[
'_Process__analyzers'] = {}
115 self.__dict__[
'_Process__outputmodules'] = {}
118 self.__dict__[
'_Process__sequences'] = {}
119 self.__dict__[
'_Process__tasks'] = {}
120 self.__dict__[
'_Process__services'] = {}
121 self.__dict__[
'_Process__essources'] = {}
122 self.__dict__[
'_Process__esproducers'] = {}
123 self.__dict__[
'_Process__esprefers'] = {}
124 self.__dict__[
'_Process__aliases'] = {}
125 self.__dict__[
'_Process__psets']={}
126 self.__dict__[
'_Process__vpsets']={}
127 self.__dict__[
'_cloneToObjectDict'] = {}
129 self.__dict__[
'_Process__InExtendCall'] =
False 130 self.__dict__[
'_Process__partialschedules'] = {}
132 self.__dict__[
'_Process__modifiers'] = Mods
133 for m
in self.__modifiers:
138 _Module.__isStrict__ =
True 142 """Returns a string containing all the EDProducer labels separated by a blank""" 145 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 148 """Returns a string containing all the EDFilter labels separated by a blank""" 151 """Returns a string containing all the Path names separated by a blank""" 158 Since cloneToObjectDict stores a hash of objects by their 159 id() it needs to be updated when unpickling to use the 160 new object id values instantiated during the unpickle. 163 self.__dict__.update(pkldict)
165 for value
in self._cloneToObjectDict.values():
166 tmpDict[
id(value)] = value
167 self.__dict__[
'_cloneToObjectDict'] = tmpDict
172 """returns a dict of the filters that have been added to the Process""" 174 filters = property(filters_, doc=
"dictionary containing the filters for the process")
178 if not name.isalnum():
179 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
180 self.__dict__[
'_Process__name'] = name
181 process = property(name_,setName_, doc=
"name of the process")
183 """returns a dict of the producers that have been added to the Process""" 185 producers = property(producers_,doc=
"dictionary containing the producers for the process")
187 """returns the source that has been added to the Process or None if none have been added""" 191 source = property(source_,setSource_,doc=
'the main source or None if not set')
193 """returns the looper that has been added to the Process or None if none have been added""" 197 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
199 """returns a list of the subProcesses that have been added to the Process""" 200 return self.__subProcesses
201 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
203 """returns a dict of the analyzers that have been added to the Process""" 205 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
207 """returns a dict of the output modules that have been added to the Process""" 209 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
211 """returns a dict of the paths that have been added to the Process""" 213 paths = property(paths_,doc=
"dictionary containing the paths for the process")
215 """returns a dict of the endpaths that have been added to the Process""" 217 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
219 """returns a dict of the sequences that have been added to the Process""" 221 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
223 """returns a dict of the tasks that have been added to the Process""" 225 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
227 """returns the schedule that has been added to the Process or None if none have been added""" 228 return self.__schedule
230 if label ==
"schedule":
233 self.
_place(label, sch, self.__partialschedules)
242 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
243 self.__dict__[
'_Process__schedule'] = sch
244 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
246 """returns a dict of the services that have been added to the Process""" 248 services = property(services_,doc=
"dictionary containing the services for the process")
250 """returns a dict of the esproducers that have been added to the Process""" 252 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
254 """returns a the es_sources that have been added to the Process""" 256 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
258 """returns a dict of the es_prefers that have been added to the Process""" 260 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
262 """returns a dict of the aliases that have been added to the Process""" 264 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
266 """returns a dict of the PSets that have been added to the Process""" 268 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
270 """returns a dict of the VPSets that have been added to the Process""" 272 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
275 """returns True if the Modifier is in used by this Process""" 277 for m
in self.__modifiers:
278 if m._isOrContains(mod):
283 if not object.hasLabel_() :
284 object.setLabel(newLabel)
286 if newLabel == object.label_() :
288 if newLabel
is None :
289 object.setLabel(
None)
291 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
292 msg100 =
"Attempting to change the label of an attribute of the Process\n" 293 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 294 msg102 =
"Type = "+
str(type(object))+
"\n" 295 msg103 =
"Some possible solutions:\n" 296 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 297 msg105 =
" also preferred for other types when possible.\n" 298 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 299 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 300 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 301 msg109 =
" the name.\n" 302 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 303 msg111 =
" name to the same object usually causes confusion and problems.\n" 304 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 305 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
306 object.setLabel(
None)
307 object.setLabel(newLabel)
311 if not name.replace(
'_',
'').isalnum():
312 raise ValueError(
'The label '+name+
' contains forbiden characters')
315 if name.startswith(
'_Process__'):
316 self.__dict__[name]=value
318 if not isinstance(value,_ConfigureComponent):
319 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 320 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
321 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
322 if name == value.type_():
327 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
328 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
331 newValue =value.copy()
333 newValue._filename = value._filename
339 if not self.
_okToPlace(name, value, self.__dict__):
340 newFile=
'top level config' 341 if hasattr(value,
'_filename'):
342 newFile = value._filename
343 oldFile=
'top level config' 344 oldValue = getattr(self,name)
345 if hasattr(oldValue,
'_filename'):
346 oldFile = oldValue._filename
347 msg =
"Trying to override definition of process."+name
348 msg +=
"\n new object defined in: "+newFile
349 msg +=
"\n existing object defined in: "+oldFile
350 raise ValueError(msg)
352 if hasattr(self,name)
and not (getattr(self,name)==newValue):
356 if newValue._isTaskComponent():
357 if not self.__InExtendCall:
361 if not isinstance(newValue, Task):
363 newFile=
'top level config' 364 if hasattr(value,
'_filename'):
365 newFile = value._filename
366 oldFile=
'top level config' 367 oldValue = getattr(self,name)
368 if hasattr(oldValue,
'_filename'):
369 oldFile = oldValue._filename
370 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 371 msg2 =
"\n new object defined in: "+newFile
372 msg2 +=
"\n existing object defined in: "+oldFile
375 raise ValueError(msg1+s.label_()+msg2)
377 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent():
378 if not self.__InExtendCall:
382 newFile=
'top level config' 383 if hasattr(value,
'_filename'):
384 newFile = value._filename
385 oldFile=
'top level config' 386 oldValue = getattr(self,name)
387 if hasattr(oldValue,
'_filename'):
388 oldFile = oldValue._filename
389 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 390 msg2 =
"\n new object defined in: "+newFile
391 msg2 +=
"\n existing object defined in: "+oldFile
394 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
397 raise ValueError(msg1+
"path "+s.label_()+msg2)
400 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
402 self.__dict__[name]=newValue
403 if isinstance(newValue,_Labelable):
405 self._cloneToObjectDict[
id(value)] = newValue
406 self._cloneToObjectDict[
id(newValue)] = newValue
408 newValue._place(name,self)
410 """Given a container of sequences or tasks, find the first sequence or task 411 containing mod and return it. If none is found, return None""" 414 for seqOrTask
in seqsOrTasks.itervalues():
423 if not hasattr(self,name):
424 raise KeyError(
'process does not know about '+name)
425 elif name.startswith(
'_Process__'):
426 raise ValueError(
'this attribute cannot be deleted')
431 if name
in reg: del reg[name]
433 obj = getattr(self,name)
434 if isinstance(obj,_Labelable):
436 if isinstance(obj,Service):
437 obj._inProcess =
False 441 obj = getattr(self,name)
443 if not isinstance(obj, Sequence)
and not isinstance(obj, Task):
453 if obj._isTaskComponent():
456 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
460 del self.__dict__[name]
465 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 469 del self.__dict__[name]
474 """Allows addition of components that do not have to have a label, e.g. Services""" 475 if not isinstance(value,_ConfigureComponent):
477 if not isinstance(value,_Unlabelable):
482 newValue =value.copy()
486 newValue._place(
'',self)
489 if not self.__InExtendCall:
500 if d[name]._isModified:
511 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
512 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
515 if isinstance(mod,_Labelable):
518 self.
_place(name, mod, self.__outputmodules)
520 self.
_place(name, mod, self.__producers)
522 self.
_place(name, mod, self.__filters)
524 self.
_place(name, mod, self.__analyzers)
528 self.
_place(name, mod, self.__paths)
529 except ModuleCloneError
as msg:
531 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
535 self.
_place(name, mod, self.__endpaths)
536 except ModuleCloneError
as msg:
538 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
541 self.
_place(name, mod, self.__sequences)
543 self.
_place(name, mod, self.__esproducers)
545 self.
_place(name, mod, self.__esprefers)
547 self.
_place(name, mod, self.__essources)
550 self.
_place(name, task, self.__tasks)
552 self.
_place(name, mod, self.__aliases)
554 self.
_place(name, mod, self.__psets)
556 self.
_place(name, mod, self.__vpsets)
558 """Allow the source to be referenced by 'source' or by type name""" 560 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
561 if self.__dict__[
'_Process__source']
is not None :
562 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
563 self.__dict__[
'_Process__source'] = mod
564 self.__dict__[mod.type_()] = mod
567 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
568 self.__dict__[
'_Process__looper'] = mod
569 self.__dict__[mod.type_()] = mod
571 self.__dict__[
'_Process__subProcess'] = mod
572 self.__dict__[mod.type_()] = mod
574 self.__subProcesses.append(mod)
576 self.
_place(typeName, mod, self.__services)
577 if typeName
in self.__dict__:
578 self.__dict__[typeName]._inProcess =
False 579 self.__dict__[typeName]=mod
581 moduleName = moduleName.replace(
"/",
".")
582 module = __import__(moduleName)
583 self.
extend(sys.modules[moduleName])
585 """Look in other and find types that we can use""" 587 self.__dict__[
'_Process__InExtendCall'] =
True 590 tasksToAttach =
dict()
592 for name
in dir(other):
594 if name.startswith(
'_'):
596 item = getattr(other,name)
597 if name ==
"source" or name ==
"looper":
601 elif isinstance(item,_ModuleSequenceType):
603 elif isinstance(item,Task):
604 tasksToAttach[name] = item
605 elif isinstance(item,_Labelable):
607 if not item.hasLabel_() :
609 elif isinstance(item,Schedule):
611 elif isinstance(item,_Unlabelable):
613 elif isinstance(item,ProcessModifier):
615 elif isinstance(item,ProcessFragment):
619 for name
in seqs.iterkeys():
623 if id(seq)
not in self._cloneToObjectDict:
626 newSeq = self._cloneToObjectDict[
id(seq)]
627 self.__dict__[name]=newSeq
630 newSeq._place(name,self)
632 for name
in tasksToAttach.iterkeys():
633 task = tasksToAttach[name]
640 self.__dict__[
'_Process__InExtendCall'] =
False 644 for name,item
in items:
645 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
649 for name,item
in items:
650 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
654 for name,item
in items:
655 if name == item.type_():
657 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
660 """return a string containing the equivalent process defined using the old configuration language""" 661 config =
"process "+self.__name+
" = {\n" 707 for name,item
in self.psets.iteritems():
708 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
709 for name,item
in self.vpsets.iteritems():
710 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
712 pathNames = [p.label_()
for p
in self.
schedule]
713 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 724 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
729 returnValue += item.dumpPython(options)+
'\n\n' 734 for name,item
in d.items():
735 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 737 for name,item
in sorted(d.items()):
738 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 745 sequence.visit(visitor)
747 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
755 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
766 for label,item
in processDictionaryOfItems.iteritems():
768 if isinstance(item, Task):
775 if isinstance(item, Task):
776 raise RuntimeError(
"Failed in a Task visitor. Probably " \
777 "a circular dependency discovered in Task with label " + label)
779 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
780 "circular dependency discovered in Sequence with label " + label)
781 for containedItem
in containedItems:
787 if containedItem.hasLabel_():
788 testItem = processDictionaryOfItems.get(containedItem.label_())
789 if testItem
is None or containedItem != testItem:
790 if isinstance(item, Task):
791 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
792 " from the process yields a different object or None\n"+
793 "label = " + containedItem.label_())
795 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
796 " from the process yields a different object or None\n"+
797 "label = " + containedItem.label_())
798 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
802 oldDeps =
dict(dependencies)
803 for label,deps
in oldDeps.iteritems():
805 returnValue[label]=processDictionaryOfItems[label]
807 del dependencies[label]
808 for lb2,deps2
in dependencies.iteritems():
809 while deps2.count(label):
814 for name, value
in sorted(d.iteritems()):
815 result += value.dumpPythonAs(name,options)+
'\n' 818 """return a string containing the equivalent process defined using python""" 819 result =
"import FWCore.ParameterSet.Config as cms\n\n" 820 result +=
"process = cms.Process(\""+self.__name+
"\")\n\n" 842 result +=
'process.schedule = ' + self.schedule.dumpPython(options)
845 old = getattr(self,label)
847 for sequenceable
in self.sequences.itervalues():
848 sequenceable.replace(old,new)
849 for sequenceable
in self.paths.itervalues():
850 sequenceable.replace(old,new)
851 for sequenceable
in self.endpaths.itervalues():
852 sequenceable.replace(old,new)
854 old = getattr(self,label)
855 for task
in self.tasks.itervalues():
856 task.replace(old, new)
860 old = getattr(self,label)
862 task.replace(old, new)
864 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 865 if not hasattr(self,label):
866 raise LookupError(
"process has no item of label "+label)
867 setattr(self,label,new)
869 for name,value
in itemDict.iteritems():
870 value.insertInto(parameterSet, name)
874 newlabel = item.nameInProcessDesc_(label)
876 item.insertInto(parameterSet, newlabel)
877 parameterSet.addVString(tracked, label, vitems)
880 for name,value
in itemDict.iteritems():
881 newLabel = value.nameInProcessDesc_(name)
883 value.insertInto(parameterSet, name)
886 parameterSet.addVString(tracked, label, l)
890 for value
in itemList:
891 name = value.getProcessName()
892 newLabel = value.nameInProcessDesc_(name)
894 pset = value.getSubProcessPSet(parameterSet)
895 subprocs.append(pset)
898 parameterSet.addVString(tracked, label, l)
899 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
906 for name
in self.
paths_():
907 scheduledPaths.append(name)
908 triggerPaths.append(name)
910 scheduledPaths.append(name)
911 endpaths.append(name)
914 pathname = path.label_()
915 scheduledPaths.append(pathname)
917 endpaths.append(pathname)
919 triggerPaths.append(pathname)
921 task.resolve(self.__dict__)
923 task.visit(scheduleTaskValidator)
924 task.visit(nodeVisitor)
925 processPSet.addVString(
True,
"@end_paths", endpaths)
926 processPSet.addVString(
True,
"@paths", scheduledPaths)
928 p = processPSet.newPSet()
929 p.addVString(
True,
"@trigger_paths", triggerPaths)
930 processPSet.addPSet(
True,
"@trigger_paths", p)
937 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
938 for triggername
in triggerPaths:
939 iPath = self.
paths_()[triggername]
940 iPath.resolve(self.__dict__)
941 pathValidator.setLabel(triggername)
943 iPath.visit(pathCompositeVisitor)
944 iPath.insertInto(processPSet, triggername, decoratedList)
945 for endpathname
in endpaths:
947 iEndPath.resolve(self.__dict__)
948 endpathValidator.setLabel(endpathname)
950 iEndPath.visit(endpathCompositeVisitor)
951 iEndPath.insertInto(processPSet, endpathname, decoratedList)
952 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
954 def resolve(self,keepUnresolvedSequencePlaceholders=False):
955 for x
in self.paths.itervalues():
956 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
957 for x
in self.endpaths.itervalues():
958 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
961 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
963 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
964 """ Remove clutter from the process that we think is unnecessary: 965 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 966 not in the schedule will also be removed, along with an modules and sequences used only by 967 those removed Paths and EndPaths.""" 976 self.
resolve(keepUnresolvedSequencePlaceholders)
978 unneededPaths = set()
980 usedModules=set(self.
schedule_().moduleNames())
982 schedNames = set(( x.label_()
for x
in self.
schedule_()))
983 names = set(self.
paths)
985 unneededPaths = names - schedNames
986 for n
in unneededPaths:
989 pths =
list(self.paths.itervalues())
990 pths.extend(self.endpaths.itervalues())
992 usedModules=set(temp.moduleNames())
999 for p
in self.paths.itervalues():
1001 for p
in self.endpaths.itervalues():
1003 keepSeqSet = set(( s
for s
in seqs
if s.hasLabel_()))
1004 availableSeqs = set(self.sequences.itervalues())
1005 unneededSeqs = availableSeqs-keepSeqSet
1006 unneededSeqLabels = []
1007 for s
in unneededSeqs:
1008 unneededSeqLabels.append(s.label_())
1009 delattr(self,s.label_())
1011 print "prune removed the following:" 1012 print " modules:"+
",".
join(unneededModules)
1013 print " sequences:"+
",".
join(unneededSeqLabels)
1014 print " paths/endpaths:"+
",".
join(unneededPaths)
1016 moduleNames = set(d.keys())
1017 junk = moduleNames - scheduledNames
1023 """Used by the framework to convert python to C++ objects""" 1024 class ServiceInjectorAdaptor(
object):
1028 def addService(self,pset):
1029 self.__thelist.append(pset)
1031 return self.__processPSet.newPSet()
1035 class TopLevelPSetAcessorAdaptor(
object):
1039 def __getattr__(self,attr):
1040 return getattr(self.
__ppset,attr)
1041 def getTopPSet_(self,label):
1044 return TopLevelPSetAcessorAdaptor(self.__ppset.newPSet(),self.
__process)
1045 def addPSet(self,tracked,name,ppset):
1046 return self.__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1047 def addVPSet(self,tracked,name,vpset):
1048 return self.__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1049 def __extractPSet(self,pset):
1050 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1055 processPSet.addString(
True,
"@process_name", self.
name_())
1057 all_modules.update(self.
filters_())
1060 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1073 all_modules_onTasksOrScheduled = { key:value
for key, value
in all_modules.iteritems()
if value
in nodeVisitor.modules }
1074 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1078 for pTask
in self.tasks.itervalues():
1079 pTask.visit(processNodeVisitor)
1080 esProducersToEnable = {}
1081 for esProducerName, esProducer
in self.
es_producers_().iteritems():
1082 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1083 esProducersToEnable[esProducerName] = esProducer
1084 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1085 esSourcesToEnable = {}
1086 for esSourceName, esSource
in self.
es_sources_().iteritems():
1087 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1088 esSourcesToEnable[esSourceName] = esSource
1089 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1092 for serviceName, serviceObject
in self.
services_().iteritems():
1093 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1094 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1095 adaptor.addVPSet(
False,
"services",services)
1106 """Prefer this ES source or producer. The argument can 1107 either be an object label, e.g., 1108 process.prefer(process.juicerProducer) (not supported yet) 1109 or a name of an ESSource or ESProducer 1110 process.prefer("juicer") 1111 or a type of unnamed ESSource or ESProducer 1112 process.prefer("JuicerProducer") 1113 In addition, you can pass as a labelled arguments the name of the Record you wish to 1114 prefer where the type passed is a cms.vstring and that vstring can contain the 1115 name of the C++ types in the Record that are being preferred, e.g., 1116 #prefer all data in record 'OrangeRecord' from 'juicer' 1117 process.prefer("juicer", OrangeRecord=cms.vstring()) 1119 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1120 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1122 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1123 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1126 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1127 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1128 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
1129 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1132 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1137 typ = d[esname].type_()
1146 for name, value
in d.iteritems():
1147 if value.type_() == esname:
1149 raise RuntimeError(
"More than one ES module for "+esname)
1157 if isinstance(process, Process):
1159 elif isinstance(process, str):
1162 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1164 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1166 if name ==
'_ProcessFragment__process':
1167 return object.__getattribute__(self,
'_ProcessFragment__process')
1171 if name ==
'_ProcessFragment__process':
1172 object.__setattr__(self, name, value)
1176 if name ==
'_ProcessFragment__process':
1183 """a dictionary with fixed keys""" 1185 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1186 _blocked_attribute = property(_blocked_attribute)
1187 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1188 pop = popitem = setdefault = update = _blocked_attribute
1190 new = dict.__new__(cls)
1191 dict.__init__(new, *args, **kw)
1194 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1195 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1196 if not isinstance(kw[
'name'],str):
1197 raise ValueError(
"name must be of type string")
1198 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1199 raise ValueError(
"content must be of type vstring or string")
1200 if not isinstance(kw[
'dataTier'], string):
1201 raise ValueError(
"dataTier must be of type string")
1202 if not isinstance(kw[
'selectEvents'], PSet):
1203 raise ValueError(
"selectEvents must be of type PSet")
1204 if not isinstance(kw[
'paths'],(tuple, Path)):
1205 raise ValueError(
"'paths' must be a tuple of paths")
1210 return "FilteredStream object: %s" %self[
"name"]
1215 """Allows embedding another process within a parent process. This allows one to 1216 chain processes together directly in one cmsRun job rather than having to run 1217 separate jobs that are connected via a temporary file. 1219 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1222 if not isinstance(process, Process):
1223 raise ValueError(
"the 'process' argument must be of type cms.Process")
1224 if not isinstance(SelectEvents,PSet):
1225 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1226 if not isinstance(outputCommands,vstring):
1227 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1232 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1233 out += self.__process.dumpPython()
1234 out +=
"childProcess = process\n" 1235 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1236 out +=
"process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = "+self.__SelectEvents.dumpPython(options) +
", outputCommands = "+self.__outputCommands.dumpPython(options) +
"))" 1239 return self.__process.name_()
1251 process._placeSubProcess(
'subProcess',self)
1253 topPSet = parameterSet.newPSet()
1254 self.__process.fillProcessDesc(topPSet)
1255 subProcessPSet = parameterSet.newPSet()
1256 self.__SelectEvents.insertInto(subProcessPSet,
"SelectEvents")
1257 self.__outputCommands.insertInto(subProcessPSet,
"outputCommands")
1258 subProcessPSet.addPSet(
False,
"process",topPSet)
1259 return subProcessPSet
1262 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1267 for k
in self.__args.iterkeys():
1269 params[k] = getattr(obj,k)
1271 for k
in self.__args.iterkeys():
1273 setattr(obj,k,params[k])
1279 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1282 """A modifier which only applies if multiple Modifiers are chosen""" 1287 return self.__lhs.isChosen()
and self.__rhs.isChosen()
1291 self.__lhs.toModify(obj,func, **kw)
1293 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1294 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1295 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1303 """This class is used to define standard modifications to a Process. 1304 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1305 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1306 these Modifier instances are imported into a configuration and items that need to be modified 1307 are then associated with the Modifier and with the action to do the modification. 1308 The registered modifications will only occur if the Modifier was passed to 1309 the cms.Process' constructor. 1315 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1316 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1317 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1321 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1322 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1323 that will be the object passed in as the first argument. 1324 Form 2: A list of parameter name, value pairs can be passed 1325 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1326 This form can also be used to remove a parameter by passing the value of None 1327 #remove the parameter foo.fred 1328 mod.toModify(foo, fred = None) 1329 Additionally, parameters embedded within PSets can also be modified using a dictionary 1330 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1331 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1333 if func
is not None and len(kw) != 0:
1334 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1337 if func
is not None:
1343 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1345 if type(fromObj) != type(toObj):
1346 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1349 if isinstance(fromObj,_ModuleSequenceType):
1350 toObj._seq = fromObj._seq
1351 toObj._tasks = fromObj._tasks
1352 elif isinstance(fromObj,Task):
1353 toObj._collection = fromObj._collection
1354 elif isinstance(fromObj,_Parameterizable):
1356 for p
in toObj.parameterNames_():
1358 for p
in fromObj.parameterNames_():
1359 setattr(toObj,p,getattr(fromObj,p))
1360 if isinstance(fromObj,_TypedParameterizable):
1361 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1364 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1367 """Should only be called by cms.Process instances""" 1374 return self == other
1378 """A Modifier made up of a list of Modifiers 1384 """Should only be called by cms.Process instances 1385 applies list of accumulated changes to the process""" 1387 m._applyNewProcessModifiers(process)
1389 """Should only be called by cms.Process instances""" 1396 """Creates a new ModifierChain which is a copy of 1397 this ModifierChain but excludes any Modifier or 1398 ModifierChain in the list toExclude. 1399 The exclusion is done recursively down the chain. 1403 if m
not in toExclude:
1405 if isinstance(m,ModifierChain):
1406 s = m.__copyIfExclude(toExclude)
1422 if m._isOrContains(other):
1427 """A class used by a Modifier to affect an entire Process instance. 1428 When a Process 'loads' a module containing a ProcessModifier, that 1429 ProcessModifier will be applied to the Process if and only if the 1430 Modifier passed to the constructor has been chosen. 1437 if self.__modifier.isChosen():
1440 self.__seenProcesses.add(process)
1442 if __name__==
"__main__":
1447 """Has same interface as the C++ object that creates PSets 1452 self.
values[label]=(tracked,value)
1510 """Nothing to do """ 1514 self.assertEqual(len(p.parameterNames_()),0)
1516 self.assert_(
'a' in p.parameterNames_())
1517 self.assertEqual(p.a.value(), 1)
1519 self.assertEqual(p.a.value(), 10)
1520 p.a = untracked(
int32(1))
1521 self.assertEqual(p.a.value(), 1)
1522 self.failIf(p.a.isTracked())
1523 p.a = untracked.int32(1)
1524 self.assertEqual(p.a.value(), 1)
1525 self.failIf(p.a.isTracked())
1527 self.assertEqual(p.foo.value(), 10)
1528 self.assertEqual(p.bar.value(),1.0)
1529 self.failIf(p.bar.isTracked())
1530 self.assertRaises(TypeError,setattr,(p,
'c',1))
1532 self.assertEqual(p.a.foo.value(),10)
1533 self.assertEqual(p.a.bar.value(),1.0)
1535 self.assertEqual(p.b.fii.value(),1)
1536 self.failIf(p.b.isTracked())
1541 self.assertEqual(p.a.value(),11)
1543 self.assertEqual(p.a.value(),12)
1544 self.assertEqual(v.value(),12)
1550 self.assertNotEqual(p.b,other.b)
1555 self.assert_(
'a' in p.analyzers_() )
1556 self.assert_(
'a' in p.analyzers)
1557 p.add_(
Service(
"MessageLogger"))
1558 self.assert_(
'MessageLogger' in p.services_())
1559 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1561 self.assert_(
'Tracer' in p.services_())
1562 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1563 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1564 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1566 self.assertEqual(p.out.type_(),
'Outer')
1567 self.assert_(
'out' in p.outputModules_() )
1570 self.assert_(
'geom' in p.es_sources_())
1572 self.assert_(
'ConfigDB' in p.es_sources_())
1575 self.assert_(
'aliasfoo1' in p.aliases_())
1579 def __init__(self,*arg,**args):
1580 for name
in args.iterkeys():
1581 self.__dict__[name]=args[name]
1600 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1601 self.assertEqual(p.a.label_(),
"a")
1602 self.assertRaises(AttributeError,getattr,p,
'b')
1603 self.assertEqual(p.Full.type_(),
"Full")
1604 self.assertEqual(
str(p.c),
'a')
1605 self.assertEqual(
str(p.d),
'a')
1620 self.assertRaises(ValueError, p1.extend, z1)
1629 aaa=copy.deepcopy(a),
1630 s4=copy.deepcopy(s3),
1637 self.assertEqual(p2.s4.label_(),
"s4")
1639 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
1640 p2.s4.setLabel(
"s4")
1641 p2.s4.setLabel(
None)
1642 p2.s4.setLabel(
"foo")
1643 p2._Process__setObjectLabel(p2.s4,
"foo")
1644 p2._Process__setObjectLabel(p2.s4,
None)
1645 p2._Process__setObjectLabel(p2.s4,
"bar")
1657 """import FWCore.ParameterSet.Config as cms 1659 process = cms.Process("test") 1661 process.a = cms.EDAnalyzer("MyAnalyzer") 1664 process.s = cms.Sequence(process.a) 1667 process.r = cms.Sequence(process.s) 1670 process.p = cms.Path(process.a) 1673 process.p2 = cms.Path(process.s) 1676 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1689 """import FWCore.ParameterSet.Config as cms 1691 process = cms.Process("test") 1693 process.a = cms.EDAnalyzer("MyAnalyzer") 1696 process.b = cms.EDAnalyzer("YourAnalyzer") 1699 process.r = cms.Sequence(process.a) 1702 process.s = cms.Sequence(process.r) 1705 process.p = cms.Path(process.a) 1708 process.p2 = cms.Path(process.r) 1711 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1723 """import FWCore.ParameterSet.Config as cms 1725 process = cms.Process("test") 1727 process.a = cms.EDAnalyzer("MyAnalyzer") 1730 process.r = cms.Sequence((process.a)) 1733 process.p = cms.Path(process.a) 1736 process.p2 = cms.Path(process.r) 1739 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1753 p.task2 =
Task(p.c, p.task3)
1754 p.task4 =
Task(p.f, p.task2)
1755 p.task1 =
Task(p.task5)
1756 p.task3.add(p.task1)
1760 p.p2 =
Path(p.r, p.task1, p.task2)
1761 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
1764 """import FWCore.ParameterSet.Config as cms 1766 process = cms.Process("test") 1768 process.b = cms.EDProducer("bProducer") 1771 process.c = cms.EDProducer("cProducer") 1774 process.d = cms.EDProducer("dProducer") 1777 process.e = cms.EDProducer("eProducer") 1780 process.f = cms.EDProducer("fProducer") 1783 process.g = cms.EDProducer("gProducer") 1786 process.a = cms.EDAnalyzer("MyAnalyzer") 1789 process.task5 = cms.Task() 1792 process.task1 = cms.Task(process.task5) 1795 process.task3 = cms.Task(process.task1) 1798 process.task2 = cms.Task(process.c, process.task3) 1801 process.task4 = cms.Task(process.f, process.task2) 1804 process.r = cms.Sequence((process.a)) 1807 process.p = cms.Path(process.a) 1810 process.p2 = cms.Path(process.r, process.task1, process.task2) 1813 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5]) 1821 p.task1 =
Task(p.d, p.e)
1822 task2 =
Task(p.f, p.g)
1823 p.schedule =
Schedule(tasks=[p.task1,task2])
1826 """import FWCore.ParameterSet.Config as cms 1828 process = cms.Process("test") 1830 process.d = cms.EDProducer("dProducer") 1833 process.e = cms.EDProducer("eProducer") 1836 process.f = cms.EDProducer("fProducer") 1839 process.g = cms.EDProducer("gProducer") 1842 process.task1 = cms.Task(process.d, process.e) 1845 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1]) 1852 """import FWCore.ParameterSet.Config as cms 1854 process = cms.Process("test") 1856 process.schedule = cms.Schedule() 1866 d=process.dumpPython()
1868 """import FWCore.ParameterSet.Config as cms 1870 process = cms.Process("DUMP") 1872 process.a = cms.EDProducer("A") 1875 process.s2 = cms.Sequence(process.a) 1888 d=process.dumpPython()
1890 """import FWCore.ParameterSet.Config as cms 1892 process = cms.Process("DUMP") 1894 process.a = cms.EDProducer("A") 1897 process.s2 = cms.Sequence(process.a+(process.a+process.a)) 1905 self.assertEqual(p.dumpPython().
replace(
'\n',
''),
'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
1925 p.p =
Path(p.c+s+p.a)
1931 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
1933 p.globalReplace(
"a",new)
1934 p.globalReplace(
"d",new2)
1937 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
1939 p.e3.visit(visitor3)
1940 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
1942 p.s4.visit(visitor4)
1943 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
1945 p.t1.visit(visitor5)
1946 self.assertTrue(visitor5.modules == set([new2]))
1948 listOfTasks =
list(p.schedule._tasks)
1949 listOfTasks[0].
visit(visitor6)
1950 self.assertTrue(visitor6.modules == set([new2]))
1958 self.assertEqual(
str(p.s),
'a+b')
1959 self.assertEqual(p.s.label_(),
's')
1960 path =
Path(p.c+p.s)
1961 self.assertEqual(
str(path),
'c+a+b')
1962 p._validateSequence(path,
'p1')
1964 p2 =
Path(p.c+p.s*notInProcess)
1965 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
1975 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
1979 self.assertFalse(service._inProcess)
1982 self.assertTrue(service._inProcess)
1984 process.d = service2
1985 self.assertFalse(service._inProcess)
1986 self.assertTrue(service2._inProcess)
1988 self.assertFalse(service2._inProcess)
2008 testTask1 =
Task(edproducer, edfilter)
2009 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2010 testTask1.add(essource, service)
2011 testTask1.add(essource, esproducer)
2012 testTask1.add(testTask2)
2013 coll = testTask1._collection
2014 self.assertTrue(edproducer
in coll)
2015 self.assertTrue(edfilter
in coll)
2016 self.assertTrue(service
in coll)
2017 self.assertTrue(essource
in coll)
2018 self.assertTrue(esproducer
in coll)
2019 self.assertTrue(testTask2
in coll)
2020 self.assertTrue(len(coll) == 6)
2021 self.assertTrue(len(testTask2._collection) == 0)
2025 taskContents.append(i)
2026 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2031 process.mproducer = edproducer
2032 process.mproducer2 = edproducer2
2033 process.mfilter = edfilter
2034 process.messource = essource
2035 process.mesproducer = esproducer
2038 testTask3 =
Task(edproducer, edproducer2)
2039 testTask1.add(testTask3)
2040 process.myTask1 = testTask1
2047 testTask1.visit(visitor)
2048 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2049 l2 = testTask1.moduleNames
2050 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2052 testTask4 =
Task(edproducer3)
2054 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2056 process.myTask4 = testTask4
2057 self.assertTrue(
False)
2058 except RuntimeError:
2061 testTask5 =
Task(service3)
2063 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2065 process.myTask5 = testTask5
2066 self.assertTrue(
False)
2067 except RuntimeError:
2070 process.d = service3
2071 process.myTask5 = testTask5
2074 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2076 self.assertTrue(process.tasks == expectedFixedDict)
2077 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2078 self.assertTrue(process.myTask1 == testTask1)
2082 process.mproducer2 = edproducer4
2086 testTask1.visit(visitor1)
2088 expectedList = [edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4]
2090 self.assertTrue(expectedList == l)
2092 process.myTask6 =
Task()
2093 process.myTask7 =
Task()
2094 process.mproducer8 = edproducer8
2095 process.myTask8 =
Task(process.mproducer8)
2096 process.myTask6.add(process.myTask7)
2097 process.myTask7.add(process.myTask8)
2098 process.myTask1.add(process.myTask6)
2099 process.myTask8.add(process.myTask5)
2101 testDict = process._itemsInDependencyOrder(process.tasks)
2102 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2103 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2105 for testLabel, testTask
in testDict.items():
2106 self.assertTrue(testLabel == expectedLabels[index])
2107 self.assertTrue(testTask == expectedTasks[index])
2113 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2114 self.assertTrue(pythonDump == expectedPythonDump)
2116 process.myTask5 =
Task()
2117 process.myTask100 =
Task()
2118 process.mproducer9 = edproducer9
2119 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2120 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2121 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2123 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2124 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2125 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2126 process.path2 =
Path(process.mproducer)
2127 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2129 self.assertTrue(process.path1.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)\n')
2131 self.assertTrue(process.path11.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask100, process.myTask5)\n')
2136 process.path1.visit(nameVisitor)
2137 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2138 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2142 process.path21 = process.path11.copy()
2143 process.path21.replace(process.mproducer, process.mproducer10)
2145 self.assertTrue(process.path11.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask100, process.myTask5)\n')
2154 self.assertTrue(process.path21.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2156 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2157 self.assertTrue(process.path22.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2159 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2160 self.assertTrue(process.path23.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2169 process.path24 =
Path(process.a+process.b+process.c+process.d)
2170 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2171 self.assertTrue(process.path25.dumpPython(
None) ==
'cms.Path(process.d)\n')
2176 process.path200.replace(process.c,process.b)
2177 process.path200.replace(process.e,process.f)
2178 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2179 process.path200.replace(process.b,process.c)
2180 process.path200.replace(process.f,process.e)
2181 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2182 process.path200.replace(process.c,process.a)
2183 process.path200.replace(process.e,process.g)
2184 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2185 process.path200.replace(process.a,process.c)
2186 process.path200.replace(process.g,process.e)
2187 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2198 self.assertEqual(
str(path),
'a+b+c')
2199 path =
Path(p.a*p.b+p.c)
2200 self.assertEqual(
str(path),
'a+b+c')
2203 path =
Path(p.a+ p.b*p.c)
2204 self.assertEqual(
str(path),
'a+b+c')
2205 path =
Path(p.a*(p.b+p.c))
2206 self.assertEqual(
str(path),
'a+b+c')
2207 path =
Path(p.a*(p.b+~p.c))
2209 self.assertEqual(
str(path),
'a+b+~c')
2211 self.assertRaises(TypeError,Path,p.es)
2214 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path()\n')
2217 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a)\n')
2220 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(cms.Task())\n')
2223 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task())\n')
2228 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task(), process.t1)\n')
2239 p.path =
Path(p.a*p.b)
2240 lookuptable = {
id(a): p.a,
id(b): p.b}
2244 self.assertEqual(
str(path),
str(p.path))
2257 self.assertEqual(s[0],p.path1)
2258 self.assertEqual(s[1],p.path2)
2260 self.assert_(
'b' in p.schedule.moduleNames())
2261 self.assert_(hasattr(p,
'b'))
2262 self.assert_(hasattr(p,
'c'))
2263 self.assert_(hasattr(p,
'd'))
2264 self.assert_(hasattr(p,
'path1'))
2265 self.assert_(hasattr(p,
'path2'))
2266 self.assert_(hasattr(p,
'path3'))
2268 self.assert_(
'b' in p.schedule.moduleNames())
2269 self.assert_(hasattr(p,
'b'))
2270 self.assert_(
not hasattr(p,
'c'))
2271 self.assert_(
not hasattr(p,
'd'))
2272 self.assert_(hasattr(p,
'path1'))
2273 self.assert_(hasattr(p,
'path2'))
2274 self.assert_(
not hasattr(p,
'path3'))
2276 self.assertTrue(len(p.schedule._tasks) == 0)
2290 p.task2 =
Task(p.f, p.Tracer)
2291 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2292 self.assertEqual(s[0],p.path1)
2293 self.assertEqual(s[1],p.path2)
2294 self.assertTrue(len(s._tasks) == 2)
2295 self.assertTrue(p.task1
in s._tasks)
2296 self.assertTrue(p.task2
in s._tasks)
2297 listOfTasks =
list(s._tasks)
2298 self.assertTrue(len(listOfTasks) == 2)
2299 self.assertTrue(p.task1 == listOfTasks[0])
2300 self.assertTrue(p.task2 == listOfTasks[1])
2302 self.assert_(
'b' in p.schedule.moduleNames())
2307 process2.path1 =
Path(process2.a)
2308 process2.task1 =
Task(process2.e)
2309 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2310 listOfTasks =
list(process2.schedule._tasks)
2311 self.assertTrue(listOfTasks[0] == process2.task1)
2315 self.assertEqual(s2[0],p.path1)
2316 self.assertEqual(s2[1],p.path2)
2317 self.assertTrue(len(s2._tasks) == 2)
2318 self.assertTrue(p.task1
in s2._tasks)
2319 self.assertTrue(p.task2
in s2._tasks)
2320 listOfTasks =
list(s2._tasks)
2321 self.assertTrue(len(listOfTasks) == 2)
2322 self.assertTrue(p.task1 == listOfTasks[0])
2323 self.assertTrue(p.task2 == listOfTasks[1])
2325 names = s.moduleNames()
2326 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2332 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2341 self.assert_(
'a' in s.moduleNames())
2342 self.assert_(
'b' in s.moduleNames())
2343 self.assert_(
'c' in s.moduleNames())
2347 self.assert_(
'a' in s.moduleNames())
2348 self.assert_(
'b' in s.moduleNames())
2349 self.assert_(
'c' in s.moduleNames())
2358 self.assert_(p.schedule
is None)
2361 self.assertEqual(pths[keys[0]],p.path1)
2362 self.assertEqual(pths[keys[1]],p.path2)
2364 self.assert_(hasattr(p,
'a'))
2365 self.assert_(hasattr(p,
'b'))
2366 self.assert_(
not hasattr(p,
'c'))
2367 self.assert_(hasattr(p,
'path1'))
2368 self.assert_(hasattr(p,
'path2'))
2377 self.assert_(p.schedule
is None)
2380 self.assertEqual(pths[keys[1]],p.path1)
2381 self.assertEqual(pths[keys[0]],p.path2)
2388 self.assertEqual(p.modu.a.value(),1)
2389 self.assertEqual(p.modu.b.value(),2)
2394 self.assert_(
not a.isModified())
2396 self.assert_(a.isModified())
2398 self.assertEqual(p.a.a1.value(), 1)
2402 self.assertEqual(p.a.a1.value(), 2)
2411 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2412 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2416 p.source =
Source(
"PoolSource",fileNames = untracked(
string(
"file:reco.root")))
2419 p.out =
OutputModule(
"PoolOutputModule",fileName=untracked(
string(
"file:foos.root")))
2420 p.bars.foos =
'Foosball' 2421 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2422 p.p =
Path(p.foos*p.bars)
2424 p.add_(
Service(
"MessageLogger"))
2430 p.prefer(
"ForceSource")
2432 self.assertEqual(p.dumpConfig(),
2434 es_module juicer = JuicerProducer { 2436 es_source = ForceSource { 2438 es_prefer = ForceSource { 2440 es_prefer juicer = JuicerProducer { 2444 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2445 self.assertEqual(p.dumpConfig(),
2447 es_module juicer = JuicerProducer { 2449 es_source = ForceSource { 2451 es_prefer = ForceSource { 2453 es_prefer juicer = JuicerProducer { 2461 self.assertEqual(p.dumpPython(),
2462 """import FWCore.ParameterSet.Config as cms 2464 process = cms.Process("Test") 2466 process.juicer = cms.ESProducer("JuicerProducer") 2469 process.ForceSource = cms.ESSource("ForceSource") 2472 process.prefer("ForceSource") 2474 process.prefer("juicer", 2475 fooRcd = cms.vstring('Foo') 2492 self.assertEqual(process.m.p.i.value(), 4)
2502 subProcess.p =
Path(subProcess.a)
2503 subProcess.add_(
Service(
"Foo"))
2504 process.addSubProcess(
SubProcess(subProcess))
2505 d = process.dumpPython()
2506 equalD =
"""import FWCore.ParameterSet.Config as cms 2508 process = cms.Process("Parent") 2510 parentProcess = process 2511 import FWCore.ParameterSet.Config as cms 2513 process = cms.Process("Child") 2515 process.a = cms.EDProducer("A") 2518 process.Foo = cms.Service("Foo") 2521 process.p = cms.Path(process.a) 2524 childProcess = process 2525 process = parentProcess 2526 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 2528 ), outputCommands = cms.untracked.vstring())) 2531 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2532 self.assertEqual(d,equalD)
2534 process.fillProcessDesc(p)
2535 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2536 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2537 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2547 proc.fillProcessDesc(p)
2548 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2549 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2550 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2551 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2552 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2553 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2563 self.assert_(p.schedule
is None)
2566 self.assertEqual(pths[keys[0]],p.path1)
2567 self.assertEqual(pths[keys[1]],p.path2)
2569 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2571 p.vpset2 = untracked.VPSet()
2573 self.assert_(hasattr(p,
'a'))
2574 self.assert_(hasattr(p,
'b'))
2575 self.assert_(
not hasattr(p,
'c'))
2576 self.assert_(
not hasattr(p,
'd'))
2577 self.assert_(
not hasattr(p,
's'))
2578 self.assert_(hasattr(p,
'path1'))
2579 self.assert_(hasattr(p,
'path2'))
2596 p.path3 =
Path(p.b+p.s2)
2597 p.path4 =
Path(p.b+p.s3)
2598 p.schedule =
Schedule(p.path1,p.path2,p.path3)
2601 self.assertEqual(pths[keys[0]],p.path1)
2602 self.assertEqual(pths[keys[1]],p.path2)
2604 self.assert_(hasattr(p,
'a'))
2605 self.assert_(hasattr(p,
'b'))
2606 self.assert_(
not hasattr(p,
'c'))
2607 self.assert_(
not hasattr(p,
'd'))
2608 self.assert_(
not hasattr(p,
'e'))
2609 self.assert_(
not hasattr(p,
's'))
2610 self.assert_(hasattr(p,
's2'))
2611 self.assert_(
not hasattr(p,
's3'))
2612 self.assert_(hasattr(p,
'path1'))
2613 self.assert_(hasattr(p,
'path2'))
2614 self.assert_(hasattr(p,
'path3'))
2615 self.assert_(
not hasattr(p,
'path4'))
2623 self.assert_(hasattr(p,
'a'))
2624 self.assert_(hasattr(p,
'b'))
2625 self.assert_(hasattr(p,
's'))
2626 self.assert_(hasattr(p,
'pth'))
2632 p.prune(keepUnresolvedSequencePlaceholders=
True)
2633 self.assert_(hasattr(p,
'b'))
2634 self.assert_(hasattr(p,
's'))
2635 self.assert_(hasattr(p,
'pth'))
2636 self.assertEqual(p.s.dumpPython(
''),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
2644 p.path1 =
Path(p.b, p.t2, p.t3)
2647 p.endpath1 =
EndPath(p.b, p.t5)
2651 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
2660 self.assertEqual(p.dumpPython(),
2661 """import FWCore.ParameterSet.Config as cms 2663 process = cms.Process("test") 2665 process.a = cms.EDProducer("ma") 2668 process.c = cms.EDProducer("mc") 2671 process.d = cms.EDProducer("md") 2674 process.e = cms.EDProducer("me") 2677 process.f = cms.EDProducer("mf") 2680 process.g = cms.EDProducer("mg") 2683 process.h = cms.EDProducer("mh") 2686 process.i = cms.EDProducer("mi") 2689 process.j = cms.EDProducer("mj") 2692 process.b = cms.EDAnalyzer("mb") 2695 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 2698 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 2701 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 2704 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 2707 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 2710 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 2713 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 2716 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 2719 process.path1 = cms.Path(process.b, process.t2, process.t3) 2722 process.endpath1 = cms.EndPath(process.b, process.t5) 2725 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2728 self.assertEqual(p.dumpPython(),
2729 """import FWCore.ParameterSet.Config as cms 2731 process = cms.Process("test") 2733 process.a = cms.EDProducer("ma") 2736 process.c = cms.EDProducer("mc") 2739 process.d = cms.EDProducer("md") 2742 process.e = cms.EDProducer("me") 2745 process.f = cms.EDProducer("mf") 2748 process.g = cms.EDProducer("mg") 2751 process.h = cms.EDProducer("mh") 2754 process.i = cms.EDProducer("mi") 2757 process.j = cms.EDProducer("mj") 2760 process.b = cms.EDAnalyzer("mb") 2763 process.t8 = cms.Task(process.j) 2766 process.t6 = cms.Task(process.h) 2769 process.t7 = cms.Task(process.a, process.i, process.t6) 2772 process.t4 = cms.Task(process.f) 2775 process.t5 = cms.Task(process.a, process.g, process.t4) 2778 process.t3 = cms.Task(process.e) 2781 process.t1 = cms.Task(process.c) 2784 process.t2 = cms.Task(process.a, process.d, process.t1) 2787 process.path1 = cms.Path(process.b, process.t2, process.t3) 2790 process.endpath1 = cms.EndPath(process.b, process.t5) 2793 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2806 p.t1 =
Task(p.g, p.h)
2810 p.path1 =
Path(p.a+p.f+p.s,t2)
2813 self.assertTrue(hasattr(p,
'f'))
2814 self.assertTrue(hasattr(p,
'g'))
2818 self.assertFalse(hasattr(p,
'f'))
2819 self.assertFalse(hasattr(p,
'g'))
2820 self.assertTrue(p.t1.dumpPython(
None) ==
'cms.Task(process.h)\n')
2821 self.assertTrue(p.s.dumpPython(
None) ==
'cms.Sequence(process.d)\n')
2822 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
2823 self.assertTrue(p.endpath1.dumpPython(
None) ==
'cms.EndPath(process.b)\n')
2825 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
2826 self.assertTrue(p.schedule_().
dumpPython(
None) ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
2833 m1.toModify(p.a,_mod_fred)
2834 self.assertEqual(p.a.fred.value(),2)
2836 m1.toModify(p.b, wilma = 2)
2837 self.assertEqual(p.b.wilma.value(),2)
2838 self.assert_(p.isUsingModifier(m1))
2843 m1.toModify(p.a,_mod_fred)
2845 m1.toModify(p.b, wilma = 2)
2846 self.assertEqual(p.a.fred.value(),1)
2847 self.assertEqual(p.b.wilma.value(),1)
2848 self.assertEqual(p.isUsingModifier(m1),
False)
2853 m1.toModify(p.a, fred =
int32(2))
2854 p.b = p.a.clone(wilma =
int32(3))
2855 self.assertEqual(p.a.fred.value(),2)
2856 self.assertEqual(p.a.wilma.value(),1)
2857 self.assertEqual(p.b.fred.value(),2)
2858 self.assertEqual(p.b.wilma.value(),3)
2863 m1.toModify(p.a, fred =
None)
2864 self.assertEqual(hasattr(p.a,
"fred"),
False)
2865 self.assertEqual(p.a.wilma.value(),1)
2870 m1.toModify(p.a, wilma =
int32(2))
2871 self.assertEqual(p.a.fred.value(), 1)
2872 self.assertEqual(p.a.wilma.value(),2)
2877 m1.toModify(p.a, flintstones =
dict(fred =
int32(2)))
2878 self.assertEqual(p.a.flintstones.fred.value(),2)
2879 self.assertEqual(p.a.flintstones.wilma.value(),1)
2884 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones =
dict(imnothere =
dict(wilma=2))))
2885 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
2890 m1.toModify(p.a, flintstones = {1:
dict(wilma =
int32(2))})
2891 self.assertEqual(p.a.flintstones[0].fred.value(),1)
2892 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
2897 m1.toModify(p.a, fred = {1:7})
2898 self.assertEqual(p.a.fred[0],1)
2899 self.assertEqual(p.a.fred[1],7)
2900 self.assertEqual(p.a.fred[2],3)
2906 try: m1.toModify(p.a, fred = {5:7})
2907 except IndexError
as e: raised =
True 2908 self.assertEqual(raised,
True)
2914 try: m1.toModify(p.a, flintstones =
dict(bogus =
int32(37)))
2915 except TypeError
as e: raised =
True 2916 self.assertEqual(raised,
True)
2920 class ProcModifierMod(
object):
2921 def __init__(self,modifier,func):
2926 testMod = DummyMod()
2928 self.assert_(hasattr(p,
"a"))
2931 testProcMod = ProcModifierMod(m1,_rem_a)
2933 p.extend(testProcMod)
2934 self.assert_(
not hasattr(p,
"a"))
2939 self.assert_(p.isUsingModifier(m1))
2940 self.assert_(p.isUsingModifier(mc))
2941 testMod = DummyMod()
2943 m1.toModify(p.b, fred =
int32(3))
2945 testProcMod = ProcModifierMod(m1,_rem_a)
2946 p.extend(testProcMod)
2947 self.assert_(
not hasattr(p,
"a"))
2948 self.assertEqual(p.b.fred.value(),3)
2953 mclone = mc.copyAndExclude([m2])
2954 self.assert_(
not mclone._isOrContains(m2))
2955 self.assert_(mclone._isOrContains(m1))
2958 mclone = mc2.copyAndExclude([m2])
2959 self.assert_(
not mclone._isOrContains(m2))
2960 self.assert_(mclone._isOrContains(m1))
2961 self.assert_(mclone._isOrContains(m3))
2967 (m1 & m2).toModify(p.a, fred =
int32(2))
2968 self.assertEqual(p.a.fred, 1)
2973 (m1 & m2).toModify(p.a, fred =
int32(2))
2974 self.assertEqual(p.a.fred, 2)
2980 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
2981 self.assertEqual(p.a.fred, 2)
2993 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
2994 self.assertEqual(p.a.wilma.value(),3)
2995 self.assertEqual(p.a.type_(),
"YourAnalyzer")
2996 self.assertEqual(hasattr(p,
"fred"),
False)
2997 self.assertTrue(p.s.dumpPython(
"") ==
"cms.Sequence(process.a+process.b, process.td)\n")
2999 m1.toReplaceWith(p.td,
Task(p.e))
3000 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3006 self.assertEqual(p.a.type_(),
"MyAnalyzer")
def __setstate__(self, pkldict)
def addVString(self, tracked, label, value)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def addEventRange(self, tracked, label, value)
def __getattribute__(self, name)
def _place(self, label, process)
def testServiceInProcess(self)
def _dumpConfigUnnamedList(self, items, typeName, options)
def _placeAnalyzer(self, name, mod)
def addString(self, tracked, label, value)
def __findFirstUsingModule(self, seqsOrTasks, mod)
def makeProcessModifier(self, func)
def _pruneModules(self, d, scheduledNames)
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
def _placeESPrefer(self, name, mod)
def _insertPaths(self, processPSet, nodeVisitor)
def _placeESProducer(self, name, mod)
def addVESInputTag(self, tracked, label, value)
def _placeSequence(self, name, mod)
def _validateSequence(self, sequence, label)
def __getattr__(self, attr)
def setStrict(self, value)
def addDouble(self, tracked, label, value)
def _findPreferred(self, esname, d, args, kargs)
def replace(string, replacements)
def _insertOneInto(self, parameterSet, label, item, tracked)
def __delattr__(self, name)
def _placePath(self, name, mod)
def addVUInt64(self, tracked, label, value)
def _placeEndPath(self, name, mod)
def __init__(self, name, Mods)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def testTypedParameterizable(self)
def addUInt64(self, tracked, label, value)
def _itemsInDependencyOrder(self, processDictionaryOfItems)
def addVPSet(self, tracked, label, value)
def nameInProcessDesc_(self, label)
def format_outerframe(number)
def __init__(self, args, kw)
def load(self, moduleName)
def _raiseUnknownKey(key)
def _insertSubProcessesInto(self, parameterSet, label, itemList, tracked)
def addUInt32(self, tracked, label, value)
def _dumpConfigESPrefers(self, options)
def __setattr__(self, name, value)
def setLooper_(self, lpr)
def setSource_(self, src)
def __init__(self, process)
def extend(self, other, items=())
def _okToPlace(self, name, mod, d)
def visit(visitdir)
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
def _replaceInTasks(self, label, new)
def addVInt32(self, tracked, label, value)
def _placeFilter(self, name, mod)
def addVInputTag(self, tracked, label, value)
def _applyNewProcessModifiers(self, process)
def addLuminosityBlockID(self, tracked, label, value)
def addESInputTag(self, tracked, label, value)
def __new__(cls, args, kw)
def __setattr__(self, name, value)
def _placeESSource(self, name, mod)
def addVInt64(self, tracked, label, value)
def addVEventID(self, tracked, label, value)
def toModify(self, obj, func=None, kw)
def testGlobalReplace(self)
def _placeOutputModule(self, name, mod)
def addFileInPath(self, tracked, label, value)
def _placeSource(self, name, mod)
def _dumpPythonSubProcesses(self, l, options)
def checkImportPermission(minLevel=2, allowedPatterns=[])
def __init__(self, modifier, func)
def isUsingModifier(self, mod)
def dumpPython(self, options=PrintOptions())
def __copyIfExclude(self, toExclude)
def _validateTask(self, task, label)
def testParameterizable(self)
def _placeSubProcess(self, name, mod)
def setPartialSchedule_(self, sch, label)
def addPSet(self, tracked, label, value)
def testProcessDumpPython(self)
def _placeService(self, typeName, mod)
def resolve(self, keepUnresolvedSequencePlaceholders=False)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def dumpPython(process, name)
def __setObjectLabel(self, object, newLabel)
def _delHelper(self, name)
def _placeAlias(self, name, mod)
def dumpPython(self, options=PrintOptions())
def _replaceInSequences(self, label, new)
def setSchedule_(self, sch)
def toReplaceWith(self, toObj, fromObj)
def _placeProducer(self, name, mod)
def prefer(self, esmodule, args, kargs)
def __delattr__(self, name)
def _dumpConfigNamedList(self, items, typeName, options)
def addInputTag(self, tracked, label, value)
def _insertManyInto(self, parameterSet, label, itemDict, tracked)
def dumpConfig(self, options=PrintOptions())
def testCloneSequence(self)
def _placeTask(self, name, task)
def addSubProcess(self, mod)
def _placePSet(self, name, mod)
def _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def _place(self, name, mod, d)
def testProcessExtend(self)
def _dumpPythonList(self, d, options)
def __insertValue(self, tracked, label, value)
def _placeVPSet(self, name, mod)
def globalReplace(self, label, new)
def toModify(self, obj, func=None, kw)
def addBool(self, tracked, label, value)
def addEventID(self, tracked, label, value)
def _placeLooper(self, name, mod)
def testImplicitSchedule(self)
def prune(self, verbose=False, keepUnresolvedSequencePlaceholders=False)
def addVDouble(self, tracked, label, value)
def _insertInto(self, parameterSet, itemDict)
def _delattrFromSetattr(self, name)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def _replaceInSchedule(self, label, new)
def _dumpPython(self, d, options)
def addInt32(self, tracked, label, value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)