4 from __future__
import print_function
5 from __future__
import absolute_import
7 from .Options
import Options
13 from .Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
16 from .Modules
import *
17 from .Modules
import _Module
18 from .SequenceTypes
import *
19 from .SequenceTypes
import _ModuleSequenceType, _Sequenceable
20 from .SequenceVisitors
import PathValidator, EndPathValidator, FinalPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
21 from .MessageLogger
import MessageLogger
22 from .
import DictTypes
24 from .ExceptionHandling
import *
27 if sys.getrecursionlimit()<5000:
28 sys.setrecursionlimit(5000)
32 Raise an exception if called by special config files. This checks 33 the call or import stack for the importing file. An exception is raised if 34 the importing module is not in allowedPatterns and if it is called too deeply: 35 minLevel = 2: inclusion by top lvel cfg only 36 minLevel = 1: No inclusion allowed 37 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 38 by any module in Module1 or Submodule1 44 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'FWCore/ParameterSet/python/Config.py',
'<string>',
'<frozen ']
45 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
49 for item
in inspect.stack():
53 for pattern
in CMSSWPath:
54 if item[1].
find(pattern) != -1:
57 if item[1].
find(
'/') == -1:
60 for pattern
in ignorePatterns:
61 if item[1].
find(pattern) != -1:
65 if inPath
and not ignore:
66 trueStack.append(item[1])
68 importedFile = trueStack[0]
70 if len(trueStack) > 1:
71 importedBy = trueStack[1]
73 for pattern
in allowedPatterns:
74 if importedBy.find(pattern) > -1:
77 if len(trueStack) <= minLevel:
80 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 84 """Look inside the module and find the Processes it contains""" 88 if isinstance(module,dict):
89 if 'process' in module:
93 if hasattr(module,
'process'):
94 if isinstance(module.process,Process):
95 process = module.process
97 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
99 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
103 """Root class for a CMS configuration process""" 106 """The argument 'name' will be the name applied to this Process 107 Can optionally pass as additional arguments cms.Modifier instances 108 that will be used to modify the Process as it is built 110 self.__dict__[
'_Process__name'] = name
111 if not name.isalnum():
112 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
113 self.__dict__[
'_Process__filters'] = {}
114 self.__dict__[
'_Process__producers'] = {}
115 self.__dict__[
'_Process__switchproducers'] = {}
116 self.__dict__[
'_Process__source'] =
None 117 self.__dict__[
'_Process__looper'] =
None 118 self.__dict__[
'_Process__subProcesses'] = []
119 self.__dict__[
'_Process__schedule'] =
None 120 self.__dict__[
'_Process__analyzers'] = {}
121 self.__dict__[
'_Process__outputmodules'] = {}
125 self.__dict__[
'_Process__sequences'] = {}
126 self.__dict__[
'_Process__tasks'] = {}
127 self.__dict__[
'_Process__conditionaltasks'] = {}
128 self.__dict__[
'_Process__services'] = {}
129 self.__dict__[
'_Process__essources'] = {}
130 self.__dict__[
'_Process__esproducers'] = {}
131 self.__dict__[
'_Process__esprefers'] = {}
132 self.__dict__[
'_Process__aliases'] = {}
133 self.__dict__[
'_Process__psets']={}
134 self.__dict__[
'_Process__vpsets']={}
135 self.__dict__[
'_cloneToObjectDict'] = {}
137 self.__dict__[
'_Process__InExtendCall'] =
False 138 self.__dict__[
'_Process__partialschedules'] = {}
140 self.__dict__[
'_Process__modifiers'] = Mods
141 self.__dict__[
'_Process__accelerators'] = {}
150 if Process._firstProcess:
151 Process._firstProcess =
False 154 for m
in self.__modifiers:
155 if not m._isChosen():
156 raise RuntimeError(
"The Process {} tried to redefine which Modifiers to use after another Process was already started".
format(name))
157 for m
in self.__modifiers:
162 _Module.__isStrict__ =
True 166 """Returns a string containing all the EDProducer labels separated by a blank""" 169 """Returns a string containing all the SwitchProducer labels separated by a blank""" 172 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 175 """Returns a string containing all the EDFilter labels separated by a blank""" 178 """Returns a string containing all the Path names separated by a blank""" 185 Since cloneToObjectDict stores a hash of objects by their 186 id() it needs to be updated when unpickling to use the 187 new object id values instantiated during the unpickle. 190 self.__dict__.
update(pkldict)
192 for value
in self._cloneToObjectDict.
values():
193 tmpDict[
id(value)] = value
194 self.__dict__[
'_cloneToObjectDict'] = tmpDict
199 """returns a dict of the filters that have been added to the Process""" 201 filters = property(filters_, doc=
"dictionary containing the filters for the process")
205 if not name.isalnum():
206 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
207 self.__dict__[
'_Process__name'] = name
208 process = property(name_,setName_, doc=
"name of the process")
210 """returns a dict of the producers that have been added to the Process""" 212 producers = property(producers_,doc=
"dictionary containing the producers for the process")
214 """returns a dict of the SwitchProducers that have been added to the Process""" 216 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
218 """returns the source that has been added to the Process or None if none have been added""" 222 source = property(source_,setSource_,doc=
'the main source or None if not set')
224 """returns the looper that has been added to the Process or None if none have been added""" 228 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
231 return untracked.PSet(numberOfThreads = untracked.uint32(1),
232 numberOfStreams = untracked.uint32(0),
233 numberOfConcurrentRuns = untracked.uint32(1),
234 numberOfConcurrentLuminosityBlocks = untracked.uint32(0),
235 eventSetup = untracked.PSet(
236 numberOfConcurrentIOVs = untracked.uint32(0),
237 forceNumberOfConcurrentIOVs = untracked.PSet(
238 allowAnyLabel_ = required.untracked.uint32
241 accelerators = untracked.vstring(
'*'),
242 wantSummary = untracked.bool(
False),
243 fileMode = untracked.string(
'FULLMERGE'),
244 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
245 throwIfIllegalParameter = untracked.bool(
True),
246 printDependencies = untracked.bool(
False),
247 deleteNonConsumedUnscheduledModules = untracked.bool(
True),
248 sizeOfStackForThreadsInKB = optional.untracked.uint32,
249 Rethrow = untracked.vstring(),
250 SkipEvent = untracked.vstring(),
251 FailPath = untracked.vstring(),
252 IgnoreCompletely = untracked.vstring(),
253 canDeleteEarly = untracked.vstring(),
254 holdsReferencesToDeleteEarly = untracked.VPSet(),
255 modulesToIgnoreForDeleteEarly = untracked.vstring(),
256 dumpOptions = untracked.bool(
False),
257 allowUnscheduled = obsolete.untracked.bool,
258 emptyRunLumiMode = obsolete.untracked.string,
259 makeTriggerResults = obsolete.untracked.bool,
263 if isinstance(opt,dict):
264 for k,v
in opt.items():
267 for p
in opt.parameters_():
268 setattr(newOpts, p, getattr(opt,p))
272 return untracked.PSet(input=optional.untracked.int32,
273 output=optional.untracked.allowed(int32,PSet))
276 if isinstance(ps,dict):
277 for k,v
in ps.items():
280 for p
in ps.parameters_():
281 setattr(newMax, p, getattr(ps,p))
285 return untracked.PSet(input=untracked.int32(-1))
287 """returns a list of the subProcesses that have been added to the Process""" 288 return self.__subProcesses
289 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
291 """returns a dict of the analyzers that have been added to the Process""" 293 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
295 """returns a dict of the output modules that have been added to the Process""" 297 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
299 """returns a dict of the paths that have been added to the Process""" 301 paths = property(paths_,doc=
"dictionary containing the paths for the process")
303 """returns a dict of the endpaths that have been added to the Process""" 305 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
307 """returns a dict of the finalpaths that have been added to the Process""" 309 finalpaths = property(finalpaths_,doc=
"dictionary containing the finalpaths for the process")
311 """returns a dict of the sequences that have been added to the Process""" 313 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
315 """returns a dict of the tasks that have been added to the Process""" 317 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
319 """returns a dict of the conditionaltasks that have been added to the Process""" 321 conditionaltasks = property(conditionaltasks_,doc=
"dictionary containing the conditionatasks for the process")
323 """returns the schedule that has been added to the Process or None if none have been added""" 324 return self.__schedule
326 if label ==
"schedule":
329 self.
_place(label, sch, self.__partialschedules)
338 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
339 self.__dict__[
'_Process__schedule'] = sch
340 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
342 """returns a dict of the services that have been added to the Process""" 344 services = property(services_,doc=
"dictionary containing the services for the process")
346 """returns a dict of the ProcessAccelerators that have been added to the Process""" 348 processAccelerators = property(processAccelerators_,doc=
"dictionary containing the ProcessAccelerators for the process")
350 """returns a dict of the esproducers that have been added to the Process""" 352 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
354 """returns a the es_sources that have been added to the Process""" 356 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
358 """returns a dict of the es_prefers that have been added to the Process""" 360 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
362 """returns a dict of the aliases that have been added to the Process""" 364 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
366 """returns a dict of the PSets that have been added to the Process""" 368 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
370 """returns a dict of the VPSets that have been added to the Process""" 372 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
375 """returns True if the Modifier is in used by this Process""" 377 for m
in self.__modifiers:
378 if m._isOrContains(mod):
383 if not object.hasLabel_() :
384 object.setLabel(newLabel)
386 if newLabel == object.label_() :
388 if newLabel
is None :
389 object.setLabel(
None)
391 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
392 msg100 =
"Attempting to change the label of an attribute of the Process\n" 393 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 394 msg102 =
"Type = "+
str(type(object))+
"\n" 395 msg103 =
"Some possible solutions:\n" 396 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 397 msg105 =
" also preferred for other types when possible.\n" 398 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 399 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 400 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 401 msg109 =
" the name.\n" 402 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 403 msg111 =
" name to the same object usually causes confusion and problems.\n" 404 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 405 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
406 object.setLabel(
None)
407 object.setLabel(newLabel)
411 if not name.replace(
'_',
'').isalnum():
412 raise ValueError(
'The label '+name+
' contains forbiden characters')
414 if name ==
'options':
416 if name ==
'maxEvents':
420 if name.startswith(
'_Process__'):
421 self.__dict__[name]=value
423 if not isinstance(value,_ConfigureComponent):
424 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 425 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
426 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
427 if name == value.type_():
428 if hasattr(self,name)
and (getattr(self,name)!=value):
435 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
436 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
439 newValue =value.copy()
441 newValue._filename = value._filename
447 if not self.
_okToPlace(name, value, self.__dict__):
448 newFile=
'top level config' 449 if hasattr(value,
'_filename'):
450 newFile = value._filename
451 oldFile=
'top level config' 452 oldValue = getattr(self,name)
453 if hasattr(oldValue,
'_filename'):
454 oldFile = oldValue._filename
455 msg =
"Trying to override definition of process."+name
456 msg +=
"\n new object defined in: "+newFile
457 msg +=
"\n existing object defined in: "+oldFile
458 raise ValueError(msg)
460 if hasattr(self,name)
and not (getattr(self,name)==newValue):
464 if newValue._isTaskComponent():
465 if not self.__InExtendCall:
470 if not isinstance(newValue, Task):
472 newFile=
'top level config' 473 if hasattr(value,
'_filename'):
474 newFile = value._filename
475 oldFile=
'top level config' 476 oldValue = getattr(self,name)
477 if hasattr(oldValue,
'_filename'):
478 oldFile = oldValue._filename
479 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 480 msg2 =
"\n new object defined in: "+newFile
481 msg2 +=
"\n existing object defined in: "+oldFile
484 raise ValueError(msg1+s.label_()+msg2)
486 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent()
or isinstance(newValue, ConditionalTask):
487 if not self.__InExtendCall:
488 if isinstance(newValue, ConditionalTask):
493 newFile=
'top level config' 494 if hasattr(value,
'_filename'):
495 newFile = value._filename
496 oldFile=
'top level config' 497 oldValue = getattr(self,name)
498 if hasattr(oldValue,
'_filename'):
499 oldFile = oldValue._filename
500 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 501 msg2 =
"\n new object defined in: "+newFile
502 msg2 +=
"\n existing object defined in: "+oldFile
505 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
508 raise ValueError(msg1+
"path "+s.label_()+msg2)
511 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
514 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
517 if isinstance(newValue, EDAlias):
518 oldValue = getattr(self, name)
520 newFile=
'top level config' 521 if hasattr(value,
'_filename'):
522 newFile = value._filename
523 oldFile=
'top level config' 524 if hasattr(oldValue,
'_filename'):
525 oldFile = oldValue._filename
526 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the " 527 msg2 =
"\n new object defined in: "+newFile
528 msg2 +=
"\n existing object defined in: "+oldFile
531 raise ValueError(msg1+
"task "+s.label_()+msg2)
534 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
537 raise ValueError(msg1+
"path "+s.label_()+msg2)
540 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
543 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
545 if not self.__InExtendCall
and (Schedule._itemIsValid(newValue)
or isinstance(newValue, Task)):
549 self.__dict__[name]=newValue
550 if isinstance(newValue,_Labelable):
552 self._cloneToObjectDict[
id(value)] = newValue
553 self._cloneToObjectDict[
id(newValue)] = newValue
555 newValue._place(name,self)
557 """Given a container of sequences or tasks, find the first sequence or task 558 containing mod and return it. If none is found, return None""" 561 for seqOrTask
in seqsOrTasks.values():
570 if not hasattr(self,name):
571 raise KeyError(
'process does not know about '+name)
572 elif name.startswith(
'_Process__'):
573 raise ValueError(
'this attribute cannot be deleted')
578 if name
in reg: del reg[name]
580 obj = getattr(self,name)
581 if isinstance(obj,_Labelable):
583 if isinstance(obj,Service):
584 obj._inProcess =
False 588 obj = getattr(self,name)
590 if not isinstance(obj, Sequence)
and not isinstance(obj, Task)
and not isinstance(obj,ConditionalTask):
600 if obj._isTaskComponent():
604 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
606 if Schedule._itemIsValid(obj)
or isinstance(obj, Task):
610 del self.__dict__[name]
615 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 619 del self.__dict__[name]
624 """Allows addition of components that do not have to have a label, e.g. Services""" 625 if not isinstance(value,_ConfigureComponent):
627 if not isinstance(value,_Unlabelable):
631 newValue =value.copy()
635 newValue._place(
'',self)
638 if not self.__InExtendCall:
649 if d[name]._isModified:
660 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
661 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
664 if isinstance(mod,_Labelable):
667 self.
_place(name, mod, self.__outputmodules)
669 self.
_place(name, mod, self.__producers)
671 self.
_place(name, mod, self.__switchproducers)
673 self.
_place(name, mod, self.__filters)
675 self.
_place(name, mod, self.__analyzers)
679 self.
_place(name, mod, self.__paths)
680 except ModuleCloneError
as msg:
682 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
686 self.
_place(name, mod, self.__endpaths)
687 except ModuleCloneError
as msg:
689 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
693 self.
_place(name, mod, self.__finalpaths)
694 except ModuleCloneError
as msg:
696 raise Exception(
"%sThe module %s in finalpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
699 self.
_place(name, mod, self.__sequences)
701 self.
_place(name, mod, self.__esproducers)
703 self.
_place(name, mod, self.__esprefers)
705 self.
_place(name, mod, self.__essources)
708 self.
_place(name, task, self.__tasks)
711 self.
_place(name, task, self.__conditionaltasks)
713 self.
_place(name, mod, self.__aliases)
715 self.
_place(name, mod, self.__psets)
717 self.
_place(name, mod, self.__vpsets)
719 """Allow the source to be referenced by 'source' or by type name""" 721 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
722 if self.__dict__[
'_Process__source']
is not None :
723 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
724 self.__dict__[
'_Process__source'] = mod
725 self.__dict__[mod.type_()] = mod
728 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
729 self.__dict__[
'_Process__looper'] = mod
730 self.__dict__[mod.type_()] = mod
732 self.__dict__[
'_Process__subProcess'] = mod
733 self.__dict__[mod.type_()] = mod
735 self.__subProcesses.
append(mod)
737 self.
_place(typeName, mod, self.__services)
738 if typeName
in self.__dict__:
739 self.__dict__[typeName]._inProcess =
False 740 self.__dict__[typeName]=mod
742 self.
_place(typeName, mod, self.__accelerators)
743 self.__dict__[typeName]=mod
745 moduleName = moduleName.replace(
"/",
".")
746 module = __import__(moduleName)
747 self.
extend(sys.modules[moduleName])
749 """Look in other and find types that we can use""" 751 self.__dict__[
'_Process__InExtendCall'] =
True 754 tasksToAttach = dict()
756 for name
in dir(other):
758 if name.startswith(
'_'):
760 item = getattr(other,name)
761 if name ==
"source" or name ==
"looper":
765 elif isinstance(item,_ModuleSequenceType):
767 elif isinstance(item,Task)
or isinstance(item, ConditionalTask):
768 tasksToAttach[name] = item
769 elif isinstance(item,_Labelable):
771 if not item.hasLabel_() :
773 elif isinstance(item,Schedule):
775 elif isinstance(item,_Unlabelable):
777 elif isinstance(item,ProcessModifier):
779 elif isinstance(item,ProcessFragment):
783 for name,seq
in seqs.items():
784 if id(seq)
not in self._cloneToObjectDict:
787 newSeq = self._cloneToObjectDict[
id(seq)]
788 self.__dict__[name]=newSeq
791 newSeq._place(name,self)
793 for name, task
in tasksToAttach.items():
800 self.__dict__[
'_Process__InExtendCall'] =
False 804 for name,item
in items:
805 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
810 for name,item
in items:
811 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
816 for name,item
in items:
817 if name == item.type_():
819 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
823 """return a string containing the equivalent process defined using the old configuration language""" 824 config =
"process "+self.__name+
" = {\n" 877 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
879 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
881 pathNames = [p.label_()
for p
in self.
schedule]
882 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 894 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
900 returnValue += item.dumpPython(options)+
'\n\n' 906 for name,item
in d.items():
907 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 909 for name,item
in sorted(d.items()):
910 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 917 dependencies = item.directDependencies()
918 for module_subfolder, module
in dependencies:
919 module = module +
'_cfi' 920 if options.useSubdirectories
and module_subfolder:
921 module = module_subfolder +
'.' + module
922 if options.targetDirectory
is not None:
923 if options.useSubdirectories
and subfolder:
924 module =
'..' + module
926 module =
'.' + module
927 code +=
'from ' + module +
' import *\n' 930 code += name +
' = ' + item.dumpPython(options)
931 parts[name] = subfolder, code
939 sequence.visit(visitor)
940 except Exception
as e:
941 raise RuntimeError(
"An entry in sequence {} has no label\n Seen entries: {}\n Error: {}".
format(label, l, e))
950 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
958 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
970 for label,item
in processDictionaryOfItems.items():
972 if isinstance(item, Task):
974 elif isinstance(item, ConditionalTask):
981 if isinstance(item, Task):
982 raise RuntimeError(
"Failed in a Task visitor. Probably " \
983 "a circular dependency discovered in Task with label " + label)
984 elif isinstance(item, ConditionalTask):
985 raise RuntimeError(
"Failed in a ConditionalTask visitor. Probably " \
986 "a circular dependency discovered in ConditionalTask with label " + label)
988 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
989 "circular dependency discovered in Sequence with label " + label)
990 for containedItem
in containedItems:
996 if containedItem.hasLabel_():
997 testItem = processDictionaryOfItems.get(containedItem.label_())
998 if testItem
is None or containedItem != testItem:
999 if isinstance(item, Task):
1000 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
1001 " from the process yields a different object or None\n"+
1002 "label = " + containedItem.label_())
1003 if isinstance(item, ConditionalTask):
1004 raise RuntimeError(
"ConditionalTask has a label, but using its label to get an attribute" \
1005 " from the process yields a different object or None\n"+
1006 "label = " + containedItem.label_())
1008 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
1009 " from the process yields a different object or None\n"+
1010 "label = " + containedItem.label_())
1011 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
1015 oldDeps = dict(dependencies)
1016 for label,deps
in oldDeps.items():
1018 returnValue[label]=processDictionaryOfItems[label]
1020 del dependencies[label]
1021 for lb2,deps2
in dependencies.items():
1022 while deps2.count(label):
1028 for name, value
in sorted(d.items()):
1029 result += value.dumpPythonAs(name,options)+
'\n' 1034 for name, value
in sorted(d.items()):
1035 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n' 1039 """return a string containing the equivalent process defined using python""" 1040 specialImportRegistry._reset()
1041 header =
"import FWCore.ParameterSet.Config as cms" 1042 result =
"process = cms.Process(\""+self.__name+
"\")\n\n" 1069 imports = specialImportRegistry.getSpecialImports()
1070 if len(imports) > 0:
1071 header +=
"\n" +
"\n".
join(imports)
1073 return header+result
1076 """return a map of file names to python configuration fragments""" 1077 specialImportRegistry._reset()
1079 options.isCfg =
False 1080 header =
"import FWCore.ParameterSet.Config as cms" 1085 result =
'process = cms.Process("' + self.__name +
'")\n\n' 1098 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1115 if options.targetDirectory
is not None:
1116 files[options.targetDirectory +
'/__init__.py'] =
'' 1118 if options.useSubdirectories:
1119 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1120 if options.targetDirectory
is not None:
1121 sub = options.targetDirectory +
'/' + sub
1122 files[sub +
'/__init__.py'] =
'' 1125 parts = sorted(parts.items(), key =
lambda nsc: (nsc[1][0].lower()
if nsc[1][0]
else '', nsc[0].lower()))
1127 for (name, (subfolder, code))
in parts:
1128 filename = name +
'_cfi' 1129 if options.useSubdirectories
and subfolder:
1130 filename = subfolder +
'/' + filename
1131 if options.targetDirectory
is not None:
1132 filename = options.targetDirectory +
'/' + filename
1133 result +=
'process.load("%s")\n' % filename
1134 files[filename +
'.py'] = header +
'\n\n' + code
1137 options.isCfg =
True 1140 imports = specialImportRegistry.getSpecialImports()
1141 if len(imports) > 0:
1142 header +=
'\n' +
'\n'.
join(imports)
1143 files[
'-'] = header +
'\n\n' + result
1147 old = getattr(self,label)
1154 sequenceable._replaceIfHeldDirectly(old,new)
1156 sequenceable.replace(old,new)
1158 sequenceable.replace(old,new)
1160 sequenceable.replace(old,new)
1162 sequenceable.replace(old,new)
1164 old = getattr(self,label)
1166 task.replace(old, new)
1168 old = getattr(self,label)
1170 task.replace(old, new)
1174 old = getattr(self,label)
1176 task.replace(old, new)
1180 old = getattr(self,label)
1181 self.
schedule_()._replaceIfHeldDirectly(old, new)
1183 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 1184 if not hasattr(self,label):
1185 raise LookupError(
"process has no item of label "+label)
1186 setattr(self,label,new)
1188 for name,value
in itemDict.items():
1189 value.insertInto(parameterSet, name)
1192 if not item ==
None:
1193 newlabel = item.nameInProcessDesc_(label)
1195 item.insertInto(parameterSet, newlabel)
1196 parameterSet.addVString(tracked, label, vitems)
1199 for name,value
in itemDict.items():
1200 value.appendToProcessDescList_(l, name)
1201 value.insertInto(parameterSet, name)
1204 parameterSet.addVString(tracked, label, l)
1206 modules = parameterSet.getVString(tracked, labelModules)
1207 aliases = parameterSet.getVString(tracked, labelAliases)
1208 accelerators = parameterSet.getVString(
False,
"@selected_accelerators")
1209 for name,value
in itemDict.items():
1210 value.appendToProcessDescLists_(modules, aliases, name)
1211 value.insertInto(parameterSet, name, accelerators)
1214 parameterSet.addVString(tracked, labelModules, modules)
1215 parameterSet.addVString(tracked, labelAliases, aliases)
1219 for value
in itemList:
1220 name = value.getProcessName()
1221 newLabel = value.nameInProcessDesc_(name)
1223 pset = value.getSubProcessPSet(parameterSet)
1224 subprocs.append(pset)
1227 parameterSet.addVString(tracked, label, l)
1228 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1236 for name
in self.
paths_():
1237 scheduledPaths.append(name)
1238 triggerPaths.append(name)
1240 scheduledPaths.append(name)
1241 endpaths.append(name)
1243 finalpaths.append(name)
1246 pathname = path.label_()
1248 endpaths.append(pathname)
1249 scheduledPaths.append(pathname)
1251 finalpaths.append(pathname)
1253 scheduledPaths.append(pathname)
1254 triggerPaths.append(pathname)
1256 task.resolve(self.__dict__)
1258 task.visit(scheduleTaskValidator)
1259 task.visit(nodeVisitor)
1261 endPathWithFinalPathModulesName =
"@finalPath" 1264 endpaths.append(endPathWithFinalPathModulesName)
1265 scheduledPaths.append(endPathWithFinalPathModulesName)
1267 modulesOnFinalPath = []
1268 for finalpathname
in finalpaths:
1270 iFinalPath.resolve(self.__dict__)
1271 finalpathValidator.setLabel(finalpathname)
1272 iFinalPath.visit(finalpathValidator)
1273 if finalpathValidator.filtersOnFinalpaths
or finalpathValidator.producersOnFinalpaths:
1274 names = [p.label_
for p
in finalpathValidator.filtersOnFinalpaths]
1275 names.extend( [p.label_
for p
in finalpathValidator.producersOnFinalpaths])
1276 raise RuntimeError(
"FinalPath %s has non OutputModules %s" % (finalpathname,
",".
join(names)))
1277 modulesOnFinalPath.extend(iFinalPath.moduleNames())
1278 for m
in modulesOnFinalPath:
1279 mod = getattr(self, m)
1280 setattr(mod,
"@onFinalPath", untracked.bool(
True))
1281 finalPathEndPath += mod
1283 processPSet.addVString(
True,
"@end_paths", endpaths)
1284 processPSet.addVString(
True,
"@paths", scheduledPaths)
1286 p = processPSet.newPSet()
1287 p.addVString(
True,
"@trigger_paths", triggerPaths)
1288 processPSet.addPSet(
True,
"@trigger_paths", p)
1294 condTaskModules = []
1296 pathCompositeVisitor =
CompositeVisitor(pathValidator, nodeVisitor, lister, condTaskVistor)
1297 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
1298 for triggername
in triggerPaths:
1299 iPath = self.
paths_()[triggername]
1300 iPath.resolve(self.__dict__)
1301 pathValidator.setLabel(triggername)
1303 condTaskModules[:] = []
1304 iPath.visit(pathCompositeVisitor)
1306 decoratedList.append(
"#")
1307 l = list({x.label_()
for x
in condTaskModules})
1309 decoratedList.extend(l)
1310 decoratedList.append(
"@")
1311 iPath.insertInto(processPSet, triggername, decoratedList[:])
1312 for endpathname
in endpaths:
1313 if endpathname
is not endPathWithFinalPathModulesName:
1314 iEndPath = self.
endpaths_()[endpathname]
1316 iEndPath = finalPathEndPath
1317 iEndPath.resolve(self.__dict__)
1318 endpathValidator.setLabel(endpathname)
1320 iEndPath.visit(endpathCompositeVisitor)
1321 iEndPath.insertInto(processPSet, endpathname, decoratedList[:])
1322 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1325 def resolve(self,keepUnresolvedSequencePlaceholders=False):
1327 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1329 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1331 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1334 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1336 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1337 """ Remove clutter from the process that we think is unnecessary: 1338 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 1339 not in the schedule will also be removed, along with an modules and sequences used only by 1340 those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders.""" 1349 self.
resolve(keepUnresolvedSequencePlaceholders)
1351 unneededPaths = set()
1355 usedModules=set(self.
schedule_().moduleNames())
1357 schedNames = set(( x.label_()
for x
in self.
schedule_()))
1358 names = set(self.
paths)
1361 unneededPaths = names - schedNames
1362 for n
in unneededPaths:
1373 usedModules=set(temp.moduleNames())
1390 def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1391 _keepSet = set(( s
for s
in seqOrTasks
if s.hasLabel_()))
1392 _availableSet = set(allSequencesOrTasks.values())
1393 _unneededSet = _availableSet-_keepSet
1394 _unneededLabels = []
1395 for s
in _unneededSet:
1396 _unneededLabels.append(s.label_())
1397 delattr(self,s.label_())
1398 return _unneededLabels
1399 unneededSeqLabels = removeUnneeded(seqs, self.
sequences)
1400 unneededTaskLabels = removeUnneeded(tasks, self.
tasks)
1402 print(
"prune removed the following:")
1403 print(
" modules:"+
",".
join(unneededModules))
1404 print(
" tasks:"+
",".
join(unneededTaskLabels))
1405 print(
" sequences:"+
",".
join(unneededSeqLabels))
1406 print(
" paths/endpaths/finalpaths:"+
",".
join(unneededPaths))
1408 moduleNames = set(d.keys())
1409 junk = moduleNames - scheduledNames
1415 """Used by the framework to convert python to C++ objects""" 1416 class ServiceInjectorAdaptor(
object):
1427 class TopLevelPSetAcessorAdaptor(
object):
1431 def __getattr__(self,attr):
1432 return getattr(self.
__ppset,attr)
1433 def getTopPSet_(self,label):
1437 def addPSet(self,tracked,name,ppset):
1438 return self.
__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1439 def addVPSet(self,tracked,name,vpset):
1440 return self.
__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1441 def __extractPSet(self,pset):
1442 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1447 processPSet.addString(
True,
"@process_name", self.
name_())
1450 all_modules.update(self.
filters_())
1453 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1466 all_modules_onTasksOrScheduled = { key:value
for key, value
in all_modules.items()
if value
in nodeVisitor.modules }
1467 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1469 all_switches_onTasksOrScheduled = {key:value
for key, value
in all_switches.items()
if value
in nodeVisitor.modules }
1475 pTask.visit(processNodeVisitor)
1476 esProducersToEnable = {}
1478 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1479 esProducersToEnable[esProducerName] = esProducer
1480 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1481 esSourcesToEnable = {}
1483 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1484 esSourcesToEnable[esSourceName] = esSource
1485 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1489 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1490 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1491 adaptor.addVPSet(
False,
"services",services)
1503 allAccelerators = set([
"cpu"])
1504 availableAccelerators = set([
"cpu"])
1505 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1506 allAccelerators.update(acc.labels())
1507 availableAccelerators.update(acc.enabledLabels())
1508 availableAccelerators = sorted(list(availableAccelerators))
1509 parameterSet.addVString(
False,
"@available_accelerators", availableAccelerators)
1512 selectedAccelerators = []
1513 if "*" in self.options.accelerators:
1514 if len(self.options.accelerators) >= 2:
1515 raise ValueError(
"process.options.accelerators may contain '*' only as the only element, now it has {} elements".
format(len(self.options.accelerators)))
1516 selectedAccelerators = availableAccelerators
1521 for pattern
in self.options.accelerators:
1522 acc = [a
for a
in availableAccelerators
if fnmatch.fnmatchcase(a, pattern)]
1524 if not any(fnmatch.fnmatchcase(a, pattern)
for a
in allAccelerators):
1525 invalid.append(pattern)
1527 resolved.update(acc)
1529 if len(invalid) != 0:
1530 raise ValueError(
"Invalid pattern{} of {} in process.options.accelerators, valid values are {} or a pattern matching to some of them.".
format(
1531 "s" if len(invalid) > 2
else "",
1533 ",".
join(sorted(list(allAccelerators)))))
1534 selectedAccelerators = sorted(list(resolved))
1535 parameterSet.addVString(
False,
"@selected_accelerators", selectedAccelerators)
1538 wrapped = ProcessForProcessAccelerator(self)
1539 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1540 acc.apply(wrapped, selectedAccelerators)
1543 """Prefer this ES source or producer. The argument can 1544 either be an object label, e.g., 1545 process.prefer(process.juicerProducer) (not supported yet) 1546 or a name of an ESSource or ESProducer 1547 process.prefer("juicer") 1548 or a type of unnamed ESSource or ESProducer 1549 process.prefer("JuicerProducer") 1550 In addition, you can pass as a labelled arguments the name of the Record you wish to 1551 prefer where the type passed is a cms.vstring and that vstring can contain the 1552 name of the C++ types in the Record that are being preferred, e.g., 1553 #prefer all data in record 'OrangeRecord' from 'juicer' 1554 process.prefer("juicer", OrangeRecord=cms.vstring()) 1556 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1557 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1559 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1560 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1563 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1564 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1569 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1574 typ = d[esname].type_()
1583 for name, value
in d.items():
1584 if value.type_() == esname:
1586 raise RuntimeError(
"More than one ES module for "+esname)
1594 if isinstance(process, Process):
1596 elif isinstance(process, str):
1603 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1605 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1607 if name ==
'_ProcessFragment__process':
1608 return object.__getattribute__(self,
'_ProcessFragment__process')
1612 if name ==
'_ProcessFragment__process':
1613 object.__setattr__(self, name, value)
1617 if name ==
'_ProcessFragment__process':
1624 """a dictionary with fixed keys""" 1626 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1627 _blocked_attribute = property(_blocked_attribute)
1628 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1629 pop = popitem = setdefault = update = _blocked_attribute
1631 new = dict.__new__(cls)
1632 dict.__init__(new, *args, **kw)
1633 keys = sorted(kw.keys())
1634 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1635 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1636 if not isinstance(kw[
'name'],str):
1637 raise ValueError(
"name must be of type string")
1638 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1639 raise ValueError(
"content must be of type vstring or string")
1640 if not isinstance(kw[
'dataTier'], string):
1641 raise ValueError(
"dataTier must be of type string")
1642 if not isinstance(kw[
'selectEvents'], PSet):
1643 raise ValueError(
"selectEvents must be of type PSet")
1644 if not isinstance(kw[
'paths'],(tuple, Path)):
1645 raise ValueError(
"'paths' must be a tuple of paths")
1650 return "FilteredStream object: %s" %self[
"name"]
1655 """Allows embedding another process within a parent process. This allows one to 1656 chain processes together directly in one cmsRun job rather than having to run 1657 separate jobs that are connected via a temporary file. 1659 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1662 if not isinstance(process, Process):
1663 raise ValueError(
"the 'process' argument must be of type cms.Process")
1664 if not isinstance(SelectEvents,PSet):
1665 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1666 if not isinstance(outputCommands,vstring):
1667 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1672 if self.
__process.MessageLogger
is not MessageLogger:
1673 print(
"""Warning: You have reconfigured service 1674 'edm::MessageLogger' in a subprocess. 1675 This service has already been configured. 1676 This particular service may not be reconfigured in a subprocess. 1677 The reconfiguration will be ignored.""")
1680 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1682 out +=
"childProcess = process\n" 1683 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1699 process._placeSubProcess(
'subProcess',self)
1701 topPSet = parameterSet.newPSet()
1703 subProcessPSet = parameterSet.newPSet()
1706 subProcessPSet.addPSet(
False,
"process",topPSet)
1707 return subProcessPSet
1710 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1717 params[k] = getattr(obj,k)
1721 setattr(obj,k,params[k])
1727 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1730 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1736 Modifier._toModifyCheck(obj,func,**kw)
1737 if self._isChosen():
1738 Modifier._toModify(obj,func,**kw)
1741 Modifier._toReplaceWithCheck(toObj,fromObj)
1742 if self._isChosen():
1743 Modifier._toReplaceWith(toObj,fromObj)
1746 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1747 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1748 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1758 """A modifier which only applies if multiple Modifiers are chosen""" 1760 super(_AndModifier,self).
__init__(lhs, rhs)
1765 """A modifier which only applies if a Modifier is not chosen""" 1767 super(_InvertModifier,self).
__init__(lhs)
1772 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1774 super(_OrModifier,self).
__init__(lhs, rhs)
1780 """This class is used to define standard modifications to a Process. 1781 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1782 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1783 these Modifier instances are imported into a configuration and items that need to be modified 1784 are then associated with the Modifier and with the action to do the modification. 1785 The registered modifications will only occur if the Modifier was passed to 1786 the cms.Process' constructor. 1792 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1793 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1794 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1799 if func
is not None and len(kw) != 0:
1800 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1802 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1803 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1804 that will be the object passed in as the first argument. 1805 Form 2: A list of parameter name, value pairs can be passed 1806 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1807 This form can also be used to remove a parameter by passing the value of None 1808 #remove the parameter foo.fred 1809 mod.toModify(foo, fred = None) 1810 Additionally, parameters embedded within PSets can also be modified using a dictionary 1811 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1812 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1814 Modifier._toModifyCheck(obj,func,**kw)
1816 Modifier._toModify(obj,func,**kw)
1820 if func
is not None:
1827 if not isinstance(fromObj, type(toObj)):
1828 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1830 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1832 Modifier._toReplaceWithCheck(toObj,fromObj)
1834 Modifier._toReplaceWith(toObj,fromObj)
1838 if isinstance(fromObj,_ModuleSequenceType):
1839 toObj._seq = fromObj._seq
1840 toObj._tasks = fromObj._tasks
1841 elif isinstance(fromObj,Task):
1842 toObj._collection = fromObj._collection
1843 elif isinstance(fromObj,ConditionalTask):
1844 toObj._collection = fromObj._collection
1845 elif isinstance(fromObj,_Parameterizable):
1847 for p
in toObj.parameterNames_():
1849 for p
in fromObj.parameterNames_():
1850 setattr(toObj,p,getattr(fromObj,p))
1851 if isinstance(fromObj,_TypedParameterizable):
1852 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1855 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1858 """Should only be called by cms.Process instances""" 1869 return self == other
1873 """A Modifier made up of a list of Modifiers 1879 """Should only be called by cms.Process instances 1880 applies list of accumulated changes to the process""" 1882 m._applyNewProcessModifiers(process)
1884 """Should only be called by cms.Process instances""" 1891 """Creates a new ModifierChain which is a copy of 1892 this ModifierChain but excludes any Modifier or 1893 ModifierChain in the list toExclude. 1894 The exclusion is done recursively down the chain. 1898 if m
not in toExclude:
1900 if isinstance(m,ModifierChain):
1901 s = m.__copyIfExclude(toExclude)
1917 if m._isOrContains(other):
1922 """A class used by a Modifier to affect an entire Process instance. 1923 When a Process 'loads' a module containing a ProcessModifier, that 1924 ProcessModifier will be applied to the Process if and only if the 1925 Modifier passed to the constructor has been chosen. 1938 """A class used to specify possible compute accelerators in a Process 1939 instance. It is intended to be derived for any 1940 accelerator/portability technology, and provides hooks such that a 1941 specific customization can be applied to the Process on a worker 1942 node at the point where the python configuration is serialized for C++. 1944 The customization must not change the configuration hash. To 1945 enforce this reuirement, the customization gets a 1946 ProcessForProcessAccelerator wrapper that gives access to only 1947 those parts of the configuration that can be changed. Nevertheless 1948 it would be good to have specific unit test for each deriving 1949 class to ensure that all combinations of the enabled accelerators 1950 give the same configuration hash. 1955 proc._placeAccelerator(self.type_(), self)
1957 return type(self).__name__
1959 specialImportRegistry.registerUse(self)
1960 result = self.__class__.__name__+
"(" 1965 result +=
"\n"+res+
"\n" 1971 """Override if need to add any 'body' content to dumpPython(). Returns a string.""" 1974 """Override to return a list of strings for the accelerator labels.""" 1977 """Override to return a list of strings for the accelerator labels 1978 that are enabled in the system the job is being run on.""" 1981 """Override if need to customize the Process at worker node. The 1982 selected available accelerator labels are given in the 1983 'accelerators' argument (the patterns, e.g. '*' have been 1984 expanded to concrete labels). 1986 This function may touch only untracked parameters. 1991 """This class is inteded to wrap the Process object to constrain the 1992 available functionality for ProcessAccelerator.apply()""" 1997 if not isinstance(value, Service):
1998 raise TypeError(
"ProcessAccelerator.apply() can get only Services. Tried to get {} with label {}".
format(
str(type(value)), label))
2001 if label ==
"_ProcessForProcessAccelerator__process":
2004 if not isinstance(value, Service):
2005 raise TypeError(
"ProcessAccelerator.apply() can only set Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2008 if not isinstance(value, Service):
2009 raise TypeError(
"ProcessAccelerator.apply() can only add Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2015 return (
"test1" in accelerators, -10)
2017 return (
"test2" in accelerators, -9)
2019 if __name__==
"__main__":
2024 newString = ( x
for x
in newString.split(
'\n')
if len(x) > 0)
2025 oldString = [ x
for x
in oldString.split(
'\n')
if len(x) > 0]
2029 if oldStringLine >= len(oldString):
2032 if l == oldString[oldStringLine]:
2036 return "\n".
join( diff )
2039 """Has same interface as the C++ object that creates PSets 2044 self.
values[label]=(tracked,value)
2046 pair = self.
values[label]
2047 if pair[0] != tracked:
2048 raise Exception(
"Asked for %s parameter '%s', but it is %s" % (
"tracked" if tracked
else "untracked",
2050 "tracked" if pair[0]
else "untracked"))
2111 super(SwitchProducerTest,self).
__init__(
2113 test1 =
lambda accelerators: (
True, -10),
2114 test2 =
lambda accelerators: (
True, -9),
2115 test3 =
lambda accelerators: (
True, -8),
2116 test4 =
lambda accelerators: (
True, -7)
2118 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest,
"from test import SwitchProducerTest")
2122 super(SwitchProducerTest2,self).
__init__(
2124 test1 = _switchproducer_test2_case1,
2125 test2 = _switchproducer_test2_case2,
2127 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest2,
"from test import SwitchProducerTest2")
2130 def __init__(self, enabled=["test1", "test2", "anothertest3"]):
2131 super(ProcessAcceleratorTest,self).
__init__()
2135 invalid = set(enabled).difference(set(self.
_labels))
2136 if len(invalid) > 0:
2137 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2140 result =
"{}enabled = [{}]".
format(options.indentation(),
2148 process.AcceleratorTestService =
Service(
"AcceleratorTestService")
2149 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest,
"from test import ProcessAcceleratorTest")
2152 def __init__(self, enabled=["anothertest3", "anothertest4"]):
2153 super(ProcessAcceleratorTest2,self).
__init__()
2157 invalid = set(enabled).difference(set(self.
_labels))
2158 if len(invalid) > 0:
2159 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2162 result =
"{}enabled = [{}]".
format(options.indentation(),
2171 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest2,
"from test import ProcessAcceleratorTest2")
2175 """Nothing to do """ 2179 self.assertEqual(len(p.parameterNames_()),0)
2181 self.assertTrue(
'a' in p.parameterNames_())
2182 self.assertEqual(p.a.value(), 1)
2184 self.assertEqual(p.a.value(), 10)
2186 self.assertEqual(p.a.value(), 1)
2187 self.assertFalse(p.a.isTracked())
2188 p.a = untracked.int32(1)
2189 self.assertEqual(p.a.value(), 1)
2190 self.assertFalse(p.a.isTracked())
2192 self.assertEqual(p.foo.value(), 10)
2193 self.assertEqual(p.bar.value(),1.0)
2194 self.assertFalse(p.bar.isTracked())
2195 self.assertRaises(TypeError,setattr,(p,
'c',1))
2197 self.assertEqual(p.a.foo.value(),10)
2198 self.assertEqual(p.a.bar.value(),1.0)
2200 self.assertEqual(p.b.fii.value(),1)
2201 self.assertFalse(p.b.isTracked())
2206 self.assertEqual(p.a.value(),11)
2208 self.assertEqual(p.a.value(),12)
2209 self.assertEqual(v.value(),12)
2215 self.assertNotEqual(p.b,other.b)
2220 self.assertTrue(
'a' in p.analyzers_() )
2221 self.assertTrue(
'a' in p.analyzers)
2222 p.add_(
Service(
"SomeService"))
2223 self.assertTrue(
'SomeService' in p.services_())
2224 self.assertEqual(p.SomeService.type_(),
"SomeService")
2226 self.assertTrue(
'Tracer' in p.services_())
2227 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
2228 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
2229 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
2231 self.assertEqual(p.out.type_(),
'Outer')
2232 self.assertTrue(
'out' in p.outputModules_() )
2235 self.assertTrue(
'geom' in p.es_sources_())
2237 self.assertTrue(
'ConfigDB' in p.es_sources_())
2240 self.assertTrue(
'aliasfoo1' in p.aliases_())
2245 for name
in args.keys():
2246 self.__dict__[name]=args[name]
2265 self.assertEqual(p.a.type_(),
"MyAnalyzer")
2266 self.assertEqual(p.a.label_(),
"a")
2267 self.assertRaises(AttributeError,getattr,p,
'b')
2268 self.assertEqual(p.Full.type_(),
"Full")
2269 self.assertEqual(
str(p.c),
'a')
2270 self.assertEqual(
str(p.d),
'a')
2285 self.assertRaises(ValueError, p1.extend, z1)
2294 aaa=copy.deepcopy(a),
2295 s4=copy.deepcopy(s3),
2302 self.assertEqual(p2.s4.label_(),
"s4")
2304 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
2305 p2.s4.setLabel(
"s4")
2306 p2.s4.setLabel(
None)
2307 p2.s4.setLabel(
"foo")
2308 p2._Process__setObjectLabel(p2.s4,
"foo")
2309 p2._Process__setObjectLabel(p2.s4,
None)
2310 p2._Process__setObjectLabel(p2.s4,
"bar")
2317 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2318 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2319 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2325 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2326 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2327 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2333 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2334 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2335 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2339 """import FWCore.ParameterSet.Config as cms 2341 process = cms.Process("test") 2343 process.maxEvents = cms.untracked.PSet( 2344 input = cms.optional.untracked.int32, 2345 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 2348 process.maxLuminosityBlocks = cms.untracked.PSet( 2349 input = cms.untracked.int32(-1) 2352 process.options = cms.untracked.PSet( 2353 FailPath = cms.untracked.vstring(), 2354 IgnoreCompletely = cms.untracked.vstring(), 2355 Rethrow = cms.untracked.vstring(), 2356 SkipEvent = cms.untracked.vstring(), 2357 accelerators = cms.untracked.vstring('*'), 2358 allowUnscheduled = cms.obsolete.untracked.bool, 2359 canDeleteEarly = cms.untracked.vstring(), 2360 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 2361 dumpOptions = cms.untracked.bool(False), 2362 emptyRunLumiMode = cms.obsolete.untracked.string, 2363 eventSetup = cms.untracked.PSet( 2364 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 2365 allowAnyLabel_=cms.required.untracked.uint32 2367 numberOfConcurrentIOVs = cms.untracked.uint32(0) 2369 fileMode = cms.untracked.string('FULLMERGE'), 2370 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 2371 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 2372 makeTriggerResults = cms.obsolete.untracked.bool, 2373 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 2374 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 2375 numberOfConcurrentRuns = cms.untracked.uint32(1), 2376 numberOfStreams = cms.untracked.uint32(0), 2377 numberOfThreads = cms.untracked.uint32(1), 2378 printDependencies = cms.untracked.bool(False), 2379 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 2380 throwIfIllegalParameter = cms.untracked.bool(True), 2381 wantSummary = cms.untracked.bool(False) 2384 process.MessageLogger = cms.Service("MessageLogger", 2385 cerr = cms.untracked.PSet( 2386 FwkReport = cms.untracked.PSet( 2387 limit = cms.untracked.int32(10000000), 2388 reportEvery = cms.untracked.int32(1) 2390 FwkSummary = cms.untracked.PSet( 2391 limit = cms.untracked.int32(10000000), 2392 reportEvery = cms.untracked.int32(1) 2394 INFO = cms.untracked.PSet( 2395 limit = cms.untracked.int32(0) 2397 Root_NoDictionary = cms.untracked.PSet( 2398 limit = cms.untracked.int32(0) 2400 default = cms.untracked.PSet( 2401 limit = cms.untracked.int32(10000000) 2403 enable = cms.untracked.bool(True), 2404 enableStatistics = cms.untracked.bool(False), 2405 lineLength = cms.optional.untracked.int32, 2406 noLineBreaks = cms.optional.untracked.bool, 2407 noTimeStamps = cms.untracked.bool(False), 2408 resetStatistics = cms.untracked.bool(False), 2409 statisticsThreshold = cms.untracked.string('WARNING'), 2410 threshold = cms.untracked.string('INFO'), 2411 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2412 limit = cms.optional.untracked.int32, 2413 reportEvery = cms.untracked.int32(1), 2414 timespan = cms.optional.untracked.int32 2417 cout = cms.untracked.PSet( 2418 enable = cms.untracked.bool(False), 2419 enableStatistics = cms.untracked.bool(False), 2420 lineLength = cms.optional.untracked.int32, 2421 noLineBreaks = cms.optional.untracked.bool, 2422 noTimeStamps = cms.optional.untracked.bool, 2423 resetStatistics = cms.untracked.bool(False), 2424 statisticsThreshold = cms.optional.untracked.string, 2425 threshold = cms.optional.untracked.string, 2426 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2427 limit = cms.optional.untracked.int32, 2428 reportEvery = cms.untracked.int32(1), 2429 timespan = cms.optional.untracked.int32 2432 debugModules = cms.untracked.vstring(), 2433 default = cms.untracked.PSet( 2434 limit = cms.optional.untracked.int32, 2435 lineLength = cms.untracked.int32(80), 2436 noLineBreaks = cms.untracked.bool(False), 2437 noTimeStamps = cms.untracked.bool(False), 2438 reportEvery = cms.untracked.int32(1), 2439 statisticsThreshold = cms.untracked.string('INFO'), 2440 threshold = cms.untracked.string('INFO'), 2441 timespan = cms.optional.untracked.int32, 2442 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2443 limit = cms.optional.untracked.int32, 2444 reportEvery = cms.untracked.int32(1), 2445 timespan = cms.optional.untracked.int32 2448 files = cms.untracked.PSet( 2449 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2450 enableStatistics = cms.untracked.bool(False), 2451 extension = cms.optional.untracked.string, 2452 filename = cms.optional.untracked.string, 2453 lineLength = cms.optional.untracked.int32, 2454 noLineBreaks = cms.optional.untracked.bool, 2455 noTimeStamps = cms.optional.untracked.bool, 2456 output = cms.optional.untracked.string, 2457 resetStatistics = cms.untracked.bool(False), 2458 statisticsThreshold = cms.optional.untracked.string, 2459 threshold = cms.optional.untracked.string, 2460 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2461 limit = cms.optional.untracked.int32, 2462 reportEvery = cms.untracked.int32(1), 2463 timespan = cms.optional.untracked.int32 2467 suppressDebug = cms.untracked.vstring(), 2468 suppressFwkInfo = cms.untracked.vstring(), 2469 suppressInfo = cms.untracked.vstring(), 2470 suppressWarning = cms.untracked.vstring(), 2471 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2472 limit = cms.optional.untracked.int32, 2473 reportEvery = cms.untracked.int32(1), 2474 timespan = cms.optional.untracked.int32 2489 """process.a = cms.EDAnalyzer("MyAnalyzer") 2490 process.s = cms.Sequence(process.a) 2491 process.r = cms.Sequence(process.s) 2492 process.p = cms.Path(process.a) 2493 process.p2 = cms.Path(process.s) 2494 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2506 """process.a = cms.EDAnalyzer("MyAnalyzer") 2507 process.b = cms.EDAnalyzer("YourAnalyzer") 2508 process.r = cms.Sequence(process.a) 2509 process.s = cms.Sequence(process.r) 2510 process.p = cms.Path(process.a) 2511 process.p2 = cms.Path(process.r) 2512 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2523 """process.a = cms.EDAnalyzer("MyAnalyzer") 2524 process.r = cms.Sequence((process.a)) 2525 process.p = cms.Path(process.a) 2526 process.p2 = cms.Path(process.r) 2527 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2543 p.task3.add(p.task1)
2547 p.p2 =
Path(p.r, p.task1, p.task2)
2548 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2551 """process.b = cms.EDProducer("bProducer") 2552 process.c = cms.EDProducer("cProducer") 2553 process.d = cms.EDProducer("dProducer") 2554 process.e = cms.EDProducer("eProducer") 2555 process.f = cms.EDProducer("fProducer") 2556 process.g = cms.EDProducer("gProducer") 2557 process.a = cms.EDAnalyzer("MyAnalyzer") 2558 process.task5 = cms.Task() 2559 process.task1 = cms.Task(process.task5) 2560 process.task3 = cms.Task(process.task1) 2561 process.task2 = cms.Task(process.c, process.task3) 2562 process.task4 = cms.Task(process.f, process.task2) 2563 process.r = cms.Sequence((process.a)) 2564 process.p = cms.Path(process.a) 2565 process.p2 = cms.Path(process.r, process.task1, process.task2) 2566 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2583 p.p2 =
Path(p.r, p.task1, p.task2)
2584 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task5])
2587 """process.b = cms.EDProducer("bProducer") 2588 process.c = cms.EDProducer("cProducer") 2589 process.d = cms.EDProducer("dProducer") 2590 process.e = cms.EDProducer("eProducer") 2591 process.f = cms.EDProducer("fProducer") 2592 process.g = cms.EDProducer("gProducer") 2593 process.a = cms.EDAnalyzer("MyAnalyzer") 2594 process.task5 = cms.Task() 2595 process.task3 = cms.Task() 2596 process.task2 = cms.ConditionalTask(process.c, process.task3) 2597 process.task1 = cms.ConditionalTask(process.task5) 2598 process.r = cms.Sequence((process.a)) 2599 process.p = cms.Path(process.a) 2600 process.p2 = cms.Path(process.r, process.task1, process.task2) 2601 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task5])""")
2608 p.task1 =
Task(p.d, p.e)
2609 task2 =
Task(p.f, p.g)
2610 p.schedule =
Schedule(tasks=[p.task1,task2])
2613 """process.d = cms.EDProducer("dProducer") 2614 process.e = cms.EDProducer("eProducer") 2615 process.f = cms.EDProducer("fProducer") 2616 process.g = cms.EDProducer("gProducer") 2617 process.task1 = cms.Task(process.d, process.e) 2618 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2624 """process.schedule = cms.Schedule()""")
2633 d=process.dumpPython()
2635 """process.a = cms.EDProducer("A") 2636 process.s2 = cms.Sequence(process.a)""")
2646 d=process.dumpPython()
2648 """process.a = cms.EDProducer("A") 2649 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2675 p.p =
Path(p.c+s+p.a)
2676 p.p2 =
Path(p.c+p.s4+p.a, p.ct1)
2682 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2684 p.globalReplace(
"a",new)
2685 p.globalReplace(
"d",new2)
2688 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2689 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2691 p.p2.visit(visitor_p2)
2692 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2693 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a, process.ct1)")
2695 p.e3.visit(visitor3)
2696 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2698 p.s4.visit(visitor4)
2699 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2700 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d), process.ct1)")
2702 p.t1.visit(visitor5)
2703 self.assertTrue(visitor5.modules == set([new2]))
2705 listOfTasks = list(p.schedule._tasks)
2706 listOfTasks[0].visit(visitor6)
2707 self.assertTrue(visitor6.modules == set([new2]))
2709 p.ct1.visit(visitor7)
2710 self.assertTrue(visitor7.modules == set([new2]))
2712 listOfConditionalTasks = list(p.conditionaltasks.values())
2713 listOfConditionalTasks[0].visit(visitor8)
2714 self.assertTrue(visitor8.modules == set([new2]))
2718 p.schedule =
Schedule(p.p, p.p2, p.e3, tasks=[p.t1])
2719 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2721 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2723 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2725 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2733 self.assertEqual(
str(p.s),
'a+b')
2734 self.assertEqual(p.s.label_(),
's')
2735 path =
Path(p.c+p.s)
2736 self.assertEqual(
str(path),
'c+a+b')
2737 p._validateSequence(path,
'p1')
2739 p2 =
Path(p.c+p.s*notInProcess)
2740 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2750 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2754 self.assertFalse(service._inProcess)
2757 self.assertTrue(service._inProcess)
2759 process.d = service2
2760 self.assertFalse(service._inProcess)
2761 self.assertTrue(service2._inProcess)
2763 self.assertFalse(service2._inProcess)
2777 service3 =
Service(
"d", v = untracked.uint32(3))
2783 testTask1 =
Task(edproducer, edfilter)
2784 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2785 testTask1.add(essource, service)
2786 testTask1.add(essource, esproducer)
2787 testTask1.add(testTask2)
2788 coll = testTask1._collection
2789 self.assertTrue(edproducer
in coll)
2790 self.assertTrue(edfilter
in coll)
2791 self.assertTrue(service
in coll)
2792 self.assertTrue(essource
in coll)
2793 self.assertTrue(esproducer
in coll)
2794 self.assertTrue(testTask2
in coll)
2795 self.assertTrue(len(coll) == 6)
2796 self.assertTrue(len(testTask2._collection) == 0)
2800 taskContents.append(i)
2801 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2806 process.mproducer = edproducer
2807 process.mproducer2 = edproducer2
2808 process.mfilter = edfilter
2809 process.messource = essource
2810 process.mesproducer = esproducer
2813 testTask3 =
Task(edproducer, edproducer2)
2814 testTask1.add(testTask3)
2815 process.myTask1 = testTask1
2822 testTask1.visit(visitor)
2823 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2824 l2 = testTask1.moduleNames
2825 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2827 testTask4 =
Task(edproducer3)
2829 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2831 process.myTask4 = testTask4
2832 self.assertTrue(
False)
2833 except RuntimeError:
2836 testTask5 =
Task(service3)
2838 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2840 process.myTask5 = testTask5
2841 self.assertTrue(
False)
2842 except RuntimeError:
2845 process.d = service3
2846 process.myTask5 = testTask5
2849 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2851 self.assertTrue(process.tasks == expectedFixedDict)
2852 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2853 self.assertTrue(process.myTask1 == testTask1)
2857 process.mproducer2 = edproducer4
2861 testTask1.visit(visitor1)
2862 l.sort(key=
lambda mod: mod.__str__())
2863 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2864 self.assertTrue(expectedList == l)
2865 process.myTask6 =
Task()
2866 process.myTask7 =
Task()
2867 process.mproducer8 = edproducer8
2868 process.myTask8 =
Task(process.mproducer8)
2869 process.myTask6.add(process.myTask7)
2870 process.myTask7.add(process.myTask8)
2871 process.myTask1.add(process.myTask6)
2872 process.myTask8.add(process.myTask5)
2874 testDict = process._itemsInDependencyOrder(process.tasks)
2875 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2876 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2878 for testLabel, testTask
in testDict.items():
2879 self.assertTrue(testLabel == expectedLabels[index])
2880 self.assertTrue(testTask == expectedTasks[index])
2886 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2887 self.assertTrue(pythonDump == expectedPythonDump)
2889 process.myTask5 =
Task()
2890 process.myTask100 =
Task()
2891 process.mproducer9 = edproducer9
2892 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2893 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2894 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2896 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2897 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2898 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2899 process.path2 =
Path(process.mproducer)
2900 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2902 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')
2904 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')
2909 process.path1.visit(nameVisitor)
2910 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2911 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2915 process.path21 = process.path11.copy()
2916 process.path21.replace(process.mproducer, process.mproducer10)
2918 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')
2927 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.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2929 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2930 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.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2932 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2933 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.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2942 process.path24 =
Path(process.a+process.b+process.c+process.d)
2943 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2944 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
2949 process.path200.replace(process.c,process.b)
2950 process.path200.replace(process.e,process.f)
2951 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2952 process.path200.replace(process.b,process.c)
2953 process.path200.replace(process.f,process.e)
2954 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2955 process.path200.replace(process.c,process.a)
2956 process.path200.replace(process.e,process.g)
2957 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2958 process.path200.replace(process.a,process.c)
2959 process.path200.replace(process.g,process.e)
2960 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2974 service3 =
Service(
"d", v = untracked.uint32(3))
2982 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2983 testTask1.add(essource, service)
2984 testTask1.add(essource, esproducer)
2985 testTask1.add(testTask2)
2986 testTask1.add(testCTask2)
2987 coll = testTask1._collection
2988 self.assertTrue(edproducer
in coll)
2989 self.assertTrue(edfilter
in coll)
2990 self.assertTrue(service
in coll)
2991 self.assertTrue(essource
in coll)
2992 self.assertTrue(esproducer
in coll)
2993 self.assertTrue(testTask2
in coll)
2994 self.assertTrue(testCTask2
in coll)
2995 self.assertTrue(len(coll) == 7)
2996 self.assertTrue(len(testTask2._collection) == 0)
3000 taskContents.append(i)
3001 self.assertEqual(taskContents, [edproducer, edfilter, essource, service, esproducer, testTask2, testCTask2])
3006 process.mproducer = edproducer
3007 process.mproducer2 = edproducer2
3008 process.mfilter = edfilter
3009 process.messource = essource
3010 process.mesproducer = esproducer
3014 testTask1.add(testTask3)
3015 process.myTask1 = testTask1
3022 testTask1.visit(visitor)
3023 self.assertEqual(l, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3024 l2 = testTask1.moduleNames()
3025 self.assertEqual(l2, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3029 self.assertRaises(RuntimeError, testTask4.visit, visitor)
3031 process.myTask4 = testTask4
3032 self.assertTrue(
False)
3033 except RuntimeError:
3038 self.assertRaises(RuntimeError, testTask5.visit, visitor)
3040 process.myTask5 = testTask5
3041 self.assertTrue(
False)
3042 except RuntimeError:
3045 process.d = service3
3046 process.myTask5 = testTask5
3049 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
3051 self.assertEqual(process.conditionaltasks, expectedFixedDict)
3052 self.assertEqual(process.conditionaltasks[
'myTask1'], testTask1)
3053 self.assertEqual(process.myTask1, testTask1)
3057 process.mproducer2 = edproducer4
3061 testTask1.visit(visitor1)
3062 l.sort(key=
lambda mod: mod.__str__())
3063 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
3064 self.assertEqual(expectedList, l)
3067 process.mproducer8 = edproducer8
3069 process.myTask6.add(process.myTask7)
3070 process.myTask7.add(process.myTask8)
3071 process.myTask1.add(process.myTask6)
3072 process.myTask8.add(process.myTask5)
3073 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3075 testDict = process._itemsInDependencyOrder(process.conditionaltasks)
3076 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
3077 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
3079 for testLabel, testTask
in testDict.items():
3080 self.assertEqual(testLabel, expectedLabels[index])
3081 self.assertEqual(testTask, expectedTasks[index])
3087 expectedPythonDump =
'cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 3088 self.assertEqual(pythonDump, expectedPythonDump)
3091 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3093 process.mproducer9 = edproducer9
3094 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3095 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3096 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3098 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3099 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3100 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3101 process.path2 =
Path(process.mproducer)
3102 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3104 self.assertEqual(process.path1.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)\n')
3106 self.assertEqual(process.path11.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3111 process.path1.visit(nameVisitor)
3112 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3113 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3117 process.path21 = process.path11.copy()
3118 process.path21.replace(process.mproducer, process.mproducer10)
3120 self.assertEqual(process.path11.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3129 self.assertEqual(process.path21.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3131 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3132 self.assertEqual(process.path22.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3134 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3135 self.assertEqual(process.path23.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None), cms.ConditionalTask(process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3144 process.fillProcessDesc(p)
3145 self.assertEqual(p.values[
"@all_modules"], (
True, [
'b',
'b2',
'b3']))
3146 self.assertEqual(p.values[
"@paths"], (
True, [
'p']))
3147 self.assertEqual(p.values[
"p"], (
True, [
'b',
'#',
'b2',
'b3',
'@']))
3158 self.assertEqual(
str(path),
'a+b+c')
3159 path =
Path(p.a*p.b+p.c)
3160 self.assertEqual(
str(path),
'a+b+c')
3163 path =
Path(p.a+ p.b*p.c)
3164 self.assertEqual(
str(path),
'a+b+c')
3165 path =
Path(p.a*(p.b+p.c))
3166 self.assertEqual(
str(path),
'a+b+c')
3167 path =
Path(p.a*(p.b+~p.c))
3169 self.assertEqual(
str(path),
'a+b+~c')
3171 self.assertRaises(TypeError,Path,p.es)
3174 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path()\n')
3177 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a)\n')
3180 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.Task())\n')
3183 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task())\n')
3188 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3191 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.ConditionalTask())\n')
3194 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.ConditionalTask())\n')
3199 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3209 self.assertEqual(
str(path),
'a+b+c')
3211 self.assertEqual(
str(path),
'a+b+c')
3213 self.assertEqual(
str(path),
'a+b+c')
3215 self.assertEqual(
str(path),
'a+b+c')
3217 self.assertRaises(TypeError,FinalPath,p.es)
3220 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath()\n')
3223 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3225 self.assertRaises(TypeError, FinalPath,
Task())
3226 self.assertRaises(TypeError, FinalPath, p.a,
Task())
3230 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
Task(), p.t1)
3234 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
ConditionalTask(), p.t1)
3238 self.assertEqual(p.t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3249 p.path =
Path(p.a*p.b)
3250 lookuptable = {
id(a): p.a,
id(b): p.b}
3254 self.assertEqual(
str(path),
str(p.path))
3276 path =
Path(a * c * seq1, task1, ctask1)
3278 self.assertTrue(path.contains(a))
3279 self.assertFalse(path.contains(b))
3280 self.assertTrue(path.contains(c))
3281 self.assertFalse(path.contains(d))
3282 self.assertTrue(path.contains(e))
3283 self.assertFalse(path.contains(f))
3284 self.assertTrue(path.contains(g))
3285 self.assertTrue(path.contains(h))
3288 self.assertFalse(endpath.contains(b))
3289 self.assertTrue(endpath.contains(i))
3292 self.assertFalse(seq.contains(b))
3293 self.assertTrue(seq.contains(c))
3296 task =
Task(j, k, task2)
3297 self.assertFalse(task.contains(b))
3298 self.assertTrue(task.contains(j))
3299 self.assertTrue(task.contains(k))
3300 self.assertTrue(task.contains(l))
3304 sch =
Schedule(path, path2, tasks=[task,task3])
3305 self.assertFalse(sch.contains(b))
3306 self.assertTrue(sch.contains(a))
3307 self.assertTrue(sch.contains(c))
3308 self.assertTrue(sch.contains(e))
3309 self.assertTrue(sch.contains(g))
3310 self.assertTrue(sch.contains(n))
3311 self.assertTrue(sch.contains(j))
3312 self.assertTrue(sch.contains(k))
3313 self.assertTrue(sch.contains(l))
3314 self.assertTrue(sch.contains(m))
3318 self.assertFalse(ctask.contains(b))
3319 self.assertTrue(ctask.contains(j))
3320 self.assertTrue(ctask.contains(k))
3321 self.assertTrue(ctask.contains(l))
3322 self.assertTrue(ctask.contains(g))
3335 self.assertEqual(s[0],p.path1)
3336 self.assertEqual(s[1],p.path2)
3338 self.assertTrue(
'b' in p.schedule.moduleNames())
3339 self.assertTrue(hasattr(p,
'b'))
3340 self.assertTrue(hasattr(p,
'c'))
3341 self.assertTrue(hasattr(p,
'd'))
3342 self.assertTrue(hasattr(p,
'path1'))
3343 self.assertTrue(hasattr(p,
'path2'))
3344 self.assertTrue(hasattr(p,
'path3'))
3346 self.assertTrue(
'b' in p.schedule.moduleNames())
3347 self.assertTrue(hasattr(p,
'b'))
3348 self.assertTrue(
not hasattr(p,
'c'))
3349 self.assertTrue(
not hasattr(p,
'd'))
3350 self.assertTrue(hasattr(p,
'path1'))
3351 self.assertTrue(hasattr(p,
'path2'))
3352 self.assertTrue(
not hasattr(p,
'path3'))
3354 self.assertTrue(len(p.schedule._tasks) == 0)
3368 p.task2 =
Task(p.f, p.Tracer)
3369 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
3370 self.assertEqual(s[0],p.path1)
3371 self.assertEqual(s[1],p.path2)
3372 self.assertTrue(len(s._tasks) == 2)
3373 self.assertTrue(p.task1
in s._tasks)
3374 self.assertTrue(p.task2
in s._tasks)
3375 listOfTasks = list(s._tasks)
3376 self.assertTrue(len(listOfTasks) == 2)
3377 self.assertTrue(p.task1 == listOfTasks[0])
3378 self.assertTrue(p.task2 == listOfTasks[1])
3380 self.assertTrue(
'b' in p.schedule.moduleNames())
3385 process2.path1 =
Path(process2.a)
3386 process2.task1 =
Task(process2.e)
3387 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
3388 listOfTasks = list(process2.schedule._tasks)
3389 self.assertTrue(listOfTasks[0] == process2.task1)
3393 self.assertEqual(s2[0],p.path1)
3394 self.assertEqual(s2[1],p.path2)
3395 self.assertTrue(len(s2._tasks) == 2)
3396 self.assertTrue(p.task1
in s2._tasks)
3397 self.assertTrue(p.task2
in s2._tasks)
3398 listOfTasks = list(s2._tasks)
3399 self.assertTrue(len(listOfTasks) == 2)
3400 self.assertTrue(p.task1 == listOfTasks[0])
3401 self.assertTrue(p.task2 == listOfTasks[1])
3403 names = s.moduleNames()
3404 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
3410 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
3419 self.assertTrue(
'a' in s.moduleNames())
3420 self.assertTrue(
'b' in s.moduleNames())
3421 self.assertTrue(
'c' in s.moduleNames())
3425 self.assertTrue(
'a' in s.moduleNames())
3426 self.assertTrue(
'b' in s.moduleNames())
3427 self.assertTrue(
'c' in s.moduleNames())
3436 self.assertTrue(p.schedule
is None)
3439 self.assertEqual(pths[keys[0]],p.path1)
3440 self.assertEqual(pths[keys[1]],p.path2)
3442 self.assertTrue(hasattr(p,
'a'))
3443 self.assertTrue(hasattr(p,
'b'))
3444 self.assertTrue(
not hasattr(p,
'c'))
3445 self.assertTrue(hasattr(p,
'path1'))
3446 self.assertTrue(hasattr(p,
'path2'))
3455 self.assertTrue(p.schedule
is None)
3458 self.assertEqual(pths[keys[1]],p.path1)
3459 self.assertEqual(pths[keys[0]],p.path2)
3466 self.assertEqual(p.modu.a.value(),1)
3467 self.assertEqual(p.modu.b.value(),2)
3472 self.assertTrue(
not a.isModified())
3474 self.assertTrue(a.isModified())
3476 self.assertEqual(p.a.a1.value(), 1)
3480 self.assertEqual(p.a.a1.value(), 2)
3489 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
3490 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
3494 self.assertEqual(p.options.numberOfThreads.value(),1)
3495 p.options.numberOfThreads = 8
3496 self.assertEqual(p.options.numberOfThreads.value(),8)
3498 self.assertEqual(p.options.numberOfThreads.value(),1)
3499 p.options = dict(numberOfStreams =2,
3501 self.assertEqual(p.options.numberOfThreads.value(),2)
3502 self.assertEqual(p.options.numberOfStreams.value(),2)
3506 p.maxEvents.input = 10
3507 self.assertEqual(p.maxEvents.input.value(),10)
3509 p.maxEvents.output = 10
3510 self.assertEqual(p.maxEvents.output.value(),10)
3512 p.maxEvents.output =
PSet(out=untracked.int32(10))
3513 self.assertEqual(p.maxEvents.output.out.value(), 10)
3515 p.maxEvents = untracked.PSet(input = untracked.int32(5))
3516 self.assertEqual(p.maxEvents.input.value(), 5)
3525 p.bars.foos =
'Foosball' 3526 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
3527 p.p =
Path(p.foos*p.bars)
3529 p.add_(
Service(
"MessageLogger"))
3535 p.prefer(
"ForceSource")
3538 """process.juicer = cms.ESProducer("JuicerProducer") 3539 process.ForceSource = cms.ESSource("ForceSource") 3540 process.prefer("ForceSource") 3541 process.prefer("juicer")""")
3542 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
3544 """process.juicer = cms.ESProducer("JuicerProducer") 3545 process.ForceSource = cms.ESSource("ForceSource") 3546 process.prefer("ForceSource") 3547 process.prefer("juicer", 3548 fooRcd = cms.vstring('Foo') 3563 self.assertEqual(process.m.p.i.value(), 4)
3573 subProcess.p =
Path(subProcess.a)
3574 subProcess.add_(
Service(
"Foo"))
3575 process.addSubProcess(
SubProcess(subProcess))
3576 d = process.dumpPython()
3577 equalD =
"""parentProcess = process 3578 process.a = cms.EDProducer("A") 3579 process.Foo = cms.Service("Foo") 3580 process.p = cms.Path(process.a) 3581 childProcess = process 3582 process = parentProcess 3583 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 3584 ), outputCommands = cms.untracked.vstring()))""" 3585 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
3593 messageLoggerSplit =
'process.MessageLogger = cms.Service' 3595 childProcess =
Process(
'Child')
3596 del childProcess.MessageLogger
3597 combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
3598 self.assertEqual(
_lineDiff(d, combinedDump), equalD)
3600 process.fillProcessDesc(p)
3601 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
3602 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
3603 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
3613 proc.fillProcessDesc(p)
3614 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
3615 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
3616 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
3617 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
3618 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
3619 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
3628 self.assertEqual(proc.sp.label_(),
"sp")
3629 self.assertEqual(proc.sp.test1.label_(),
"sp@test1")
3630 self.assertEqual(proc.sp.test2.label_(),
"sp@test2")
3633 proc.s =
Sequence(proc.a + proc.sp)
3634 proc.t =
Task(proc.a, proc.sp)
3636 proc.p.associate(proc.t)
3638 proc.fillProcessDesc(p)
3639 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3640 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3641 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3642 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3644 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3645 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3646 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
3647 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3648 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
3649 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3650 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3651 dump = proc.dumpPython()
3652 self.assertEqual(dump.find(
'@'), -1)
3653 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
3654 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
3663 proc.s =
Sequence(proc.a + proc.sp)
3664 proc.t =
Task(proc.a, proc.sp)
3666 proc.p.associate(proc.t)
3668 proc.fillProcessDesc(p)
3669 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3670 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3671 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3672 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3674 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3675 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3676 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
3677 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
3678 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3679 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3680 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3681 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
3690 proc.s =
Sequence(proc.a + proc.sp)
3691 proc.t =
Task(proc.a, proc.sp)
3693 proc.p.associate(proc.t)
3695 proc.fillProcessDesc(p)
3696 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3697 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3698 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3699 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
3700 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3701 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
3702 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
3703 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3704 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
3705 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3706 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
3717 proc.spp = proc.spct.clone()
3720 proc.p =
Path(proc.a, proc.ct)
3721 proc.pp =
Path(proc.a + proc.spp)
3723 proc.fillProcessDesc(p)
3724 self.assertEqual([
"a",
"spct",
"spct@test1",
"spct@test2",
"spp",
"spp@test1",
"spp@test2"], p.values[
"@all_modules"][1])
3725 self.assertEqual([
"a",
"#",
"spct",
"spct@test1",
"spct@test2",
"@"], p.values[
"p"][1])
3726 self.assertEqual([
"a",
"spp",
"#",
"spp@test1",
"spp@test2",
"@"], p.values[
"pp"][1])
3741 p.t3 =
Task(p.g, p.t1)
3745 p.path1 =
Path(p.a, p.t3, p.ct3)
3747 self.assertTrue(p.schedule
is None)
3750 self.assertEqual(pths[keys[0]],p.path1)
3751 self.assertEqual(pths[keys[1]],p.path2)
3753 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
3755 p.vpset2 = untracked.VPSet()
3757 self.assertTrue(hasattr(p,
'a'))
3758 self.assertTrue(hasattr(p,
'b'))
3759 self.assertTrue(
not hasattr(p,
'c'))
3760 self.assertTrue(
not hasattr(p,
'd'))
3761 self.assertTrue(hasattr(p,
'e'))
3762 self.assertTrue(
not hasattr(p,
'f'))
3763 self.assertTrue(hasattr(p,
'g'))
3764 self.assertTrue(hasattr(p,
'h'))
3765 self.assertTrue(
not hasattr(p,
's'))
3766 self.assertTrue(hasattr(p,
't1'))
3767 self.assertTrue(
not hasattr(p,
't2'))
3768 self.assertTrue(hasattr(p,
't3'))
3769 self.assertTrue(hasattr(p,
'path1'))
3770 self.assertTrue(hasattr(p,
'path2'))
3800 p.path1 =
Path(p.a, p.t3, p.ct3)
3802 p.path3 =
Path(p.b+p.s2)
3803 p.path4 =
Path(p.b+p.s3)
3804 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3805 p.schedule.associate(p.t4)
3808 self.assertEqual(pths[keys[0]],p.path1)
3809 self.assertEqual(pths[keys[1]],p.path2)
3811 self.assertTrue(hasattr(p,
'a'))
3812 self.assertTrue(hasattr(p,
'b'))
3813 self.assertTrue(
not hasattr(p,
'c'))
3814 self.assertTrue(
not hasattr(p,
'd'))
3815 self.assertTrue(
not hasattr(p,
'e'))
3816 self.assertTrue(
not hasattr(p,
'f'))
3817 self.assertTrue(hasattr(p,
'g'))
3818 self.assertTrue(hasattr(p,
'h'))
3819 self.assertTrue(hasattr(p,
'i'))
3820 self.assertTrue(hasattr(p,
'j'))
3821 self.assertTrue(hasattr(p,
'k'))
3822 self.assertTrue(
not hasattr(p,
'l'))
3823 self.assertTrue(
not hasattr(p,
't1'))
3824 self.assertTrue(hasattr(p,
't2'))
3825 self.assertTrue(hasattr(p,
't3'))
3826 self.assertTrue(hasattr(p,
't4'))
3827 self.assertTrue(
not hasattr(p,
'ct1'))
3828 self.assertTrue(hasattr(p,
'ct2'))
3829 self.assertTrue(hasattr(p,
'ct3'))
3830 self.assertTrue(
not hasattr(p,
'ct4'))
3831 self.assertTrue(
not hasattr(p,
's'))
3832 self.assertTrue(hasattr(p,
's2'))
3833 self.assertTrue(
not hasattr(p,
's3'))
3834 self.assertTrue(hasattr(p,
'path1'))
3835 self.assertTrue(hasattr(p,
'path2'))
3836 self.assertTrue(hasattr(p,
'path3'))
3837 self.assertTrue(
not hasattr(p,
'path4'))
3845 self.assertTrue(hasattr(p,
'a'))
3846 self.assertTrue(hasattr(p,
'b'))
3847 self.assertTrue(hasattr(p,
's'))
3848 self.assertTrue(hasattr(p,
'pth'))
3854 p.prune(keepUnresolvedSequencePlaceholders=
True)
3855 self.assertTrue(hasattr(p,
'b'))
3856 self.assertTrue(hasattr(p,
's'))
3857 self.assertTrue(hasattr(p,
'pth'))
3858 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3866 self.assertTrue(hasattr(p,
'a'))
3867 self.assertTrue(hasattr(p,
'b'))
3868 self.assertTrue(hasattr(p,
's'))
3869 self.assertTrue(hasattr(p,
'pth'))
3877 self.assertTrue(hasattr(p,
'a'))
3878 self.assertTrue(hasattr(p,
'b'))
3879 self.assertTrue(hasattr(p,
's'))
3880 self.assertTrue(hasattr(p,
'pth'))
3886 p.prune(keepUnresolvedSequencePlaceholders=
True)
3887 self.assertTrue(hasattr(p,
'b'))
3888 self.assertTrue(hasattr(p,
's'))
3889 self.assertTrue(hasattr(p,
'pth'))
3890 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
3898 p.path1 =
Path(p.b, p.t2, p.t3)
3901 p.endpath1 =
EndPath(p.b, p.t5)
3905 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3915 """process.a = cms.EDProducer("ma") 3916 process.c = cms.EDProducer("mc") 3917 process.d = cms.EDProducer("md") 3918 process.e = cms.EDProducer("me") 3919 process.f = cms.EDProducer("mf") 3920 process.g = cms.EDProducer("mg") 3921 process.h = cms.EDProducer("mh") 3922 process.i = cms.EDProducer("mi") 3923 process.j = cms.EDProducer("mj") 3924 process.b = cms.EDAnalyzer("mb") 3925 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 3926 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 3927 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 3928 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 3929 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 3930 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 3931 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 3932 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 3933 process.path1 = cms.Path(process.b, process.t2, process.t3) 3934 process.endpath1 = cms.EndPath(process.b, process.t5) 3935 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3938 """process.a = cms.EDProducer("ma") 3939 process.c = cms.EDProducer("mc") 3940 process.d = cms.EDProducer("md") 3941 process.e = cms.EDProducer("me") 3942 process.f = cms.EDProducer("mf") 3943 process.g = cms.EDProducer("mg") 3944 process.h = cms.EDProducer("mh") 3945 process.i = cms.EDProducer("mi") 3946 process.j = cms.EDProducer("mj") 3947 process.b = cms.EDAnalyzer("mb") 3948 process.t1 = cms.Task(process.c) 3949 process.t2 = cms.Task(process.a, process.d, process.t1) 3950 process.t3 = cms.Task(process.e) 3951 process.t4 = cms.Task(process.f) 3952 process.t6 = cms.Task(process.h) 3953 process.t7 = cms.Task(process.a, process.i, process.t6) 3954 process.t8 = cms.Task(process.j) 3955 process.t5 = cms.Task(process.a, process.g, process.t4) 3956 process.path1 = cms.Path(process.b, process.t2, process.t3) 3957 process.endpath1 = cms.EndPath(process.b, process.t5) 3958 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3966 p.path1 =
Path(p.b, p.t2, p.t3)
3969 p.path2 =
Path(p.b, p.t5)
3970 p.schedule =
Schedule(p.path1, p.path2)
3980 """process.a = cms.EDProducer("ma") 3981 process.c = cms.EDProducer("mc") 3982 process.d = cms.EDProducer("md") 3983 process.e = cms.EDProducer("me") 3984 process.f = cms.EDProducer("mf") 3985 process.g = cms.EDProducer("mg") 3986 process.h = cms.EDProducer("mh") 3987 process.i = cms.EDProducer("mi") 3988 process.j = cms.EDProducer("mj") 3989 process.b = cms.EDAnalyzer("mb") 3990 process.t1 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("c")) 3991 process.t2 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("d"), process.a, process.t1) 3992 process.t3 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("e")) 3993 process.t5 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("g"), cms.ConditionalTaskPlaceholder("t4"), process.a) 3994 process.t4 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("f")) 3995 process.path1 = cms.Path(process.b, process.t2, process.t3) 3996 process.path2 = cms.Path(process.b, process.t5) 3997 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4000 """process.a = cms.EDProducer("ma") 4001 process.c = cms.EDProducer("mc") 4002 process.d = cms.EDProducer("md") 4003 process.e = cms.EDProducer("me") 4004 process.f = cms.EDProducer("mf") 4005 process.g = cms.EDProducer("mg") 4006 process.h = cms.EDProducer("mh") 4007 process.i = cms.EDProducer("mi") 4008 process.j = cms.EDProducer("mj") 4009 process.b = cms.EDAnalyzer("mb") 4010 process.t1 = cms.ConditionalTask(process.c) 4011 process.t2 = cms.ConditionalTask(process.a, process.d, process.t1) 4012 process.t3 = cms.ConditionalTask(process.e) 4013 process.t4 = cms.ConditionalTask(process.f) 4014 process.t5 = cms.ConditionalTask(process.a, process.g, process.t4) 4015 process.path1 = cms.Path(process.b, process.t2, process.t3) 4016 process.path2 = cms.Path(process.b, process.t5) 4017 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4033 p.t1 =
Task(p.g, p.h, p.i)
4034 t2 =
Task(p.g, p.h, p.i)
4042 p.path1 =
Path(p.a+p.f+p.s,t2,ct2)
4044 p.path3 =
Path(ct3, p.ct4)
4047 p.schedule =
Schedule(p.path2, p.path3, p.endpath2, tasks=[t3, p.t4])
4048 self.assertTrue(hasattr(p,
'f'))
4049 self.assertTrue(hasattr(p,
'g'))
4050 self.assertTrue(hasattr(p,
'i'))
4055 self.assertFalse(hasattr(p,
'f'))
4056 self.assertFalse(hasattr(p,
'g'))
4057 self.assertEqual(p.t1.dumpPython(),
'cms.Task(process.h)\n')
4058 self.assertEqual(p.ct1.dumpPython(),
'cms.ConditionalTask(process.h)\n')
4059 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(process.d)\n')
4060 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+process.s, cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4061 self.assertEqual(p.endpath1.dumpPython(),
'cms.EndPath(process.b)\n')
4062 self.assertEqual(p.path3.dumpPython(),
'cms.Path(cms.ConditionalTask(process.h), process.ct4)\n')
4064 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+(process.d), cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4065 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path2, process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4067 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4069 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4071 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h), process.t4])\n')
4073 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
4076 Process._firstProcess =
True 4078 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4080 Process._firstProcess =
True 4085 m1.toModify(p.a,_mod_fred)
4086 self.assertEqual(p.a.fred.value(),2)
4088 m1.toModify(p.b, wilma = 2)
4089 self.assertEqual(p.b.wilma.value(),2)
4090 self.assertTrue(p.isUsingModifier(m1))
4093 Process._firstProcess =
True 4096 m1.toModify(p.a,_mod_fred)
4098 m1.toModify(p.b, wilma = 2)
4099 self.assertEqual(p.a.fred.value(),1)
4100 self.assertEqual(p.b.wilma.value(),1)
4101 self.assertEqual(p.isUsingModifier(m1),
False)
4104 Process._firstProcess =
True 4107 m1.toModify(p.a, fred =
int32(2))
4108 p.b = p.a.clone(wilma =
int32(3))
4109 self.assertEqual(p.a.fred.value(),2)
4110 self.assertEqual(p.a.wilma.value(),1)
4111 self.assertEqual(p.b.fred.value(),2)
4112 self.assertEqual(p.b.wilma.value(),3)
4115 Process._firstProcess =
True 4118 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4119 self.assertEqual(hasattr(p.a,
"fred"),
False)
4120 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4121 self.assertEqual(p.a.wilma.value(),1)
4124 Process._firstProcess =
True 4127 m1.toModify(p.a, wilma =
int32(2))
4128 self.assertEqual(p.a.fred.value(), 1)
4129 self.assertEqual(p.a.wilma.value(),2)
4132 Process._firstProcess =
True 4135 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
4136 self.assertEqual(p.a.flintstones.fred.value(),2)
4137 self.assertEqual(p.a.flintstones.wilma.value(),1)
4140 Process._firstProcess =
True 4143 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4144 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4147 Process._firstProcess =
True 4150 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
4151 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4152 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4155 Process._firstProcess =
True 4158 m1.toModify(p.a, fred = {1:7})
4159 self.assertEqual(p.a.fred[0],1)
4160 self.assertEqual(p.a.fred[1],7)
4161 self.assertEqual(p.a.fred[2],3)
4164 Process._firstProcess =
True 4168 try: m1.toModify(p.a, fred = {5:7})
4169 except IndexError
as e: raised =
True 4170 self.assertEqual(raised,
True)
4173 Process._firstProcess =
True 4177 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
4178 except TypeError
as e: raised =
True 4179 self.assertEqual(raised,
True)
4183 class ProcModifierMod(
object):
4189 testMod = DummyMod()
4191 self.assertTrue(hasattr(p,
"a"))
4193 Process._firstProcess =
True 4195 testProcMod = ProcModifierMod(m1,_rem_a)
4197 p.extend(testProcMod)
4198 self.assertTrue(
not hasattr(p,
"a"))
4202 Process._firstProcess =
True 4204 self.assertTrue(p.isUsingModifier(m1))
4205 self.assertTrue(p.isUsingModifier(mc))
4206 testMod = DummyMod()
4208 m1.toModify(p.b, fred =
int32(3))
4210 testProcMod = ProcModifierMod(m1,_rem_a)
4211 p.extend(testProcMod)
4212 self.assertTrue(
not hasattr(p,
"a"))
4213 self.assertEqual(p.b.fred.value(),3)
4218 mclone = mc.copyAndExclude([m2])
4219 self.assertTrue(
not mclone._isOrContains(m2))
4220 self.assertTrue(mclone._isOrContains(m1))
4223 mclone = mc2.copyAndExclude([m2])
4224 self.assertTrue(
not mclone._isOrContains(m2))
4225 self.assertTrue(mclone._isOrContains(m1))
4226 self.assertTrue(mclone._isOrContains(m3))
4230 Process._firstProcess =
True 4233 (m1 & m2).toModify(p.a, fred =
int32(2))
4234 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4235 self.assertEqual(p.a.fred, 1)
4238 Process._firstProcess =
True 4241 (m1 & m2).toModify(p.a, fred =
int32(2))
4242 self.assertEqual(p.a.fred, 2)
4246 Process._firstProcess =
True 4249 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
4250 self.assertEqual(p.a.fred, 2)
4251 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
4252 self.assertEqual(p.a.fred, 3)
4253 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
4254 self.assertEqual(p.a.fred, 4)
4258 Process._firstProcess =
True 4261 (~m1).toModify(p.a, fred=2)
4262 self.assertEqual(p.a.fred, 1)
4263 (~m2).toModify(p.a, wilma=2)
4264 self.assertEqual(p.a.wilma, 2)
4265 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4266 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4271 Process._firstProcess =
True 4274 (m1 | m2).toModify(p.a, fred=2)
4275 self.assertEqual(p.a.fred, 2)
4276 (m1 | m2 | m3).toModify(p.a, fred=3)
4277 self.assertEqual(p.a.fred, 3)
4278 (m3 | m2 | m1).toModify(p.a, fred=4)
4279 self.assertEqual(p.a.fred, 4)
4280 ((m1 | m2) | m3).toModify(p.a, fred=5)
4281 self.assertEqual(p.a.fred, 5)
4282 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4283 self.assertEqual(p.a.fred, 6)
4284 (m2 | m3).toModify(p.a, fred=7)
4285 self.assertEqual(p.a.fred, 6)
4286 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4287 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4293 Process._firstProcess =
True 4296 (m1 & ~m2).toModify(p.a, fred=2)
4297 self.assertEqual(p.a.fred, 1)
4298 (m1 & ~m3).toModify(p.a, fred=2)
4299 self.assertEqual(p.a.fred, 2)
4300 (m1 | ~m2).toModify(p.a, fred=3)
4301 self.assertEqual(p.a.fred, 3)
4302 (~m1 | ~m2).toModify(p.a, fred=4)
4303 self.assertEqual(p.a.fred, 3)
4304 (~m3 & ~m4).toModify(p.a, fred=4)
4305 self.assertEqual(p.a.fred, 4)
4306 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4307 self.assertEqual(p.a.fred, 5)
4310 Process._firstProcess =
True 4314 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4322 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4323 self.assertEqual(p.a.wilma.value(),3)
4324 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4325 self.assertEqual(hasattr(p,
"fred"),
False)
4326 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4328 m1.toReplaceWith(p.td,
Task(p.e))
4329 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4339 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4340 self.assertEqual(p.a.wilma.value(),3)
4341 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4342 self.assertEqual(hasattr(p,
"fred"),
False)
4343 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4346 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4349 Process._firstProcess =
True 4353 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4359 Process._firstProcess =
True 4362 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4363 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4364 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4365 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4366 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4367 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4368 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
4369 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4370 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4371 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4372 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4373 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4374 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4375 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4376 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
4377 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4378 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
4379 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4384 Process._firstProcess =
True 4388 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4389 self.assertEqual(p.a.fred, 2)
4390 self.assertEqual(p.a.wilma, 1)
4391 self.assertEqual(p.b.barney, 1)
4392 self.assertEqual(p.b.betty, 3)
4393 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4394 self.assertEqual(p.a.fred, 2)
4395 self.assertEqual(p.a.wilma, 4)
4396 self.assertEqual(p.b.barney, 5)
4397 self.assertEqual(p.b.betty, 3)
4398 (m2 & ~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4399 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4400 self.assertEqual(p.b.barney, 6)
4401 self.assertEqual(p.b.betty, 3)
4402 (m1 & ~m3).toModify(p.a, param=
int32(42)).toReplaceWith(p.b,
EDProducer(
"YourProducer"))
4403 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4404 self.assertEqual(p.a.param, 42)
4405 self.assertEqual(p.b.type_(),
"YourProducer")
4412 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4413 self.assertEqual(a.foo2[0].type,
"Foo3")
4416 self.assertEqual(a.foo2[0].type,
"Foo3")
4417 self.assertEqual(a.foo4[0].type,
"Foo4")
4419 m.toModify(a, foo2 =
None)
4420 self.assertFalse(hasattr(a,
"foo2"))
4421 self.assertEqual(a.foo4[0].type,
"Foo4")
4424 self.assertFalse(hasattr(a,
"foo2"))
4425 self.assertFalse(hasattr(a,
"foo4"))
4426 self.assertTrue(hasattr(a,
"bar"))
4427 self.assertEqual(a.bar[0].type,
"Bar")
4440 test1 = dict(a = 4, b = dict(c =
None)),
4441 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4442 self.assertEqual(sp.test1.a.value(), 4)
4443 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4444 self.assertEqual(sp.test2.aa.value(), 15)
4445 self.assertEqual(sp.test2.bb.cc.value(), 45)
4446 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4449 self.assertEqual(sp.test1.type_(),
"Fred")
4450 self.assertEqual(sp.test1.x.value(), 42)
4451 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
4454 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4455 self.assertEqual(sp.test2.x.value(), 24)
4456 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
4459 self.assertEqual(sp.test3.type_(),
"Wilma")
4460 self.assertEqual(sp.test3.y.value(), 24)
4461 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
4463 m.toModify(sp, test2 =
None)
4464 self.assertEqual(hasattr(sp,
"test2"),
False)
4467 self.assertTrue(hasattr(sp.test2,
"foo"))
4470 self.assertTrue(hasattr(sp.test2,
"bar"))
4473 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4475 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
4481 p.maxEvents.input = 10
4482 p.options.numberOfThreads = 4
4483 p.maxLuminosityBlocks.input = 2
4485 self.assertEqual(p.maxEvents.input.value(),10)
4486 self.assertEqual(p.options.numberOfThreads.value(), 4)
4487 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
4493 self.assertTrue(hasattr(p,
'fltr'))
4497 p.TestService =
Service(
"TestService")
4498 self.assertTrue(hasattr(proc,
"TestService"))
4499 self.assertEqual(proc.TestService.type_(),
"TestService")
4500 self.assertRaises(TypeError, setattr, p,
"a",
EDProducer(
"Foo"))
4501 p.add_(
Service(
"TestServiceTwo"))
4502 self.assertTrue(hasattr(proc,
"TestServiceTwo"))
4503 self.assertEqual(proc.TestServiceTwo.type_(),
"TestServiceTwo")
4504 p.TestService.foo = untracked.uint32(42)
4505 self.assertEqual(proc.TestService.foo.value(), 42)
4507 self.assertRaises(TypeError, getattr, p,
"mod")
4511 proc.fillProcessDesc(p)
4512 self.assertTrue([
"cpu"], p.values[
"@available_accelerators"][1])
4513 self.assertFalse(p.values[
"@selected_accelerators"][0])
4514 self.assertTrue([
"cpu"], p.values[
"@selected_accelerators"][1])
4519 del proc.MessageLogger
4521 self.assertEqual(proc.dumpPython(),
4522 """import FWCore.ParameterSet.Config as cms 4523 from test import ProcessAcceleratorTest 4525 process = cms.Process("TEST") 4527 process.maxEvents = cms.untracked.PSet( 4528 input = cms.optional.untracked.int32, 4529 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 4532 process.maxLuminosityBlocks = cms.untracked.PSet( 4533 input = cms.untracked.int32(-1) 4536 process.options = cms.untracked.PSet( 4537 FailPath = cms.untracked.vstring(), 4538 IgnoreCompletely = cms.untracked.vstring(), 4539 Rethrow = cms.untracked.vstring(), 4540 SkipEvent = cms.untracked.vstring(), 4541 accelerators = cms.untracked.vstring('*'), 4542 allowUnscheduled = cms.obsolete.untracked.bool, 4543 canDeleteEarly = cms.untracked.vstring(), 4544 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 4545 dumpOptions = cms.untracked.bool(False), 4546 emptyRunLumiMode = cms.obsolete.untracked.string, 4547 eventSetup = cms.untracked.PSet( 4548 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 4549 allowAnyLabel_=cms.required.untracked.uint32 4551 numberOfConcurrentIOVs = cms.untracked.uint32(0) 4553 fileMode = cms.untracked.string('FULLMERGE'), 4554 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 4555 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 4556 makeTriggerResults = cms.obsolete.untracked.bool, 4557 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 4558 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 4559 numberOfConcurrentRuns = cms.untracked.uint32(1), 4560 numberOfStreams = cms.untracked.uint32(0), 4561 numberOfThreads = cms.untracked.uint32(1), 4562 printDependencies = cms.untracked.bool(False), 4563 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 4564 throwIfIllegalParameter = cms.untracked.bool(True), 4565 wantSummary = cms.untracked.bool(False) 4568 process.ProcessAcceleratorTest = ProcessAcceleratorTest( 4569 enabled = ['test1', 'test2', 'anothertest3'] 4575 proc.fillProcessDesc(p)
4576 self.assertEqual([
"*"], p.values[
"options"][1].values[
"accelerators"][1])
4577 self.assertFalse(p.values[
"options"][1].values[
"accelerators"][0])
4578 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4579 self.assertEqual(
"AcceleratorTestService", p.values[
"services"][1][0].values[
"@service_type"][1])
4580 self.assertFalse(p.values[
"@available_accelerators"][0])
4581 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4586 proc.fillProcessDesc(p)
4587 self.assertEqual([
"cpu",
"test1"], p.values[
"@selected_accelerators"][1])
4588 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4592 proc.options.accelerators = [
"test2"]
4594 proc.fillProcessDesc(p)
4595 self.assertEqual([
"test2"], p.values[
"@selected_accelerators"][1])
4596 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4600 proc.options.accelerators = [
"test*"]
4601 proc.fillProcessDesc(p)
4602 self.assertEqual([
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4603 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4607 proc.options.accelerators = [
"test2"]
4609 proc.fillProcessDesc(p)
4610 self.assertEqual([], p.values[
"@selected_accelerators"][1])
4611 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4615 proc.options.accelerators = [
"cpu*"]
4617 proc.fillProcessDesc(p)
4618 self.assertEqual([
"cpu"], p.values[
"@selected_accelerators"][1])
4619 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4623 proc.options.accelerators = [
"test3"]
4625 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4629 proc.options.accelerators = [
"*",
"test1"]
4631 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4637 proc.fillProcessDesc(p)
4638 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4639 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4644 proc.options.accelerators = [
"*test3",
"c*"]
4646 proc.fillProcessDesc(p)
4647 self.assertEqual([
"anothertest3",
"cpu"], p.values[
"@selected_accelerators"][1])
4648 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4658 proc.p =
Path(proc.sp)
4660 proc.fillProcessDesc(p)
4661 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4671 proc.p =
Path(proc.sp)
4673 proc.fillProcessDesc(p)
4674 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4678 proc.options.accelerators = [
"test1"]
4685 proc.p =
Path(proc.sp)
4687 proc.fillProcessDesc(p)
4688 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4692 proc.options.accelerators = [
"test*"]
4699 proc.p =
Path(proc.sp)
4701 proc.fillProcessDesc(p)
4702 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4706 proc.options.accelerators = [
"anothertest3"]
4713 proc.p =
Path(proc.sp)
4715 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4726 proc.p =
Path(proc.sp)
4727 pkl = pickle.dumps(proc)
4728 unpkl = pickle.loads(pkl)
4730 unpkl.fillProcessDesc(p)
4731 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4732 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4733 unpkl = pickle.loads(pkl)
4734 unpkl.ProcessAcceleratorTest.setEnabled([
"test1"])
4736 unpkl.fillProcessDesc(p)
4737 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4738 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
def __setstate__(self, pkldict)
def conditionaltasks_(self)
def addVString(self, tracked, label, value)
def testProcessAccelerator(self)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def testConditionalTaskPlaceholder(self)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def __init__(self, enabled=["test1", test2, anothertest3)
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 __init__(self, process)
def __updateMaxEvents(self, ps)
def _placeSwitchProducer(self, name, mod)
def _insertPaths(self, processPSet, nodeVisitor)
def apply(self, process, accelerators)
def _placeESProducer(self, name, mod)
def _splitPythonList(self, subfolder, d, options)
bool any(const std::vector< T > &v, const T &what)
def addVESInputTag(self, tracked, label, value)
def _switchproducer_test2_case2(accelerators)
def _placeSequence(self, name, mod)
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def _validateSequence(self, sequence, label)
def __getattr__(self, attr)
def setStrict(self, value)
def addDouble(self, tracked, label, value)
def dumpPythonImpl(self, options)
def _findPreferred(self, esname, d, args, kargs)
def apply(self, process, accelerators)
def __init__(self, kargs)
def apply(self, process, accelerators)
def _insertOneInto(self, parameterSet, label, item, tracked)
def __setattr__(self, label, value)
def __updateOptions(self, opt)
def __delattr__(self, name)
def _placePath(self, name, mod)
def addVUInt64(self, tracked, label, value)
def _placeEndPath(self, name, mod)
def __init__(self, enabled=["anothertest3", anothertest4)
def testProcessForProcessAccelerator(self)
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 _lineDiff(newString, oldString)
def dumpPythonImpl(self, options)
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 __getattr__(self, label)
def _replaceInTasks(self, label, new)
def addVInt32(self, tracked, label, value)
def _placeFilter(self, name, mod)
def handleProcessAccelerators(self, parameterSet)
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 setEnabled(self, enabled)
def __setattr__(self, name, value)
def _placeESSource(self, name, mod)
def addVInt64(self, tracked, label, value)
def addVEventID(self, tracked, label, value)
def setEnabled(self, enabled)
def toModify(self, obj, func=None, kw)
def testGlobalReplace(self)
def testSwitchProducer(self)
def getVString(self, tracked, label)
def defaultMaxLuminosityBlocks_()
def testProcessFragment(self)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
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 _insertSwitchProducersInto(self, parameterSet, labelModules, labelAliases, itemDict, tracked)
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 split(sequence, size)
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)
def _switchproducer_test2_case1(accelerators)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def _validateConditionalTask(self, task, label)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def _splitPython(self, subfolder, d, options)
def __init__(self, lhs, rhs)
def _placeAccelerator(self, typeName, mod)
def dumpPython(process, name)
def __setObjectLabel(self, object, newLabel)
def testConditionalTask(self)
def _delHelper(self, name)
def _placeAlias(self, name, mod)
def dumpPython(self, options=PrintOptions())
def _replaceInSequences(self, label, new)
def setSchedule_(self, sch)
def dumpPython(self, options=PrintOptions())
def _toReplaceWithCheck(toObj, fromObj)
def switchProducerNames(self)
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)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
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 switchProducers_(self)
def _placePSet(self, name, mod)
def _placeFinalPath(self, name, mod)
def _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def addService(process, multirun=False)
def _place(self, name, mod, d)
def testProcessExtend(self)
def _dumpPythonList(self, d, options)
def __insertValue(self, tracked, label, value)
def splitPython(self, options=PrintOptions())
def __init__(self, kargs)
def __getValue(self, tracked, label)
def _place(self, name, proc)
def _placeVPSet(self, name, mod)
def processAccelerators_(self)
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 _replaceInConditionalTasks(self, label, new)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def _placeConditionalTask(self, name, task)
def _replaceInScheduleDirectly(self, label, new)
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def _replaceInSchedule(self, label, new)
def dumpPythonImpl(self, options)
def _dumpPython(self, d, options)
def addInt32(self, tracked, label, value)
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)