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 helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1288 Modifier._toModifyCheck(obj,func,**kw)
1289 if not self.isChosen():
1291 Modifier._toModify(obj,func,**kw)
1293 Modifier._toReplaceWithCheck(toObj,fromObj)
1294 if not self.isChosen():
1296 Modifier._toReplaceWith(toObj,fromObj)
1298 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1299 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1300 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1310 """A modifier which only applies if multiple Modifiers are chosen""" 1312 super(_AndModifier,self).
__init__(lhs, rhs)
1314 return self._lhs.isChosen()
and self._rhs.isChosen()
1317 """A modifier which only applies if a Modifier is not chosen""" 1319 super(_InvertModifier,self).
__init__(lhs)
1321 return not self._lhs.isChosen()
1324 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1326 super(_OrModifier,self).
__init__(lhs, rhs)
1328 return self._lhs.isChosen()
or self._rhs.isChosen()
1332 """This class is used to define standard modifications to a Process. 1333 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1334 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1335 these Modifier instances are imported into a configuration and items that need to be modified 1336 are then associated with the Modifier and with the action to do the modification. 1337 The registered modifications will only occur if the Modifier was passed to 1338 the cms.Process' constructor. 1344 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1345 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1346 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1351 if func
is not None and len(kw) != 0:
1352 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1354 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1355 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1356 that will be the object passed in as the first argument. 1357 Form 2: A list of parameter name, value pairs can be passed 1358 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1359 This form can also be used to remove a parameter by passing the value of None 1360 #remove the parameter foo.fred 1361 mod.toModify(foo, fred = None) 1362 Additionally, parameters embedded within PSets can also be modified using a dictionary 1363 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1364 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1366 Modifier._toModifyCheck(obj,func,**kw)
1369 Modifier._toModify(obj,func,**kw)
1372 if func
is not None:
1379 if type(fromObj) != type(toObj):
1380 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1382 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1384 Modifier._toReplaceWithCheck(toObj,fromObj)
1387 Modifier._toReplaceWith(toObj,fromObj)
1390 if isinstance(fromObj,_ModuleSequenceType):
1391 toObj._seq = fromObj._seq
1392 toObj._tasks = fromObj._tasks
1393 elif isinstance(fromObj,Task):
1394 toObj._collection = fromObj._collection
1395 elif isinstance(fromObj,_Parameterizable):
1397 for p
in toObj.parameterNames_():
1399 for p
in fromObj.parameterNames_():
1400 setattr(toObj,p,getattr(fromObj,p))
1401 if isinstance(fromObj,_TypedParameterizable):
1402 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1405 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1408 """Should only be called by cms.Process instances""" 1419 return self == other
1423 """A Modifier made up of a list of Modifiers 1429 """Should only be called by cms.Process instances 1430 applies list of accumulated changes to the process""" 1432 m._applyNewProcessModifiers(process)
1434 """Should only be called by cms.Process instances""" 1441 """Creates a new ModifierChain which is a copy of 1442 this ModifierChain but excludes any Modifier or 1443 ModifierChain in the list toExclude. 1444 The exclusion is done recursively down the chain. 1448 if m
not in toExclude:
1450 if isinstance(m,ModifierChain):
1451 s = m.__copyIfExclude(toExclude)
1467 if m._isOrContains(other):
1472 """A class used by a Modifier to affect an entire Process instance. 1473 When a Process 'loads' a module containing a ProcessModifier, that 1474 ProcessModifier will be applied to the Process if and only if the 1475 Modifier passed to the constructor has been chosen. 1482 if self.__modifier.isChosen():
1485 self.__seenProcesses.add(process)
1487 if __name__==
"__main__":
1492 """Has same interface as the C++ object that creates PSets 1497 self.
values[label]=(tracked,value)
1555 """Nothing to do """ 1559 self.assertEqual(len(p.parameterNames_()),0)
1561 self.assert_(
'a' in p.parameterNames_())
1562 self.assertEqual(p.a.value(), 1)
1564 self.assertEqual(p.a.value(), 10)
1565 p.a = untracked(
int32(1))
1566 self.assertEqual(p.a.value(), 1)
1567 self.failIf(p.a.isTracked())
1568 p.a = untracked.int32(1)
1569 self.assertEqual(p.a.value(), 1)
1570 self.failIf(p.a.isTracked())
1572 self.assertEqual(p.foo.value(), 10)
1573 self.assertEqual(p.bar.value(),1.0)
1574 self.failIf(p.bar.isTracked())
1575 self.assertRaises(TypeError,setattr,(p,
'c',1))
1577 self.assertEqual(p.a.foo.value(),10)
1578 self.assertEqual(p.a.bar.value(),1.0)
1580 self.assertEqual(p.b.fii.value(),1)
1581 self.failIf(p.b.isTracked())
1586 self.assertEqual(p.a.value(),11)
1588 self.assertEqual(p.a.value(),12)
1589 self.assertEqual(v.value(),12)
1595 self.assertNotEqual(p.b,other.b)
1600 self.assert_(
'a' in p.analyzers_() )
1601 self.assert_(
'a' in p.analyzers)
1602 p.add_(
Service(
"MessageLogger"))
1603 self.assert_(
'MessageLogger' in p.services_())
1604 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1606 self.assert_(
'Tracer' in p.services_())
1607 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1608 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1609 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1611 self.assertEqual(p.out.type_(),
'Outer')
1612 self.assert_(
'out' in p.outputModules_() )
1615 self.assert_(
'geom' in p.es_sources_())
1617 self.assert_(
'ConfigDB' in p.es_sources_())
1620 self.assert_(
'aliasfoo1' in p.aliases_())
1624 def __init__(self,*arg,**args):
1625 for name
in args.iterkeys():
1626 self.__dict__[name]=args[name]
1645 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1646 self.assertEqual(p.a.label_(),
"a")
1647 self.assertRaises(AttributeError,getattr,p,
'b')
1648 self.assertEqual(p.Full.type_(),
"Full")
1649 self.assertEqual(
str(p.c),
'a')
1650 self.assertEqual(
str(p.d),
'a')
1665 self.assertRaises(ValueError, p1.extend, z1)
1674 aaa=copy.deepcopy(a),
1675 s4=copy.deepcopy(s3),
1682 self.assertEqual(p2.s4.label_(),
"s4")
1684 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
1685 p2.s4.setLabel(
"s4")
1686 p2.s4.setLabel(
None)
1687 p2.s4.setLabel(
"foo")
1688 p2._Process__setObjectLabel(p2.s4,
"foo")
1689 p2._Process__setObjectLabel(p2.s4,
None)
1690 p2._Process__setObjectLabel(p2.s4,
"bar")
1702 """import FWCore.ParameterSet.Config as cms 1704 process = cms.Process("test") 1706 process.a = cms.EDAnalyzer("MyAnalyzer") 1709 process.s = cms.Sequence(process.a) 1712 process.r = cms.Sequence(process.s) 1715 process.p = cms.Path(process.a) 1718 process.p2 = cms.Path(process.s) 1721 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1734 """import FWCore.ParameterSet.Config as cms 1736 process = cms.Process("test") 1738 process.a = cms.EDAnalyzer("MyAnalyzer") 1741 process.b = cms.EDAnalyzer("YourAnalyzer") 1744 process.r = cms.Sequence(process.a) 1747 process.s = cms.Sequence(process.r) 1750 process.p = cms.Path(process.a) 1753 process.p2 = cms.Path(process.r) 1756 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1768 """import FWCore.ParameterSet.Config as cms 1770 process = cms.Process("test") 1772 process.a = cms.EDAnalyzer("MyAnalyzer") 1775 process.r = cms.Sequence((process.a)) 1778 process.p = cms.Path(process.a) 1781 process.p2 = cms.Path(process.r) 1784 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1798 p.task2 =
Task(p.c, p.task3)
1799 p.task4 =
Task(p.f, p.task2)
1800 p.task1 =
Task(p.task5)
1801 p.task3.add(p.task1)
1805 p.p2 =
Path(p.r, p.task1, p.task2)
1806 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
1809 """import FWCore.ParameterSet.Config as cms 1811 process = cms.Process("test") 1813 process.b = cms.EDProducer("bProducer") 1816 process.c = cms.EDProducer("cProducer") 1819 process.d = cms.EDProducer("dProducer") 1822 process.e = cms.EDProducer("eProducer") 1825 process.f = cms.EDProducer("fProducer") 1828 process.g = cms.EDProducer("gProducer") 1831 process.a = cms.EDAnalyzer("MyAnalyzer") 1834 process.task5 = cms.Task() 1837 process.task1 = cms.Task(process.task5) 1840 process.task3 = cms.Task(process.task1) 1843 process.task2 = cms.Task(process.c, process.task3) 1846 process.task4 = cms.Task(process.f, process.task2) 1849 process.r = cms.Sequence((process.a)) 1852 process.p = cms.Path(process.a) 1855 process.p2 = cms.Path(process.r, process.task1, process.task2) 1858 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5]) 1866 p.task1 =
Task(p.d, p.e)
1867 task2 =
Task(p.f, p.g)
1868 p.schedule =
Schedule(tasks=[p.task1,task2])
1871 """import FWCore.ParameterSet.Config as cms 1873 process = cms.Process("test") 1875 process.d = cms.EDProducer("dProducer") 1878 process.e = cms.EDProducer("eProducer") 1881 process.f = cms.EDProducer("fProducer") 1884 process.g = cms.EDProducer("gProducer") 1887 process.task1 = cms.Task(process.d, process.e) 1890 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1]) 1897 """import FWCore.ParameterSet.Config as cms 1899 process = cms.Process("test") 1901 process.schedule = cms.Schedule() 1911 d=process.dumpPython()
1913 """import FWCore.ParameterSet.Config as cms 1915 process = cms.Process("DUMP") 1917 process.a = cms.EDProducer("A") 1920 process.s2 = cms.Sequence(process.a) 1933 d=process.dumpPython()
1935 """import FWCore.ParameterSet.Config as cms 1937 process = cms.Process("DUMP") 1939 process.a = cms.EDProducer("A") 1942 process.s2 = cms.Sequence(process.a+(process.a+process.a)) 1950 self.assertEqual(p.dumpPython().
replace(
'\n',
''),
'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
1970 p.p =
Path(p.c+s+p.a)
1976 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
1978 p.globalReplace(
"a",new)
1979 p.globalReplace(
"d",new2)
1982 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
1984 p.e3.visit(visitor3)
1985 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
1987 p.s4.visit(visitor4)
1988 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
1990 p.t1.visit(visitor5)
1991 self.assertTrue(visitor5.modules == set([new2]))
1993 listOfTasks =
list(p.schedule._tasks)
1994 listOfTasks[0].
visit(visitor6)
1995 self.assertTrue(visitor6.modules == set([new2]))
2003 self.assertEqual(
str(p.s),
'a+b')
2004 self.assertEqual(p.s.label_(),
's')
2005 path =
Path(p.c+p.s)
2006 self.assertEqual(
str(path),
'c+a+b')
2007 p._validateSequence(path,
'p1')
2009 p2 =
Path(p.c+p.s*notInProcess)
2010 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2020 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2024 self.assertFalse(service._inProcess)
2027 self.assertTrue(service._inProcess)
2029 process.d = service2
2030 self.assertFalse(service._inProcess)
2031 self.assertTrue(service2._inProcess)
2033 self.assertFalse(service2._inProcess)
2053 testTask1 =
Task(edproducer, edfilter)
2054 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2055 testTask1.add(essource, service)
2056 testTask1.add(essource, esproducer)
2057 testTask1.add(testTask2)
2058 coll = testTask1._collection
2059 self.assertTrue(edproducer
in coll)
2060 self.assertTrue(edfilter
in coll)
2061 self.assertTrue(service
in coll)
2062 self.assertTrue(essource
in coll)
2063 self.assertTrue(esproducer
in coll)
2064 self.assertTrue(testTask2
in coll)
2065 self.assertTrue(len(coll) == 6)
2066 self.assertTrue(len(testTask2._collection) == 0)
2070 taskContents.append(i)
2071 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2076 process.mproducer = edproducer
2077 process.mproducer2 = edproducer2
2078 process.mfilter = edfilter
2079 process.messource = essource
2080 process.mesproducer = esproducer
2083 testTask3 =
Task(edproducer, edproducer2)
2084 testTask1.add(testTask3)
2085 process.myTask1 = testTask1
2092 testTask1.visit(visitor)
2093 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2094 l2 = testTask1.moduleNames
2095 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2097 testTask4 =
Task(edproducer3)
2099 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2101 process.myTask4 = testTask4
2102 self.assertTrue(
False)
2103 except RuntimeError:
2106 testTask5 =
Task(service3)
2108 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2110 process.myTask5 = testTask5
2111 self.assertTrue(
False)
2112 except RuntimeError:
2115 process.d = service3
2116 process.myTask5 = testTask5
2119 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2121 self.assertTrue(process.tasks == expectedFixedDict)
2122 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2123 self.assertTrue(process.myTask1 == testTask1)
2127 process.mproducer2 = edproducer4
2131 testTask1.visit(visitor1)
2133 expectedList = [edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4]
2135 self.assertTrue(expectedList == l)
2137 process.myTask6 =
Task()
2138 process.myTask7 =
Task()
2139 process.mproducer8 = edproducer8
2140 process.myTask8 =
Task(process.mproducer8)
2141 process.myTask6.add(process.myTask7)
2142 process.myTask7.add(process.myTask8)
2143 process.myTask1.add(process.myTask6)
2144 process.myTask8.add(process.myTask5)
2146 testDict = process._itemsInDependencyOrder(process.tasks)
2147 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2148 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2150 for testLabel, testTask
in testDict.items():
2151 self.assertTrue(testLabel == expectedLabels[index])
2152 self.assertTrue(testTask == expectedTasks[index])
2158 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2159 self.assertTrue(pythonDump == expectedPythonDump)
2161 process.myTask5 =
Task()
2162 process.myTask100 =
Task()
2163 process.mproducer9 = edproducer9
2164 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2165 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2166 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2168 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2169 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2170 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2171 process.path2 =
Path(process.mproducer)
2172 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2174 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')
2176 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')
2181 process.path1.visit(nameVisitor)
2182 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2183 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2187 process.path21 = process.path11.copy()
2188 process.path21.replace(process.mproducer, process.mproducer10)
2190 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')
2199 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')
2201 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2202 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')
2204 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2205 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')
2214 process.path24 =
Path(process.a+process.b+process.c+process.d)
2215 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2216 self.assertTrue(process.path25.dumpPython(
None) ==
'cms.Path(process.d)\n')
2221 process.path200.replace(process.c,process.b)
2222 process.path200.replace(process.e,process.f)
2223 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2224 process.path200.replace(process.b,process.c)
2225 process.path200.replace(process.f,process.e)
2226 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2227 process.path200.replace(process.c,process.a)
2228 process.path200.replace(process.e,process.g)
2229 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2230 process.path200.replace(process.a,process.c)
2231 process.path200.replace(process.g,process.e)
2232 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2243 self.assertEqual(
str(path),
'a+b+c')
2244 path =
Path(p.a*p.b+p.c)
2245 self.assertEqual(
str(path),
'a+b+c')
2248 path =
Path(p.a+ p.b*p.c)
2249 self.assertEqual(
str(path),
'a+b+c')
2250 path =
Path(p.a*(p.b+p.c))
2251 self.assertEqual(
str(path),
'a+b+c')
2252 path =
Path(p.a*(p.b+~p.c))
2254 self.assertEqual(
str(path),
'a+b+~c')
2256 self.assertRaises(TypeError,Path,p.es)
2259 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path()\n')
2262 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a)\n')
2265 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(cms.Task())\n')
2268 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task())\n')
2273 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task(), process.t1)\n')
2284 p.path =
Path(p.a*p.b)
2285 lookuptable = {
id(a): p.a,
id(b): p.b}
2289 self.assertEqual(
str(path),
str(p.path))
2302 self.assertEqual(s[0],p.path1)
2303 self.assertEqual(s[1],p.path2)
2305 self.assert_(
'b' in p.schedule.moduleNames())
2306 self.assert_(hasattr(p,
'b'))
2307 self.assert_(hasattr(p,
'c'))
2308 self.assert_(hasattr(p,
'd'))
2309 self.assert_(hasattr(p,
'path1'))
2310 self.assert_(hasattr(p,
'path2'))
2311 self.assert_(hasattr(p,
'path3'))
2313 self.assert_(
'b' in p.schedule.moduleNames())
2314 self.assert_(hasattr(p,
'b'))
2315 self.assert_(
not hasattr(p,
'c'))
2316 self.assert_(
not hasattr(p,
'd'))
2317 self.assert_(hasattr(p,
'path1'))
2318 self.assert_(hasattr(p,
'path2'))
2319 self.assert_(
not hasattr(p,
'path3'))
2321 self.assertTrue(len(p.schedule._tasks) == 0)
2335 p.task2 =
Task(p.f, p.Tracer)
2336 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2337 self.assertEqual(s[0],p.path1)
2338 self.assertEqual(s[1],p.path2)
2339 self.assertTrue(len(s._tasks) == 2)
2340 self.assertTrue(p.task1
in s._tasks)
2341 self.assertTrue(p.task2
in s._tasks)
2342 listOfTasks =
list(s._tasks)
2343 self.assertTrue(len(listOfTasks) == 2)
2344 self.assertTrue(p.task1 == listOfTasks[0])
2345 self.assertTrue(p.task2 == listOfTasks[1])
2347 self.assert_(
'b' in p.schedule.moduleNames())
2352 process2.path1 =
Path(process2.a)
2353 process2.task1 =
Task(process2.e)
2354 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2355 listOfTasks =
list(process2.schedule._tasks)
2356 self.assertTrue(listOfTasks[0] == process2.task1)
2360 self.assertEqual(s2[0],p.path1)
2361 self.assertEqual(s2[1],p.path2)
2362 self.assertTrue(len(s2._tasks) == 2)
2363 self.assertTrue(p.task1
in s2._tasks)
2364 self.assertTrue(p.task2
in s2._tasks)
2365 listOfTasks =
list(s2._tasks)
2366 self.assertTrue(len(listOfTasks) == 2)
2367 self.assertTrue(p.task1 == listOfTasks[0])
2368 self.assertTrue(p.task2 == listOfTasks[1])
2370 names = s.moduleNames()
2371 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2377 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2386 self.assert_(
'a' in s.moduleNames())
2387 self.assert_(
'b' in s.moduleNames())
2388 self.assert_(
'c' in s.moduleNames())
2392 self.assert_(
'a' in s.moduleNames())
2393 self.assert_(
'b' in s.moduleNames())
2394 self.assert_(
'c' in s.moduleNames())
2403 self.assert_(p.schedule
is None)
2406 self.assertEqual(pths[keys[0]],p.path1)
2407 self.assertEqual(pths[keys[1]],p.path2)
2409 self.assert_(hasattr(p,
'a'))
2410 self.assert_(hasattr(p,
'b'))
2411 self.assert_(
not hasattr(p,
'c'))
2412 self.assert_(hasattr(p,
'path1'))
2413 self.assert_(hasattr(p,
'path2'))
2422 self.assert_(p.schedule
is None)
2425 self.assertEqual(pths[keys[1]],p.path1)
2426 self.assertEqual(pths[keys[0]],p.path2)
2433 self.assertEqual(p.modu.a.value(),1)
2434 self.assertEqual(p.modu.b.value(),2)
2439 self.assert_(
not a.isModified())
2441 self.assert_(a.isModified())
2443 self.assertEqual(p.a.a1.value(), 1)
2447 self.assertEqual(p.a.a1.value(), 2)
2456 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2457 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2461 p.source =
Source(
"PoolSource",fileNames = untracked(
string(
"file:reco.root")))
2464 p.out =
OutputModule(
"PoolOutputModule",fileName=untracked(
string(
"file:foos.root")))
2465 p.bars.foos =
'Foosball' 2466 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2467 p.p =
Path(p.foos*p.bars)
2469 p.add_(
Service(
"MessageLogger"))
2475 p.prefer(
"ForceSource")
2477 self.assertEqual(p.dumpConfig(),
2479 es_module juicer = JuicerProducer { 2481 es_source = ForceSource { 2483 es_prefer = ForceSource { 2485 es_prefer juicer = JuicerProducer { 2489 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2490 self.assertEqual(p.dumpConfig(),
2492 es_module juicer = JuicerProducer { 2494 es_source = ForceSource { 2496 es_prefer = ForceSource { 2498 es_prefer juicer = JuicerProducer { 2506 self.assertEqual(p.dumpPython(),
2507 """import FWCore.ParameterSet.Config as cms 2509 process = cms.Process("Test") 2511 process.juicer = cms.ESProducer("JuicerProducer") 2514 process.ForceSource = cms.ESSource("ForceSource") 2517 process.prefer("ForceSource") 2519 process.prefer("juicer", 2520 fooRcd = cms.vstring('Foo') 2537 self.assertEqual(process.m.p.i.value(), 4)
2547 subProcess.p =
Path(subProcess.a)
2548 subProcess.add_(
Service(
"Foo"))
2549 process.addSubProcess(
SubProcess(subProcess))
2550 d = process.dumpPython()
2551 equalD =
"""import FWCore.ParameterSet.Config as cms 2553 process = cms.Process("Parent") 2555 parentProcess = process 2556 import FWCore.ParameterSet.Config as cms 2558 process = cms.Process("Child") 2560 process.a = cms.EDProducer("A") 2563 process.Foo = cms.Service("Foo") 2566 process.p = cms.Path(process.a) 2569 childProcess = process 2570 process = parentProcess 2571 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 2573 ), outputCommands = cms.untracked.vstring())) 2576 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2577 self.assertEqual(d,equalD)
2579 process.fillProcessDesc(p)
2580 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2581 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2582 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2592 proc.fillProcessDesc(p)
2593 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2594 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2595 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2596 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2597 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2598 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2608 self.assert_(p.schedule
is None)
2611 self.assertEqual(pths[keys[0]],p.path1)
2612 self.assertEqual(pths[keys[1]],p.path2)
2614 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2616 p.vpset2 = untracked.VPSet()
2618 self.assert_(hasattr(p,
'a'))
2619 self.assert_(hasattr(p,
'b'))
2620 self.assert_(
not hasattr(p,
'c'))
2621 self.assert_(
not hasattr(p,
'd'))
2622 self.assert_(
not hasattr(p,
's'))
2623 self.assert_(hasattr(p,
'path1'))
2624 self.assert_(hasattr(p,
'path2'))
2641 p.path3 =
Path(p.b+p.s2)
2642 p.path4 =
Path(p.b+p.s3)
2643 p.schedule =
Schedule(p.path1,p.path2,p.path3)
2646 self.assertEqual(pths[keys[0]],p.path1)
2647 self.assertEqual(pths[keys[1]],p.path2)
2649 self.assert_(hasattr(p,
'a'))
2650 self.assert_(hasattr(p,
'b'))
2651 self.assert_(
not hasattr(p,
'c'))
2652 self.assert_(
not hasattr(p,
'd'))
2653 self.assert_(
not hasattr(p,
'e'))
2654 self.assert_(
not hasattr(p,
's'))
2655 self.assert_(hasattr(p,
's2'))
2656 self.assert_(
not hasattr(p,
's3'))
2657 self.assert_(hasattr(p,
'path1'))
2658 self.assert_(hasattr(p,
'path2'))
2659 self.assert_(hasattr(p,
'path3'))
2660 self.assert_(
not hasattr(p,
'path4'))
2668 self.assert_(hasattr(p,
'a'))
2669 self.assert_(hasattr(p,
'b'))
2670 self.assert_(hasattr(p,
's'))
2671 self.assert_(hasattr(p,
'pth'))
2677 p.prune(keepUnresolvedSequencePlaceholders=
True)
2678 self.assert_(hasattr(p,
'b'))
2679 self.assert_(hasattr(p,
's'))
2680 self.assert_(hasattr(p,
'pth'))
2681 self.assertEqual(p.s.dumpPython(
''),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
2689 p.path1 =
Path(p.b, p.t2, p.t3)
2692 p.endpath1 =
EndPath(p.b, p.t5)
2696 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
2705 self.assertEqual(p.dumpPython(),
2706 """import FWCore.ParameterSet.Config as cms 2708 process = cms.Process("test") 2710 process.a = cms.EDProducer("ma") 2713 process.c = cms.EDProducer("mc") 2716 process.d = cms.EDProducer("md") 2719 process.e = cms.EDProducer("me") 2722 process.f = cms.EDProducer("mf") 2725 process.g = cms.EDProducer("mg") 2728 process.h = cms.EDProducer("mh") 2731 process.i = cms.EDProducer("mi") 2734 process.j = cms.EDProducer("mj") 2737 process.b = cms.EDAnalyzer("mb") 2740 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 2743 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 2746 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 2749 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 2752 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 2755 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 2758 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 2761 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 2764 process.path1 = cms.Path(process.b, process.t2, process.t3) 2767 process.endpath1 = cms.EndPath(process.b, process.t5) 2770 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2773 self.assertEqual(p.dumpPython(),
2774 """import FWCore.ParameterSet.Config as cms 2776 process = cms.Process("test") 2778 process.a = cms.EDProducer("ma") 2781 process.c = cms.EDProducer("mc") 2784 process.d = cms.EDProducer("md") 2787 process.e = cms.EDProducer("me") 2790 process.f = cms.EDProducer("mf") 2793 process.g = cms.EDProducer("mg") 2796 process.h = cms.EDProducer("mh") 2799 process.i = cms.EDProducer("mi") 2802 process.j = cms.EDProducer("mj") 2805 process.b = cms.EDAnalyzer("mb") 2808 process.t8 = cms.Task(process.j) 2811 process.t6 = cms.Task(process.h) 2814 process.t7 = cms.Task(process.a, process.i, process.t6) 2817 process.t4 = cms.Task(process.f) 2820 process.t5 = cms.Task(process.a, process.g, process.t4) 2823 process.t3 = cms.Task(process.e) 2826 process.t1 = cms.Task(process.c) 2829 process.t2 = cms.Task(process.a, process.d, process.t1) 2832 process.path1 = cms.Path(process.b, process.t2, process.t3) 2835 process.endpath1 = cms.EndPath(process.b, process.t5) 2838 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2851 p.t1 =
Task(p.g, p.h)
2855 p.path1 =
Path(p.a+p.f+p.s,t2)
2858 self.assertTrue(hasattr(p,
'f'))
2859 self.assertTrue(hasattr(p,
'g'))
2863 self.assertFalse(hasattr(p,
'f'))
2864 self.assertFalse(hasattr(p,
'g'))
2865 self.assertTrue(p.t1.dumpPython(
None) ==
'cms.Task(process.h)\n')
2866 self.assertTrue(p.s.dumpPython(
None) ==
'cms.Sequence(process.d)\n')
2867 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
2868 self.assertTrue(p.endpath1.dumpPython(
None) ==
'cms.EndPath(process.b)\n')
2870 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
2871 self.assertTrue(p.schedule_().
dumpPython(
None) ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
2878 m1.toModify(p.a,_mod_fred)
2879 self.assertEqual(p.a.fred.value(),2)
2881 m1.toModify(p.b, wilma = 2)
2882 self.assertEqual(p.b.wilma.value(),2)
2883 self.assert_(p.isUsingModifier(m1))
2888 m1.toModify(p.a,_mod_fred)
2890 m1.toModify(p.b, wilma = 2)
2891 self.assertEqual(p.a.fred.value(),1)
2892 self.assertEqual(p.b.wilma.value(),1)
2893 self.assertEqual(p.isUsingModifier(m1),
False)
2898 m1.toModify(p.a, fred =
int32(2))
2899 p.b = p.a.clone(wilma =
int32(3))
2900 self.assertEqual(p.a.fred.value(),2)
2901 self.assertEqual(p.a.wilma.value(),1)
2902 self.assertEqual(p.b.fred.value(),2)
2903 self.assertEqual(p.b.wilma.value(),3)
2908 m1.toModify(p.a, fred =
None, fintstones =
dict(fred =
None))
2909 self.assertEqual(hasattr(p.a,
"fred"),
False)
2910 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
2911 self.assertEqual(p.a.wilma.value(),1)
2916 m1.toModify(p.a, wilma =
int32(2))
2917 self.assertEqual(p.a.fred.value(), 1)
2918 self.assertEqual(p.a.wilma.value(),2)
2923 m1.toModify(p.a, flintstones =
dict(fred =
int32(2)))
2924 self.assertEqual(p.a.flintstones.fred.value(),2)
2925 self.assertEqual(p.a.flintstones.wilma.value(),1)
2930 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones =
dict(imnothere =
dict(wilma=2))))
2931 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
2936 m1.toModify(p.a, flintstones = {1:
dict(wilma =
int32(2))})
2937 self.assertEqual(p.a.flintstones[0].fred.value(),1)
2938 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
2943 m1.toModify(p.a, fred = {1:7})
2944 self.assertEqual(p.a.fred[0],1)
2945 self.assertEqual(p.a.fred[1],7)
2946 self.assertEqual(p.a.fred[2],3)
2952 try: m1.toModify(p.a, fred = {5:7})
2953 except IndexError
as e: raised =
True 2954 self.assertEqual(raised,
True)
2960 try: m1.toModify(p.a, flintstones =
dict(bogus =
int32(37)))
2961 except TypeError
as e: raised =
True 2962 self.assertEqual(raised,
True)
2966 class ProcModifierMod(
object):
2967 def __init__(self,modifier,func):
2972 testMod = DummyMod()
2974 self.assert_(hasattr(p,
"a"))
2977 testProcMod = ProcModifierMod(m1,_rem_a)
2979 p.extend(testProcMod)
2980 self.assert_(
not hasattr(p,
"a"))
2985 self.assert_(p.isUsingModifier(m1))
2986 self.assert_(p.isUsingModifier(mc))
2987 testMod = DummyMod()
2989 m1.toModify(p.b, fred =
int32(3))
2991 testProcMod = ProcModifierMod(m1,_rem_a)
2992 p.extend(testProcMod)
2993 self.assert_(
not hasattr(p,
"a"))
2994 self.assertEqual(p.b.fred.value(),3)
2999 mclone = mc.copyAndExclude([m2])
3000 self.assert_(
not mclone._isOrContains(m2))
3001 self.assert_(mclone._isOrContains(m1))
3004 mclone = mc2.copyAndExclude([m2])
3005 self.assert_(
not mclone._isOrContains(m2))
3006 self.assert_(mclone._isOrContains(m1))
3007 self.assert_(mclone._isOrContains(m3))
3013 (m1 & m2).toModify(p.a, fred =
int32(2))
3014 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3015 self.assertEqual(p.a.fred, 1)
3020 (m1 & m2).toModify(p.a, fred =
int32(2))
3021 self.assertEqual(p.a.fred, 2)
3027 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3028 self.assertEqual(p.a.fred, 2)
3029 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3030 self.assertEqual(p.a.fred, 3)
3031 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3032 self.assertEqual(p.a.fred, 4)
3038 (~m1).toModify(p.a, fred=2)
3039 self.assertEqual(p.a.fred, 1)
3040 (~m2).toModify(p.a, wilma=2)
3041 self.assertEqual(p.a.wilma, 2)
3042 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3043 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3050 (m1 | m2).toModify(p.a, fred=2)
3051 self.assertEqual(p.a.fred, 2)
3052 (m1 | m2 | m3).toModify(p.a, fred=3)
3053 self.assertEqual(p.a.fred, 3)
3054 (m3 | m2 | m1).toModify(p.a, fred=4)
3055 self.assertEqual(p.a.fred, 4)
3056 ((m1 | m2) | m3).toModify(p.a, fred=5)
3057 self.assertEqual(p.a.fred, 5)
3058 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3059 self.assertEqual(p.a.fred, 6)
3060 (m2 | m3).toModify(p.a, fred=7)
3061 self.assertEqual(p.a.fred, 6)
3062 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3063 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3071 (m1 & ~m2).toModify(p.a, fred=2)
3072 self.assertEqual(p.a.fred, 1)
3073 (m1 & ~m3).toModify(p.a, fred=2)
3074 self.assertEqual(p.a.fred, 2)
3075 (m1 | ~m2).toModify(p.a, fred=3)
3076 self.assertEqual(p.a.fred, 3)
3077 (~m1 | ~m2).toModify(p.a, fred=4)
3078 self.assertEqual(p.a.fred, 3)
3079 (~m3 & ~m4).toModify(p.a, fred=4)
3080 self.assertEqual(p.a.fred, 4)
3081 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3082 self.assertEqual(p.a.fred, 5)
3088 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3095 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3096 self.assertEqual(p.a.wilma.value(),3)
3097 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3098 self.assertEqual(hasattr(p,
"fred"),
False)
3099 self.assertTrue(p.s.dumpPython(
"") ==
"cms.Sequence(process.a+process.b, process.td)\n")
3101 m1.toReplaceWith(p.td,
Task(p.e))
3102 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3108 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3116 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3117 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3118 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3119 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3120 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3121 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3122 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3123 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3124 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3125 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3126 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3127 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3128 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3129 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3130 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3131 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3132 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3133 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
def __setstate__(self, pkldict)
def addVString(self, tracked, label, value)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
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 _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 toModify(self, obj, func=None, 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 toReplaceWith(self, toObj, fromObj)
def _placeOutputModule(self, name, mod)
def addFileInPath(self, tracked, label, value)
def _placeSource(self, name, mod)
def __init__(self, lhs, rhs=None)
def _dumpPythonSubProcesses(self, l, options)
def checkImportPermission(minLevel=2, allowedPatterns=[])
def _toModify(obj, func, kw)
def __init__(self, modifier, func)
def _toReplaceWith(toObj, fromObj)
def _toModifyCheck(obj, func, kw)
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 _toReplaceWithCheck(toObj, fromObj)
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 makeProcessModifier(self, func)
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 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)