5 from Options
import Options
11 from Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
15 from Modules
import _Module
16 from SequenceTypes
import *
17 from SequenceTypes
import _ModuleSequenceType, _Sequenceable
18 from SequenceVisitors
import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
21 from ExceptionHandling
import *
24 if sys.getrecursionlimit()<5000:
25 sys.setrecursionlimit(5000)
29 Raise an exception if called by special config files. This checks 30 the call or import stack for the importing file. An exception is raised if 31 the importing module is not in allowedPatterns and if it is called too deeply: 32 minLevel = 2: inclusion by top lvel cfg only 33 minLevel = 1: No inclusion allowed 34 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 35 by any module in Module1 or Submodule1 41 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>']
42 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
46 for item
in inspect.stack():
50 for pattern
in CMSSWPath:
51 if item[1].
find(pattern) != -1:
54 if item[1].
find(
'/') == -1:
57 for pattern
in ignorePatterns:
58 if item[1].
find(pattern) != -1:
62 if inPath
and not ignore:
63 trueStack.append(item[1])
65 importedFile = trueStack[0]
67 if len(trueStack) > 1:
68 importedBy = trueStack[1]
70 for pattern
in allowedPatterns:
71 if importedBy.find(pattern) > -1:
74 if len(trueStack) <= minLevel:
77 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 81 """Look inside the module and find the Processes it contains""" 85 if isinstance(module,dict):
86 if 'process' in module:
90 if hasattr(module,
'process'):
91 if isinstance(module.process,Process):
92 process = module.process
94 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
96 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
100 """Root class for a CMS configuration process""" 102 """The argument 'name' will be the name applied to this Process 103 Can optionally pass as additional arguments cms.Modifier instances 104 that will be used to modify the Process as it is built 106 self.__dict__[
'_Process__name'] = name
107 if not name.isalnum():
108 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
109 self.__dict__[
'_Process__filters'] = {}
110 self.__dict__[
'_Process__producers'] = {}
111 self.__dict__[
'_Process__source'] =
None 112 self.__dict__[
'_Process__looper'] =
None 113 self.__dict__[
'_Process__subProcesses'] = []
114 self.__dict__[
'_Process__schedule'] =
None 115 self.__dict__[
'_Process__analyzers'] = {}
116 self.__dict__[
'_Process__outputmodules'] = {}
119 self.__dict__[
'_Process__sequences'] = {}
120 self.__dict__[
'_Process__tasks'] = {}
121 self.__dict__[
'_Process__services'] = {}
122 self.__dict__[
'_Process__essources'] = {}
123 self.__dict__[
'_Process__esproducers'] = {}
124 self.__dict__[
'_Process__esprefers'] = {}
125 self.__dict__[
'_Process__aliases'] = {}
126 self.__dict__[
'_Process__psets']={}
127 self.__dict__[
'_Process__vpsets']={}
128 self.__dict__[
'_cloneToObjectDict'] = {}
130 self.__dict__[
'_Process__InExtendCall'] =
False 131 self.__dict__[
'_Process__partialschedules'] = {}
133 self.__dict__[
'_Process__modifiers'] = Mods
134 for m
in self.__modifiers:
139 _Module.__isStrict__ =
True 143 """Returns a string containing all the EDProducer labels separated by a blank""" 146 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 149 """Returns a string containing all the EDFilter labels separated by a blank""" 152 """Returns a string containing all the Path names separated by a blank""" 159 Since cloneToObjectDict stores a hash of objects by their 160 id() it needs to be updated when unpickling to use the 161 new object id values instantiated during the unpickle. 164 self.__dict__.update(pkldict)
166 for value
in self._cloneToObjectDict.values():
167 tmpDict[
id(value)] = value
168 self.__dict__[
'_cloneToObjectDict'] = tmpDict
173 """returns a dict of the filters that have been added to the Process""" 175 filters = property(filters_, doc=
"dictionary containing the filters for the process")
179 if not name.isalnum():
180 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
181 self.__dict__[
'_Process__name'] = name
182 process = property(name_,setName_, doc=
"name of the process")
184 """returns a dict of the producers that have been added to the Process""" 186 producers = property(producers_,doc=
"dictionary containing the producers for the process")
188 """returns the source that has been added to the Process or None if none have been added""" 192 source = property(source_,setSource_,doc=
'the main source or None if not set')
194 """returns the looper that has been added to the Process or None if none have been added""" 198 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
200 """returns a list of the subProcesses that have been added to the Process""" 201 return self.__subProcesses
202 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
204 """returns a dict of the analyzers that have been added to the Process""" 206 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
208 """returns a dict of the output modules that have been added to the Process""" 210 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
212 """returns a dict of the paths that have been added to the Process""" 214 paths = property(paths_,doc=
"dictionary containing the paths for the process")
216 """returns a dict of the endpaths that have been added to the Process""" 218 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
220 """returns a dict of the sequences that have been added to the Process""" 222 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
224 """returns a dict of the tasks that have been added to the Process""" 226 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
228 """returns the schedule that has been added to the Process or None if none have been added""" 229 return self.__schedule
231 if label ==
"schedule":
234 self.
_place(label, sch, self.__partialschedules)
243 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
244 self.__dict__[
'_Process__schedule'] = sch
245 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
247 """returns a dict of the services that have been added to the Process""" 249 services = property(services_,doc=
"dictionary containing the services for the process")
251 """returns a dict of the esproducers that have been added to the Process""" 253 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
255 """returns a the es_sources that have been added to the Process""" 257 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
259 """returns a dict of the es_prefers that have been added to the Process""" 261 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
263 """returns a dict of the aliases that have been added to the Process""" 265 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
267 """returns a dict of the PSets that have been added to the Process""" 269 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
271 """returns a dict of the VPSets that have been added to the Process""" 273 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
276 """returns True if the Modifier is in used by this Process""" 278 for m
in self.__modifiers:
279 if m._isOrContains(mod):
284 if not object.hasLabel_() :
285 object.setLabel(newLabel)
287 if newLabel == object.label_() :
289 if newLabel
is None :
290 object.setLabel(
None)
292 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
293 msg100 =
"Attempting to change the label of an attribute of the Process\n" 294 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 295 msg102 =
"Type = "+
str(type(object))+
"\n" 296 msg103 =
"Some possible solutions:\n" 297 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 298 msg105 =
" also preferred for other types when possible.\n" 299 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 300 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 301 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 302 msg109 =
" the name.\n" 303 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 304 msg111 =
" name to the same object usually causes confusion and problems.\n" 305 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 306 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
307 object.setLabel(
None)
308 object.setLabel(newLabel)
312 if not name.replace(
'_',
'').isalnum():
313 raise ValueError(
'The label '+name+
' contains forbiden characters')
316 if name.startswith(
'_Process__'):
317 self.__dict__[name]=value
319 if not isinstance(value,_ConfigureComponent):
320 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 321 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
322 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
323 if name == value.type_():
328 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
329 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
332 newValue =value.copy()
334 newValue._filename = value._filename
340 if not self.
_okToPlace(name, value, self.__dict__):
341 newFile=
'top level config' 342 if hasattr(value,
'_filename'):
343 newFile = value._filename
344 oldFile=
'top level config' 345 oldValue = getattr(self,name)
346 if hasattr(oldValue,
'_filename'):
347 oldFile = oldValue._filename
348 msg =
"Trying to override definition of process."+name
349 msg +=
"\n new object defined in: "+newFile
350 msg +=
"\n existing object defined in: "+oldFile
351 raise ValueError(msg)
353 if hasattr(self,name)
and not (getattr(self,name)==newValue):
357 if newValue._isTaskComponent():
358 if not self.__InExtendCall:
362 if not isinstance(newValue, Task):
364 newFile=
'top level config' 365 if hasattr(value,
'_filename'):
366 newFile = value._filename
367 oldFile=
'top level config' 368 oldValue = getattr(self,name)
369 if hasattr(oldValue,
'_filename'):
370 oldFile = oldValue._filename
371 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 372 msg2 =
"\n new object defined in: "+newFile
373 msg2 +=
"\n existing object defined in: "+oldFile
376 raise ValueError(msg1+s.label_()+msg2)
378 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent():
379 if not self.__InExtendCall:
383 newFile=
'top level config' 384 if hasattr(value,
'_filename'):
385 newFile = value._filename
386 oldFile=
'top level config' 387 oldValue = getattr(self,name)
388 if hasattr(oldValue,
'_filename'):
389 oldFile = oldValue._filename
390 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 391 msg2 =
"\n new object defined in: "+newFile
392 msg2 +=
"\n existing object defined in: "+oldFile
395 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
398 raise ValueError(msg1+
"path "+s.label_()+msg2)
401 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
403 self.__dict__[name]=newValue
404 if isinstance(newValue,_Labelable):
406 self._cloneToObjectDict[
id(value)] = newValue
407 self._cloneToObjectDict[
id(newValue)] = newValue
409 newValue._place(name,self)
411 """Given a container of sequences or tasks, find the first sequence or task 412 containing mod and return it. If none is found, return None""" 415 for seqOrTask
in six.itervalues(seqsOrTasks):
424 if not hasattr(self,name):
425 raise KeyError(
'process does not know about '+name)
426 elif name.startswith(
'_Process__'):
427 raise ValueError(
'this attribute cannot be deleted')
430 dicts = [item
for item
in self.__dict__.values()
if (isinstance(item, dict)
or isinstance(item,
DictTypes.SortedKeysDict))]
432 if name
in reg: del reg[name]
434 obj = getattr(self,name)
435 if isinstance(obj,_Labelable):
437 if isinstance(obj,Service):
438 obj._inProcess =
False 442 obj = getattr(self,name)
444 if not isinstance(obj, Sequence)
and not isinstance(obj, Task):
454 if obj._isTaskComponent():
457 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
461 del self.__dict__[name]
466 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 470 del self.__dict__[name]
475 """Allows addition of components that do not have to have a label, e.g. Services""" 476 if not isinstance(value,_ConfigureComponent):
478 if not isinstance(value,_Unlabelable):
483 newValue =value.copy()
487 newValue._place(
'',self)
490 if not self.__InExtendCall:
501 if d[name]._isModified:
512 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
513 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
516 if isinstance(mod,_Labelable):
519 self.
_place(name, mod, self.__outputmodules)
521 self.
_place(name, mod, self.__producers)
523 self.
_place(name, mod, self.__filters)
525 self.
_place(name, mod, self.__analyzers)
529 self.
_place(name, mod, self.__paths)
530 except ModuleCloneError
as msg:
532 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
536 self.
_place(name, mod, self.__endpaths)
537 except ModuleCloneError
as msg:
539 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
542 self.
_place(name, mod, self.__sequences)
544 self.
_place(name, mod, self.__esproducers)
546 self.
_place(name, mod, self.__esprefers)
548 self.
_place(name, mod, self.__essources)
551 self.
_place(name, task, self.__tasks)
553 self.
_place(name, mod, self.__aliases)
555 self.
_place(name, mod, self.__psets)
557 self.
_place(name, mod, self.__vpsets)
559 """Allow the source to be referenced by 'source' or by type name""" 561 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
562 if self.__dict__[
'_Process__source']
is not None :
563 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
564 self.__dict__[
'_Process__source'] = mod
565 self.__dict__[mod.type_()] = mod
568 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
569 self.__dict__[
'_Process__looper'] = mod
570 self.__dict__[mod.type_()] = mod
572 self.__dict__[
'_Process__subProcess'] = mod
573 self.__dict__[mod.type_()] = mod
575 self.__subProcesses.append(mod)
577 self.
_place(typeName, mod, self.__services)
578 if typeName
in self.__dict__:
579 self.__dict__[typeName]._inProcess =
False 580 self.__dict__[typeName]=mod
582 moduleName = moduleName.replace(
"/",
".")
583 module = __import__(moduleName)
584 self.
extend(sys.modules[moduleName])
586 """Look in other and find types that we can use""" 588 self.__dict__[
'_Process__InExtendCall'] =
True 591 tasksToAttach =
dict()
593 for name
in dir(other):
595 if name.startswith(
'_'):
597 item = getattr(other,name)
598 if name ==
"source" or name ==
"looper":
602 elif isinstance(item,_ModuleSequenceType):
604 elif isinstance(item,Task):
605 tasksToAttach[name] = item
606 elif isinstance(item,_Labelable):
608 if not item.hasLabel_() :
610 elif isinstance(item,Schedule):
612 elif isinstance(item,_Unlabelable):
614 elif isinstance(item,ProcessModifier):
616 elif isinstance(item,ProcessFragment):
620 for name
in seqs.iterkeys():
624 if id(seq)
not in self._cloneToObjectDict:
627 newSeq = self._cloneToObjectDict[
id(seq)]
628 self.__dict__[name]=newSeq
631 newSeq._place(name,self)
633 for name
in tasksToAttach.iterkeys():
634 task = tasksToAttach[name]
641 self.__dict__[
'_Process__InExtendCall'] =
False 645 for name,item
in items:
646 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
650 for name,item
in items:
651 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
655 for name,item
in items:
656 if name == item.type_():
658 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
661 """return a string containing the equivalent process defined using the old configuration language""" 662 config =
"process "+self.__name+
" = {\n" 708 for name,item
in six.iteritems(self.
psets):
709 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
710 for name,item
in six.iteritems(self.
vpsets):
711 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
713 pathNames = [p.label_()
for p
in self.
schedule]
714 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 725 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
730 returnValue += item.dumpPython(options)+
'\n\n' 735 for name,item
in d.items():
736 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 738 for name,item
in sorted(d.items()):
739 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 746 sequence.visit(visitor)
748 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
756 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
767 for label,item
in six.iteritems(processDictionaryOfItems):
769 if isinstance(item, Task):
776 if isinstance(item, Task):
777 raise RuntimeError(
"Failed in a Task visitor. Probably " \
778 "a circular dependency discovered in Task with label " + label)
780 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
781 "circular dependency discovered in Sequence with label " + label)
782 for containedItem
in containedItems:
788 if containedItem.hasLabel_():
789 testItem = processDictionaryOfItems.get(containedItem.label_())
790 if testItem
is None or containedItem != testItem:
791 if isinstance(item, Task):
792 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
793 " from the process yields a different object or None\n"+
794 "label = " + containedItem.label_())
796 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
797 " from the process yields a different object or None\n"+
798 "label = " + containedItem.label_())
799 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
803 oldDeps =
dict(dependencies)
804 for label,deps
in six.iteritems(oldDeps):
806 returnValue[label]=processDictionaryOfItems[label]
808 del dependencies[label]
809 for lb2,deps2
in six.iteritems(dependencies):
810 while deps2.count(label):
815 for name, value
in sorted(six.iteritems(d)):
816 result += value.dumpPythonAs(name,options)+
'\n' 819 """return a string containing the equivalent process defined using python""" 820 result =
"import FWCore.ParameterSet.Config as cms\n\n" 821 result +=
"process = cms.Process(\""+self.__name+
"\")\n\n" 843 result +=
'process.schedule = ' + self.schedule.dumpPython(options)
846 old = getattr(self,label)
848 for sequenceable
in six.itervalues(self.
sequences):
849 sequenceable.replace(old,new)
850 for sequenceable
in six.itervalues(self.
paths):
851 sequenceable.replace(old,new)
852 for sequenceable
in six.itervalues(self.
endpaths):
853 sequenceable.replace(old,new)
855 old = getattr(self,label)
856 for task
in six.itervalues(self.
tasks):
857 task.replace(old, new)
861 old = getattr(self,label)
863 task.replace(old, new)
865 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 866 if not hasattr(self,label):
867 raise LookupError(
"process has no item of label "+label)
868 setattr(self,label,new)
870 for name,value
in six.iteritems(itemDict):
871 value.insertInto(parameterSet, name)
875 newlabel = item.nameInProcessDesc_(label)
877 item.insertInto(parameterSet, newlabel)
878 parameterSet.addVString(tracked, label, vitems)
881 for name,value
in six.iteritems(itemDict):
882 newLabel = value.nameInProcessDesc_(name)
884 value.insertInto(parameterSet, name)
887 parameterSet.addVString(tracked, label, l)
891 for value
in itemList:
892 name = value.getProcessName()
893 newLabel = value.nameInProcessDesc_(name)
895 pset = value.getSubProcessPSet(parameterSet)
896 subprocs.append(pset)
899 parameterSet.addVString(tracked, label, l)
900 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
907 for name
in self.
paths_():
908 scheduledPaths.append(name)
909 triggerPaths.append(name)
911 scheduledPaths.append(name)
912 endpaths.append(name)
915 pathname = path.label_()
916 scheduledPaths.append(pathname)
918 endpaths.append(pathname)
920 triggerPaths.append(pathname)
922 task.resolve(self.__dict__)
924 task.visit(scheduleTaskValidator)
925 task.visit(nodeVisitor)
926 processPSet.addVString(
True,
"@end_paths", endpaths)
927 processPSet.addVString(
True,
"@paths", scheduledPaths)
929 p = processPSet.newPSet()
930 p.addVString(
True,
"@trigger_paths", triggerPaths)
931 processPSet.addPSet(
True,
"@trigger_paths", p)
938 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
939 for triggername
in triggerPaths:
940 iPath = self.
paths_()[triggername]
941 iPath.resolve(self.__dict__)
942 pathValidator.setLabel(triggername)
944 iPath.visit(pathCompositeVisitor)
945 iPath.insertInto(processPSet, triggername, decoratedList)
946 for endpathname
in endpaths:
948 iEndPath.resolve(self.__dict__)
949 endpathValidator.setLabel(endpathname)
951 iEndPath.visit(endpathCompositeVisitor)
952 iEndPath.insertInto(processPSet, endpathname, decoratedList)
953 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
955 def resolve(self,keepUnresolvedSequencePlaceholders=False):
956 for x
in six.itervalues(self.
paths):
957 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
958 for x
in six.itervalues(self.
endpaths):
959 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
962 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
964 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
965 """ Remove clutter from the process that we think is unnecessary: 966 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 967 not in the schedule will also be removed, along with an modules and sequences used only by 968 those removed Paths and EndPaths.""" 977 self.
resolve(keepUnresolvedSequencePlaceholders)
979 unneededPaths = set()
981 usedModules=set(self.
schedule_().moduleNames())
983 schedNames = set(( x.label_()
for x
in self.
schedule_()))
984 names = set(self.
paths)
986 unneededPaths = names - schedNames
987 for n
in unneededPaths:
991 pths.extend(six.itervalues(self.
endpaths))
993 usedModules=set(temp.moduleNames())
1000 for p
in six.itervalues(self.
paths):
1002 for p
in six.itervalues(self.
endpaths):
1004 keepSeqSet = set(( s
for s
in seqs
if s.hasLabel_()))
1005 availableSeqs = set(six.itervalues(self.
sequences))
1006 unneededSeqs = availableSeqs-keepSeqSet
1007 unneededSeqLabels = []
1008 for s
in unneededSeqs:
1009 unneededSeqLabels.append(s.label_())
1010 delattr(self,s.label_())
1012 print "prune removed the following:" 1013 print " modules:"+
",".
join(unneededModules)
1014 print " sequences:"+
",".
join(unneededSeqLabels)
1015 print " paths/endpaths:"+
",".
join(unneededPaths)
1017 moduleNames = set(d.keys())
1018 junk = moduleNames - scheduledNames
1024 """Used by the framework to convert python to C++ objects""" 1025 class ServiceInjectorAdaptor(
object):
1029 def addService(self,pset):
1030 self.__thelist.append(pset)
1032 return self.__processPSet.newPSet()
1036 class TopLevelPSetAcessorAdaptor(
object):
1040 def __getattr__(self,attr):
1041 return getattr(self.
__ppset,attr)
1042 def getTopPSet_(self,label):
1045 return TopLevelPSetAcessorAdaptor(self.__ppset.newPSet(),self.
__process)
1046 def addPSet(self,tracked,name,ppset):
1047 return self.__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1048 def addVPSet(self,tracked,name,vpset):
1049 return self.__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1050 def __extractPSet(self,pset):
1051 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1056 processPSet.addString(
True,
"@process_name", self.
name_())
1058 all_modules.update(self.
filters_())
1061 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1074 all_modules_onTasksOrScheduled = { key:value
for key, value
in six.iteritems(all_modules)
if value
in nodeVisitor.modules }
1075 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1079 for pTask
in six.itervalues(self.
tasks):
1080 pTask.visit(processNodeVisitor)
1081 esProducersToEnable = {}
1082 for esProducerName, esProducer
in six.iteritems(self.
es_producers_()):
1083 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1084 esProducersToEnable[esProducerName] = esProducer
1085 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1086 esSourcesToEnable = {}
1087 for esSourceName, esSource
in six.iteritems(self.
es_sources_()):
1088 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1089 esSourcesToEnable[esSourceName] = esSource
1090 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1093 for serviceName, serviceObject
in six.iteritems(self.
services_()):
1094 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1095 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1096 adaptor.addVPSet(
False,
"services",services)
1107 """Prefer this ES source or producer. The argument can 1108 either be an object label, e.g., 1109 process.prefer(process.juicerProducer) (not supported yet) 1110 or a name of an ESSource or ESProducer 1111 process.prefer("juicer") 1112 or a type of unnamed ESSource or ESProducer 1113 process.prefer("JuicerProducer") 1114 In addition, you can pass as a labelled arguments the name of the Record you wish to 1115 prefer where the type passed is a cms.vstring and that vstring can contain the 1116 name of the C++ types in the Record that are being preferred, e.g., 1117 #prefer all data in record 'OrangeRecord' from 'juicer' 1118 process.prefer("juicer", OrangeRecord=cms.vstring()) 1120 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1121 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1123 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1124 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1127 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1128 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1129 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
1130 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1133 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1138 typ = d[esname].type_()
1147 for name, value
in six.iteritems(d):
1148 if value.type_() == esname:
1150 raise RuntimeError(
"More than one ES module for "+esname)
1158 if isinstance(process, Process):
1160 elif isinstance(process, str):
1163 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1165 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1167 if name ==
'_ProcessFragment__process':
1168 return object.__getattribute__(self,
'_ProcessFragment__process')
1172 if name ==
'_ProcessFragment__process':
1173 object.__setattr__(self, name, value)
1177 if name ==
'_ProcessFragment__process':
1184 """a dictionary with fixed keys""" 1186 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1187 _blocked_attribute = property(_blocked_attribute)
1188 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1189 pop = popitem = setdefault = update = _blocked_attribute
1191 new = dict.__new__(cls)
1192 dict.__init__(new, *args, **kw)
1193 keys = sorted(kw.keys())
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 not isinstance(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 = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4])
2134 self.assertTrue(expectedList == l)
2136 process.myTask6 =
Task()
2137 process.myTask7 =
Task()
2138 process.mproducer8 = edproducer8
2139 process.myTask8 =
Task(process.mproducer8)
2140 process.myTask6.add(process.myTask7)
2141 process.myTask7.add(process.myTask8)
2142 process.myTask1.add(process.myTask6)
2143 process.myTask8.add(process.myTask5)
2145 testDict = process._itemsInDependencyOrder(process.tasks)
2146 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2147 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2149 for testLabel, testTask
in testDict.items():
2150 self.assertTrue(testLabel == expectedLabels[index])
2151 self.assertTrue(testTask == expectedTasks[index])
2157 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2158 self.assertTrue(pythonDump == expectedPythonDump)
2160 process.myTask5 =
Task()
2161 process.myTask100 =
Task()
2162 process.mproducer9 = edproducer9
2163 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2164 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2165 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2167 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2168 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2169 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2170 process.path2 =
Path(process.mproducer)
2171 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2173 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')
2175 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')
2180 process.path1.visit(nameVisitor)
2181 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2182 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2186 process.path21 = process.path11.copy()
2187 process.path21.replace(process.mproducer, process.mproducer10)
2189 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')
2198 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')
2200 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2201 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')
2203 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2204 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')
2213 process.path24 =
Path(process.a+process.b+process.c+process.d)
2214 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2215 self.assertTrue(process.path25.dumpPython(
None) ==
'cms.Path(process.d)\n')
2220 process.path200.replace(process.c,process.b)
2221 process.path200.replace(process.e,process.f)
2222 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2223 process.path200.replace(process.b,process.c)
2224 process.path200.replace(process.f,process.e)
2225 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2226 process.path200.replace(process.c,process.a)
2227 process.path200.replace(process.e,process.g)
2228 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2229 process.path200.replace(process.a,process.c)
2230 process.path200.replace(process.g,process.e)
2231 self.assertEqual(process.path200.dumpPython(
None),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2242 self.assertEqual(
str(path),
'a+b+c')
2243 path =
Path(p.a*p.b+p.c)
2244 self.assertEqual(
str(path),
'a+b+c')
2247 path =
Path(p.a+ p.b*p.c)
2248 self.assertEqual(
str(path),
'a+b+c')
2249 path =
Path(p.a*(p.b+p.c))
2250 self.assertEqual(
str(path),
'a+b+c')
2251 path =
Path(p.a*(p.b+~p.c))
2253 self.assertEqual(
str(path),
'a+b+~c')
2255 self.assertRaises(TypeError,Path,p.es)
2258 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path()\n')
2261 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a)\n')
2264 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(cms.Task())\n')
2267 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task())\n')
2272 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task(), process.t1)\n')
2283 p.path =
Path(p.a*p.b)
2284 lookuptable = {
id(a): p.a,
id(b): p.b}
2288 self.assertEqual(
str(path),
str(p.path))
2309 path =
Path(a * c * seq1, task1)
2311 self.assertTrue(path.contains(a))
2312 self.assertFalse(path.contains(b))
2313 self.assertTrue(path.contains(c))
2314 self.assertFalse(path.contains(d))
2315 self.assertTrue(path.contains(e))
2316 self.assertFalse(path.contains(f))
2317 self.assertTrue(path.contains(g))
2320 self.assertFalse(endpath.contains(b))
2321 self.assertTrue(endpath.contains(i))
2324 self.assertFalse(seq.contains(b))
2325 self.assertTrue(seq.contains(c))
2328 task =
Task(j, k, task2)
2329 self.assertFalse(task.contains(b))
2330 self.assertTrue(task.contains(j))
2331 self.assertTrue(task.contains(k))
2332 self.assertTrue(task.contains(l))
2336 sch =
Schedule(path, path2, tasks=[task,task3])
2337 self.assertFalse(sch.contains(b))
2338 self.assertTrue(sch.contains(a))
2339 self.assertTrue(sch.contains(c))
2340 self.assertTrue(sch.contains(e))
2341 self.assertTrue(sch.contains(g))
2342 self.assertTrue(sch.contains(n))
2343 self.assertTrue(sch.contains(j))
2344 self.assertTrue(sch.contains(k))
2345 self.assertTrue(sch.contains(l))
2346 self.assertTrue(sch.contains(m))
2359 self.assertEqual(s[0],p.path1)
2360 self.assertEqual(s[1],p.path2)
2362 self.assert_(
'b' in p.schedule.moduleNames())
2363 self.assert_(hasattr(p,
'b'))
2364 self.assert_(hasattr(p,
'c'))
2365 self.assert_(hasattr(p,
'd'))
2366 self.assert_(hasattr(p,
'path1'))
2367 self.assert_(hasattr(p,
'path2'))
2368 self.assert_(hasattr(p,
'path3'))
2370 self.assert_(
'b' in p.schedule.moduleNames())
2371 self.assert_(hasattr(p,
'b'))
2372 self.assert_(
not hasattr(p,
'c'))
2373 self.assert_(
not hasattr(p,
'd'))
2374 self.assert_(hasattr(p,
'path1'))
2375 self.assert_(hasattr(p,
'path2'))
2376 self.assert_(
not hasattr(p,
'path3'))
2378 self.assertTrue(len(p.schedule._tasks) == 0)
2392 p.task2 =
Task(p.f, p.Tracer)
2393 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2394 self.assertEqual(s[0],p.path1)
2395 self.assertEqual(s[1],p.path2)
2396 self.assertTrue(len(s._tasks) == 2)
2397 self.assertTrue(p.task1
in s._tasks)
2398 self.assertTrue(p.task2
in s._tasks)
2399 listOfTasks =
list(s._tasks)
2400 self.assertTrue(len(listOfTasks) == 2)
2401 self.assertTrue(p.task1 == listOfTasks[0])
2402 self.assertTrue(p.task2 == listOfTasks[1])
2404 self.assert_(
'b' in p.schedule.moduleNames())
2409 process2.path1 =
Path(process2.a)
2410 process2.task1 =
Task(process2.e)
2411 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2412 listOfTasks =
list(process2.schedule._tasks)
2413 self.assertTrue(listOfTasks[0] == process2.task1)
2417 self.assertEqual(s2[0],p.path1)
2418 self.assertEqual(s2[1],p.path2)
2419 self.assertTrue(len(s2._tasks) == 2)
2420 self.assertTrue(p.task1
in s2._tasks)
2421 self.assertTrue(p.task2
in s2._tasks)
2422 listOfTasks =
list(s2._tasks)
2423 self.assertTrue(len(listOfTasks) == 2)
2424 self.assertTrue(p.task1 == listOfTasks[0])
2425 self.assertTrue(p.task2 == listOfTasks[1])
2427 names = s.moduleNames()
2428 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2434 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2443 self.assert_(
'a' in s.moduleNames())
2444 self.assert_(
'b' in s.moduleNames())
2445 self.assert_(
'c' in s.moduleNames())
2449 self.assert_(
'a' in s.moduleNames())
2450 self.assert_(
'b' in s.moduleNames())
2451 self.assert_(
'c' in s.moduleNames())
2460 self.assert_(p.schedule
is None)
2463 self.assertEqual(pths[keys[0]],p.path1)
2464 self.assertEqual(pths[keys[1]],p.path2)
2466 self.assert_(hasattr(p,
'a'))
2467 self.assert_(hasattr(p,
'b'))
2468 self.assert_(
not hasattr(p,
'c'))
2469 self.assert_(hasattr(p,
'path1'))
2470 self.assert_(hasattr(p,
'path2'))
2479 self.assert_(p.schedule
is None)
2482 self.assertEqual(pths[keys[1]],p.path1)
2483 self.assertEqual(pths[keys[0]],p.path2)
2490 self.assertEqual(p.modu.a.value(),1)
2491 self.assertEqual(p.modu.b.value(),2)
2496 self.assert_(
not a.isModified())
2498 self.assert_(a.isModified())
2500 self.assertEqual(p.a.a1.value(), 1)
2504 self.assertEqual(p.a.a1.value(), 2)
2513 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2514 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2518 p.source =
Source(
"PoolSource",fileNames = untracked(
string(
"file:reco.root")))
2521 p.out =
OutputModule(
"PoolOutputModule",fileName=untracked(
string(
"file:foos.root")))
2522 p.bars.foos =
'Foosball' 2523 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2524 p.p =
Path(p.foos*p.bars)
2526 p.add_(
Service(
"MessageLogger"))
2532 p.prefer(
"ForceSource")
2534 self.assertEqual(p.dumpConfig(),
2536 es_module juicer = JuicerProducer { 2538 es_source = ForceSource { 2540 es_prefer = ForceSource { 2542 es_prefer juicer = JuicerProducer { 2546 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2547 self.assertEqual(p.dumpConfig(),
2549 es_module juicer = JuicerProducer { 2551 es_source = ForceSource { 2553 es_prefer = ForceSource { 2555 es_prefer juicer = JuicerProducer { 2563 self.assertEqual(p.dumpPython(),
2564 """import FWCore.ParameterSet.Config as cms 2566 process = cms.Process("Test") 2568 process.juicer = cms.ESProducer("JuicerProducer") 2571 process.ForceSource = cms.ESSource("ForceSource") 2574 process.prefer("ForceSource") 2576 process.prefer("juicer", 2577 fooRcd = cms.vstring('Foo') 2594 self.assertEqual(process.m.p.i.value(), 4)
2604 subProcess.p =
Path(subProcess.a)
2605 subProcess.add_(
Service(
"Foo"))
2606 process.addSubProcess(
SubProcess(subProcess))
2607 d = process.dumpPython()
2608 equalD =
"""import FWCore.ParameterSet.Config as cms 2610 process = cms.Process("Parent") 2612 parentProcess = process 2613 import FWCore.ParameterSet.Config as cms 2615 process = cms.Process("Child") 2617 process.a = cms.EDProducer("A") 2620 process.Foo = cms.Service("Foo") 2623 process.p = cms.Path(process.a) 2626 childProcess = process 2627 process = parentProcess 2628 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 2630 ), outputCommands = cms.untracked.vstring())) 2633 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2634 self.assertEqual(d,equalD)
2636 process.fillProcessDesc(p)
2637 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2638 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2639 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2649 proc.fillProcessDesc(p)
2650 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2651 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2652 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2653 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2654 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2655 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2665 self.assert_(p.schedule
is None)
2668 self.assertEqual(pths[keys[0]],p.path1)
2669 self.assertEqual(pths[keys[1]],p.path2)
2671 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2673 p.vpset2 = untracked.VPSet()
2675 self.assert_(hasattr(p,
'a'))
2676 self.assert_(hasattr(p,
'b'))
2677 self.assert_(
not hasattr(p,
'c'))
2678 self.assert_(
not hasattr(p,
'd'))
2679 self.assert_(
not hasattr(p,
's'))
2680 self.assert_(hasattr(p,
'path1'))
2681 self.assert_(hasattr(p,
'path2'))
2698 p.path3 =
Path(p.b+p.s2)
2699 p.path4 =
Path(p.b+p.s3)
2700 p.schedule =
Schedule(p.path1,p.path2,p.path3)
2703 self.assertEqual(pths[keys[0]],p.path1)
2704 self.assertEqual(pths[keys[1]],p.path2)
2706 self.assert_(hasattr(p,
'a'))
2707 self.assert_(hasattr(p,
'b'))
2708 self.assert_(
not hasattr(p,
'c'))
2709 self.assert_(
not hasattr(p,
'd'))
2710 self.assert_(
not hasattr(p,
'e'))
2711 self.assert_(
not hasattr(p,
's'))
2712 self.assert_(hasattr(p,
's2'))
2713 self.assert_(
not hasattr(p,
's3'))
2714 self.assert_(hasattr(p,
'path1'))
2715 self.assert_(hasattr(p,
'path2'))
2716 self.assert_(hasattr(p,
'path3'))
2717 self.assert_(
not hasattr(p,
'path4'))
2725 self.assert_(hasattr(p,
'a'))
2726 self.assert_(hasattr(p,
'b'))
2727 self.assert_(hasattr(p,
's'))
2728 self.assert_(hasattr(p,
'pth'))
2734 p.prune(keepUnresolvedSequencePlaceholders=
True)
2735 self.assert_(hasattr(p,
'b'))
2736 self.assert_(hasattr(p,
's'))
2737 self.assert_(hasattr(p,
'pth'))
2738 self.assertEqual(p.s.dumpPython(
''),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
2746 p.path1 =
Path(p.b, p.t2, p.t3)
2749 p.endpath1 =
EndPath(p.b, p.t5)
2753 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
2762 self.assertEqual(p.dumpPython(),
2763 """import FWCore.ParameterSet.Config as cms 2765 process = cms.Process("test") 2767 process.a = cms.EDProducer("ma") 2770 process.c = cms.EDProducer("mc") 2773 process.d = cms.EDProducer("md") 2776 process.e = cms.EDProducer("me") 2779 process.f = cms.EDProducer("mf") 2782 process.g = cms.EDProducer("mg") 2785 process.h = cms.EDProducer("mh") 2788 process.i = cms.EDProducer("mi") 2791 process.j = cms.EDProducer("mj") 2794 process.b = cms.EDAnalyzer("mb") 2797 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 2800 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 2803 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 2806 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 2809 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 2812 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 2815 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 2818 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 2821 process.path1 = cms.Path(process.b, process.t2, process.t3) 2824 process.endpath1 = cms.EndPath(process.b, process.t5) 2827 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2830 self.assertEqual(p.dumpPython(),
2831 """import FWCore.ParameterSet.Config as cms 2833 process = cms.Process("test") 2835 process.a = cms.EDProducer("ma") 2838 process.c = cms.EDProducer("mc") 2841 process.d = cms.EDProducer("md") 2844 process.e = cms.EDProducer("me") 2847 process.f = cms.EDProducer("mf") 2850 process.g = cms.EDProducer("mg") 2853 process.h = cms.EDProducer("mh") 2856 process.i = cms.EDProducer("mi") 2859 process.j = cms.EDProducer("mj") 2862 process.b = cms.EDAnalyzer("mb") 2865 process.t8 = cms.Task(process.j) 2868 process.t6 = cms.Task(process.h) 2871 process.t7 = cms.Task(process.a, process.i, process.t6) 2874 process.t4 = cms.Task(process.f) 2877 process.t5 = cms.Task(process.a, process.g, process.t4) 2880 process.t3 = cms.Task(process.e) 2883 process.t1 = cms.Task(process.c) 2886 process.t2 = cms.Task(process.a, process.d, process.t1) 2889 process.path1 = cms.Path(process.b, process.t2, process.t3) 2892 process.endpath1 = cms.EndPath(process.b, process.t5) 2895 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2908 p.t1 =
Task(p.g, p.h)
2912 p.path1 =
Path(p.a+p.f+p.s,t2)
2915 self.assertTrue(hasattr(p,
'f'))
2916 self.assertTrue(hasattr(p,
'g'))
2920 self.assertFalse(hasattr(p,
'f'))
2921 self.assertFalse(hasattr(p,
'g'))
2922 self.assertTrue(p.t1.dumpPython(
None) ==
'cms.Task(process.h)\n')
2923 self.assertTrue(p.s.dumpPython(
None) ==
'cms.Sequence(process.d)\n')
2924 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
2925 self.assertTrue(p.endpath1.dumpPython(
None) ==
'cms.EndPath(process.b)\n')
2927 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
2928 self.assertTrue(p.schedule_().
dumpPython(
None) ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
2935 m1.toModify(p.a,_mod_fred)
2936 self.assertEqual(p.a.fred.value(),2)
2938 m1.toModify(p.b, wilma = 2)
2939 self.assertEqual(p.b.wilma.value(),2)
2940 self.assert_(p.isUsingModifier(m1))
2945 m1.toModify(p.a,_mod_fred)
2947 m1.toModify(p.b, wilma = 2)
2948 self.assertEqual(p.a.fred.value(),1)
2949 self.assertEqual(p.b.wilma.value(),1)
2950 self.assertEqual(p.isUsingModifier(m1),
False)
2955 m1.toModify(p.a, fred =
int32(2))
2956 p.b = p.a.clone(wilma =
int32(3))
2957 self.assertEqual(p.a.fred.value(),2)
2958 self.assertEqual(p.a.wilma.value(),1)
2959 self.assertEqual(p.b.fred.value(),2)
2960 self.assertEqual(p.b.wilma.value(),3)
2965 m1.toModify(p.a, fred =
None, fintstones =
dict(fred =
None))
2966 self.assertEqual(hasattr(p.a,
"fred"),
False)
2967 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
2968 self.assertEqual(p.a.wilma.value(),1)
2973 m1.toModify(p.a, wilma =
int32(2))
2974 self.assertEqual(p.a.fred.value(), 1)
2975 self.assertEqual(p.a.wilma.value(),2)
2980 m1.toModify(p.a, flintstones =
dict(fred =
int32(2)))
2981 self.assertEqual(p.a.flintstones.fred.value(),2)
2982 self.assertEqual(p.a.flintstones.wilma.value(),1)
2987 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones =
dict(imnothere =
dict(wilma=2))))
2988 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
2993 m1.toModify(p.a, flintstones = {1:
dict(wilma =
int32(2))})
2994 self.assertEqual(p.a.flintstones[0].fred.value(),1)
2995 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3000 m1.toModify(p.a, fred = {1:7})
3001 self.assertEqual(p.a.fred[0],1)
3002 self.assertEqual(p.a.fred[1],7)
3003 self.assertEqual(p.a.fred[2],3)
3009 try: m1.toModify(p.a, fred = {5:7})
3010 except IndexError
as e: raised =
True 3011 self.assertEqual(raised,
True)
3017 try: m1.toModify(p.a, flintstones =
dict(bogus =
int32(37)))
3018 except TypeError
as e: raised =
True 3019 self.assertEqual(raised,
True)
3023 class ProcModifierMod(
object):
3024 def __init__(self,modifier,func):
3029 testMod = DummyMod()
3031 self.assert_(hasattr(p,
"a"))
3034 testProcMod = ProcModifierMod(m1,_rem_a)
3036 p.extend(testProcMod)
3037 self.assert_(
not hasattr(p,
"a"))
3042 self.assert_(p.isUsingModifier(m1))
3043 self.assert_(p.isUsingModifier(mc))
3044 testMod = DummyMod()
3046 m1.toModify(p.b, fred =
int32(3))
3048 testProcMod = ProcModifierMod(m1,_rem_a)
3049 p.extend(testProcMod)
3050 self.assert_(
not hasattr(p,
"a"))
3051 self.assertEqual(p.b.fred.value(),3)
3056 mclone = mc.copyAndExclude([m2])
3057 self.assert_(
not mclone._isOrContains(m2))
3058 self.assert_(mclone._isOrContains(m1))
3061 mclone = mc2.copyAndExclude([m2])
3062 self.assert_(
not mclone._isOrContains(m2))
3063 self.assert_(mclone._isOrContains(m1))
3064 self.assert_(mclone._isOrContains(m3))
3070 (m1 & m2).toModify(p.a, fred =
int32(2))
3071 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3072 self.assertEqual(p.a.fred, 1)
3077 (m1 & m2).toModify(p.a, fred =
int32(2))
3078 self.assertEqual(p.a.fred, 2)
3084 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3085 self.assertEqual(p.a.fred, 2)
3086 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3087 self.assertEqual(p.a.fred, 3)
3088 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3089 self.assertEqual(p.a.fred, 4)
3095 (~m1).toModify(p.a, fred=2)
3096 self.assertEqual(p.a.fred, 1)
3097 (~m2).toModify(p.a, wilma=2)
3098 self.assertEqual(p.a.wilma, 2)
3099 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3100 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3107 (m1 | m2).toModify(p.a, fred=2)
3108 self.assertEqual(p.a.fred, 2)
3109 (m1 | m2 | m3).toModify(p.a, fred=3)
3110 self.assertEqual(p.a.fred, 3)
3111 (m3 | m2 | m1).toModify(p.a, fred=4)
3112 self.assertEqual(p.a.fred, 4)
3113 ((m1 | m2) | m3).toModify(p.a, fred=5)
3114 self.assertEqual(p.a.fred, 5)
3115 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3116 self.assertEqual(p.a.fred, 6)
3117 (m2 | m3).toModify(p.a, fred=7)
3118 self.assertEqual(p.a.fred, 6)
3119 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3120 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3128 (m1 & ~m2).toModify(p.a, fred=2)
3129 self.assertEqual(p.a.fred, 1)
3130 (m1 & ~m3).toModify(p.a, fred=2)
3131 self.assertEqual(p.a.fred, 2)
3132 (m1 | ~m2).toModify(p.a, fred=3)
3133 self.assertEqual(p.a.fred, 3)
3134 (~m1 | ~m2).toModify(p.a, fred=4)
3135 self.assertEqual(p.a.fred, 3)
3136 (~m3 & ~m4).toModify(p.a, fred=4)
3137 self.assertEqual(p.a.fred, 4)
3138 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3139 self.assertEqual(p.a.fred, 5)
3145 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3152 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3153 self.assertEqual(p.a.wilma.value(),3)
3154 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3155 self.assertEqual(hasattr(p,
"fred"),
False)
3156 self.assertTrue(p.s.dumpPython(
"") ==
"cms.Sequence(process.a+process.b, process.td)\n")
3158 m1.toReplaceWith(p.td,
Task(p.e))
3159 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3165 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3173 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3174 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3175 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3176 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3177 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3178 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3179 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3180 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3181 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3182 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3183 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3184 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3185 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3186 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3187 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3188 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3189 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3190 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)