4 from __future__
import print_function
6 from Options
import Options
12 from Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
16 from Modules
import _Module
17 from SequenceTypes
import *
18 from SequenceTypes
import _ModuleSequenceType, _Sequenceable
19 from SequenceVisitors
import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
22 from ExceptionHandling
import *
25 if sys.getrecursionlimit()<5000:
26 sys.setrecursionlimit(5000)
30 Raise an exception if called by special config files. This checks 31 the call or import stack for the importing file. An exception is raised if 32 the importing module is not in allowedPatterns and if it is called too deeply: 33 minLevel = 2: inclusion by top lvel cfg only 34 minLevel = 1: No inclusion allowed 35 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 36 by any module in Module1 or Submodule1 42 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>']
43 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
47 for item
in inspect.stack():
51 for pattern
in CMSSWPath:
52 if item[1].
find(pattern) != -1:
55 if item[1].
find(
'/') == -1:
58 for pattern
in ignorePatterns:
59 if item[1].
find(pattern) != -1:
63 if inPath
and not ignore:
64 trueStack.append(item[1])
66 importedFile = trueStack[0]
68 if len(trueStack) > 1:
69 importedBy = trueStack[1]
71 for pattern
in allowedPatterns:
72 if importedBy.find(pattern) > -1:
75 if len(trueStack) <= minLevel:
78 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 82 """Look inside the module and find the Processes it contains""" 86 if isinstance(module,dict):
87 if 'process' in module:
91 if hasattr(module,
'process'):
92 if isinstance(module.process,Process):
93 process = module.process
95 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
97 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
101 """Root class for a CMS configuration process""" 103 """The argument 'name' will be the name applied to this Process 104 Can optionally pass as additional arguments cms.Modifier instances 105 that will be used to modify the Process as it is built 107 self.__dict__[
'_Process__name'] = name
108 if not name.isalnum():
109 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
110 self.__dict__[
'_Process__filters'] = {}
111 self.__dict__[
'_Process__producers'] = {}
112 self.__dict__[
'_Process__source'] =
None 113 self.__dict__[
'_Process__looper'] =
None 114 self.__dict__[
'_Process__subProcesses'] = []
115 self.__dict__[
'_Process__schedule'] =
None 116 self.__dict__[
'_Process__analyzers'] = {}
117 self.__dict__[
'_Process__outputmodules'] = {}
120 self.__dict__[
'_Process__sequences'] = {}
121 self.__dict__[
'_Process__tasks'] = {}
122 self.__dict__[
'_Process__services'] = {}
123 self.__dict__[
'_Process__essources'] = {}
124 self.__dict__[
'_Process__esproducers'] = {}
125 self.__dict__[
'_Process__esprefers'] = {}
126 self.__dict__[
'_Process__aliases'] = {}
127 self.__dict__[
'_Process__psets']={}
128 self.__dict__[
'_Process__vpsets']={}
129 self.__dict__[
'_cloneToObjectDict'] = {}
131 self.__dict__[
'_Process__InExtendCall'] =
False 132 self.__dict__[
'_Process__partialschedules'] = {}
134 self.__dict__[
'_Process__modifiers'] = Mods
135 for m
in self.__modifiers:
140 _Module.__isStrict__ =
True 144 """Returns a string containing all the EDProducer labels separated by a blank""" 147 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 150 """Returns a string containing all the EDFilter labels separated by a blank""" 153 """Returns a string containing all the Path names separated by a blank""" 160 Since cloneToObjectDict stores a hash of objects by their 161 id() it needs to be updated when unpickling to use the 162 new object id values instantiated during the unpickle. 165 self.__dict__.update(pkldict)
167 for value
in self._cloneToObjectDict.values():
168 tmpDict[
id(value)] = value
169 self.__dict__[
'_cloneToObjectDict'] = tmpDict
174 """returns a dict of the filters that have been added to the Process""" 176 filters = property(filters_, doc=
"dictionary containing the filters for the process")
180 if not name.isalnum():
181 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
182 self.__dict__[
'_Process__name'] = name
183 process = property(name_,setName_, doc=
"name of the process")
185 """returns a dict of the producers that have been added to the Process""" 187 producers = property(producers_,doc=
"dictionary containing the producers for the process")
189 """returns the source that has been added to the Process or None if none have been added""" 193 source = property(source_,setSource_,doc=
'the main source or None if not set')
195 """returns the looper that has been added to the Process or None if none have been added""" 199 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
201 """returns a list of the subProcesses that have been added to the Process""" 202 return self.__subProcesses
203 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
205 """returns a dict of the analyzers that have been added to the Process""" 207 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
209 """returns a dict of the output modules that have been added to the Process""" 211 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
213 """returns a dict of the paths that have been added to the Process""" 215 paths = property(paths_,doc=
"dictionary containing the paths for the process")
217 """returns a dict of the endpaths that have been added to the Process""" 219 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
221 """returns a dict of the sequences that have been added to the Process""" 223 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
225 """returns a dict of the tasks that have been added to the Process""" 227 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
229 """returns the schedule that has been added to the Process or None if none have been added""" 230 return self.__schedule
232 if label ==
"schedule":
235 self.
_place(label, sch, self.__partialschedules)
244 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
245 self.__dict__[
'_Process__schedule'] = sch
246 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
248 """returns a dict of the services that have been added to the Process""" 250 services = property(services_,doc=
"dictionary containing the services for the process")
252 """returns a dict of the esproducers that have been added to the Process""" 254 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
256 """returns a the es_sources that have been added to the Process""" 258 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
260 """returns a dict of the es_prefers that have been added to the Process""" 262 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
264 """returns a dict of the aliases that have been added to the Process""" 266 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
268 """returns a dict of the PSets that have been added to the Process""" 270 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
272 """returns a dict of the VPSets that have been added to the Process""" 274 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
277 """returns True if the Modifier is in used by this Process""" 279 for m
in self.__modifiers:
280 if m._isOrContains(mod):
285 if not object.hasLabel_() :
286 object.setLabel(newLabel)
288 if newLabel == object.label_() :
290 if newLabel
is None :
291 object.setLabel(
None)
293 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
294 msg100 =
"Attempting to change the label of an attribute of the Process\n" 295 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 296 msg102 =
"Type = "+
str(type(object))+
"\n" 297 msg103 =
"Some possible solutions:\n" 298 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 299 msg105 =
" also preferred for other types when possible.\n" 300 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 301 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 302 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 303 msg109 =
" the name.\n" 304 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 305 msg111 =
" name to the same object usually causes confusion and problems.\n" 306 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 307 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
308 object.setLabel(
None)
309 object.setLabel(newLabel)
313 if not name.replace(
'_',
'').isalnum():
314 raise ValueError(
'The label '+name+
' contains forbiden characters')
317 if name.startswith(
'_Process__'):
318 self.__dict__[name]=value
320 if not isinstance(value,_ConfigureComponent):
321 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 322 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
323 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
324 if name == value.type_():
329 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
330 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
333 newValue =value.copy()
335 newValue._filename = value._filename
341 if not self.
_okToPlace(name, value, self.__dict__):
342 newFile=
'top level config' 343 if hasattr(value,
'_filename'):
344 newFile = value._filename
345 oldFile=
'top level config' 346 oldValue = getattr(self,name)
347 if hasattr(oldValue,
'_filename'):
348 oldFile = oldValue._filename
349 msg =
"Trying to override definition of process."+name
350 msg +=
"\n new object defined in: "+newFile
351 msg +=
"\n existing object defined in: "+oldFile
352 raise ValueError(msg)
354 if hasattr(self,name)
and not (getattr(self,name)==newValue):
358 if newValue._isTaskComponent():
359 if not self.__InExtendCall:
363 if not isinstance(newValue, Task):
365 newFile=
'top level config' 366 if hasattr(value,
'_filename'):
367 newFile = value._filename
368 oldFile=
'top level config' 369 oldValue = getattr(self,name)
370 if hasattr(oldValue,
'_filename'):
371 oldFile = oldValue._filename
372 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 373 msg2 =
"\n new object defined in: "+newFile
374 msg2 +=
"\n existing object defined in: "+oldFile
377 raise ValueError(msg1+s.label_()+msg2)
379 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent():
380 if not self.__InExtendCall:
384 newFile=
'top level config' 385 if hasattr(value,
'_filename'):
386 newFile = value._filename
387 oldFile=
'top level config' 388 oldValue = getattr(self,name)
389 if hasattr(oldValue,
'_filename'):
390 oldFile = oldValue._filename
391 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 392 msg2 =
"\n new object defined in: "+newFile
393 msg2 +=
"\n existing object defined in: "+oldFile
396 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
399 raise ValueError(msg1+
"path "+s.label_()+msg2)
402 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
404 self.__dict__[name]=newValue
405 if isinstance(newValue,_Labelable):
407 self._cloneToObjectDict[
id(value)] = newValue
408 self._cloneToObjectDict[
id(newValue)] = newValue
410 newValue._place(name,self)
412 """Given a container of sequences or tasks, find the first sequence or task 413 containing mod and return it. If none is found, return None""" 416 for seqOrTask
in six.itervalues(seqsOrTasks):
425 if not hasattr(self,name):
426 raise KeyError(
'process does not know about '+name)
427 elif name.startswith(
'_Process__'):
428 raise ValueError(
'this attribute cannot be deleted')
431 dicts = [item
for item
in self.__dict__.values()
if (isinstance(item, dict)
or isinstance(item,
DictTypes.SortedKeysDict))]
433 if name
in reg: del reg[name]
435 obj = getattr(self,name)
436 if isinstance(obj,_Labelable):
438 if isinstance(obj,Service):
439 obj._inProcess =
False 443 obj = getattr(self,name)
445 if not isinstance(obj, Sequence)
and not isinstance(obj, Task):
455 if obj._isTaskComponent():
458 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
462 del self.__dict__[name]
467 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 471 del self.__dict__[name]
476 """Allows addition of components that do not have to have a label, e.g. Services""" 477 if not isinstance(value,_ConfigureComponent):
479 if not isinstance(value,_Unlabelable):
484 newValue =value.copy()
488 newValue._place(
'',self)
491 if not self.__InExtendCall:
502 if d[name]._isModified:
513 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
514 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
517 if isinstance(mod,_Labelable):
520 self.
_place(name, mod, self.__outputmodules)
522 self.
_place(name, mod, self.__producers)
524 self.
_place(name, mod, self.__filters)
526 self.
_place(name, mod, self.__analyzers)
530 self.
_place(name, mod, self.__paths)
531 except ModuleCloneError
as msg:
533 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
537 self.
_place(name, mod, self.__endpaths)
538 except ModuleCloneError
as msg:
540 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
543 self.
_place(name, mod, self.__sequences)
545 self.
_place(name, mod, self.__esproducers)
547 self.
_place(name, mod, self.__esprefers)
549 self.
_place(name, mod, self.__essources)
552 self.
_place(name, task, self.__tasks)
554 self.
_place(name, mod, self.__aliases)
556 self.
_place(name, mod, self.__psets)
558 self.
_place(name, mod, self.__vpsets)
560 """Allow the source to be referenced by 'source' or by type name""" 562 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
563 if self.__dict__[
'_Process__source']
is not None :
564 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
565 self.__dict__[
'_Process__source'] = mod
566 self.__dict__[mod.type_()] = mod
569 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
570 self.__dict__[
'_Process__looper'] = mod
571 self.__dict__[mod.type_()] = mod
573 self.__dict__[
'_Process__subProcess'] = mod
574 self.__dict__[mod.type_()] = mod
576 self.__subProcesses.append(mod)
578 self.
_place(typeName, mod, self.__services)
579 if typeName
in self.__dict__:
580 self.__dict__[typeName]._inProcess =
False 581 self.__dict__[typeName]=mod
583 moduleName = moduleName.replace(
"/",
".")
584 module = __import__(moduleName)
585 self.
extend(sys.modules[moduleName])
587 """Look in other and find types that we can use""" 589 self.__dict__[
'_Process__InExtendCall'] =
True 592 tasksToAttach =
dict()
594 for name
in dir(other):
596 if name.startswith(
'_'):
598 item = getattr(other,name)
599 if name ==
"source" or name ==
"looper":
603 elif isinstance(item,_ModuleSequenceType):
605 elif isinstance(item,Task):
606 tasksToAttach[name] = item
607 elif isinstance(item,_Labelable):
609 if not item.hasLabel_() :
611 elif isinstance(item,Schedule):
613 elif isinstance(item,_Unlabelable):
615 elif isinstance(item,ProcessModifier):
617 elif isinstance(item,ProcessFragment):
621 for name
in seqs.iterkeys():
625 if id(seq)
not in self._cloneToObjectDict:
628 newSeq = self._cloneToObjectDict[
id(seq)]
629 self.__dict__[name]=newSeq
632 newSeq._place(name,self)
634 for name
in tasksToAttach.iterkeys():
635 task = tasksToAttach[name]
642 self.__dict__[
'_Process__InExtendCall'] =
False 646 for name,item
in items:
647 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
651 for name,item
in items:
652 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
656 for name,item
in items:
657 if name == item.type_():
659 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
662 """return a string containing the equivalent process defined using the old configuration language""" 663 config =
"process "+self.__name+
" = {\n" 709 for name,item
in six.iteritems(self.
psets):
710 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
711 for name,item
in six.iteritems(self.
vpsets):
712 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
714 pathNames = [p.label_()
for p
in self.
schedule]
715 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 726 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
731 returnValue += item.dumpPython(options)+
'\n\n' 736 for name,item
in d.items():
737 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 739 for name,item
in sorted(d.items()):
740 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 747 sequence.visit(visitor)
749 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
757 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
768 for label,item
in six.iteritems(processDictionaryOfItems):
770 if isinstance(item, Task):
777 if isinstance(item, Task):
778 raise RuntimeError(
"Failed in a Task visitor. Probably " \
779 "a circular dependency discovered in Task with label " + label)
781 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
782 "circular dependency discovered in Sequence with label " + label)
783 for containedItem
in containedItems:
789 if containedItem.hasLabel_():
790 testItem = processDictionaryOfItems.get(containedItem.label_())
791 if testItem
is None or containedItem != testItem:
792 if isinstance(item, Task):
793 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
794 " from the process yields a different object or None\n"+
795 "label = " + containedItem.label_())
797 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
798 " from the process yields a different object or None\n"+
799 "label = " + containedItem.label_())
800 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
804 oldDeps =
dict(dependencies)
805 for label,deps
in six.iteritems(oldDeps):
807 returnValue[label]=processDictionaryOfItems[label]
809 del dependencies[label]
810 for lb2,deps2
in six.iteritems(dependencies):
811 while deps2.count(label):
816 for name, value
in sorted(six.iteritems(d)):
817 result += value.dumpPythonAs(name,options)+
'\n' 820 """return a string containing the equivalent process defined using python""" 821 result =
"import FWCore.ParameterSet.Config as cms\n\n" 822 result +=
"process = cms.Process(\""+self.__name+
"\")\n\n" 844 result +=
'process.schedule = ' + self.schedule.dumpPython(options)
847 old = getattr(self,label)
849 for sequenceable
in six.itervalues(self.
sequences):
850 sequenceable.replace(old,new)
851 for sequenceable
in six.itervalues(self.
paths):
852 sequenceable.replace(old,new)
853 for sequenceable
in six.itervalues(self.
endpaths):
854 sequenceable.replace(old,new)
856 old = getattr(self,label)
857 for task
in six.itervalues(self.
tasks):
858 task.replace(old, new)
862 old = getattr(self,label)
864 task.replace(old, new)
866 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 867 if not hasattr(self,label):
868 raise LookupError(
"process has no item of label "+label)
869 setattr(self,label,new)
871 for name,value
in six.iteritems(itemDict):
872 value.insertInto(parameterSet, name)
876 newlabel = item.nameInProcessDesc_(label)
878 item.insertInto(parameterSet, newlabel)
879 parameterSet.addVString(tracked, label, vitems)
882 for name,value
in six.iteritems(itemDict):
883 newLabel = value.nameInProcessDesc_(name)
885 value.insertInto(parameterSet, name)
888 parameterSet.addVString(tracked, label, l)
892 for value
in itemList:
893 name = value.getProcessName()
894 newLabel = value.nameInProcessDesc_(name)
896 pset = value.getSubProcessPSet(parameterSet)
897 subprocs.append(pset)
900 parameterSet.addVString(tracked, label, l)
901 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
908 for name
in self.
paths_():
909 scheduledPaths.append(name)
910 triggerPaths.append(name)
912 scheduledPaths.append(name)
913 endpaths.append(name)
916 pathname = path.label_()
917 scheduledPaths.append(pathname)
919 endpaths.append(pathname)
921 triggerPaths.append(pathname)
923 task.resolve(self.__dict__)
925 task.visit(scheduleTaskValidator)
926 task.visit(nodeVisitor)
927 processPSet.addVString(
True,
"@end_paths", endpaths)
928 processPSet.addVString(
True,
"@paths", scheduledPaths)
930 p = processPSet.newPSet()
931 p.addVString(
True,
"@trigger_paths", triggerPaths)
932 processPSet.addPSet(
True,
"@trigger_paths", p)
939 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
940 for triggername
in triggerPaths:
941 iPath = self.
paths_()[triggername]
942 iPath.resolve(self.__dict__)
943 pathValidator.setLabel(triggername)
945 iPath.visit(pathCompositeVisitor)
946 iPath.insertInto(processPSet, triggername, decoratedList)
947 for endpathname
in endpaths:
949 iEndPath.resolve(self.__dict__)
950 endpathValidator.setLabel(endpathname)
952 iEndPath.visit(endpathCompositeVisitor)
953 iEndPath.insertInto(processPSet, endpathname, decoratedList)
954 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
956 def resolve(self,keepUnresolvedSequencePlaceholders=False):
957 for x
in six.itervalues(self.
paths):
958 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
959 for x
in six.itervalues(self.
endpaths):
960 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
963 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
965 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
966 """ Remove clutter from the process that we think is unnecessary: 967 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 968 not in the schedule will also be removed, along with an modules and sequences used only by 969 those removed Paths and EndPaths.""" 978 self.
resolve(keepUnresolvedSequencePlaceholders)
980 unneededPaths = set()
982 usedModules=set(self.
schedule_().moduleNames())
984 schedNames = set(( x.label_()
for x
in self.
schedule_()))
985 names = set(self.
paths)
987 unneededPaths = names - schedNames
988 for n
in unneededPaths:
992 pths.extend(six.itervalues(self.
endpaths))
994 usedModules=set(temp.moduleNames())
1001 for p
in six.itervalues(self.
paths):
1003 for p
in six.itervalues(self.
endpaths):
1005 keepSeqSet = set(( s
for s
in seqs
if s.hasLabel_()))
1006 availableSeqs = set(six.itervalues(self.
sequences))
1007 unneededSeqs = availableSeqs-keepSeqSet
1008 unneededSeqLabels = []
1009 for s
in unneededSeqs:
1010 unneededSeqLabels.append(s.label_())
1011 delattr(self,s.label_())
1013 print(
"prune removed the following:")
1014 print(
" modules:"+
",".
join(unneededModules))
1015 print(
" sequences:"+
",".
join(unneededSeqLabels))
1016 print(
" paths/endpaths:"+
",".
join(unneededPaths))
1018 moduleNames = set(d.keys())
1019 junk = moduleNames - scheduledNames
1025 """Used by the framework to convert python to C++ objects""" 1026 class ServiceInjectorAdaptor(
object):
1030 def addService(self,pset):
1031 self.__thelist.append(pset)
1033 return self.__processPSet.newPSet()
1037 class TopLevelPSetAcessorAdaptor(
object):
1041 def __getattr__(self,attr):
1042 return getattr(self.
__ppset,attr)
1043 def getTopPSet_(self,label):
1046 return TopLevelPSetAcessorAdaptor(self.__ppset.newPSet(),self.
__process)
1047 def addPSet(self,tracked,name,ppset):
1048 return self.__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1049 def addVPSet(self,tracked,name,vpset):
1050 return self.__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1051 def __extractPSet(self,pset):
1052 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1057 processPSet.addString(
True,
"@process_name", self.
name_())
1059 all_modules.update(self.
filters_())
1062 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1075 all_modules_onTasksOrScheduled = { key:value
for key, value
in six.iteritems(all_modules)
if value
in nodeVisitor.modules }
1076 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1080 for pTask
in six.itervalues(self.
tasks):
1081 pTask.visit(processNodeVisitor)
1082 esProducersToEnable = {}
1083 for esProducerName, esProducer
in six.iteritems(self.
es_producers_()):
1084 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1085 esProducersToEnable[esProducerName] = esProducer
1086 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1087 esSourcesToEnable = {}
1088 for esSourceName, esSource
in six.iteritems(self.
es_sources_()):
1089 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1090 esSourcesToEnable[esSourceName] = esSource
1091 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1094 for serviceName, serviceObject
in six.iteritems(self.
services_()):
1095 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1096 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1097 adaptor.addVPSet(
False,
"services",services)
1108 """Prefer this ES source or producer. The argument can 1109 either be an object label, e.g., 1110 process.prefer(process.juicerProducer) (not supported yet) 1111 or a name of an ESSource or ESProducer 1112 process.prefer("juicer") 1113 or a type of unnamed ESSource or ESProducer 1114 process.prefer("JuicerProducer") 1115 In addition, you can pass as a labelled arguments the name of the Record you wish to 1116 prefer where the type passed is a cms.vstring and that vstring can contain the 1117 name of the C++ types in the Record that are being preferred, e.g., 1118 #prefer all data in record 'OrangeRecord' from 'juicer' 1119 process.prefer("juicer", OrangeRecord=cms.vstring()) 1121 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1122 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1124 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1125 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1128 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1129 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1130 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
1131 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1134 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1139 typ = d[esname].type_()
1148 for name, value
in six.iteritems(d):
1149 if value.type_() == esname:
1151 raise RuntimeError(
"More than one ES module for "+esname)
1159 if isinstance(process, Process):
1161 elif isinstance(process, str):
1164 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1166 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1168 if name ==
'_ProcessFragment__process':
1169 return object.__getattribute__(self,
'_ProcessFragment__process')
1173 if name ==
'_ProcessFragment__process':
1174 object.__setattr__(self, name, value)
1178 if name ==
'_ProcessFragment__process':
1185 """a dictionary with fixed keys""" 1187 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1188 _blocked_attribute = property(_blocked_attribute)
1189 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1190 pop = popitem = setdefault = update = _blocked_attribute
1192 new = dict.__new__(cls)
1193 dict.__init__(new, *args, **kw)
1194 keys = sorted(kw.keys())
1195 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1196 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1197 if not isinstance(kw[
'name'],str):
1198 raise ValueError(
"name must be of type string")
1199 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1200 raise ValueError(
"content must be of type vstring or string")
1201 if not isinstance(kw[
'dataTier'], string):
1202 raise ValueError(
"dataTier must be of type string")
1203 if not isinstance(kw[
'selectEvents'], PSet):
1204 raise ValueError(
"selectEvents must be of type PSet")
1205 if not isinstance(kw[
'paths'],(tuple, Path)):
1206 raise ValueError(
"'paths' must be a tuple of paths")
1211 return "FilteredStream object: %s" %self[
"name"]
1216 """Allows embedding another process within a parent process. This allows one to 1217 chain processes together directly in one cmsRun job rather than having to run 1218 separate jobs that are connected via a temporary file. 1220 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1223 if not isinstance(process, Process):
1224 raise ValueError(
"the 'process' argument must be of type cms.Process")
1225 if not isinstance(SelectEvents,PSet):
1226 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1227 if not isinstance(outputCommands,vstring):
1228 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1233 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1234 out += self.__process.dumpPython()
1235 out +=
"childProcess = process\n" 1236 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1237 out +=
"process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = "+self.__SelectEvents.dumpPython(options) +
", outputCommands = "+self.__outputCommands.dumpPython(options) +
"))" 1240 return self.__process.name_()
1252 process._placeSubProcess(
'subProcess',self)
1254 topPSet = parameterSet.newPSet()
1255 self.__process.fillProcessDesc(topPSet)
1256 subProcessPSet = parameterSet.newPSet()
1257 self.__SelectEvents.insertInto(subProcessPSet,
"SelectEvents")
1258 self.__outputCommands.insertInto(subProcessPSet,
"outputCommands")
1259 subProcessPSet.addPSet(
False,
"process",topPSet)
1260 return subProcessPSet
1263 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1268 for k
in self.__args.iterkeys():
1270 params[k] = getattr(obj,k)
1272 for k
in self.__args.iterkeys():
1274 setattr(obj,k,params[k])
1280 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1283 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1289 Modifier._toModifyCheck(obj,func,**kw)
1290 if not self.isChosen():
1292 Modifier._toModify(obj,func,**kw)
1294 Modifier._toReplaceWithCheck(toObj,fromObj)
1295 if not self.isChosen():
1297 Modifier._toReplaceWith(toObj,fromObj)
1299 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1300 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1301 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1311 """A modifier which only applies if multiple Modifiers are chosen""" 1313 super(_AndModifier,self).
__init__(lhs, rhs)
1315 return self._lhs.isChosen()
and self._rhs.isChosen()
1318 """A modifier which only applies if a Modifier is not chosen""" 1320 super(_InvertModifier,self).
__init__(lhs)
1322 return not self._lhs.isChosen()
1325 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1327 super(_OrModifier,self).
__init__(lhs, rhs)
1329 return self._lhs.isChosen()
or self._rhs.isChosen()
1333 """This class is used to define standard modifications to a Process. 1334 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1335 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1336 these Modifier instances are imported into a configuration and items that need to be modified 1337 are then associated with the Modifier and with the action to do the modification. 1338 The registered modifications will only occur if the Modifier was passed to 1339 the cms.Process' constructor. 1345 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1346 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1347 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1352 if func
is not None and len(kw) != 0:
1353 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1355 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1356 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1357 that will be the object passed in as the first argument. 1358 Form 2: A list of parameter name, value pairs can be passed 1359 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1360 This form can also be used to remove a parameter by passing the value of None 1361 #remove the parameter foo.fred 1362 mod.toModify(foo, fred = None) 1363 Additionally, parameters embedded within PSets can also be modified using a dictionary 1364 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1365 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1367 Modifier._toModifyCheck(obj,func,**kw)
1370 Modifier._toModify(obj,func,**kw)
1373 if func
is not None:
1380 if not isinstance(fromObj, type(toObj)):
1381 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1383 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1385 Modifier._toReplaceWithCheck(toObj,fromObj)
1388 Modifier._toReplaceWith(toObj,fromObj)
1391 if isinstance(fromObj,_ModuleSequenceType):
1392 toObj._seq = fromObj._seq
1393 toObj._tasks = fromObj._tasks
1394 elif isinstance(fromObj,Task):
1395 toObj._collection = fromObj._collection
1396 elif isinstance(fromObj,_Parameterizable):
1398 for p
in toObj.parameterNames_():
1400 for p
in fromObj.parameterNames_():
1401 setattr(toObj,p,getattr(fromObj,p))
1402 if isinstance(fromObj,_TypedParameterizable):
1403 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1406 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1409 """Should only be called by cms.Process instances""" 1420 return self == other
1424 """A Modifier made up of a list of Modifiers 1430 """Should only be called by cms.Process instances 1431 applies list of accumulated changes to the process""" 1433 m._applyNewProcessModifiers(process)
1435 """Should only be called by cms.Process instances""" 1442 """Creates a new ModifierChain which is a copy of 1443 this ModifierChain but excludes any Modifier or 1444 ModifierChain in the list toExclude. 1445 The exclusion is done recursively down the chain. 1449 if m
not in toExclude:
1451 if isinstance(m,ModifierChain):
1452 s = m.__copyIfExclude(toExclude)
1468 if m._isOrContains(other):
1473 """A class used by a Modifier to affect an entire Process instance. 1474 When a Process 'loads' a module containing a ProcessModifier, that 1475 ProcessModifier will be applied to the Process if and only if the 1476 Modifier passed to the constructor has been chosen. 1483 if self.__modifier.isChosen():
1486 self.__seenProcesses.add(process)
1488 if __name__==
"__main__":
1493 """Has same interface as the C++ object that creates PSets 1498 self.
values[label]=(tracked,value)
1556 """Nothing to do """ 1560 self.assertEqual(len(p.parameterNames_()),0)
1562 self.assert_(
'a' in p.parameterNames_())
1563 self.assertEqual(p.a.value(), 1)
1565 self.assertEqual(p.a.value(), 10)
1566 p.a = untracked(
int32(1))
1567 self.assertEqual(p.a.value(), 1)
1568 self.failIf(p.a.isTracked())
1569 p.a = untracked.int32(1)
1570 self.assertEqual(p.a.value(), 1)
1571 self.failIf(p.a.isTracked())
1573 self.assertEqual(p.foo.value(), 10)
1574 self.assertEqual(p.bar.value(),1.0)
1575 self.failIf(p.bar.isTracked())
1576 self.assertRaises(TypeError,setattr,(p,
'c',1))
1578 self.assertEqual(p.a.foo.value(),10)
1579 self.assertEqual(p.a.bar.value(),1.0)
1581 self.assertEqual(p.b.fii.value(),1)
1582 self.failIf(p.b.isTracked())
1587 self.assertEqual(p.a.value(),11)
1589 self.assertEqual(p.a.value(),12)
1590 self.assertEqual(v.value(),12)
1596 self.assertNotEqual(p.b,other.b)
1601 self.assert_(
'a' in p.analyzers_() )
1602 self.assert_(
'a' in p.analyzers)
1603 p.add_(
Service(
"MessageLogger"))
1604 self.assert_(
'MessageLogger' in p.services_())
1605 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1607 self.assert_(
'Tracer' in p.services_())
1608 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1609 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1610 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1612 self.assertEqual(p.out.type_(),
'Outer')
1613 self.assert_(
'out' in p.outputModules_() )
1616 self.assert_(
'geom' in p.es_sources_())
1618 self.assert_(
'ConfigDB' in p.es_sources_())
1621 self.assert_(
'aliasfoo1' in p.aliases_())
1625 def __init__(self,*arg,**args):
1626 for name
in args.iterkeys():
1627 self.__dict__[name]=args[name]
1646 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1647 self.assertEqual(p.a.label_(),
"a")
1648 self.assertRaises(AttributeError,getattr,p,
'b')
1649 self.assertEqual(p.Full.type_(),
"Full")
1650 self.assertEqual(
str(p.c),
'a')
1651 self.assertEqual(
str(p.d),
'a')
1666 self.assertRaises(ValueError, p1.extend, z1)
1675 aaa=copy.deepcopy(a),
1676 s4=copy.deepcopy(s3),
1683 self.assertEqual(p2.s4.label_(),
"s4")
1685 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
1686 p2.s4.setLabel(
"s4")
1687 p2.s4.setLabel(
None)
1688 p2.s4.setLabel(
"foo")
1689 p2._Process__setObjectLabel(p2.s4,
"foo")
1690 p2._Process__setObjectLabel(p2.s4,
None)
1691 p2._Process__setObjectLabel(p2.s4,
"bar")
1703 """import FWCore.ParameterSet.Config as cms 1705 process = cms.Process("test") 1707 process.a = cms.EDAnalyzer("MyAnalyzer") 1710 process.s = cms.Sequence(process.a) 1713 process.r = cms.Sequence(process.s) 1716 process.p = cms.Path(process.a) 1719 process.p2 = cms.Path(process.s) 1722 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1735 """import FWCore.ParameterSet.Config as cms 1737 process = cms.Process("test") 1739 process.a = cms.EDAnalyzer("MyAnalyzer") 1742 process.b = cms.EDAnalyzer("YourAnalyzer") 1745 process.r = cms.Sequence(process.a) 1748 process.s = cms.Sequence(process.r) 1751 process.p = cms.Path(process.a) 1754 process.p2 = cms.Path(process.r) 1757 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1769 """import FWCore.ParameterSet.Config as cms 1771 process = cms.Process("test") 1773 process.a = cms.EDAnalyzer("MyAnalyzer") 1776 process.r = cms.Sequence((process.a)) 1779 process.p = cms.Path(process.a) 1782 process.p2 = cms.Path(process.r) 1785 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 1799 p.task2 =
Task(p.c, p.task3)
1800 p.task4 =
Task(p.f, p.task2)
1801 p.task1 =
Task(p.task5)
1802 p.task3.add(p.task1)
1806 p.p2 =
Path(p.r, p.task1, p.task2)
1807 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
1810 """import FWCore.ParameterSet.Config as cms 1812 process = cms.Process("test") 1814 process.b = cms.EDProducer("bProducer") 1817 process.c = cms.EDProducer("cProducer") 1820 process.d = cms.EDProducer("dProducer") 1823 process.e = cms.EDProducer("eProducer") 1826 process.f = cms.EDProducer("fProducer") 1829 process.g = cms.EDProducer("gProducer") 1832 process.a = cms.EDAnalyzer("MyAnalyzer") 1835 process.task5 = cms.Task() 1838 process.task1 = cms.Task(process.task5) 1841 process.task3 = cms.Task(process.task1) 1844 process.task2 = cms.Task(process.c, process.task3) 1847 process.task4 = cms.Task(process.f, process.task2) 1850 process.r = cms.Sequence((process.a)) 1853 process.p = cms.Path(process.a) 1856 process.p2 = cms.Path(process.r, process.task1, process.task2) 1859 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5]) 1867 p.task1 =
Task(p.d, p.e)
1868 task2 =
Task(p.f, p.g)
1869 p.schedule =
Schedule(tasks=[p.task1,task2])
1872 """import FWCore.ParameterSet.Config as cms 1874 process = cms.Process("test") 1876 process.d = cms.EDProducer("dProducer") 1879 process.e = cms.EDProducer("eProducer") 1882 process.f = cms.EDProducer("fProducer") 1885 process.g = cms.EDProducer("gProducer") 1888 process.task1 = cms.Task(process.d, process.e) 1891 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1]) 1898 """import FWCore.ParameterSet.Config as cms 1900 process = cms.Process("test") 1902 process.schedule = cms.Schedule() 1912 d=process.dumpPython()
1914 """import FWCore.ParameterSet.Config as cms 1916 process = cms.Process("DUMP") 1918 process.a = cms.EDProducer("A") 1921 process.s2 = cms.Sequence(process.a) 1934 d=process.dumpPython()
1936 """import FWCore.ParameterSet.Config as cms 1938 process = cms.Process("DUMP") 1940 process.a = cms.EDProducer("A") 1943 process.s2 = cms.Sequence(process.a+(process.a+process.a)) 1951 self.assertEqual(p.dumpPython().
replace(
'\n',
''),
'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
1971 p.p =
Path(p.c+s+p.a)
1977 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
1979 p.globalReplace(
"a",new)
1980 p.globalReplace(
"d",new2)
1983 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
1985 p.e3.visit(visitor3)
1986 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
1988 p.s4.visit(visitor4)
1989 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
1991 p.t1.visit(visitor5)
1992 self.assertTrue(visitor5.modules == set([new2]))
1994 listOfTasks =
list(p.schedule._tasks)
1995 listOfTasks[0].
visit(visitor6)
1996 self.assertTrue(visitor6.modules == set([new2]))
2004 self.assertEqual(
str(p.s),
'a+b')
2005 self.assertEqual(p.s.label_(),
's')
2006 path =
Path(p.c+p.s)
2007 self.assertEqual(
str(path),
'c+a+b')
2008 p._validateSequence(path,
'p1')
2010 p2 =
Path(p.c+p.s*notInProcess)
2011 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2021 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2025 self.assertFalse(service._inProcess)
2028 self.assertTrue(service._inProcess)
2030 process.d = service2
2031 self.assertFalse(service._inProcess)
2032 self.assertTrue(service2._inProcess)
2034 self.assertFalse(service2._inProcess)
2054 testTask1 =
Task(edproducer, edfilter)
2055 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2056 testTask1.add(essource, service)
2057 testTask1.add(essource, esproducer)
2058 testTask1.add(testTask2)
2059 coll = testTask1._collection
2060 self.assertTrue(edproducer
in coll)
2061 self.assertTrue(edfilter
in coll)
2062 self.assertTrue(service
in coll)
2063 self.assertTrue(essource
in coll)
2064 self.assertTrue(esproducer
in coll)
2065 self.assertTrue(testTask2
in coll)
2066 self.assertTrue(len(coll) == 6)
2067 self.assertTrue(len(testTask2._collection) == 0)
2071 taskContents.append(i)
2072 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2077 process.mproducer = edproducer
2078 process.mproducer2 = edproducer2
2079 process.mfilter = edfilter
2080 process.messource = essource
2081 process.mesproducer = esproducer
2084 testTask3 =
Task(edproducer, edproducer2)
2085 testTask1.add(testTask3)
2086 process.myTask1 = testTask1
2093 testTask1.visit(visitor)
2094 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2095 l2 = testTask1.moduleNames
2096 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2098 testTask4 =
Task(edproducer3)
2100 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2102 process.myTask4 = testTask4
2103 self.assertTrue(
False)
2104 except RuntimeError:
2107 testTask5 =
Task(service3)
2109 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2111 process.myTask5 = testTask5
2112 self.assertTrue(
False)
2113 except RuntimeError:
2116 process.d = service3
2117 process.myTask5 = testTask5
2120 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2122 self.assertTrue(process.tasks == expectedFixedDict)
2123 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2124 self.assertTrue(process.myTask1 == testTask1)
2128 process.mproducer2 = edproducer4
2132 testTask1.visit(visitor1)
2134 expectedList = sorted([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))
2310 path =
Path(a * c * seq1, task1)
2312 self.assertTrue(path.contains(a))
2313 self.assertFalse(path.contains(b))
2314 self.assertTrue(path.contains(c))
2315 self.assertFalse(path.contains(d))
2316 self.assertTrue(path.contains(e))
2317 self.assertFalse(path.contains(f))
2318 self.assertTrue(path.contains(g))
2321 self.assertFalse(endpath.contains(b))
2322 self.assertTrue(endpath.contains(i))
2325 self.assertFalse(seq.contains(b))
2326 self.assertTrue(seq.contains(c))
2329 task =
Task(j, k, task2)
2330 self.assertFalse(task.contains(b))
2331 self.assertTrue(task.contains(j))
2332 self.assertTrue(task.contains(k))
2333 self.assertTrue(task.contains(l))
2337 sch =
Schedule(path, path2, tasks=[task,task3])
2338 self.assertFalse(sch.contains(b))
2339 self.assertTrue(sch.contains(a))
2340 self.assertTrue(sch.contains(c))
2341 self.assertTrue(sch.contains(e))
2342 self.assertTrue(sch.contains(g))
2343 self.assertTrue(sch.contains(n))
2344 self.assertTrue(sch.contains(j))
2345 self.assertTrue(sch.contains(k))
2346 self.assertTrue(sch.contains(l))
2347 self.assertTrue(sch.contains(m))
2360 self.assertEqual(s[0],p.path1)
2361 self.assertEqual(s[1],p.path2)
2363 self.assert_(
'b' in p.schedule.moduleNames())
2364 self.assert_(hasattr(p,
'b'))
2365 self.assert_(hasattr(p,
'c'))
2366 self.assert_(hasattr(p,
'd'))
2367 self.assert_(hasattr(p,
'path1'))
2368 self.assert_(hasattr(p,
'path2'))
2369 self.assert_(hasattr(p,
'path3'))
2371 self.assert_(
'b' in p.schedule.moduleNames())
2372 self.assert_(hasattr(p,
'b'))
2373 self.assert_(
not hasattr(p,
'c'))
2374 self.assert_(
not hasattr(p,
'd'))
2375 self.assert_(hasattr(p,
'path1'))
2376 self.assert_(hasattr(p,
'path2'))
2377 self.assert_(
not hasattr(p,
'path3'))
2379 self.assertTrue(len(p.schedule._tasks) == 0)
2393 p.task2 =
Task(p.f, p.Tracer)
2394 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2395 self.assertEqual(s[0],p.path1)
2396 self.assertEqual(s[1],p.path2)
2397 self.assertTrue(len(s._tasks) == 2)
2398 self.assertTrue(p.task1
in s._tasks)
2399 self.assertTrue(p.task2
in s._tasks)
2400 listOfTasks =
list(s._tasks)
2401 self.assertTrue(len(listOfTasks) == 2)
2402 self.assertTrue(p.task1 == listOfTasks[0])
2403 self.assertTrue(p.task2 == listOfTasks[1])
2405 self.assert_(
'b' in p.schedule.moduleNames())
2410 process2.path1 =
Path(process2.a)
2411 process2.task1 =
Task(process2.e)
2412 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2413 listOfTasks =
list(process2.schedule._tasks)
2414 self.assertTrue(listOfTasks[0] == process2.task1)
2418 self.assertEqual(s2[0],p.path1)
2419 self.assertEqual(s2[1],p.path2)
2420 self.assertTrue(len(s2._tasks) == 2)
2421 self.assertTrue(p.task1
in s2._tasks)
2422 self.assertTrue(p.task2
in s2._tasks)
2423 listOfTasks =
list(s2._tasks)
2424 self.assertTrue(len(listOfTasks) == 2)
2425 self.assertTrue(p.task1 == listOfTasks[0])
2426 self.assertTrue(p.task2 == listOfTasks[1])
2428 names = s.moduleNames()
2429 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2435 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2444 self.assert_(
'a' in s.moduleNames())
2445 self.assert_(
'b' in s.moduleNames())
2446 self.assert_(
'c' in s.moduleNames())
2450 self.assert_(
'a' in s.moduleNames())
2451 self.assert_(
'b' in s.moduleNames())
2452 self.assert_(
'c' in s.moduleNames())
2461 self.assert_(p.schedule
is None)
2464 self.assertEqual(pths[keys[0]],p.path1)
2465 self.assertEqual(pths[keys[1]],p.path2)
2467 self.assert_(hasattr(p,
'a'))
2468 self.assert_(hasattr(p,
'b'))
2469 self.assert_(
not hasattr(p,
'c'))
2470 self.assert_(hasattr(p,
'path1'))
2471 self.assert_(hasattr(p,
'path2'))
2480 self.assert_(p.schedule
is None)
2483 self.assertEqual(pths[keys[1]],p.path1)
2484 self.assertEqual(pths[keys[0]],p.path2)
2491 self.assertEqual(p.modu.a.value(),1)
2492 self.assertEqual(p.modu.b.value(),2)
2497 self.assert_(
not a.isModified())
2499 self.assert_(a.isModified())
2501 self.assertEqual(p.a.a1.value(), 1)
2505 self.assertEqual(p.a.a1.value(), 2)
2514 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2515 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2519 p.source =
Source(
"PoolSource",fileNames = untracked(
string(
"file:reco.root")))
2522 p.out =
OutputModule(
"PoolOutputModule",fileName=untracked(
string(
"file:foos.root")))
2523 p.bars.foos =
'Foosball' 2524 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2525 p.p =
Path(p.foos*p.bars)
2527 p.add_(
Service(
"MessageLogger"))
2533 p.prefer(
"ForceSource")
2535 self.assertEqual(p.dumpConfig(),
2537 es_module juicer = JuicerProducer { 2539 es_source = ForceSource { 2541 es_prefer = ForceSource { 2543 es_prefer juicer = JuicerProducer { 2547 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2548 self.assertEqual(p.dumpConfig(),
2550 es_module juicer = JuicerProducer { 2552 es_source = ForceSource { 2554 es_prefer = ForceSource { 2556 es_prefer juicer = JuicerProducer { 2564 self.assertEqual(p.dumpPython(),
2565 """import FWCore.ParameterSet.Config as cms 2567 process = cms.Process("Test") 2569 process.juicer = cms.ESProducer("JuicerProducer") 2572 process.ForceSource = cms.ESSource("ForceSource") 2575 process.prefer("ForceSource") 2577 process.prefer("juicer", 2578 fooRcd = cms.vstring('Foo') 2595 self.assertEqual(process.m.p.i.value(), 4)
2605 subProcess.p =
Path(subProcess.a)
2606 subProcess.add_(
Service(
"Foo"))
2607 process.addSubProcess(
SubProcess(subProcess))
2608 d = process.dumpPython()
2609 equalD =
"""import FWCore.ParameterSet.Config as cms 2611 process = cms.Process("Parent") 2613 parentProcess = process 2614 import FWCore.ParameterSet.Config as cms 2616 process = cms.Process("Child") 2618 process.a = cms.EDProducer("A") 2621 process.Foo = cms.Service("Foo") 2624 process.p = cms.Path(process.a) 2627 childProcess = process 2628 process = parentProcess 2629 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 2631 ), outputCommands = cms.untracked.vstring())) 2634 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2635 self.assertEqual(d,equalD)
2637 process.fillProcessDesc(p)
2638 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2639 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2640 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2650 proc.fillProcessDesc(p)
2651 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2652 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2653 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2654 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2655 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2656 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2666 self.assert_(p.schedule
is None)
2669 self.assertEqual(pths[keys[0]],p.path1)
2670 self.assertEqual(pths[keys[1]],p.path2)
2672 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2674 p.vpset2 = untracked.VPSet()
2676 self.assert_(hasattr(p,
'a'))
2677 self.assert_(hasattr(p,
'b'))
2678 self.assert_(
not hasattr(p,
'c'))
2679 self.assert_(
not hasattr(p,
'd'))
2680 self.assert_(
not hasattr(p,
's'))
2681 self.assert_(hasattr(p,
'path1'))
2682 self.assert_(hasattr(p,
'path2'))
2699 p.path3 =
Path(p.b+p.s2)
2700 p.path4 =
Path(p.b+p.s3)
2701 p.schedule =
Schedule(p.path1,p.path2,p.path3)
2704 self.assertEqual(pths[keys[0]],p.path1)
2705 self.assertEqual(pths[keys[1]],p.path2)
2707 self.assert_(hasattr(p,
'a'))
2708 self.assert_(hasattr(p,
'b'))
2709 self.assert_(
not hasattr(p,
'c'))
2710 self.assert_(
not hasattr(p,
'd'))
2711 self.assert_(
not hasattr(p,
'e'))
2712 self.assert_(
not hasattr(p,
's'))
2713 self.assert_(hasattr(p,
's2'))
2714 self.assert_(
not hasattr(p,
's3'))
2715 self.assert_(hasattr(p,
'path1'))
2716 self.assert_(hasattr(p,
'path2'))
2717 self.assert_(hasattr(p,
'path3'))
2718 self.assert_(
not hasattr(p,
'path4'))
2726 self.assert_(hasattr(p,
'a'))
2727 self.assert_(hasattr(p,
'b'))
2728 self.assert_(hasattr(p,
's'))
2729 self.assert_(hasattr(p,
'pth'))
2735 p.prune(keepUnresolvedSequencePlaceholders=
True)
2736 self.assert_(hasattr(p,
'b'))
2737 self.assert_(hasattr(p,
's'))
2738 self.assert_(hasattr(p,
'pth'))
2739 self.assertEqual(p.s.dumpPython(
''),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
2747 p.path1 =
Path(p.b, p.t2, p.t3)
2750 p.endpath1 =
EndPath(p.b, p.t5)
2754 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
2763 self.assertEqual(p.dumpPython(),
2764 """import FWCore.ParameterSet.Config as cms 2766 process = cms.Process("test") 2768 process.a = cms.EDProducer("ma") 2771 process.c = cms.EDProducer("mc") 2774 process.d = cms.EDProducer("md") 2777 process.e = cms.EDProducer("me") 2780 process.f = cms.EDProducer("mf") 2783 process.g = cms.EDProducer("mg") 2786 process.h = cms.EDProducer("mh") 2789 process.i = cms.EDProducer("mi") 2792 process.j = cms.EDProducer("mj") 2795 process.b = cms.EDAnalyzer("mb") 2798 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 2801 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 2804 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 2807 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 2810 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 2813 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 2816 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 2819 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 2822 process.path1 = cms.Path(process.b, process.t2, process.t3) 2825 process.endpath1 = cms.EndPath(process.b, process.t5) 2828 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2831 self.assertEqual(p.dumpPython(),
2832 """import FWCore.ParameterSet.Config as cms 2834 process = cms.Process("test") 2836 process.a = cms.EDProducer("ma") 2839 process.c = cms.EDProducer("mc") 2842 process.d = cms.EDProducer("md") 2845 process.e = cms.EDProducer("me") 2848 process.f = cms.EDProducer("mf") 2851 process.g = cms.EDProducer("mg") 2854 process.h = cms.EDProducer("mh") 2857 process.i = cms.EDProducer("mi") 2860 process.j = cms.EDProducer("mj") 2863 process.b = cms.EDAnalyzer("mb") 2866 process.t8 = cms.Task(process.j) 2869 process.t6 = cms.Task(process.h) 2872 process.t7 = cms.Task(process.a, process.i, process.t6) 2875 process.t4 = cms.Task(process.f) 2878 process.t5 = cms.Task(process.a, process.g, process.t4) 2881 process.t3 = cms.Task(process.e) 2884 process.t1 = cms.Task(process.c) 2887 process.t2 = cms.Task(process.a, process.d, process.t1) 2890 process.path1 = cms.Path(process.b, process.t2, process.t3) 2893 process.endpath1 = cms.EndPath(process.b, process.t5) 2896 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8]) 2909 p.t1 =
Task(p.g, p.h)
2913 p.path1 =
Path(p.a+p.f+p.s,t2)
2916 self.assertTrue(hasattr(p,
'f'))
2917 self.assertTrue(hasattr(p,
'g'))
2921 self.assertFalse(hasattr(p,
'f'))
2922 self.assertFalse(hasattr(p,
'g'))
2923 self.assertTrue(p.t1.dumpPython(
None) ==
'cms.Task(process.h)\n')
2924 self.assertTrue(p.s.dumpPython(
None) ==
'cms.Sequence(process.d)\n')
2925 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
2926 self.assertTrue(p.endpath1.dumpPython(
None) ==
'cms.EndPath(process.b)\n')
2928 self.assertTrue(p.path1.dumpPython(
None) ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
2929 self.assertTrue(p.schedule_().
dumpPython(
None) ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
2936 m1.toModify(p.a,_mod_fred)
2937 self.assertEqual(p.a.fred.value(),2)
2939 m1.toModify(p.b, wilma = 2)
2940 self.assertEqual(p.b.wilma.value(),2)
2941 self.assert_(p.isUsingModifier(m1))
2946 m1.toModify(p.a,_mod_fred)
2948 m1.toModify(p.b, wilma = 2)
2949 self.assertEqual(p.a.fred.value(),1)
2950 self.assertEqual(p.b.wilma.value(),1)
2951 self.assertEqual(p.isUsingModifier(m1),
False)
2956 m1.toModify(p.a, fred =
int32(2))
2957 p.b = p.a.clone(wilma =
int32(3))
2958 self.assertEqual(p.a.fred.value(),2)
2959 self.assertEqual(p.a.wilma.value(),1)
2960 self.assertEqual(p.b.fred.value(),2)
2961 self.assertEqual(p.b.wilma.value(),3)
2966 m1.toModify(p.a, fred =
None, fintstones =
dict(fred =
None))
2967 self.assertEqual(hasattr(p.a,
"fred"),
False)
2968 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
2969 self.assertEqual(p.a.wilma.value(),1)
2974 m1.toModify(p.a, wilma =
int32(2))
2975 self.assertEqual(p.a.fred.value(), 1)
2976 self.assertEqual(p.a.wilma.value(),2)
2981 m1.toModify(p.a, flintstones =
dict(fred =
int32(2)))
2982 self.assertEqual(p.a.flintstones.fred.value(),2)
2983 self.assertEqual(p.a.flintstones.wilma.value(),1)
2988 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones =
dict(imnothere =
dict(wilma=2))))
2989 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
2994 m1.toModify(p.a, flintstones = {1:
dict(wilma =
int32(2))})
2995 self.assertEqual(p.a.flintstones[0].fred.value(),1)
2996 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3001 m1.toModify(p.a, fred = {1:7})
3002 self.assertEqual(p.a.fred[0],1)
3003 self.assertEqual(p.a.fred[1],7)
3004 self.assertEqual(p.a.fred[2],3)
3010 try: m1.toModify(p.a, fred = {5:7})
3011 except IndexError
as e: raised =
True 3012 self.assertEqual(raised,
True)
3018 try: m1.toModify(p.a, flintstones =
dict(bogus =
int32(37)))
3019 except TypeError
as e: raised =
True 3020 self.assertEqual(raised,
True)
3024 class ProcModifierMod(
object):
3025 def __init__(self,modifier,func):
3030 testMod = DummyMod()
3032 self.assert_(hasattr(p,
"a"))
3035 testProcMod = ProcModifierMod(m1,_rem_a)
3037 p.extend(testProcMod)
3038 self.assert_(
not hasattr(p,
"a"))
3043 self.assert_(p.isUsingModifier(m1))
3044 self.assert_(p.isUsingModifier(mc))
3045 testMod = DummyMod()
3047 m1.toModify(p.b, fred =
int32(3))
3049 testProcMod = ProcModifierMod(m1,_rem_a)
3050 p.extend(testProcMod)
3051 self.assert_(
not hasattr(p,
"a"))
3052 self.assertEqual(p.b.fred.value(),3)
3057 mclone = mc.copyAndExclude([m2])
3058 self.assert_(
not mclone._isOrContains(m2))
3059 self.assert_(mclone._isOrContains(m1))
3062 mclone = mc2.copyAndExclude([m2])
3063 self.assert_(
not mclone._isOrContains(m2))
3064 self.assert_(mclone._isOrContains(m1))
3065 self.assert_(mclone._isOrContains(m3))
3071 (m1 & m2).toModify(p.a, fred =
int32(2))
3072 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3073 self.assertEqual(p.a.fred, 1)
3078 (m1 & m2).toModify(p.a, fred =
int32(2))
3079 self.assertEqual(p.a.fred, 2)
3085 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3086 self.assertEqual(p.a.fred, 2)
3087 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3088 self.assertEqual(p.a.fred, 3)
3089 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3090 self.assertEqual(p.a.fred, 4)
3096 (~m1).toModify(p.a, fred=2)
3097 self.assertEqual(p.a.fred, 1)
3098 (~m2).toModify(p.a, wilma=2)
3099 self.assertEqual(p.a.wilma, 2)
3100 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3101 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3108 (m1 | m2).toModify(p.a, fred=2)
3109 self.assertEqual(p.a.fred, 2)
3110 (m1 | m2 | m3).toModify(p.a, fred=3)
3111 self.assertEqual(p.a.fred, 3)
3112 (m3 | m2 | m1).toModify(p.a, fred=4)
3113 self.assertEqual(p.a.fred, 4)
3114 ((m1 | m2) | m3).toModify(p.a, fred=5)
3115 self.assertEqual(p.a.fred, 5)
3116 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3117 self.assertEqual(p.a.fred, 6)
3118 (m2 | m3).toModify(p.a, fred=7)
3119 self.assertEqual(p.a.fred, 6)
3120 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3121 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3129 (m1 & ~m2).toModify(p.a, fred=2)
3130 self.assertEqual(p.a.fred, 1)
3131 (m1 & ~m3).toModify(p.a, fred=2)
3132 self.assertEqual(p.a.fred, 2)
3133 (m1 | ~m2).toModify(p.a, fred=3)
3134 self.assertEqual(p.a.fred, 3)
3135 (~m1 | ~m2).toModify(p.a, fred=4)
3136 self.assertEqual(p.a.fred, 3)
3137 (~m3 & ~m4).toModify(p.a, fred=4)
3138 self.assertEqual(p.a.fred, 4)
3139 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3140 self.assertEqual(p.a.fred, 5)
3146 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3153 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3154 self.assertEqual(p.a.wilma.value(),3)
3155 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3156 self.assertEqual(hasattr(p,
"fred"),
False)
3157 self.assertTrue(p.s.dumpPython(
"") ==
"cms.Sequence(process.a+process.b, process.td)\n")
3159 m1.toReplaceWith(p.td,
Task(p.e))
3160 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3166 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3174 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3175 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3176 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3177 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3178 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3179 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3180 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3181 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3182 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3183 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3184 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3185 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3186 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3187 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3188 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3189 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3190 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3191 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)
S & print(S &os, JobReport::InputFile const &f)
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)