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, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
21 from .
import DictTypes
23 from .ExceptionHandling
import *
26 if sys.getrecursionlimit()<5000:
27 sys.setrecursionlimit(5000)
31 Raise an exception if called by special config files. This checks
32 the call or import stack for the importing file. An exception is raised if
33 the importing module is not in allowedPatterns and if it is called too deeply:
34 minLevel = 2: inclusion by top lvel cfg only
35 minLevel = 1: No inclusion allowed
36 allowedPatterns = ['Module1','Module2/SubModule1'] allows import
37 by any module in Module1 or Submodule1
43 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>',
'<frozen ']
44 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
48 for item
in inspect.stack():
52 for pattern
in CMSSWPath:
53 if item[1].
find(pattern) != -1:
56 if item[1].
find(
'/') == -1:
59 for pattern
in ignorePatterns:
60 if item[1].
find(pattern) != -1:
64 if inPath
and not ignore:
65 trueStack.append(item[1])
67 importedFile = trueStack[0]
69 if len(trueStack) > 1:
70 importedBy = trueStack[1]
72 for pattern
in allowedPatterns:
73 if importedBy.find(pattern) > -1:
76 if len(trueStack) <= minLevel:
79 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files."
83 """Look inside the module and find the Processes it contains"""
87 if isinstance(module,dict):
88 if 'process' in module:
92 if hasattr(module,
'process'):
93 if isinstance(module.process,Process):
94 process = module.process
96 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
98 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
102 """Root class for a CMS configuration process"""
104 """The argument 'name' will be the name applied to this Process
105 Can optionally pass as additional arguments cms.Modifier instances
106 that will be used to modify the Process as it is built
108 self.__dict__[
'_Process__name'] = name
109 if not name.isalnum():
110 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
111 self.__dict__[
'_Process__filters'] = {}
112 self.__dict__[
'_Process__producers'] = {}
113 self.__dict__[
'_Process__switchproducers'] = {}
114 self.__dict__[
'_Process__source'] =
None
115 self.__dict__[
'_Process__looper'] =
None
116 self.__dict__[
'_Process__subProcesses'] = []
117 self.__dict__[
'_Process__schedule'] =
None
118 self.__dict__[
'_Process__analyzers'] = {}
119 self.__dict__[
'_Process__outputmodules'] = {}
122 self.__dict__[
'_Process__sequences'] = {}
123 self.__dict__[
'_Process__tasks'] = {}
124 self.__dict__[
'_Process__services'] = {}
125 self.__dict__[
'_Process__essources'] = {}
126 self.__dict__[
'_Process__esproducers'] = {}
127 self.__dict__[
'_Process__esprefers'] = {}
128 self.__dict__[
'_Process__aliases'] = {}
129 self.__dict__[
'_Process__psets']={}
130 self.__dict__[
'_Process__vpsets']={}
131 self.__dict__[
'_cloneToObjectDict'] = {}
133 self.__dict__[
'_Process__InExtendCall'] =
False
134 self.__dict__[
'_Process__partialschedules'] = {}
136 self.__dict__[
'_Process__modifiers'] = Mods
140 for m
in self.__modifiers:
145 _Module.__isStrict__ =
True
149 """Returns a string containing all the EDProducer labels separated by a blank"""
152 """Returns a string containing all the SwitchProducer labels separated by a blank"""
155 """Returns a string containing all the EDAnalyzer labels separated by a blank"""
158 """Returns a string containing all the EDFilter labels separated by a blank"""
161 """Returns a string containing all the Path names separated by a blank"""
168 Since cloneToObjectDict stores a hash of objects by their
169 id() it needs to be updated when unpickling to use the
170 new object id values instantiated during the unpickle.
173 self.__dict__.
update(pkldict)
175 for value
in self._cloneToObjectDict.
values():
176 tmpDict[
id(value)] = value
177 self.__dict__[
'_cloneToObjectDict'] = tmpDict
182 """returns a dict of the filters that have been added to the Process"""
184 filters = property(filters_, doc=
"dictionary containing the filters for the process")
188 if not name.isalnum():
189 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
190 self.__dict__[
'_Process__name'] = name
191 process = property(name_,setName_, doc=
"name of the process")
193 """returns a dict of the producers that have been added to the Process"""
195 producers = property(producers_,doc=
"dictionary containing the producers for the process")
197 """returns a dict of the SwitchProducers that have been added to the Process"""
199 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
201 """returns the source that has been added to the Process or None if none have been added"""
205 source = property(source_,setSource_,doc=
'the main source or None if not set')
207 """returns the looper that has been added to the Process or None if none have been added"""
211 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
214 return untracked.PSet(numberOfThreads = untracked.uint32(1),
215 numberOfStreams = untracked.uint32(0),
216 numberOfConcurrentRuns = untracked.uint32(1),
217 numberOfConcurrentLuminosityBlocks = untracked.uint32(0),
218 eventSetup = untracked.PSet(
219 numberOfConcurrentIOVs = untracked.uint32(0),
220 forceNumberOfConcurrentIOVs = untracked.PSet(
221 allowAnyLabel_ = required.untracked.uint32
224 wantSummary = untracked.bool(
False),
225 fileMode = untracked.string(
'FULLMERGE'),
226 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
227 throwIfIllegalParameter = untracked.bool(
True),
228 printDependencies = untracked.bool(
False),
229 deleteNonConsumedUnscheduledModules = untracked.bool(
True),
230 sizeOfStackForThreadsInKB = optional.untracked.uint32,
231 Rethrow = untracked.vstring(),
232 SkipEvent = untracked.vstring(),
233 FailPath = untracked.vstring(),
234 IgnoreCompletely = untracked.vstring(),
235 canDeleteEarly = untracked.vstring(),
236 dumpOptions = untracked.bool(
False),
237 allowUnscheduled = obsolete.untracked.bool,
238 emptyRunLumiMode = obsolete.untracked.string,
239 makeTriggerResults = obsolete.untracked.bool
243 if isinstance(opt,dict):
244 for k,v
in opt.items():
247 for p
in opt.parameters_():
248 setattr(newOpts, p, getattr(opt,p))
252 return untracked.PSet(input=optional.untracked.int32,
253 output=optional.untracked.allowed(int32,PSet))
256 if isinstance(ps,dict):
257 for k,v
in ps.items():
260 for p
in ps.parameters_():
261 setattr(newMax, p, getattr(ps,p))
265 return untracked.PSet(input=untracked.int32(-1))
267 """returns a list of the subProcesses that have been added to the Process"""
268 return self.__subProcesses
269 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
271 """returns a dict of the analyzers that have been added to the Process"""
273 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
275 """returns a dict of the output modules that have been added to the Process"""
277 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
279 """returns a dict of the paths that have been added to the Process"""
281 paths = property(paths_,doc=
"dictionary containing the paths for the process")
283 """returns a dict of the endpaths that have been added to the Process"""
285 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
287 """returns a dict of the sequences that have been added to the Process"""
289 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
291 """returns a dict of the tasks that have been added to the Process"""
293 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
295 """returns the schedule that has been added to the Process or None if none have been added"""
296 return self.__schedule
298 if label ==
"schedule":
301 self.
_place(label, sch, self.__partialschedules)
310 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
311 self.__dict__[
'_Process__schedule'] = sch
312 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
314 """returns a dict of the services that have been added to the Process"""
316 services = property(services_,doc=
"dictionary containing the services for the process")
318 """returns a dict of the esproducers that have been added to the Process"""
320 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
322 """returns a the es_sources that have been added to the Process"""
324 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
326 """returns a dict of the es_prefers that have been added to the Process"""
328 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
330 """returns a dict of the aliases that have been added to the Process"""
332 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
334 """returns a dict of the PSets that have been added to the Process"""
336 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
338 """returns a dict of the VPSets that have been added to the Process"""
340 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
343 """returns True if the Modifier is in used by this Process"""
345 for m
in self.__modifiers:
346 if m._isOrContains(mod):
351 if not object.hasLabel_() :
352 object.setLabel(newLabel)
354 if newLabel == object.label_() :
356 if newLabel
is None :
357 object.setLabel(
None)
359 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
360 msg100 =
"Attempting to change the label of an attribute of the Process\n"
361 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n"
362 msg102 =
"Type = "+
str(type(object))+
"\n"
363 msg103 =
"Some possible solutions:\n"
364 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n"
365 msg105 =
" also preferred for other types when possible.\n"
366 msg106 =
" 2. Declare new names starting with an underscore if they are\n"
367 msg107 =
" for temporaries you do not want propagated into the Process. The\n"
368 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n"
369 msg109 =
" the name.\n"
370 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n"
371 msg111 =
" name to the same object usually causes confusion and problems.\n"
372 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n"
373 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
374 object.setLabel(
None)
375 object.setLabel(newLabel)
379 if not name.replace(
'_',
'').isalnum():
380 raise ValueError(
'The label '+name+
' contains forbiden characters')
382 if name ==
'options':
384 if name ==
'maxEvents':
388 if name.startswith(
'_Process__'):
389 self.__dict__[name]=value
391 if not isinstance(value,_ConfigureComponent):
392 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n"
393 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
394 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
395 if name == value.type_():
400 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
401 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
404 newValue =value.copy()
406 newValue._filename = value._filename
412 if not self.
_okToPlace(name, value, self.__dict__):
413 newFile=
'top level config'
414 if hasattr(value,
'_filename'):
415 newFile = value._filename
416 oldFile=
'top level config'
417 oldValue = getattr(self,name)
418 if hasattr(oldValue,
'_filename'):
419 oldFile = oldValue._filename
420 msg =
"Trying to override definition of process."+name
421 msg +=
"\n new object defined in: "+newFile
422 msg +=
"\n existing object defined in: "+oldFile
423 raise ValueError(msg)
425 if hasattr(self,name)
and not (getattr(self,name)==newValue):
429 if newValue._isTaskComponent():
430 if not self.__InExtendCall:
434 if not isinstance(newValue, Task):
436 newFile=
'top level config'
437 if hasattr(value,
'_filename'):
438 newFile = value._filename
439 oldFile=
'top level config'
440 oldValue = getattr(self,name)
441 if hasattr(oldValue,
'_filename'):
442 oldFile = oldValue._filename
443 msg1 =
"Trying to override definition of "+name+
" while it is used by the task "
444 msg2 =
"\n new object defined in: "+newFile
445 msg2 +=
"\n existing object defined in: "+oldFile
448 raise ValueError(msg1+s.label_()+msg2)
450 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent():
451 if not self.__InExtendCall:
455 newFile=
'top level config'
456 if hasattr(value,
'_filename'):
457 newFile = value._filename
458 oldFile=
'top level config'
459 oldValue = getattr(self,name)
460 if hasattr(oldValue,
'_filename'):
461 oldFile = oldValue._filename
462 msg1 =
"Trying to override definition of "+name+
" while it is used by the "
463 msg2 =
"\n new object defined in: "+newFile
464 msg2 +=
"\n existing object defined in: "+oldFile
467 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
470 raise ValueError(msg1+
"path "+s.label_()+msg2)
473 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
476 if isinstance(newValue, EDAlias):
477 oldValue = getattr(self, name)
479 newFile=
'top level config'
480 if hasattr(value,
'_filename'):
481 newFile = value._filename
482 oldFile=
'top level config'
483 if hasattr(oldValue,
'_filename'):
484 oldFile = oldValue._filename
485 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the "
486 msg2 =
"\n new object defined in: "+newFile
487 msg2 +=
"\n existing object defined in: "+oldFile
490 raise ValueError(msg1+
"task "+s.label_()+msg2)
493 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
496 raise ValueError(msg1+
"path "+s.label_()+msg2)
499 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
502 self.__dict__[name]=newValue
503 if isinstance(newValue,_Labelable):
505 self._cloneToObjectDict[
id(value)] = newValue
506 self._cloneToObjectDict[
id(newValue)] = newValue
508 newValue._place(name,self)
510 """Given a container of sequences or tasks, find the first sequence or task
511 containing mod and return it. If none is found, return None"""
514 for seqOrTask
in seqsOrTasks.values():
523 if not hasattr(self,name):
524 raise KeyError(
'process does not know about '+name)
525 elif name.startswith(
'_Process__'):
526 raise ValueError(
'this attribute cannot be deleted')
531 if name
in reg: del reg[name]
533 obj = getattr(self,name)
534 if isinstance(obj,_Labelable):
536 if isinstance(obj,Service):
537 obj._inProcess =
False
541 obj = getattr(self,name)
543 if not isinstance(obj, Sequence)
and not isinstance(obj, Task):
553 if obj._isTaskComponent():
556 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
560 del self.__dict__[name]
565 """Similar to __delattr__ but we need different behavior when called from __setattr__"""
569 del self.__dict__[name]
574 """Allows addition of components that do not have to have a label, e.g. Services"""
575 if not isinstance(value,_ConfigureComponent):
577 if not isinstance(value,_Unlabelable):
582 newValue =value.copy()
586 newValue._place(
'',self)
589 if not self.__InExtendCall:
600 if d[name]._isModified:
611 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
612 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
615 if isinstance(mod,_Labelable):
618 self.
_place(name, mod, self.__outputmodules)
620 self.
_place(name, mod, self.__producers)
622 self.
_place(name, mod, self.__switchproducers)
624 self.
_place(name, mod, self.__filters)
626 self.
_place(name, mod, self.__analyzers)
630 self.
_place(name, mod, self.__paths)
631 except ModuleCloneError
as msg:
633 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
637 self.
_place(name, mod, self.__endpaths)
638 except ModuleCloneError
as msg:
640 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
643 self.
_place(name, mod, self.__sequences)
645 self.
_place(name, mod, self.__esproducers)
647 self.
_place(name, mod, self.__esprefers)
649 self.
_place(name, mod, self.__essources)
652 self.
_place(name, task, self.__tasks)
654 self.
_place(name, mod, self.__aliases)
656 self.
_place(name, mod, self.__psets)
658 self.
_place(name, mod, self.__vpsets)
660 """Allow the source to be referenced by 'source' or by type name"""
662 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
663 if self.__dict__[
'_Process__source']
is not None :
664 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
665 self.__dict__[
'_Process__source'] = mod
666 self.__dict__[mod.type_()] = mod
669 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
670 self.__dict__[
'_Process__looper'] = mod
671 self.__dict__[mod.type_()] = mod
673 self.__dict__[
'_Process__subProcess'] = mod
674 self.__dict__[mod.type_()] = mod
676 self.__subProcesses.
append(mod)
678 self.
_place(typeName, mod, self.__services)
679 if typeName
in self.__dict__:
680 self.__dict__[typeName]._inProcess =
False
681 self.__dict__[typeName]=mod
683 moduleName = moduleName.replace(
"/",
".")
684 module = __import__(moduleName)
685 self.
extend(sys.modules[moduleName])
687 """Look in other and find types that we can use"""
689 self.__dict__[
'_Process__InExtendCall'] =
True
692 tasksToAttach = dict()
694 for name
in dir(other):
696 if name.startswith(
'_'):
698 item = getattr(other,name)
699 if name ==
"source" or name ==
"looper":
703 elif isinstance(item,_ModuleSequenceType):
705 elif isinstance(item,Task):
706 tasksToAttach[name] = item
707 elif isinstance(item,_Labelable):
709 if not item.hasLabel_() :
711 elif isinstance(item,Schedule):
713 elif isinstance(item,_Unlabelable):
715 elif isinstance(item,ProcessModifier):
717 elif isinstance(item,ProcessFragment):
721 for name,seq
in seqs.items():
722 if id(seq)
not in self._cloneToObjectDict:
725 newSeq = self._cloneToObjectDict[
id(seq)]
726 self.__dict__[name]=newSeq
729 newSeq._place(name,self)
731 for name, task
in tasksToAttach.items():
738 self.__dict__[
'_Process__InExtendCall'] =
False
742 for name,item
in items:
743 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
748 for name,item
in items:
749 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
754 for name,item
in items:
755 if name == item.type_():
757 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
761 """return a string containing the equivalent process defined using the old configuration language"""
762 config =
"process "+self.__name+
" = {\n"
812 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
814 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
816 pathNames = [p.label_()
for p
in self.
schedule]
817 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n'
829 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
835 returnValue += item.dumpPython(options)+
'\n\n'
841 for name,item
in d.items():
842 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n'
844 for name,item
in sorted(d.items()):
845 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n'
852 dependencies = item.directDependencies()
853 for module_subfolder, module
in dependencies:
854 module = module +
'_cfi'
855 if options.useSubdirectories
and module_subfolder:
856 module = module_subfolder +
'.' + module
857 if options.targetDirectory
is not None:
858 if options.useSubdirectories
and subfolder:
859 module =
'..' + module
861 module =
'.' + module
862 code +=
'from ' + module +
' import *\n'
865 code += name +
' = ' + item.dumpPython(options)
866 parts[name] = subfolder, code
874 sequence.visit(visitor)
876 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
885 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
897 for label,item
in processDictionaryOfItems.items():
899 if isinstance(item, Task):
906 if isinstance(item, Task):
907 raise RuntimeError(
"Failed in a Task visitor. Probably " \
908 "a circular dependency discovered in Task with label " + label)
910 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
911 "circular dependency discovered in Sequence with label " + label)
912 for containedItem
in containedItems:
918 if containedItem.hasLabel_():
919 testItem = processDictionaryOfItems.get(containedItem.label_())
920 if testItem
is None or containedItem != testItem:
921 if isinstance(item, Task):
922 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
923 " from the process yields a different object or None\n"+
924 "label = " + containedItem.label_())
926 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
927 " from the process yields a different object or None\n"+
928 "label = " + containedItem.label_())
929 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
933 oldDeps = dict(dependencies)
934 for label,deps
in oldDeps.items():
936 returnValue[label]=processDictionaryOfItems[label]
938 del dependencies[label]
939 for lb2,deps2
in dependencies.items():
940 while deps2.count(label):
946 for name, value
in sorted(d.items()):
947 result += value.dumpPythonAs(name,options)+
'\n'
952 for name, value
in sorted(d.items()):
953 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n'
957 """return a string containing the equivalent process defined using python"""
958 specialImportRegistry._reset()
959 header =
"import FWCore.ParameterSet.Config as cms"
960 result =
"process = cms.Process(\""+self.__name+
"\")\n\n"
984 imports = specialImportRegistry.getSpecialImports()
986 header +=
"\n" +
"\n".
join(imports)
991 """return a map of file names to python configuration fragments"""
992 specialImportRegistry._reset()
994 options.isCfg =
False
995 header =
"import FWCore.ParameterSet.Config as cms"
1000 result =
'process = cms.Process("' + self.__name +
'")\n\n'
1013 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1029 if options.targetDirectory
is not None:
1030 files[options.targetDirectory +
'/__init__.py'] =
''
1032 if options.useSubdirectories:
1033 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1034 if options.targetDirectory
is not None:
1035 sub = options.targetDirectory +
'/' + sub
1036 files[sub +
'/__init__.py'] =
''
1039 parts = sorted(parts.items(), key =
lambda nsc: (nsc[1][0].lower()
if nsc[1][0]
else '', nsc[0].lower()))
1041 for (name, (subfolder, code))
in parts:
1042 filename = name +
'_cfi'
1043 if options.useSubdirectories
and subfolder:
1044 filename = subfolder +
'/' + filename
1045 if options.targetDirectory
is not None:
1046 filename = options.targetDirectory +
'/' + filename
1047 result +=
'process.load("%s")\n' % filename
1048 files[filename +
'.py'] = header +
'\n\n' + code
1051 options.isCfg =
True
1054 imports = specialImportRegistry.getSpecialImports()
1055 if len(imports) > 0:
1056 header +=
'\n' +
'\n'.
join(imports)
1057 files[
'-'] = header +
'\n\n' + result
1061 old = getattr(self,label)
1068 sequenceable._replaceIfHeldDirectly(old,new)
1070 sequenceable.replace(old,new)
1072 sequenceable.replace(old,new)
1074 sequenceable.replace(old,new)
1076 old = getattr(self,label)
1078 task.replace(old, new)
1082 old = getattr(self,label)
1084 task.replace(old, new)
1086 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks"""
1087 if not hasattr(self,label):
1088 raise LookupError(
"process has no item of label "+label)
1089 setattr(self,label,new)
1091 for name,value
in itemDict.items():
1092 value.insertInto(parameterSet, name)
1095 if not item ==
None:
1096 newlabel = item.nameInProcessDesc_(label)
1098 item.insertInto(parameterSet, newlabel)
1099 parameterSet.addVString(tracked, label, vitems)
1102 for name,value
in itemDict.items():
1103 value.appendToProcessDescList_(l, name)
1104 value.insertInto(parameterSet, name)
1107 parameterSet.addVString(tracked, label, l)
1109 modules = parameterSet.getVString(tracked, labelModules)
1110 aliases = parameterSet.getVString(tracked, labelAliases)
1111 for name,value
in itemDict.items():
1112 value.appendToProcessDescLists_(modules, aliases, name)
1113 value.insertInto(parameterSet, name)
1116 parameterSet.addVString(tracked, labelModules, modules)
1117 parameterSet.addVString(tracked, labelAliases, aliases)
1121 for value
in itemList:
1122 name = value.getProcessName()
1123 newLabel = value.nameInProcessDesc_(name)
1125 pset = value.getSubProcessPSet(parameterSet)
1126 subprocs.append(pset)
1129 parameterSet.addVString(tracked, label, l)
1130 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1137 for name
in self.
paths_():
1138 scheduledPaths.append(name)
1139 triggerPaths.append(name)
1141 scheduledPaths.append(name)
1142 endpaths.append(name)
1145 pathname = path.label_()
1146 scheduledPaths.append(pathname)
1148 endpaths.append(pathname)
1150 triggerPaths.append(pathname)
1152 task.resolve(self.__dict__)
1154 task.visit(scheduleTaskValidator)
1155 task.visit(nodeVisitor)
1156 processPSet.addVString(
True,
"@end_paths", endpaths)
1157 processPSet.addVString(
True,
"@paths", scheduledPaths)
1159 p = processPSet.newPSet()
1160 p.addVString(
True,
"@trigger_paths", triggerPaths)
1161 processPSet.addPSet(
True,
"@trigger_paths", p)
1167 pathCompositeVisitor =
CompositeVisitor(pathValidator, nodeVisitor, lister)
1168 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
1169 for triggername
in triggerPaths:
1170 iPath = self.
paths_()[triggername]
1171 iPath.resolve(self.__dict__)
1172 pathValidator.setLabel(triggername)
1174 iPath.visit(pathCompositeVisitor)
1175 iPath.insertInto(processPSet, triggername, decoratedList)
1176 for endpathname
in endpaths:
1177 iEndPath = self.
endpaths_()[endpathname]
1178 iEndPath.resolve(self.__dict__)
1179 endpathValidator.setLabel(endpathname)
1181 iEndPath.visit(endpathCompositeVisitor)
1182 iEndPath.insertInto(processPSet, endpathname, decoratedList)
1183 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1185 def resolve(self,keepUnresolvedSequencePlaceholders=False):
1187 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1189 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1192 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1194 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1195 """ Remove clutter from the process that we think is unnecessary:
1196 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths
1197 not in the schedule will also be removed, along with an modules and sequences used only by
1198 those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders."""
1207 self.
resolve(keepUnresolvedSequencePlaceholders)
1209 unneededPaths = set()
1213 usedModules=set(self.
schedule_().moduleNames())
1215 schedNames = set(( x.label_()
for x
in self.
schedule_()))
1216 names = set(self.
paths)
1218 unneededPaths = names - schedNames
1219 for n
in unneededPaths:
1229 usedModules=set(temp.moduleNames())
1243 def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1244 _keepSet = set(( s
for s
in seqOrTasks
if s.hasLabel_()))
1245 _availableSet = set(allSequencesOrTasks.values())
1246 _unneededSet = _availableSet-_keepSet
1247 _unneededLabels = []
1248 for s
in _unneededSet:
1249 _unneededLabels.append(s.label_())
1250 delattr(self,s.label_())
1251 return _unneededLabels
1252 unneededSeqLabels = removeUnneeded(seqs, self.
sequences)
1253 unneededTaskLabels = removeUnneeded(tasks, self.
tasks)
1255 print(
"prune removed the following:")
1256 print(
" modules:"+
",".
join(unneededModules))
1257 print(
" tasks:"+
",".
join(unneededTaskLabels))
1258 print(
" sequences:"+
",".
join(unneededSeqLabels))
1259 print(
" paths/endpaths:"+
",".
join(unneededPaths))
1261 moduleNames = set(d.keys())
1262 junk = moduleNames - scheduledNames
1268 """Used by the framework to convert python to C++ objects"""
1269 class ServiceInjectorAdaptor(
object):
1280 class TopLevelPSetAcessorAdaptor(
object):
1284 def __getattr__(self,attr):
1285 return getattr(self.
__ppset,attr)
1286 def getTopPSet_(self,label):
1290 def addPSet(self,tracked,name,ppset):
1291 return self.
__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1292 def addVPSet(self,tracked,name,vpset):
1293 return self.
__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1294 def __extractPSet(self,pset):
1295 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1300 processPSet.addString(
True,
"@process_name", self.
name_())
1302 all_modules.update(self.
filters_())
1305 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1318 all_modules_onTasksOrScheduled = { key:value
for key, value
in all_modules.items()
if value
in nodeVisitor.modules }
1319 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1321 all_switches_onTasksOrScheduled = {key:value
for key, value
in all_switches.items()
if value
in nodeVisitor.modules }
1327 pTask.visit(processNodeVisitor)
1328 esProducersToEnable = {}
1330 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1331 esProducersToEnable[esProducerName] = esProducer
1332 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1333 esSourcesToEnable = {}
1335 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1336 esSourcesToEnable[esSourceName] = esSource
1337 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1341 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1342 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1343 adaptor.addVPSet(
False,
"services",services)
1354 """Prefer this ES source or producer. The argument can
1355 either be an object label, e.g.,
1356 process.prefer(process.juicerProducer) (not supported yet)
1357 or a name of an ESSource or ESProducer
1358 process.prefer("juicer")
1359 or a type of unnamed ESSource or ESProducer
1360 process.prefer("JuicerProducer")
1361 In addition, you can pass as a labelled arguments the name of the Record you wish to
1362 prefer where the type passed is a cms.vstring and that vstring can contain the
1363 name of the C++ types in the Record that are being preferred, e.g.,
1364 #prefer all data in record 'OrangeRecord' from 'juicer'
1365 process.prefer("juicer", OrangeRecord=cms.vstring())
1367 #prefer only "Orange" data in "OrangeRecord" from "juicer"
1368 process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
1370 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
1371 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))
1374 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1375 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1376 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
1377 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1380 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1385 typ = d[esname].type_()
1394 for name, value
in d.items():
1395 if value.type_() == esname:
1397 raise RuntimeError(
"More than one ES module for "+esname)
1405 if isinstance(process, Process):
1407 elif isinstance(process, str):
1414 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1416 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1418 if name ==
'_ProcessFragment__process':
1419 return object.__getattribute__(self,
'_ProcessFragment__process')
1423 if name ==
'_ProcessFragment__process':
1424 object.__setattr__(self, name, value)
1428 if name ==
'_ProcessFragment__process':
1435 """a dictionary with fixed keys"""
1437 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1438 _blocked_attribute = property(_blocked_attribute)
1439 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1440 pop = popitem = setdefault = update = _blocked_attribute
1442 new = dict.__new__(cls)
1443 dict.__init__(new, *args, **kw)
1444 keys = sorted(kw.keys())
1445 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1446 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1447 if not isinstance(kw[
'name'],str):
1448 raise ValueError(
"name must be of type string")
1449 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1450 raise ValueError(
"content must be of type vstring or string")
1451 if not isinstance(kw[
'dataTier'], string):
1452 raise ValueError(
"dataTier must be of type string")
1453 if not isinstance(kw[
'selectEvents'], PSet):
1454 raise ValueError(
"selectEvents must be of type PSet")
1455 if not isinstance(kw[
'paths'],(tuple, Path)):
1456 raise ValueError(
"'paths' must be a tuple of paths")
1461 return "FilteredStream object: %s" %self[
"name"]
1466 """Allows embedding another process within a parent process. This allows one to
1467 chain processes together directly in one cmsRun job rather than having to run
1468 separate jobs that are connected via a temporary file.
1470 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1473 if not isinstance(process, Process):
1474 raise ValueError(
"the 'process' argument must be of type cms.Process")
1475 if not isinstance(SelectEvents,PSet):
1476 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1477 if not isinstance(outputCommands,vstring):
1478 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1483 out =
"parentProcess"+
str(
hash(self))+
" = process\n"
1485 out +=
"childProcess = process\n"
1486 out +=
"process = parentProcess"+
str(
hash(self))+
"\n"
1502 process._placeSubProcess(
'subProcess',self)
1504 topPSet = parameterSet.newPSet()
1506 subProcessPSet = parameterSet.newPSet()
1509 subProcessPSet.addPSet(
False,
"process",topPSet)
1510 return subProcessPSet
1513 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object"""
1520 params[k] = getattr(obj,k)
1524 setattr(obj,k,params[k])
1530 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1533 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code"""
1539 Modifier._toModifyCheck(obj,func,**kw)
1540 if not self._isChosen():
1542 Modifier._toModify(obj,func,**kw)
1544 Modifier._toReplaceWithCheck(toObj,fromObj)
1545 if not self._isChosen():
1547 Modifier._toReplaceWith(toObj,fromObj)
1549 """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1550 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1551 In order to work, the value returned from this function must be assigned to a uniquely named variable."""
1561 """A modifier which only applies if multiple Modifiers are chosen"""
1563 super(_AndModifier,self).
__init__(lhs, rhs)
1568 """A modifier which only applies if a Modifier is not chosen"""
1570 super(_InvertModifier,self).
__init__(lhs)
1575 """A modifier which only applies if at least one of multiple Modifiers is chosen"""
1577 super(_OrModifier,self).
__init__(lhs, rhs)
1583 """This class is used to define standard modifications to a Process.
1584 An instance of this class is declared to denote a specific modification,e.g. era2017 could
1585 reconfigure items in a process to match our expectation of running in 2017. Once declared,
1586 these Modifier instances are imported into a configuration and items that need to be modified
1587 are then associated with the Modifier and with the action to do the modification.
1588 The registered modifications will only occur if the Modifier was passed to
1589 the cms.Process' constructor.
1595 """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1596 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1597 In order to work, the value returned from this function must be assigned to a uniquely named variable.
1602 if func
is not None and len(kw) != 0:
1603 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1605 """This is used to register an action to be performed on the specific object. Two different forms are allowed
1606 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1607 that will be the object passed in as the first argument.
1608 Form 2: A list of parameter name, value pairs can be passed
1609 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1610 This form can also be used to remove a parameter by passing the value of None
1611 #remove the parameter foo.fred
1612 mod.toModify(foo, fred = None)
1613 Additionally, parameters embedded within PSets can also be modified using a dictionary
1614 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1615 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1617 Modifier._toModifyCheck(obj,func,**kw)
1620 Modifier._toModify(obj,func,**kw)
1623 if func
is not None:
1630 if not isinstance(fromObj, type(toObj)):
1631 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1633 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1635 Modifier._toReplaceWithCheck(toObj,fromObj)
1638 Modifier._toReplaceWith(toObj,fromObj)
1641 if isinstance(fromObj,_ModuleSequenceType):
1642 toObj._seq = fromObj._seq
1643 toObj._tasks = fromObj._tasks
1644 elif isinstance(fromObj,Task):
1645 toObj._collection = fromObj._collection
1646 elif isinstance(fromObj,_Parameterizable):
1648 for p
in toObj.parameterNames_():
1650 for p
in fromObj.parameterNames_():
1651 setattr(toObj,p,getattr(fromObj,p))
1652 if isinstance(fromObj,_TypedParameterizable):
1653 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1656 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1659 """Should only be called by cms.Process instances"""
1670 return self == other
1674 """A Modifier made up of a list of Modifiers
1680 """Should only be called by cms.Process instances
1681 applies list of accumulated changes to the process"""
1683 m._applyNewProcessModifiers(process)
1685 """Should only be called by cms.Process instances"""
1692 """Creates a new ModifierChain which is a copy of
1693 this ModifierChain but excludes any Modifier or
1694 ModifierChain in the list toExclude.
1695 The exclusion is done recursively down the chain.
1699 if m
not in toExclude:
1701 if isinstance(m,ModifierChain):
1702 s = m.__copyIfExclude(toExclude)
1718 if m._isOrContains(other):
1723 """A class used by a Modifier to affect an entire Process instance.
1724 When a Process 'loads' a module containing a ProcessModifier, that
1725 ProcessModifier will be applied to the Process if and only if the
1726 Modifier passed to the constructor has been chosen.
1738 if __name__==
"__main__":
1743 newString = ( x
for x
in newString.split(
'\n')
if len(x) > 0)
1744 oldString = [ x
for x
in oldString.split(
'\n')
if len(x) > 0]
1748 if oldStringLine >= len(oldString):
1751 if l == oldString[oldStringLine]:
1755 return "\n".
join( diff )
1758 """Has same interface as the C++ object that creates PSets
1763 self.
values[label]=(tracked,value)
1765 pair = self.
values[label]
1766 if pair[0] != tracked:
1767 raise Exception(
"Asked for %s parameter '%s', but it is %s" % (
"tracked" if tracked
else "untracked",
1769 "tracked" if pair[0]
else "untracked"))
1830 super(SwitchProducerTest,self).
__init__(
1832 test1 =
lambda: (
True, -10),
1833 test2 =
lambda: (
True, -9),
1834 test3 =
lambda: (
True, -8),
1835 test4 =
lambda: (
True, -7)
1837 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest,
"from test import SwitchProducerTest")
1841 """Nothing to do """
1845 self.assertEqual(len(p.parameterNames_()),0)
1847 self.assertTrue(
'a' in p.parameterNames_())
1848 self.assertEqual(p.a.value(), 1)
1850 self.assertEqual(p.a.value(), 10)
1852 self.assertEqual(p.a.value(), 1)
1853 self.assertFalse(p.a.isTracked())
1854 p.a = untracked.int32(1)
1855 self.assertEqual(p.a.value(), 1)
1856 self.assertFalse(p.a.isTracked())
1858 self.assertEqual(p.foo.value(), 10)
1859 self.assertEqual(p.bar.value(),1.0)
1860 self.assertFalse(p.bar.isTracked())
1861 self.assertRaises(TypeError,setattr,(p,
'c',1))
1863 self.assertEqual(p.a.foo.value(),10)
1864 self.assertEqual(p.a.bar.value(),1.0)
1866 self.assertEqual(p.b.fii.value(),1)
1867 self.assertFalse(p.b.isTracked())
1872 self.assertEqual(p.a.value(),11)
1874 self.assertEqual(p.a.value(),12)
1875 self.assertEqual(v.value(),12)
1881 self.assertNotEqual(p.b,other.b)
1886 self.assertTrue(
'a' in p.analyzers_() )
1887 self.assertTrue(
'a' in p.analyzers)
1888 p.add_(
Service(
"MessageLogger"))
1889 self.assertTrue(
'MessageLogger' in p.services_())
1890 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1892 self.assertTrue(
'Tracer' in p.services_())
1893 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1894 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1895 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1897 self.assertEqual(p.out.type_(),
'Outer')
1898 self.assertTrue(
'out' in p.outputModules_() )
1901 self.assertTrue(
'geom' in p.es_sources_())
1903 self.assertTrue(
'ConfigDB' in p.es_sources_())
1906 self.assertTrue(
'aliasfoo1' in p.aliases_())
1910 def __init__(self,*arg,**args):
1911 for name
in args.keys():
1912 self.__dict__[name]=args[name]
1931 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1932 self.assertEqual(p.a.label_(),
"a")
1933 self.assertRaises(AttributeError,getattr,p,
'b')
1934 self.assertEqual(p.Full.type_(),
"Full")
1935 self.assertEqual(
str(p.c),
'a')
1936 self.assertEqual(
str(p.d),
'a')
1951 self.assertRaises(ValueError, p1.extend, z1)
1960 aaa=copy.deepcopy(a),
1961 s4=copy.deepcopy(s3),
1968 self.assertEqual(p2.s4.label_(),
"s4")
1970 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
1971 p2.s4.setLabel(
"s4")
1972 p2.s4.setLabel(
None)
1973 p2.s4.setLabel(
"foo")
1974 p2._Process__setObjectLabel(p2.s4,
"foo")
1975 p2._Process__setObjectLabel(p2.s4,
None)
1976 p2._Process__setObjectLabel(p2.s4,
"bar")
1983 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
1984 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
1985 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
1991 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
1992 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
1993 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
1997 """import FWCore.ParameterSet.Config as cms
1999 process = cms.Process("test")
2001 process.maxEvents = cms.untracked.PSet(
2002 input = cms.optional.untracked.int32,
2003 output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
2006 process.maxLuminosityBlocks = cms.untracked.PSet(
2007 input = cms.untracked.int32(-1)
2010 process.options = cms.untracked.PSet(
2011 FailPath = cms.untracked.vstring(),
2012 IgnoreCompletely = cms.untracked.vstring(),
2013 Rethrow = cms.untracked.vstring(),
2014 SkipEvent = cms.untracked.vstring(),
2015 allowUnscheduled = cms.obsolete.untracked.bool,
2016 canDeleteEarly = cms.untracked.vstring(),
2017 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
2018 dumpOptions = cms.untracked.bool(False),
2019 emptyRunLumiMode = cms.obsolete.untracked.string,
2020 eventSetup = cms.untracked.PSet(
2021 forceNumberOfConcurrentIOVs = cms.untracked.PSet(
2022 allowAnyLabel_=cms.required.untracked.uint32
2024 numberOfConcurrentIOVs = cms.untracked.uint32(0)
2026 fileMode = cms.untracked.string('FULLMERGE'),
2027 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
2028 makeTriggerResults = cms.obsolete.untracked.bool,
2029 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
2030 numberOfConcurrentRuns = cms.untracked.uint32(1),
2031 numberOfStreams = cms.untracked.uint32(0),
2032 numberOfThreads = cms.untracked.uint32(1),
2033 printDependencies = cms.untracked.bool(False),
2034 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
2035 throwIfIllegalParameter = cms.untracked.bool(True),
2036 wantSummary = cms.untracked.bool(False)
2049 """process.a = cms.EDAnalyzer("MyAnalyzer")
2050 process.s = cms.Sequence(process.a)
2051 process.r = cms.Sequence(process.s)
2052 process.p = cms.Path(process.a)
2053 process.p2 = cms.Path(process.s)
2054 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2066 """process.a = cms.EDAnalyzer("MyAnalyzer")
2067 process.b = cms.EDAnalyzer("YourAnalyzer")
2068 process.r = cms.Sequence(process.a)
2069 process.s = cms.Sequence(process.r)
2070 process.p = cms.Path(process.a)
2071 process.p2 = cms.Path(process.r)
2072 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2083 """process.a = cms.EDAnalyzer("MyAnalyzer")
2084 process.r = cms.Sequence((process.a))
2085 process.p = cms.Path(process.a)
2086 process.p2 = cms.Path(process.r)
2087 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2103 p.task3.add(p.task1)
2107 p.p2 =
Path(p.r, p.task1, p.task2)
2108 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2111 """process.b = cms.EDProducer("bProducer")
2112 process.c = cms.EDProducer("cProducer")
2113 process.d = cms.EDProducer("dProducer")
2114 process.e = cms.EDProducer("eProducer")
2115 process.f = cms.EDProducer("fProducer")
2116 process.g = cms.EDProducer("gProducer")
2117 process.a = cms.EDAnalyzer("MyAnalyzer")
2118 process.task5 = cms.Task()
2119 process.task1 = cms.Task(process.task5)
2120 process.task3 = cms.Task(process.task1)
2121 process.task2 = cms.Task(process.c, process.task3)
2122 process.task4 = cms.Task(process.f, process.task2)
2123 process.r = cms.Sequence((process.a))
2124 process.p = cms.Path(process.a)
2125 process.p2 = cms.Path(process.r, process.task1, process.task2)
2126 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2133 p.task1 =
Task(p.d, p.e)
2134 task2 =
Task(p.f, p.g)
2135 p.schedule =
Schedule(tasks=[p.task1,task2])
2138 """process.d = cms.EDProducer("dProducer")
2139 process.e = cms.EDProducer("eProducer")
2140 process.f = cms.EDProducer("fProducer")
2141 process.g = cms.EDProducer("gProducer")
2142 process.task1 = cms.Task(process.d, process.e)
2143 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2149 """process.schedule = cms.Schedule()""")
2158 d=process.dumpPython()
2160 """process.a = cms.EDProducer("A")
2161 process.s2 = cms.Sequence(process.a)""")
2171 d=process.dumpPython()
2173 """process.a = cms.EDProducer("A")
2174 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2199 p.p =
Path(p.c+s+p.a)
2200 p.p2 =
Path(p.c+p.s4+p.a)
2206 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2208 p.globalReplace(
"a",new)
2209 p.globalReplace(
"d",new2)
2212 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2213 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2215 p.p2.visit(visitor_p2)
2216 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2217 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a)")
2219 p.e3.visit(visitor3)
2220 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2222 p.s4.visit(visitor4)
2223 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2224 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d))")
2226 p.t1.visit(visitor5)
2227 self.assertTrue(visitor5.modules == set([new2]))
2229 listOfTasks = list(p.schedule._tasks)
2230 listOfTasks[0].visit(visitor6)
2231 self.assertTrue(visitor6.modules == set([new2]))
2239 self.assertEqual(
str(p.s),
'a+b')
2240 self.assertEqual(p.s.label_(),
's')
2241 path =
Path(p.c+p.s)
2242 self.assertEqual(
str(path),
'c+a+b')
2243 p._validateSequence(path,
'p1')
2245 p2 =
Path(p.c+p.s*notInProcess)
2246 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2256 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2260 self.assertFalse(service._inProcess)
2263 self.assertTrue(service._inProcess)
2265 process.d = service2
2266 self.assertFalse(service._inProcess)
2267 self.assertTrue(service2._inProcess)
2269 self.assertFalse(service2._inProcess)
2289 testTask1 =
Task(edproducer, edfilter)
2290 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2291 testTask1.add(essource, service)
2292 testTask1.add(essource, esproducer)
2293 testTask1.add(testTask2)
2294 coll = testTask1._collection
2295 self.assertTrue(edproducer
in coll)
2296 self.assertTrue(edfilter
in coll)
2297 self.assertTrue(service
in coll)
2298 self.assertTrue(essource
in coll)
2299 self.assertTrue(esproducer
in coll)
2300 self.assertTrue(testTask2
in coll)
2301 self.assertTrue(len(coll) == 6)
2302 self.assertTrue(len(testTask2._collection) == 0)
2306 taskContents.append(i)
2307 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2312 process.mproducer = edproducer
2313 process.mproducer2 = edproducer2
2314 process.mfilter = edfilter
2315 process.messource = essource
2316 process.mesproducer = esproducer
2319 testTask3 =
Task(edproducer, edproducer2)
2320 testTask1.add(testTask3)
2321 process.myTask1 = testTask1
2328 testTask1.visit(visitor)
2329 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2330 l2 = testTask1.moduleNames
2331 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2333 testTask4 =
Task(edproducer3)
2335 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2337 process.myTask4 = testTask4
2338 self.assertTrue(
False)
2339 except RuntimeError:
2342 testTask5 =
Task(service3)
2344 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2346 process.myTask5 = testTask5
2347 self.assertTrue(
False)
2348 except RuntimeError:
2351 process.d = service3
2352 process.myTask5 = testTask5
2355 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2357 self.assertTrue(process.tasks == expectedFixedDict)
2358 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2359 self.assertTrue(process.myTask1 == testTask1)
2363 process.mproducer2 = edproducer4
2367 testTask1.visit(visitor1)
2368 l.sort(key=
lambda mod: mod.__str__())
2369 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2370 self.assertTrue(expectedList == l)
2371 process.myTask6 =
Task()
2372 process.myTask7 =
Task()
2373 process.mproducer8 = edproducer8
2374 process.myTask8 =
Task(process.mproducer8)
2375 process.myTask6.add(process.myTask7)
2376 process.myTask7.add(process.myTask8)
2377 process.myTask1.add(process.myTask6)
2378 process.myTask8.add(process.myTask5)
2380 testDict = process._itemsInDependencyOrder(process.tasks)
2381 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2382 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2384 for testLabel, testTask
in testDict.items():
2385 self.assertTrue(testLabel == expectedLabels[index])
2386 self.assertTrue(testTask == expectedTasks[index])
2392 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n'
2393 self.assertTrue(pythonDump == expectedPythonDump)
2395 process.myTask5 =
Task()
2396 process.myTask100 =
Task()
2397 process.mproducer9 = edproducer9
2398 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2399 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2400 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2402 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2403 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2404 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2405 process.path2 =
Path(process.mproducer)
2406 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2408 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')
2410 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')
2415 process.path1.visit(nameVisitor)
2416 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2417 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2421 process.path21 = process.path11.copy()
2422 process.path21.replace(process.mproducer, process.mproducer10)
2424 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')
2433 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')
2435 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2436 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')
2438 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2439 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')
2448 process.path24 =
Path(process.a+process.b+process.c+process.d)
2449 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2450 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
2455 process.path200.replace(process.c,process.b)
2456 process.path200.replace(process.e,process.f)
2457 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2458 process.path200.replace(process.b,process.c)
2459 process.path200.replace(process.f,process.e)
2460 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2461 process.path200.replace(process.c,process.a)
2462 process.path200.replace(process.e,process.g)
2463 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2464 process.path200.replace(process.a,process.c)
2465 process.path200.replace(process.g,process.e)
2466 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2477 self.assertEqual(
str(path),
'a+b+c')
2478 path =
Path(p.a*p.b+p.c)
2479 self.assertEqual(
str(path),
'a+b+c')
2482 path =
Path(p.a+ p.b*p.c)
2483 self.assertEqual(
str(path),
'a+b+c')
2484 path =
Path(p.a*(p.b+p.c))
2485 self.assertEqual(
str(path),
'a+b+c')
2486 path =
Path(p.a*(p.b+~p.c))
2488 self.assertEqual(
str(path),
'a+b+~c')
2490 self.assertRaises(TypeError,Path,p.es)
2493 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path()\n')
2496 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a)\n')
2499 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(cms.Task())\n')
2502 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task())\n')
2507 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task(), process.t1)\n')
2518 p.path =
Path(p.a*p.b)
2519 lookuptable = {
id(a): p.a,
id(b): p.b}
2523 self.assertEqual(
str(path),
str(p.path))
2544 path =
Path(a * c * seq1, task1)
2546 self.assertTrue(path.contains(a))
2547 self.assertFalse(path.contains(b))
2548 self.assertTrue(path.contains(c))
2549 self.assertFalse(path.contains(d))
2550 self.assertTrue(path.contains(e))
2551 self.assertFalse(path.contains(f))
2552 self.assertTrue(path.contains(g))
2555 self.assertFalse(endpath.contains(b))
2556 self.assertTrue(endpath.contains(i))
2559 self.assertFalse(seq.contains(b))
2560 self.assertTrue(seq.contains(c))
2563 task =
Task(j, k, task2)
2564 self.assertFalse(task.contains(b))
2565 self.assertTrue(task.contains(j))
2566 self.assertTrue(task.contains(k))
2567 self.assertTrue(task.contains(l))
2571 sch =
Schedule(path, path2, tasks=[task,task3])
2572 self.assertFalse(sch.contains(b))
2573 self.assertTrue(sch.contains(a))
2574 self.assertTrue(sch.contains(c))
2575 self.assertTrue(sch.contains(e))
2576 self.assertTrue(sch.contains(g))
2577 self.assertTrue(sch.contains(n))
2578 self.assertTrue(sch.contains(j))
2579 self.assertTrue(sch.contains(k))
2580 self.assertTrue(sch.contains(l))
2581 self.assertTrue(sch.contains(m))
2594 self.assertEqual(s[0],p.path1)
2595 self.assertEqual(s[1],p.path2)
2597 self.assertTrue(
'b' in p.schedule.moduleNames())
2598 self.assertTrue(hasattr(p,
'b'))
2599 self.assertTrue(hasattr(p,
'c'))
2600 self.assertTrue(hasattr(p,
'd'))
2601 self.assertTrue(hasattr(p,
'path1'))
2602 self.assertTrue(hasattr(p,
'path2'))
2603 self.assertTrue(hasattr(p,
'path3'))
2605 self.assertTrue(
'b' in p.schedule.moduleNames())
2606 self.assertTrue(hasattr(p,
'b'))
2607 self.assertTrue(
not hasattr(p,
'c'))
2608 self.assertTrue(
not hasattr(p,
'd'))
2609 self.assertTrue(hasattr(p,
'path1'))
2610 self.assertTrue(hasattr(p,
'path2'))
2611 self.assertTrue(
not hasattr(p,
'path3'))
2613 self.assertTrue(len(p.schedule._tasks) == 0)
2627 p.task2 =
Task(p.f, p.Tracer)
2628 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2629 self.assertEqual(s[0],p.path1)
2630 self.assertEqual(s[1],p.path2)
2631 self.assertTrue(len(s._tasks) == 2)
2632 self.assertTrue(p.task1
in s._tasks)
2633 self.assertTrue(p.task2
in s._tasks)
2634 listOfTasks = list(s._tasks)
2635 self.assertTrue(len(listOfTasks) == 2)
2636 self.assertTrue(p.task1 == listOfTasks[0])
2637 self.assertTrue(p.task2 == listOfTasks[1])
2639 self.assertTrue(
'b' in p.schedule.moduleNames())
2644 process2.path1 =
Path(process2.a)
2645 process2.task1 =
Task(process2.e)
2646 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2647 listOfTasks = list(process2.schedule._tasks)
2648 self.assertTrue(listOfTasks[0] == process2.task1)
2652 self.assertEqual(s2[0],p.path1)
2653 self.assertEqual(s2[1],p.path2)
2654 self.assertTrue(len(s2._tasks) == 2)
2655 self.assertTrue(p.task1
in s2._tasks)
2656 self.assertTrue(p.task2
in s2._tasks)
2657 listOfTasks = list(s2._tasks)
2658 self.assertTrue(len(listOfTasks) == 2)
2659 self.assertTrue(p.task1 == listOfTasks[0])
2660 self.assertTrue(p.task2 == listOfTasks[1])
2662 names = s.moduleNames()
2663 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2669 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2678 self.assertTrue(
'a' in s.moduleNames())
2679 self.assertTrue(
'b' in s.moduleNames())
2680 self.assertTrue(
'c' in s.moduleNames())
2684 self.assertTrue(
'a' in s.moduleNames())
2685 self.assertTrue(
'b' in s.moduleNames())
2686 self.assertTrue(
'c' in s.moduleNames())
2695 self.assertTrue(p.schedule
is None)
2698 self.assertEqual(pths[keys[0]],p.path1)
2699 self.assertEqual(pths[keys[1]],p.path2)
2701 self.assertTrue(hasattr(p,
'a'))
2702 self.assertTrue(hasattr(p,
'b'))
2703 self.assertTrue(
not hasattr(p,
'c'))
2704 self.assertTrue(hasattr(p,
'path1'))
2705 self.assertTrue(hasattr(p,
'path2'))
2714 self.assertTrue(p.schedule
is None)
2717 self.assertEqual(pths[keys[1]],p.path1)
2718 self.assertEqual(pths[keys[0]],p.path2)
2725 self.assertEqual(p.modu.a.value(),1)
2726 self.assertEqual(p.modu.b.value(),2)
2731 self.assertTrue(
not a.isModified())
2733 self.assertTrue(a.isModified())
2735 self.assertEqual(p.a.a1.value(), 1)
2739 self.assertEqual(p.a.a1.value(), 2)
2748 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2749 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2753 self.assertEqual(p.options.numberOfThreads.value(),1)
2754 p.options.numberOfThreads = 8
2755 self.assertEqual(p.options.numberOfThreads.value(),8)
2757 self.assertEqual(p.options.numberOfThreads.value(),1)
2758 p.options = dict(numberOfStreams =2,
2760 self.assertEqual(p.options.numberOfThreads.value(),2)
2761 self.assertEqual(p.options.numberOfStreams.value(),2)
2765 p.maxEvents.input = 10
2766 self.assertEqual(p.maxEvents.input.value(),10)
2768 p.maxEvents.output = 10
2769 self.assertEqual(p.maxEvents.output.value(),10)
2771 p.maxEvents.output =
PSet(out=untracked.int32(10))
2772 self.assertEqual(p.maxEvents.output.out.value(), 10)
2774 p.maxEvents = untracked.PSet(input = untracked.int32(5))
2775 self.assertEqual(p.maxEvents.input.value(), 5)
2784 p.bars.foos =
'Foosball'
2785 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2786 p.p =
Path(p.foos*p.bars)
2788 p.add_(
Service(
"MessageLogger"))
2794 p.prefer(
"ForceSource")
2797 """process.juicer = cms.ESProducer("JuicerProducer")
2798 process.ForceSource = cms.ESSource("ForceSource")
2799 process.prefer("ForceSource")
2800 process.prefer("juicer")""")
2801 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2803 """process.juicer = cms.ESProducer("JuicerProducer")
2804 process.ForceSource = cms.ESSource("ForceSource")
2805 process.prefer("ForceSource")
2806 process.prefer("juicer",
2807 fooRcd = cms.vstring('Foo')
2822 self.assertEqual(process.m.p.i.value(), 4)
2832 subProcess.p =
Path(subProcess.a)
2833 subProcess.add_(
Service(
"Foo"))
2834 process.addSubProcess(
SubProcess(subProcess))
2835 d = process.dumpPython()
2836 equalD =
"""parentProcess = process
2837 process.a = cms.EDProducer("A")
2838 process.Foo = cms.Service("Foo")
2839 process.p = cms.Path(process.a)
2840 childProcess = process
2841 process = parentProcess
2842 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
2843 ), outputCommands = cms.untracked.vstring()))"""
2844 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2847 process.fillProcessDesc(p)
2848 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2849 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2850 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2860 proc.fillProcessDesc(p)
2861 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2862 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2863 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2864 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2865 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2866 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2876 proc.s =
Sequence(proc.a + proc.sp)
2877 proc.t =
Task(proc.a, proc.sp)
2879 proc.p.associate(proc.t)
2881 proc.fillProcessDesc(p)
2882 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2883 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2884 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2885 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
2887 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
2888 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2889 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
2890 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2891 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
2892 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2893 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
2894 dump = proc.dumpPython()
2895 self.assertEqual(dump.find(
'@'), -1)
2896 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
2897 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
2906 proc.s =
Sequence(proc.a + proc.sp)
2907 proc.t =
Task(proc.a, proc.sp)
2909 proc.p.associate(proc.t)
2911 proc.fillProcessDesc(p)
2912 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2913 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2914 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2915 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
2917 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
2918 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2919 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
2920 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
2921 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2922 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
2923 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2924 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
2933 proc.s =
Sequence(proc.a + proc.sp)
2934 proc.t =
Task(proc.a, proc.sp)
2936 proc.p.associate(proc.t)
2938 proc.fillProcessDesc(p)
2939 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2940 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2941 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2942 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
2943 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2944 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
2945 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
2946 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2947 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
2948 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2949 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
2963 p.t3 =
Task(p.g, p.t1)
2964 p.path1 =
Path(p.a, p.t3)
2966 self.assertTrue(p.schedule
is None)
2969 self.assertEqual(pths[keys[0]],p.path1)
2970 self.assertEqual(pths[keys[1]],p.path2)
2972 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2974 p.vpset2 = untracked.VPSet()
2976 self.assertTrue(hasattr(p,
'a'))
2977 self.assertTrue(hasattr(p,
'b'))
2978 self.assertTrue(
not hasattr(p,
'c'))
2979 self.assertTrue(
not hasattr(p,
'd'))
2980 self.assertTrue(hasattr(p,
'e'))
2981 self.assertTrue(
not hasattr(p,
'f'))
2982 self.assertTrue(hasattr(p,
'g'))
2983 self.assertTrue(
not hasattr(p,
's'))
2984 self.assertTrue(hasattr(p,
't1'))
2985 self.assertTrue(
not hasattr(p,
't2'))
2986 self.assertTrue(hasattr(p,
't3'))
2987 self.assertTrue(hasattr(p,
'path1'))
2988 self.assertTrue(hasattr(p,
'path2'))
3011 p.path1 =
Path(p.a, p.t3)
3013 p.path3 =
Path(p.b+p.s2)
3014 p.path4 =
Path(p.b+p.s3)
3015 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3016 p.schedule.associate(p.t4)
3019 self.assertEqual(pths[keys[0]],p.path1)
3020 self.assertEqual(pths[keys[1]],p.path2)
3022 self.assertTrue(hasattr(p,
'a'))
3023 self.assertTrue(hasattr(p,
'b'))
3024 self.assertTrue(
not hasattr(p,
'c'))
3025 self.assertTrue(
not hasattr(p,
'd'))
3026 self.assertTrue(
not hasattr(p,
'e'))
3027 self.assertTrue(
not hasattr(p,
'f'))
3028 self.assertTrue(hasattr(p,
'g'))
3029 self.assertTrue(hasattr(p,
'h'))
3030 self.assertTrue(hasattr(p,
'i'))
3031 self.assertTrue(
not hasattr(p,
't1'))
3032 self.assertTrue(hasattr(p,
't2'))
3033 self.assertTrue(hasattr(p,
't3'))
3034 self.assertTrue(hasattr(p,
't4'))
3035 self.assertTrue(
not hasattr(p,
's'))
3036 self.assertTrue(hasattr(p,
's2'))
3037 self.assertTrue(
not hasattr(p,
's3'))
3038 self.assertTrue(hasattr(p,
'path1'))
3039 self.assertTrue(hasattr(p,
'path2'))
3040 self.assertTrue(hasattr(p,
'path3'))
3041 self.assertTrue(
not hasattr(p,
'path4'))
3049 self.assertTrue(hasattr(p,
'a'))
3050 self.assertTrue(hasattr(p,
'b'))
3051 self.assertTrue(hasattr(p,
's'))
3052 self.assertTrue(hasattr(p,
'pth'))
3058 p.prune(keepUnresolvedSequencePlaceholders=
True)
3059 self.assertTrue(hasattr(p,
'b'))
3060 self.assertTrue(hasattr(p,
's'))
3061 self.assertTrue(hasattr(p,
'pth'))
3062 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3070 self.assertTrue(hasattr(p,
'a'))
3071 self.assertTrue(hasattr(p,
'b'))
3072 self.assertTrue(hasattr(p,
's'))
3073 self.assertTrue(hasattr(p,
'pth'))
3079 p.prune(keepUnresolvedSequencePlaceholders=
True)
3080 self.assertTrue(hasattr(p,
'b'))
3081 self.assertTrue(hasattr(p,
's'))
3082 self.assertTrue(hasattr(p,
'pth'))
3083 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
3091 p.path1 =
Path(p.b, p.t2, p.t3)
3094 p.endpath1 =
EndPath(p.b, p.t5)
3098 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3108 """process.a = cms.EDProducer("ma")
3109 process.c = cms.EDProducer("mc")
3110 process.d = cms.EDProducer("md")
3111 process.e = cms.EDProducer("me")
3112 process.f = cms.EDProducer("mf")
3113 process.g = cms.EDProducer("mg")
3114 process.h = cms.EDProducer("mh")
3115 process.i = cms.EDProducer("mi")
3116 process.j = cms.EDProducer("mj")
3117 process.b = cms.EDAnalyzer("mb")
3118 process.t1 = cms.Task(cms.TaskPlaceholder("c"))
3119 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1)
3120 process.t3 = cms.Task(cms.TaskPlaceholder("e"))
3121 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
3122 process.t4 = cms.Task(cms.TaskPlaceholder("f"))
3123 process.t6 = cms.Task(cms.TaskPlaceholder("h"))
3124 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
3125 process.t8 = cms.Task(cms.TaskPlaceholder("j"))
3126 process.path1 = cms.Path(process.b, process.t2, process.t3)
3127 process.endpath1 = cms.EndPath(process.b, process.t5)
3128 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3131 """process.a = cms.EDProducer("ma")
3132 process.c = cms.EDProducer("mc")
3133 process.d = cms.EDProducer("md")
3134 process.e = cms.EDProducer("me")
3135 process.f = cms.EDProducer("mf")
3136 process.g = cms.EDProducer("mg")
3137 process.h = cms.EDProducer("mh")
3138 process.i = cms.EDProducer("mi")
3139 process.j = cms.EDProducer("mj")
3140 process.b = cms.EDAnalyzer("mb")
3141 process.t1 = cms.Task(process.c)
3142 process.t2 = cms.Task(process.a, process.d, process.t1)
3143 process.t3 = cms.Task(process.e)
3144 process.t4 = cms.Task(process.f)
3145 process.t6 = cms.Task(process.h)
3146 process.t7 = cms.Task(process.a, process.i, process.t6)
3147 process.t8 = cms.Task(process.j)
3148 process.t5 = cms.Task(process.a, process.g, process.t4)
3149 process.path1 = cms.Path(process.b, process.t2, process.t3)
3150 process.endpath1 = cms.EndPath(process.b, process.t5)
3151 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3163 p.t1 =
Task(p.g, p.h)
3167 p.path1 =
Path(p.a+p.f+p.s,t2)
3170 self.assertTrue(hasattr(p,
'f'))
3171 self.assertTrue(hasattr(p,
'g'))
3175 self.assertFalse(hasattr(p,
'f'))
3176 self.assertFalse(hasattr(p,
'g'))
3177 self.assertTrue(p.t1.dumpPython() ==
'cms.Task(process.h)\n')
3178 self.assertTrue(p.s.dumpPython() ==
'cms.Sequence(process.d)\n')
3179 self.assertTrue(p.path1.dumpPython() ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
3180 self.assertTrue(p.endpath1.dumpPython() ==
'cms.EndPath(process.b)\n')
3182 self.assertTrue(p.path1.dumpPython() ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
3183 self.assertTrue(p.schedule_().
dumpPython() ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
3190 m1.toModify(p.a,_mod_fred)
3191 self.assertEqual(p.a.fred.value(),2)
3193 m1.toModify(p.b, wilma = 2)
3194 self.assertEqual(p.b.wilma.value(),2)
3195 self.assertTrue(p.isUsingModifier(m1))
3200 m1.toModify(p.a,_mod_fred)
3202 m1.toModify(p.b, wilma = 2)
3203 self.assertEqual(p.a.fred.value(),1)
3204 self.assertEqual(p.b.wilma.value(),1)
3205 self.assertEqual(p.isUsingModifier(m1),
False)
3210 m1.toModify(p.a, fred =
int32(2))
3211 p.b = p.a.clone(wilma =
int32(3))
3212 self.assertEqual(p.a.fred.value(),2)
3213 self.assertEqual(p.a.wilma.value(),1)
3214 self.assertEqual(p.b.fred.value(),2)
3215 self.assertEqual(p.b.wilma.value(),3)
3220 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
3221 self.assertEqual(hasattr(p.a,
"fred"),
False)
3222 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
3223 self.assertEqual(p.a.wilma.value(),1)
3228 m1.toModify(p.a, wilma =
int32(2))
3229 self.assertEqual(p.a.fred.value(), 1)
3230 self.assertEqual(p.a.wilma.value(),2)
3235 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
3236 self.assertEqual(p.a.flintstones.fred.value(),2)
3237 self.assertEqual(p.a.flintstones.wilma.value(),1)
3242 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
3243 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
3248 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
3249 self.assertEqual(p.a.flintstones[0].fred.value(),1)
3250 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3255 m1.toModify(p.a, fred = {1:7})
3256 self.assertEqual(p.a.fred[0],1)
3257 self.assertEqual(p.a.fred[1],7)
3258 self.assertEqual(p.a.fred[2],3)
3264 try: m1.toModify(p.a, fred = {5:7})
3265 except IndexError
as e: raised =
True
3266 self.assertEqual(raised,
True)
3272 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
3273 except TypeError
as e: raised =
True
3274 self.assertEqual(raised,
True)
3278 class ProcModifierMod(
object):
3279 def __init__(self,modifier,func):
3284 testMod = DummyMod()
3286 self.assertTrue(hasattr(p,
"a"))
3289 testProcMod = ProcModifierMod(m1,_rem_a)
3291 p.extend(testProcMod)
3292 self.assertTrue(
not hasattr(p,
"a"))
3297 self.assertTrue(p.isUsingModifier(m1))
3298 self.assertTrue(p.isUsingModifier(mc))
3299 testMod = DummyMod()
3301 m1.toModify(p.b, fred =
int32(3))
3303 testProcMod = ProcModifierMod(m1,_rem_a)
3304 p.extend(testProcMod)
3305 self.assertTrue(
not hasattr(p,
"a"))
3306 self.assertEqual(p.b.fred.value(),3)
3311 mclone = mc.copyAndExclude([m2])
3312 self.assertTrue(
not mclone._isOrContains(m2))
3313 self.assertTrue(mclone._isOrContains(m1))
3316 mclone = mc2.copyAndExclude([m2])
3317 self.assertTrue(
not mclone._isOrContains(m2))
3318 self.assertTrue(mclone._isOrContains(m1))
3319 self.assertTrue(mclone._isOrContains(m3))
3325 (m1 & m2).toModify(p.a, fred =
int32(2))
3326 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3327 self.assertEqual(p.a.fred, 1)
3332 (m1 & m2).toModify(p.a, fred =
int32(2))
3333 self.assertEqual(p.a.fred, 2)
3339 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3340 self.assertEqual(p.a.fred, 2)
3341 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3342 self.assertEqual(p.a.fred, 3)
3343 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3344 self.assertEqual(p.a.fred, 4)
3350 (~m1).toModify(p.a, fred=2)
3351 self.assertEqual(p.a.fred, 1)
3352 (~m2).toModify(p.a, wilma=2)
3353 self.assertEqual(p.a.wilma, 2)
3354 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3355 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3362 (m1 | m2).toModify(p.a, fred=2)
3363 self.assertEqual(p.a.fred, 2)
3364 (m1 | m2 | m3).toModify(p.a, fred=3)
3365 self.assertEqual(p.a.fred, 3)
3366 (m3 | m2 | m1).toModify(p.a, fred=4)
3367 self.assertEqual(p.a.fred, 4)
3368 ((m1 | m2) | m3).toModify(p.a, fred=5)
3369 self.assertEqual(p.a.fred, 5)
3370 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3371 self.assertEqual(p.a.fred, 6)
3372 (m2 | m3).toModify(p.a, fred=7)
3373 self.assertEqual(p.a.fred, 6)
3374 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3375 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3383 (m1 & ~m2).toModify(p.a, fred=2)
3384 self.assertEqual(p.a.fred, 1)
3385 (m1 & ~m3).toModify(p.a, fred=2)
3386 self.assertEqual(p.a.fred, 2)
3387 (m1 | ~m2).toModify(p.a, fred=3)
3388 self.assertEqual(p.a.fred, 3)
3389 (~m1 | ~m2).toModify(p.a, fred=4)
3390 self.assertEqual(p.a.fred, 3)
3391 (~m3 & ~m4).toModify(p.a, fred=4)
3392 self.assertEqual(p.a.fred, 4)
3393 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3394 self.assertEqual(p.a.fred, 5)
3400 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3407 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3408 self.assertEqual(p.a.wilma.value(),3)
3409 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3410 self.assertEqual(hasattr(p,
"fred"),
False)
3411 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
3413 m1.toReplaceWith(p.td,
Task(p.e))
3414 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3420 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3428 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3429 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3430 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3431 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3432 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3433 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3434 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3435 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3436 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3437 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3438 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3439 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3440 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3441 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3442 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3443 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3444 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3445 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3452 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
3453 self.assertEqual(a.foo2[0].type,
"Foo3")
3456 self.assertEqual(a.foo2[0].type,
"Foo3")
3457 self.assertEqual(a.foo4[0].type,
"Foo4")
3459 m.toModify(a, foo2 =
None)
3460 self.assertFalse(hasattr(a,
"foo2"))
3461 self.assertEqual(a.foo4[0].type,
"Foo4")
3464 self.assertFalse(hasattr(a,
"foo2"))
3465 self.assertFalse(hasattr(a,
"foo4"))
3466 self.assertTrue(hasattr(a,
"bar"))
3467 self.assertEqual(a.bar[0].type,
"Bar")
3480 test1 = dict(a = 4, b = dict(c =
None)),
3481 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
3482 self.assertEqual(sp.test1.a.value(), 4)
3483 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
3484 self.assertEqual(sp.test2.aa.value(), 15)
3485 self.assertEqual(sp.test2.bb.cc.value(), 45)
3486 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
3489 self.assertEqual(sp.test1.type_(),
"Fred")
3490 self.assertEqual(sp.test1.x.value(), 42)
3491 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
3494 self.assertEqual(sp.test2.type_(),
"Xyzzy")
3495 self.assertEqual(sp.test2.x.value(), 24)
3496 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
3499 self.assertEqual(sp.test3.type_(),
"Wilma")
3500 self.assertEqual(sp.test3.y.value(), 24)
3501 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
3503 m.toModify(sp, test2 =
None)
3504 self.assertEqual(hasattr(sp,
"test2"),
False)
3507 self.assertTrue(hasattr(sp.test2,
"foo"))
3510 self.assertTrue(hasattr(sp.test2,
"bar"))
3513 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
3515 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
3521 p.maxEvents.input = 10
3522 p.options.numberOfThreads = 4
3523 p.maxLuminosityBlocks.input = 2
3525 self.assertEqual(p.maxEvents.input.value(),10)
3526 self.assertEqual(p.options.numberOfThreads.value(), 4)
3527 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
3533 self.assertTrue(hasattr(p,
'fltr'))