4 from __future__
import print_function
5 from __future__
import absolute_import
8 from .Options
import Options
14 from .Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
17 from .Modules
import *
18 from .Modules
import _Module
19 from .SequenceTypes
import *
20 from .SequenceTypes
import _ModuleSequenceType, _Sequenceable
21 from .SequenceVisitors
import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
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',
'<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""" 105 """The argument 'name' will be the name applied to this Process 106 Can optionally pass as additional arguments cms.Modifier instances 107 that will be used to modify the Process as it is built 109 self.__dict__[
'_Process__name'] = name
110 if not name.isalnum():
111 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
112 self.__dict__[
'_Process__filters'] = {}
113 self.__dict__[
'_Process__producers'] = {}
114 self.__dict__[
'_Process__switchproducers'] = {}
115 self.__dict__[
'_Process__source'] =
None 116 self.__dict__[
'_Process__looper'] =
None 117 self.__dict__[
'_Process__subProcesses'] = []
118 self.__dict__[
'_Process__schedule'] =
None 119 self.__dict__[
'_Process__analyzers'] = {}
120 self.__dict__[
'_Process__outputmodules'] = {}
123 self.__dict__[
'_Process__sequences'] = {}
124 self.__dict__[
'_Process__tasks'] = {}
125 self.__dict__[
'_Process__services'] = {}
126 self.__dict__[
'_Process__essources'] = {}
127 self.__dict__[
'_Process__esproducers'] = {}
128 self.__dict__[
'_Process__esprefers'] = {}
129 self.__dict__[
'_Process__aliases'] = {}
130 self.__dict__[
'_Process__psets']={}
131 self.__dict__[
'_Process__vpsets']={}
132 self.__dict__[
'_cloneToObjectDict'] = {}
134 self.__dict__[
'_Process__InExtendCall'] =
False 135 self.__dict__[
'_Process__partialschedules'] = {}
137 self.__dict__[
'_Process__modifiers'] = Mods
141 for m
in self.__modifiers:
146 _Module.__isStrict__ =
True 150 """Returns a string containing all the EDProducer labels separated by a blank""" 153 """Returns a string containing all the SwitchProducer labels separated by a blank""" 156 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 159 """Returns a string containing all the EDFilter labels separated by a blank""" 162 """Returns a string containing all the Path names separated by a blank""" 169 Since cloneToObjectDict stores a hash of objects by their 170 id() it needs to be updated when unpickling to use the 171 new object id values instantiated during the unpickle. 174 self.__dict__.update(pkldict)
176 for value
in self._cloneToObjectDict.values():
177 tmpDict[
id(value)] = value
178 self.__dict__[
'_cloneToObjectDict'] = tmpDict
183 """returns a dict of the filters that have been added to the Process""" 185 filters = property(filters_, doc=
"dictionary containing the filters for the process")
189 if not name.isalnum():
190 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
191 self.__dict__[
'_Process__name'] = name
192 process = property(name_,setName_, doc=
"name of the process")
194 """returns a dict of the producers that have been added to the Process""" 196 producers = property(producers_,doc=
"dictionary containing the producers for the process")
198 """returns a dict of the SwitchProducers that have been added to the Process""" 200 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
202 """returns the source that has been added to the Process or None if none have been added""" 206 source = property(source_,setSource_,doc=
'the main source or None if not set')
208 """returns the looper that has been added to the Process or None if none have been added""" 212 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
215 return untracked.PSet(numberOfThreads = untracked.uint32(1),
216 numberOfStreams = untracked.uint32(0),
217 numberOfConcurrentRuns = untracked.uint32(1),
218 numberOfConcurrentLuminosityBlocks = untracked.uint32(1),
219 eventSetup = untracked.PSet(
220 numberOfConcurrentIOVs = untracked.uint32(1),
221 forceNumberOfConcurrentIOVs = untracked.PSet(
222 allowAnyLabel_ = required.untracked.uint32
225 wantSummary = untracked.bool(
False),
226 fileMode = untracked.string(
'FULLMERGE'),
227 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
228 throwIfIllegalParameter = untracked.bool(
True),
229 printDependencies = untracked.bool(
False),
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 allowUnscheduled = obsolete.untracked.bool,
237 emptyRunLumiMode = obsolete.untracked.string,
238 makeTriggerResults = obsolete.untracked.bool
242 if isinstance(opt,dict):
243 for k,v
in six.iteritems(opt):
246 for p
in opt.parameters_():
247 setattr(newOpts, p, getattr(opt,p))
251 return untracked.PSet(input=optional.untracked.int32,
252 output=optional.untracked.allowed(int32,PSet))
255 if isinstance(ps,dict):
256 for k,v
in six.iteritems(ps):
259 for p
in ps.parameters_():
260 setattr(newMax, p, getattr(ps,p))
264 return untracked.PSet(input=untracked.int32(-1))
266 """returns a list of the subProcesses that have been added to the Process""" 267 return self.__subProcesses
268 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
270 """returns a dict of the analyzers that have been added to the Process""" 272 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
274 """returns a dict of the output modules that have been added to the Process""" 276 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
278 """returns a dict of the paths that have been added to the Process""" 280 paths = property(paths_,doc=
"dictionary containing the paths for the process")
282 """returns a dict of the endpaths that have been added to the Process""" 284 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
286 """returns a dict of the sequences that have been added to the Process""" 288 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
290 """returns a dict of the tasks that have been added to the Process""" 292 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
294 """returns the schedule that has been added to the Process or None if none have been added""" 295 return self.__schedule
297 if label ==
"schedule":
300 self.
_place(label, sch, self.__partialschedules)
309 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
310 self.__dict__[
'_Process__schedule'] = sch
311 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
313 """returns a dict of the services that have been added to the Process""" 315 services = property(services_,doc=
"dictionary containing the services for the process")
317 """returns a dict of the esproducers that have been added to the Process""" 319 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
321 """returns a the es_sources that have been added to the Process""" 323 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
325 """returns a dict of the es_prefers that have been added to the Process""" 327 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
329 """returns a dict of the aliases that have been added to the Process""" 331 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
333 """returns a dict of the PSets that have been added to the Process""" 335 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
337 """returns a dict of the VPSets that have been added to the Process""" 339 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
342 """returns True if the Modifier is in used by this Process""" 344 for m
in self.__modifiers:
345 if m._isOrContains(mod):
350 if not object.hasLabel_() :
351 object.setLabel(newLabel)
353 if newLabel == object.label_() :
355 if newLabel
is None :
356 object.setLabel(
None)
358 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
359 msg100 =
"Attempting to change the label of an attribute of the Process\n" 360 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 361 msg102 =
"Type = "+
str(type(object))+
"\n" 362 msg103 =
"Some possible solutions:\n" 363 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 364 msg105 =
" also preferred for other types when possible.\n" 365 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 366 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 367 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 368 msg109 =
" the name.\n" 369 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 370 msg111 =
" name to the same object usually causes confusion and problems.\n" 371 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 372 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
373 object.setLabel(
None)
374 object.setLabel(newLabel)
378 if not name.replace(
'_',
'').isalnum():
379 raise ValueError(
'The label '+name+
' contains forbiden characters')
381 if name ==
'options':
383 if name ==
'maxEvents':
387 if name.startswith(
'_Process__'):
388 self.__dict__[name]=value
390 if not isinstance(value,_ConfigureComponent):
391 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 392 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
393 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
394 if name == value.type_():
399 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
400 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
403 newValue =value.copy()
405 newValue._filename = value._filename
411 if not self.
_okToPlace(name, value, self.__dict__):
412 newFile=
'top level config' 413 if hasattr(value,
'_filename'):
414 newFile = value._filename
415 oldFile=
'top level config' 416 oldValue = getattr(self,name)
417 if hasattr(oldValue,
'_filename'):
418 oldFile = oldValue._filename
419 msg =
"Trying to override definition of process."+name
420 msg +=
"\n new object defined in: "+newFile
421 msg +=
"\n existing object defined in: "+oldFile
422 raise ValueError(msg)
424 if hasattr(self,name)
and not (getattr(self,name)==newValue):
428 if newValue._isTaskComponent():
429 if not self.__InExtendCall:
433 if not isinstance(newValue, Task):
435 newFile=
'top level config' 436 if hasattr(value,
'_filename'):
437 newFile = value._filename
438 oldFile=
'top level config' 439 oldValue = getattr(self,name)
440 if hasattr(oldValue,
'_filename'):
441 oldFile = oldValue._filename
442 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 443 msg2 =
"\n new object defined in: "+newFile
444 msg2 +=
"\n existing object defined in: "+oldFile
447 raise ValueError(msg1+s.label_()+msg2)
449 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent():
450 if not self.__InExtendCall:
454 newFile=
'top level config' 455 if hasattr(value,
'_filename'):
456 newFile = value._filename
457 oldFile=
'top level config' 458 oldValue = getattr(self,name)
459 if hasattr(oldValue,
'_filename'):
460 oldFile = oldValue._filename
461 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 462 msg2 =
"\n new object defined in: "+newFile
463 msg2 +=
"\n existing object defined in: "+oldFile
466 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
469 raise ValueError(msg1+
"path "+s.label_()+msg2)
472 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
475 if isinstance(newValue, EDAlias):
476 oldValue = getattr(self, name)
478 newFile=
'top level config' 479 if hasattr(value,
'_filename'):
480 newFile = value._filename
481 oldFile=
'top level config' 482 if hasattr(oldValue,
'_filename'):
483 oldFile = oldValue._filename
484 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the " 485 msg2 =
"\n new object defined in: "+newFile
486 msg2 +=
"\n existing object defined in: "+oldFile
489 raise ValueError(msg1+
"task "+s.label_()+msg2)
492 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
495 raise ValueError(msg1+
"path "+s.label_()+msg2)
498 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
501 self.__dict__[name]=newValue
502 if isinstance(newValue,_Labelable):
504 self._cloneToObjectDict[
id(value)] = newValue
505 self._cloneToObjectDict[
id(newValue)] = newValue
507 newValue._place(name,self)
509 """Given a container of sequences or tasks, find the first sequence or task 510 containing mod and return it. If none is found, return None""" 513 for seqOrTask
in six.itervalues(seqsOrTasks):
522 if not hasattr(self,name):
523 raise KeyError(
'process does not know about '+name)
524 elif name.startswith(
'_Process__'):
525 raise ValueError(
'this attribute cannot be deleted')
528 dicts = [item
for item
in self.__dict__.values()
if (isinstance(item, dict)
or isinstance(item,
DictTypes.SortedKeysDict))]
530 if name
in reg: del reg[name]
532 obj = getattr(self,name)
533 if isinstance(obj,_Labelable):
535 if isinstance(obj,Service):
536 obj._inProcess =
False 540 obj = getattr(self,name)
542 if not isinstance(obj, Sequence)
and not isinstance(obj, Task):
552 if obj._isTaskComponent():
555 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
559 del self.__dict__[name]
564 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 568 del self.__dict__[name]
573 """Allows addition of components that do not have to have a label, e.g. Services""" 574 if not isinstance(value,_ConfigureComponent):
576 if not isinstance(value,_Unlabelable):
581 newValue =value.copy()
585 newValue._place(
'',self)
588 if not self.__InExtendCall:
599 if d[name]._isModified:
610 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
611 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
614 if isinstance(mod,_Labelable):
617 self.
_place(name, mod, self.__outputmodules)
619 self.
_place(name, mod, self.__producers)
621 self.
_place(name, mod, self.__switchproducers)
623 self.
_place(name, mod, self.__filters)
625 self.
_place(name, mod, self.__analyzers)
629 self.
_place(name, mod, self.__paths)
630 except ModuleCloneError
as msg:
632 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
636 self.
_place(name, mod, self.__endpaths)
637 except ModuleCloneError
as msg:
639 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
642 self.
_place(name, mod, self.__sequences)
644 self.
_place(name, mod, self.__esproducers)
646 self.
_place(name, mod, self.__esprefers)
648 self.
_place(name, mod, self.__essources)
651 self.
_place(name, task, self.__tasks)
653 self.
_place(name, mod, self.__aliases)
655 self.
_place(name, mod, self.__psets)
657 self.
_place(name, mod, self.__vpsets)
659 """Allow the source to be referenced by 'source' or by type name""" 661 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
662 if self.__dict__[
'_Process__source']
is not None :
663 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
664 self.__dict__[
'_Process__source'] = mod
665 self.__dict__[mod.type_()] = mod
668 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
669 self.__dict__[
'_Process__looper'] = mod
670 self.__dict__[mod.type_()] = mod
672 self.__dict__[
'_Process__subProcess'] = mod
673 self.__dict__[mod.type_()] = mod
675 self.__subProcesses.append(mod)
677 self.
_place(typeName, mod, self.__services)
678 if typeName
in self.__dict__:
679 self.__dict__[typeName]._inProcess =
False 680 self.__dict__[typeName]=mod
682 moduleName = moduleName.replace(
"/",
".")
683 module = __import__(moduleName)
684 self.
extend(sys.modules[moduleName])
686 """Look in other and find types that we can use""" 688 self.__dict__[
'_Process__InExtendCall'] =
True 691 tasksToAttach = dict()
693 for name
in dir(other):
695 if name.startswith(
'_'):
697 item = getattr(other,name)
698 if name ==
"source" or name ==
"looper":
702 elif isinstance(item,_ModuleSequenceType):
704 elif isinstance(item,Task):
705 tasksToAttach[name] = item
706 elif isinstance(item,_Labelable):
708 if not item.hasLabel_() :
710 elif isinstance(item,Schedule):
712 elif isinstance(item,_Unlabelable):
714 elif isinstance(item,ProcessModifier):
716 elif isinstance(item,ProcessFragment):
720 for name,seq
in six.iteritems(seqs):
721 if id(seq)
not in self._cloneToObjectDict:
724 newSeq = self._cloneToObjectDict[
id(seq)]
725 self.__dict__[name]=newSeq
728 newSeq._place(name,self)
730 for name, task
in six.iteritems(tasksToAttach):
737 self.__dict__[
'_Process__InExtendCall'] =
False 741 for name,item
in items:
742 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
747 for name,item
in items:
748 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
753 for name,item
in items:
754 if name == item.type_():
756 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
760 """return a string containing the equivalent process defined using the old configuration language""" 761 config =
"process "+self.__name+
" = {\n" 810 for name,item
in six.iteritems(self.
psets):
811 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
812 for name,item
in six.iteritems(self.
vpsets):
813 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
815 pathNames = [p.label_()
for p
in self.
schedule]
816 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 828 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
834 returnValue += item.dumpPython(options)+
'\n\n' 840 for name,item
in d.items():
841 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 843 for name,item
in sorted(d.items()):
844 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 851 dependencies = item.directDependencies()
852 for module_subfolder, module
in dependencies:
853 module = module +
'_cfi' 854 if options.useSubdirectories
and module_subfolder:
855 module = module_subfolder +
'.' + module
856 if options.targetDirectory
is not None:
857 if options.useSubdirectories
and subfolder:
858 module =
'..' + module
860 module =
'.' + module
861 code +=
'from ' + module +
' import *\n' 864 code += name +
' = ' + item.dumpPython(options)
865 parts[name] = subfolder, code
873 sequence.visit(visitor)
875 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
884 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
896 for label,item
in six.iteritems(processDictionaryOfItems):
898 if isinstance(item, Task):
905 if isinstance(item, Task):
906 raise RuntimeError(
"Failed in a Task visitor. Probably " \
907 "a circular dependency discovered in Task with label " + label)
909 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
910 "circular dependency discovered in Sequence with label " + label)
911 for containedItem
in containedItems:
917 if containedItem.hasLabel_():
918 testItem = processDictionaryOfItems.get(containedItem.label_())
919 if testItem
is None or containedItem != testItem:
920 if isinstance(item, Task):
921 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
922 " from the process yields a different object or None\n"+
923 "label = " + containedItem.label_())
925 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
926 " from the process yields a different object or None\n"+
927 "label = " + containedItem.label_())
928 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
932 oldDeps = dict(dependencies)
933 for label,deps
in six.iteritems(oldDeps):
935 returnValue[label]=processDictionaryOfItems[label]
937 del dependencies[label]
938 for lb2,deps2
in six.iteritems(dependencies):
939 while deps2.count(label):
945 for name, value
in sorted(six.iteritems(d)):
946 result += value.dumpPythonAs(name,options)+
'\n' 951 for name, value
in sorted(six.iteritems(d)):
952 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n' 956 """return a string containing the equivalent process defined using python""" 957 specialImportRegistry._reset()
958 header =
"import FWCore.ParameterSet.Config as cms" 959 result =
"process = cms.Process(\""+self.__name+
"\")\n\n" 982 result +=
'process.schedule = ' + self.schedule.dumpPython(options)
983 imports = specialImportRegistry.getSpecialImports()
985 header +=
"\n" +
"\n".
join(imports)
990 """return a map of file names to python configuration fragments""" 991 specialImportRegistry._reset()
993 options.isCfg =
False 994 header =
"import FWCore.ParameterSet.Config as cms" 999 result =
'process = cms.Process("' + self.__name +
'")\n\n' 1012 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1028 if options.targetDirectory
is not None:
1029 files[options.targetDirectory +
'/__init__.py'] =
'' 1031 if options.useSubdirectories:
1032 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1033 if options.targetDirectory
is not None:
1034 sub = options.targetDirectory +
'/' + sub
1035 files[sub +
'/__init__.py'] =
'' 1037 for (name, (subfolder, code))
in six.iteritems(parts):
1038 filename = name +
'_cfi' 1039 if options.useSubdirectories
and subfolder:
1040 filename = subfolder +
'/' + filename
1041 if options.targetDirectory
is not None:
1042 filename = options.targetDirectory +
'/' + filename
1043 result +=
'process.load("%s")\n' % filename
1044 files[filename +
'.py'] = header +
'\n\n' + code
1047 options.isCfg =
True 1048 result +=
'process.schedule = ' + self.schedule.dumpPython(options)
1050 imports = specialImportRegistry.getSpecialImports()
1051 if len(imports) > 0:
1052 header +=
'\n' +
'\n'.
join(imports)
1053 files[
'-'] = header +
'\n\n' + result
1057 old = getattr(self,label)
1063 for sequenceable
in six.itervalues(self.
sequences):
1064 sequenceable._replaceIfHeldDirectly(old,new)
1065 for sequenceable
in six.itervalues(self.
sequences):
1066 sequenceable.replace(old,new)
1067 for sequenceable
in six.itervalues(self.
paths):
1068 sequenceable.replace(old,new)
1069 for sequenceable
in six.itervalues(self.
endpaths):
1070 sequenceable.replace(old,new)
1072 old = getattr(self,label)
1073 for task
in six.itervalues(self.
tasks):
1074 task.replace(old, new)
1078 old = getattr(self,label)
1080 task.replace(old, new)
1082 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 1083 if not hasattr(self,label):
1084 raise LookupError(
"process has no item of label "+label)
1085 setattr(self,label,new)
1087 for name,value
in six.iteritems(itemDict):
1088 value.insertInto(parameterSet, name)
1091 if not item ==
None:
1092 newlabel = item.nameInProcessDesc_(label)
1094 item.insertInto(parameterSet, newlabel)
1095 parameterSet.addVString(tracked, label, vitems)
1098 for name,value
in six.iteritems(itemDict):
1099 value.appendToProcessDescList_(l, name)
1100 value.insertInto(parameterSet, name)
1103 parameterSet.addVString(tracked, label, l)
1105 modules = parameterSet.getVString(tracked, labelModules)
1106 aliases = parameterSet.getVString(tracked, labelAliases)
1107 for name,value
in six.iteritems(itemDict):
1108 value.appendToProcessDescLists_(modules, aliases, name)
1109 value.insertInto(parameterSet, name)
1112 parameterSet.addVString(tracked, labelModules, modules)
1113 parameterSet.addVString(tracked, labelAliases, aliases)
1117 for value
in itemList:
1118 name = value.getProcessName()
1119 newLabel = value.nameInProcessDesc_(name)
1121 pset = value.getSubProcessPSet(parameterSet)
1122 subprocs.append(pset)
1125 parameterSet.addVString(tracked, label, l)
1126 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1133 for name
in self.
paths_():
1134 scheduledPaths.append(name)
1135 triggerPaths.append(name)
1137 scheduledPaths.append(name)
1138 endpaths.append(name)
1141 pathname = path.label_()
1142 scheduledPaths.append(pathname)
1144 endpaths.append(pathname)
1146 triggerPaths.append(pathname)
1148 task.resolve(self.__dict__)
1150 task.visit(scheduleTaskValidator)
1151 task.visit(nodeVisitor)
1152 processPSet.addVString(
True,
"@end_paths", endpaths)
1153 processPSet.addVString(
True,
"@paths", scheduledPaths)
1155 p = processPSet.newPSet()
1156 p.addVString(
True,
"@trigger_paths", triggerPaths)
1157 processPSet.addPSet(
True,
"@trigger_paths", p)
1163 pathCompositeVisitor =
CompositeVisitor(pathValidator, nodeVisitor, lister)
1164 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
1165 for triggername
in triggerPaths:
1166 iPath = self.
paths_()[triggername]
1167 iPath.resolve(self.__dict__)
1168 pathValidator.setLabel(triggername)
1170 iPath.visit(pathCompositeVisitor)
1171 iPath.insertInto(processPSet, triggername, decoratedList)
1172 for endpathname
in endpaths:
1173 iEndPath = self.
endpaths_()[endpathname]
1174 iEndPath.resolve(self.__dict__)
1175 endpathValidator.setLabel(endpathname)
1177 iEndPath.visit(endpathCompositeVisitor)
1178 iEndPath.insertInto(processPSet, endpathname, decoratedList)
1179 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1181 def resolve(self,keepUnresolvedSequencePlaceholders=False):
1182 for x
in six.itervalues(self.
paths):
1183 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1184 for x
in six.itervalues(self.
endpaths):
1185 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1188 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1190 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1191 """ Remove clutter from the process that we think is unnecessary: 1192 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 1193 not in the schedule will also be removed, along with an modules and sequences used only by 1194 those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders.""" 1203 self.
resolve(keepUnresolvedSequencePlaceholders)
1205 unneededPaths = set()
1209 usedModules=set(self.
schedule_().moduleNames())
1211 schedNames = set(( x.label_()
for x
in self.
schedule_()))
1212 names = set(self.
paths)
1214 unneededPaths = names - schedNames
1215 for n
in unneededPaths:
1223 pths.extend(six.itervalues(self.
endpaths))
1225 usedModules=set(temp.moduleNames())
1233 for p
in six.itervalues(self.
paths):
1236 for p
in six.itervalues(self.
endpaths):
1239 def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1240 _keepSet = set(( s
for s
in seqOrTasks
if s.hasLabel_()))
1241 _availableSet = set(six.itervalues(allSequencesOrTasks))
1242 _unneededSet = _availableSet-_keepSet
1243 _unneededLabels = []
1244 for s
in _unneededSet:
1245 _unneededLabels.append(s.label_())
1246 delattr(self,s.label_())
1247 return _unneededLabels
1248 unneededSeqLabels = removeUnneeded(seqs, self.
sequences)
1249 unneededTaskLabels = removeUnneeded(tasks, self.
tasks)
1251 print(
"prune removed the following:")
1252 print(
" modules:"+
",".
join(unneededModules))
1253 print(
" tasks:"+
",".
join(unneededTaskLabels))
1254 print(
" sequences:"+
",".
join(unneededSeqLabels))
1255 print(
" paths/endpaths:"+
",".
join(unneededPaths))
1257 moduleNames = set(d.keys())
1258 junk = moduleNames - scheduledNames
1264 """Used by the framework to convert python to C++ objects""" 1265 class ServiceInjectorAdaptor(
object):
1269 def addService(self,pset):
1270 self.__thelist.append(pset)
1272 return self.__processPSet.newPSet()
1276 class TopLevelPSetAcessorAdaptor(
object):
1280 def __getattr__(self,attr):
1281 return getattr(self.
__ppset,attr)
1282 def getTopPSet_(self,label):
1285 return TopLevelPSetAcessorAdaptor(self.__ppset.newPSet(),self.
__process)
1286 def addPSet(self,tracked,name,ppset):
1287 return self.__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1288 def addVPSet(self,tracked,name,vpset):
1289 return self.__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1290 def __extractPSet(self,pset):
1291 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1296 processPSet.addString(
True,
"@process_name", self.
name_())
1298 all_modules.update(self.
filters_())
1301 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1314 all_modules_onTasksOrScheduled = { key:value
for key, value
in six.iteritems(all_modules)
if value
in nodeVisitor.modules }
1315 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1317 all_switches_onTasksOrScheduled = {key:value
for key, value
in six.iteritems(all_switches)
if value
in nodeVisitor.modules }
1322 for pTask
in six.itervalues(self.
tasks):
1323 pTask.visit(processNodeVisitor)
1324 esProducersToEnable = {}
1325 for esProducerName, esProducer
in six.iteritems(self.
es_producers_()):
1326 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1327 esProducersToEnable[esProducerName] = esProducer
1328 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1329 esSourcesToEnable = {}
1330 for esSourceName, esSource
in six.iteritems(self.
es_sources_()):
1331 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1332 esSourcesToEnable[esSourceName] = esSource
1333 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1336 for serviceName, serviceObject
in six.iteritems(self.
services_()):
1337 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1338 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1339 adaptor.addVPSet(
False,
"services",services)
1350 """Prefer this ES source or producer. The argument can 1351 either be an object label, e.g., 1352 process.prefer(process.juicerProducer) (not supported yet) 1353 or a name of an ESSource or ESProducer 1354 process.prefer("juicer") 1355 or a type of unnamed ESSource or ESProducer 1356 process.prefer("JuicerProducer") 1357 In addition, you can pass as a labelled arguments the name of the Record you wish to 1358 prefer where the type passed is a cms.vstring and that vstring can contain the 1359 name of the C++ types in the Record that are being preferred, e.g., 1360 #prefer all data in record 'OrangeRecord' from 'juicer' 1361 process.prefer("juicer", OrangeRecord=cms.vstring()) 1363 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1364 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1366 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1367 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1370 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1371 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1372 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
1373 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1376 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1381 typ = d[esname].type_()
1390 for name, value
in six.iteritems(d):
1391 if value.type_() == esname:
1393 raise RuntimeError(
"More than one ES module for "+esname)
1401 if isinstance(process, Process):
1403 elif isinstance(process, str):
1406 del self.__process.options
1407 del self.__process.maxEvents
1408 del self.__process.maxLuminosityBlocks
1410 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1412 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1414 if name ==
'_ProcessFragment__process':
1415 return object.__getattribute__(self,
'_ProcessFragment__process')
1419 if name ==
'_ProcessFragment__process':
1420 object.__setattr__(self, name, value)
1424 if name ==
'_ProcessFragment__process':
1431 """a dictionary with fixed keys""" 1433 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1434 _blocked_attribute = property(_blocked_attribute)
1435 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1436 pop = popitem = setdefault = update = _blocked_attribute
1438 new = dict.__new__(cls)
1439 dict.__init__(new, *args, **kw)
1440 keys = sorted(kw.keys())
1441 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1442 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1443 if not isinstance(kw[
'name'],str):
1444 raise ValueError(
"name must be of type string")
1445 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1446 raise ValueError(
"content must be of type vstring or string")
1447 if not isinstance(kw[
'dataTier'], string):
1448 raise ValueError(
"dataTier must be of type string")
1449 if not isinstance(kw[
'selectEvents'], PSet):
1450 raise ValueError(
"selectEvents must be of type PSet")
1451 if not isinstance(kw[
'paths'],(tuple, Path)):
1452 raise ValueError(
"'paths' must be a tuple of paths")
1457 return "FilteredStream object: %s" %self[
"name"]
1462 """Allows embedding another process within a parent process. This allows one to 1463 chain processes together directly in one cmsRun job rather than having to run 1464 separate jobs that are connected via a temporary file. 1466 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1469 if not isinstance(process, Process):
1470 raise ValueError(
"the 'process' argument must be of type cms.Process")
1471 if not isinstance(SelectEvents,PSet):
1472 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1473 if not isinstance(outputCommands,vstring):
1474 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1479 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1480 out += self.__process.dumpPython()
1481 out +=
"childProcess = process\n" 1482 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1483 out +=
"process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = "+self.__SelectEvents.dumpPython(options) +
", outputCommands = "+self.__outputCommands.dumpPython(options) +
"))" 1486 return self.__process.name_()
1498 process._placeSubProcess(
'subProcess',self)
1500 topPSet = parameterSet.newPSet()
1501 self.__process.fillProcessDesc(topPSet)
1502 subProcessPSet = parameterSet.newPSet()
1503 self.__SelectEvents.insertInto(subProcessPSet,
"SelectEvents")
1504 self.__outputCommands.insertInto(subProcessPSet,
"outputCommands")
1505 subProcessPSet.addPSet(
False,
"process",topPSet)
1506 return subProcessPSet
1509 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1514 for k
in six.iterkeys(self.
__args):
1516 params[k] = getattr(obj,k)
1518 for k
in six.iterkeys(self.
__args):
1520 setattr(obj,k,params[k])
1526 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1529 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1535 Modifier._toModifyCheck(obj,func,**kw)
1536 if not self._isChosen():
1538 Modifier._toModify(obj,func,**kw)
1540 Modifier._toReplaceWithCheck(toObj,fromObj)
1541 if not self._isChosen():
1543 Modifier._toReplaceWith(toObj,fromObj)
1545 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1546 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1547 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1557 """A modifier which only applies if multiple Modifiers are chosen""" 1559 super(_AndModifier,self).
__init__(lhs, rhs)
1561 return self._lhs._isChosen()
and self._rhs._isChosen()
1564 """A modifier which only applies if a Modifier is not chosen""" 1566 super(_InvertModifier,self).
__init__(lhs)
1568 return not self._lhs._isChosen()
1571 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1573 super(_OrModifier,self).
__init__(lhs, rhs)
1575 return self._lhs._isChosen()
or self._rhs._isChosen()
1579 """This class is used to define standard modifications to a Process. 1580 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1581 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1582 these Modifier instances are imported into a configuration and items that need to be modified 1583 are then associated with the Modifier and with the action to do the modification. 1584 The registered modifications will only occur if the Modifier was passed to 1585 the cms.Process' constructor. 1591 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1592 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1593 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1598 if func
is not None and len(kw) != 0:
1599 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1601 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1602 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1603 that will be the object passed in as the first argument. 1604 Form 2: A list of parameter name, value pairs can be passed 1605 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1606 This form can also be used to remove a parameter by passing the value of None 1607 #remove the parameter foo.fred 1608 mod.toModify(foo, fred = None) 1609 Additionally, parameters embedded within PSets can also be modified using a dictionary 1610 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1611 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1613 Modifier._toModifyCheck(obj,func,**kw)
1616 Modifier._toModify(obj,func,**kw)
1619 if func
is not None:
1626 if not isinstance(fromObj, type(toObj)):
1627 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1629 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1631 Modifier._toReplaceWithCheck(toObj,fromObj)
1634 Modifier._toReplaceWith(toObj,fromObj)
1637 if isinstance(fromObj,_ModuleSequenceType):
1638 toObj._seq = fromObj._seq
1639 toObj._tasks = fromObj._tasks
1640 elif isinstance(fromObj,Task):
1641 toObj._collection = fromObj._collection
1642 elif isinstance(fromObj,_Parameterizable):
1644 for p
in toObj.parameterNames_():
1646 for p
in fromObj.parameterNames_():
1647 setattr(toObj,p,getattr(fromObj,p))
1648 if isinstance(fromObj,_TypedParameterizable):
1649 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1652 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1655 """Should only be called by cms.Process instances""" 1666 return self == other
1670 """A Modifier made up of a list of Modifiers 1676 """Should only be called by cms.Process instances 1677 applies list of accumulated changes to the process""" 1679 m._applyNewProcessModifiers(process)
1681 """Should only be called by cms.Process instances""" 1688 """Creates a new ModifierChain which is a copy of 1689 this ModifierChain but excludes any Modifier or 1690 ModifierChain in the list toExclude. 1691 The exclusion is done recursively down the chain. 1695 if m
not in toExclude:
1697 if isinstance(m,ModifierChain):
1698 s = m.__copyIfExclude(toExclude)
1714 if m._isOrContains(other):
1719 """A class used by a Modifier to affect an entire Process instance. 1720 When a Process 'loads' a module containing a ProcessModifier, that 1721 ProcessModifier will be applied to the Process if and only if the 1722 Modifier passed to the constructor has been chosen. 1729 if self.__modifier._isChosen():
1732 self.__seenProcesses.add(process)
1734 if __name__==
"__main__":
1739 newString = ( x
for x
in newString.split(
'\n')
if len(x) > 0)
1740 oldString = [ x
for x
in oldString.split(
'\n')
if len(x) > 0]
1744 if oldStringLine >= len(oldString):
1747 if l == oldString[oldStringLine]:
1751 return "\n".
join( diff )
1754 """Has same interface as the C++ object that creates PSets 1759 self.
values[label]=(tracked,value)
1761 pair = self.
values[label]
1762 if pair[0] != tracked:
1763 raise Exception(
"Asked for %s parameter '%s', but it is %s" % (
"tracked" if tracked
else "untracked",
1765 "tracked" if pair[0]
else "untracked"))
1826 super(SwitchProducerTest,self).
__init__(
1828 test1 =
lambda: (
True, -10),
1829 test2 =
lambda: (
True, -9),
1830 test3 =
lambda: (
True, -8),
1831 test4 =
lambda: (
True, -7)
1833 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest,
"from test import SwitchProducerTest")
1837 """Nothing to do """ 1841 self.assertEqual(len(p.parameterNames_()),0)
1843 self.assertTrue(
'a' in p.parameterNames_())
1844 self.assertEqual(p.a.value(), 1)
1846 self.assertEqual(p.a.value(), 10)
1848 self.assertEqual(p.a.value(), 1)
1849 self.assertFalse(p.a.isTracked())
1850 p.a = untracked.int32(1)
1851 self.assertEqual(p.a.value(), 1)
1852 self.assertFalse(p.a.isTracked())
1854 self.assertEqual(p.foo.value(), 10)
1855 self.assertEqual(p.bar.value(),1.0)
1856 self.assertFalse(p.bar.isTracked())
1857 self.assertRaises(TypeError,setattr,(p,
'c',1))
1859 self.assertEqual(p.a.foo.value(),10)
1860 self.assertEqual(p.a.bar.value(),1.0)
1862 self.assertEqual(p.b.fii.value(),1)
1863 self.assertFalse(p.b.isTracked())
1868 self.assertEqual(p.a.value(),11)
1870 self.assertEqual(p.a.value(),12)
1871 self.assertEqual(v.value(),12)
1877 self.assertNotEqual(p.b,other.b)
1882 self.assertTrue(
'a' in p.analyzers_() )
1883 self.assertTrue(
'a' in p.analyzers)
1884 p.add_(
Service(
"MessageLogger"))
1885 self.assertTrue(
'MessageLogger' in p.services_())
1886 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1888 self.assertTrue(
'Tracer' in p.services_())
1889 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1890 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1891 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1893 self.assertEqual(p.out.type_(),
'Outer')
1894 self.assertTrue(
'out' in p.outputModules_() )
1897 self.assertTrue(
'geom' in p.es_sources_())
1899 self.assertTrue(
'ConfigDB' in p.es_sources_())
1902 self.assertTrue(
'aliasfoo1' in p.aliases_())
1906 def __init__(self,*arg,**args):
1907 for name
in six.iterkeys(args):
1908 self.__dict__[name]=args[name]
1927 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1928 self.assertEqual(p.a.label_(),
"a")
1929 self.assertRaises(AttributeError,getattr,p,
'b')
1930 self.assertEqual(p.Full.type_(),
"Full")
1931 self.assertEqual(
str(p.c),
'a')
1932 self.assertEqual(
str(p.d),
'a')
1947 self.assertRaises(ValueError, p1.extend, z1)
1956 aaa=copy.deepcopy(a),
1957 s4=copy.deepcopy(s3),
1964 self.assertEqual(p2.s4.label_(),
"s4")
1966 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
1967 p2.s4.setLabel(
"s4")
1968 p2.s4.setLabel(
None)
1969 p2.s4.setLabel(
"foo")
1970 p2._Process__setObjectLabel(p2.s4,
"foo")
1971 p2._Process__setObjectLabel(p2.s4,
None)
1972 p2._Process__setObjectLabel(p2.s4,
"bar")
1979 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
1980 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
1981 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
1987 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
1988 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
1989 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
1993 """import FWCore.ParameterSet.Config as cms\n\nprocess = cms.Process("test") 1995 process.maxEvents = cms.untracked.PSet( 1996 input = cms.optional.untracked.int32, 1997 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 2000 process.maxLuminosityBlocks = cms.untracked.PSet( 2001 input = cms.untracked.int32(-1) 2004 process.options = cms.untracked.PSet( 2005 FailPath = cms.untracked.vstring(), 2006 IgnoreCompletely = cms.untracked.vstring(), 2007 Rethrow = cms.untracked.vstring(), 2008 SkipEvent = cms.untracked.vstring(), 2009 allowUnscheduled = cms.obsolete.untracked.bool, 2010 canDeleteEarly = cms.untracked.vstring(), 2011 emptyRunLumiMode = cms.obsolete.untracked.string, 2012 eventSetup = cms.untracked.PSet( 2013 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 2016 numberOfConcurrentIOVs = cms.untracked.uint32(1) 2018 fileMode = cms.untracked.string('FULLMERGE'), 2019 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 2020 makeTriggerResults = cms.obsolete.untracked.bool, 2021 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(1), 2022 numberOfConcurrentRuns = cms.untracked.uint32(1), 2023 numberOfStreams = cms.untracked.uint32(0), 2024 numberOfThreads = cms.untracked.uint32(1), 2025 printDependencies = cms.untracked.bool(False), 2026 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 2027 throwIfIllegalParameter = cms.untracked.bool(True), 2028 wantSummary = cms.untracked.bool(False) 2041 """process.a = cms.EDAnalyzer("MyAnalyzer") 2042 process.s = cms.Sequence(process.a) 2043 process.r = cms.Sequence(process.s) 2044 process.p = cms.Path(process.a) 2045 process.p2 = cms.Path(process.s) 2046 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2058 """process.a = cms.EDAnalyzer("MyAnalyzer") 2059 process.b = cms.EDAnalyzer("YourAnalyzer") 2060 process.r = cms.Sequence(process.a) 2061 process.s = cms.Sequence(process.r) 2062 process.p = cms.Path(process.a) 2063 process.p2 = cms.Path(process.r) 2064 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2075 """process.a = cms.EDAnalyzer("MyAnalyzer") 2076 process.r = cms.Sequence((process.a)) 2077 process.p = cms.Path(process.a) 2078 process.p2 = cms.Path(process.r) 2079 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2095 p.task3.add(p.task1)
2099 p.p2 =
Path(p.r, p.task1, p.task2)
2100 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2103 """process.b = cms.EDProducer("bProducer") 2104 process.c = cms.EDProducer("cProducer") 2105 process.d = cms.EDProducer("dProducer") 2106 process.e = cms.EDProducer("eProducer") 2107 process.f = cms.EDProducer("fProducer") 2108 process.g = cms.EDProducer("gProducer") 2109 process.a = cms.EDAnalyzer("MyAnalyzer") 2110 process.task5 = cms.Task() 2111 process.task1 = cms.Task(process.task5) 2112 process.task3 = cms.Task(process.task1) 2113 process.task2 = cms.Task(process.c, process.task3) 2114 process.task4 = cms.Task(process.f, process.task2) 2115 process.r = cms.Sequence((process.a)) 2116 process.p = cms.Path(process.a) 2117 process.p2 = cms.Path(process.r, process.task1, process.task2) 2118 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2125 p.task1 =
Task(p.d, p.e)
2126 task2 =
Task(p.f, p.g)
2127 p.schedule =
Schedule(tasks=[p.task1,task2])
2130 """process.d = cms.EDProducer("dProducer") 2131 process.e = cms.EDProducer("eProducer") 2132 process.f = cms.EDProducer("fProducer") 2133 process.g = cms.EDProducer("gProducer") 2134 process.task1 = cms.Task(process.d, process.e) 2135 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2141 """process.schedule = cms.Schedule()""")
2150 d=process.dumpPython()
2152 """process.a = cms.EDProducer("A") 2153 process.s2 = cms.Sequence(process.a)""")
2163 d=process.dumpPython()
2165 """process.a = cms.EDProducer("A") 2166 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2191 p.p =
Path(p.c+s+p.a)
2192 p.p2 =
Path(p.c+p.s4+p.a)
2198 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2200 p.globalReplace(
"a",new)
2201 p.globalReplace(
"d",new2)
2204 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2205 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2207 p.p2.visit(visitor_p2)
2208 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2209 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a)")
2211 p.e3.visit(visitor3)
2212 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2214 p.s4.visit(visitor4)
2215 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2216 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d))")
2218 p.t1.visit(visitor5)
2219 self.assertTrue(visitor5.modules == set([new2]))
2221 listOfTasks =
list(p.schedule._tasks)
2222 listOfTasks[0].visit(visitor6)
2223 self.assertTrue(visitor6.modules == set([new2]))
2231 self.assertEqual(
str(p.s),
'a+b')
2232 self.assertEqual(p.s.label_(),
's')
2233 path =
Path(p.c+p.s)
2234 self.assertEqual(
str(path),
'c+a+b')
2235 p._validateSequence(path,
'p1')
2237 p2 =
Path(p.c+p.s*notInProcess)
2238 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2248 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2252 self.assertFalse(service._inProcess)
2255 self.assertTrue(service._inProcess)
2257 process.d = service2
2258 self.assertFalse(service._inProcess)
2259 self.assertTrue(service2._inProcess)
2261 self.assertFalse(service2._inProcess)
2281 testTask1 =
Task(edproducer, edfilter)
2282 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2283 testTask1.add(essource, service)
2284 testTask1.add(essource, esproducer)
2285 testTask1.add(testTask2)
2286 coll = testTask1._collection
2287 self.assertTrue(edproducer
in coll)
2288 self.assertTrue(edfilter
in coll)
2289 self.assertTrue(service
in coll)
2290 self.assertTrue(essource
in coll)
2291 self.assertTrue(esproducer
in coll)
2292 self.assertTrue(testTask2
in coll)
2293 self.assertTrue(len(coll) == 6)
2294 self.assertTrue(len(testTask2._collection) == 0)
2298 taskContents.append(i)
2299 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2304 process.mproducer = edproducer
2305 process.mproducer2 = edproducer2
2306 process.mfilter = edfilter
2307 process.messource = essource
2308 process.mesproducer = esproducer
2311 testTask3 =
Task(edproducer, edproducer2)
2312 testTask1.add(testTask3)
2313 process.myTask1 = testTask1
2320 testTask1.visit(visitor)
2321 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2322 l2 = testTask1.moduleNames
2323 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2325 testTask4 =
Task(edproducer3)
2327 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2329 process.myTask4 = testTask4
2330 self.assertTrue(
False)
2331 except RuntimeError:
2334 testTask5 =
Task(service3)
2336 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2338 process.myTask5 = testTask5
2339 self.assertTrue(
False)
2340 except RuntimeError:
2343 process.d = service3
2344 process.myTask5 = testTask5
2347 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2349 self.assertTrue(process.tasks == expectedFixedDict)
2350 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2351 self.assertTrue(process.myTask1 == testTask1)
2355 process.mproducer2 = edproducer4
2359 testTask1.visit(visitor1)
2360 l.sort(key=
lambda mod: mod.__str__())
2361 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2362 self.assertTrue(expectedList == l)
2363 process.myTask6 =
Task()
2364 process.myTask7 =
Task()
2365 process.mproducer8 = edproducer8
2366 process.myTask8 =
Task(process.mproducer8)
2367 process.myTask6.add(process.myTask7)
2368 process.myTask7.add(process.myTask8)
2369 process.myTask1.add(process.myTask6)
2370 process.myTask8.add(process.myTask5)
2372 testDict = process._itemsInDependencyOrder(process.tasks)
2373 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2374 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2376 for testLabel, testTask
in testDict.items():
2377 self.assertTrue(testLabel == expectedLabels[index])
2378 self.assertTrue(testTask == expectedTasks[index])
2384 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2385 self.assertTrue(pythonDump == expectedPythonDump)
2387 process.myTask5 =
Task()
2388 process.myTask100 =
Task()
2389 process.mproducer9 = edproducer9
2390 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2391 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
2392 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
2394 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2395 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2396 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2397 process.path2 =
Path(process.mproducer)
2398 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
2400 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')
2402 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')
2407 process.path1.visit(nameVisitor)
2408 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2409 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
2413 process.path21 = process.path11.copy()
2414 process.path21.replace(process.mproducer, process.mproducer10)
2416 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')
2425 self.assertTrue(process.path21.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2427 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2428 self.assertTrue(process.path22.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2430 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2431 self.assertTrue(process.path23.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2440 process.path24 =
Path(process.a+process.b+process.c+process.d)
2441 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2442 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
2447 process.path200.replace(process.c,process.b)
2448 process.path200.replace(process.e,process.f)
2449 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
2450 process.path200.replace(process.b,process.c)
2451 process.path200.replace(process.f,process.e)
2452 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2453 process.path200.replace(process.c,process.a)
2454 process.path200.replace(process.e,process.g)
2455 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
2456 process.path200.replace(process.a,process.c)
2457 process.path200.replace(process.g,process.e)
2458 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
2469 self.assertEqual(
str(path),
'a+b+c')
2470 path =
Path(p.a*p.b+p.c)
2471 self.assertEqual(
str(path),
'a+b+c')
2474 path =
Path(p.a+ p.b*p.c)
2475 self.assertEqual(
str(path),
'a+b+c')
2476 path =
Path(p.a*(p.b+p.c))
2477 self.assertEqual(
str(path),
'a+b+c')
2478 path =
Path(p.a*(p.b+~p.c))
2480 self.assertEqual(
str(path),
'a+b+~c')
2482 self.assertRaises(TypeError,Path,p.es)
2485 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path()\n')
2488 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a)\n')
2491 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(cms.Task())\n')
2494 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task())\n')
2499 self.assertTrue(t.dumpPython(
PrintOptions()) ==
'cms.Path(process.a, cms.Task(), process.t1)\n')
2510 p.path =
Path(p.a*p.b)
2511 lookuptable = {
id(a): p.a,
id(b): p.b}
2515 self.assertEqual(
str(path),
str(p.path))
2536 path =
Path(a * c * seq1, task1)
2538 self.assertTrue(path.contains(a))
2539 self.assertFalse(path.contains(b))
2540 self.assertTrue(path.contains(c))
2541 self.assertFalse(path.contains(d))
2542 self.assertTrue(path.contains(e))
2543 self.assertFalse(path.contains(f))
2544 self.assertTrue(path.contains(g))
2547 self.assertFalse(endpath.contains(b))
2548 self.assertTrue(endpath.contains(i))
2551 self.assertFalse(seq.contains(b))
2552 self.assertTrue(seq.contains(c))
2555 task =
Task(j, k, task2)
2556 self.assertFalse(task.contains(b))
2557 self.assertTrue(task.contains(j))
2558 self.assertTrue(task.contains(k))
2559 self.assertTrue(task.contains(l))
2563 sch =
Schedule(path, path2, tasks=[task,task3])
2564 self.assertFalse(sch.contains(b))
2565 self.assertTrue(sch.contains(a))
2566 self.assertTrue(sch.contains(c))
2567 self.assertTrue(sch.contains(e))
2568 self.assertTrue(sch.contains(g))
2569 self.assertTrue(sch.contains(n))
2570 self.assertTrue(sch.contains(j))
2571 self.assertTrue(sch.contains(k))
2572 self.assertTrue(sch.contains(l))
2573 self.assertTrue(sch.contains(m))
2586 self.assertEqual(s[0],p.path1)
2587 self.assertEqual(s[1],p.path2)
2589 self.assertTrue(
'b' in p.schedule.moduleNames())
2590 self.assertTrue(hasattr(p,
'b'))
2591 self.assertTrue(hasattr(p,
'c'))
2592 self.assertTrue(hasattr(p,
'd'))
2593 self.assertTrue(hasattr(p,
'path1'))
2594 self.assertTrue(hasattr(p,
'path2'))
2595 self.assertTrue(hasattr(p,
'path3'))
2597 self.assertTrue(
'b' in p.schedule.moduleNames())
2598 self.assertTrue(hasattr(p,
'b'))
2599 self.assertTrue(
not hasattr(p,
'c'))
2600 self.assertTrue(
not hasattr(p,
'd'))
2601 self.assertTrue(hasattr(p,
'path1'))
2602 self.assertTrue(hasattr(p,
'path2'))
2603 self.assertTrue(
not hasattr(p,
'path3'))
2605 self.assertTrue(len(p.schedule._tasks) == 0)
2619 p.task2 =
Task(p.f, p.Tracer)
2620 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2621 self.assertEqual(s[0],p.path1)
2622 self.assertEqual(s[1],p.path2)
2623 self.assertTrue(len(s._tasks) == 2)
2624 self.assertTrue(p.task1
in s._tasks)
2625 self.assertTrue(p.task2
in s._tasks)
2626 listOfTasks =
list(s._tasks)
2627 self.assertTrue(len(listOfTasks) == 2)
2628 self.assertTrue(p.task1 == listOfTasks[0])
2629 self.assertTrue(p.task2 == listOfTasks[1])
2631 self.assertTrue(
'b' in p.schedule.moduleNames())
2636 process2.path1 =
Path(process2.a)
2637 process2.task1 =
Task(process2.e)
2638 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
2639 listOfTasks =
list(process2.schedule._tasks)
2640 self.assertTrue(listOfTasks[0] == process2.task1)
2644 self.assertEqual(s2[0],p.path1)
2645 self.assertEqual(s2[1],p.path2)
2646 self.assertTrue(len(s2._tasks) == 2)
2647 self.assertTrue(p.task1
in s2._tasks)
2648 self.assertTrue(p.task2
in s2._tasks)
2649 listOfTasks =
list(s2._tasks)
2650 self.assertTrue(len(listOfTasks) == 2)
2651 self.assertTrue(p.task1 == listOfTasks[0])
2652 self.assertTrue(p.task2 == listOfTasks[1])
2654 names = s.moduleNames()
2655 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
2661 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
2670 self.assertTrue(
'a' in s.moduleNames())
2671 self.assertTrue(
'b' in s.moduleNames())
2672 self.assertTrue(
'c' in s.moduleNames())
2676 self.assertTrue(
'a' in s.moduleNames())
2677 self.assertTrue(
'b' in s.moduleNames())
2678 self.assertTrue(
'c' in s.moduleNames())
2687 self.assertTrue(p.schedule
is None)
2690 self.assertEqual(pths[keys[0]],p.path1)
2691 self.assertEqual(pths[keys[1]],p.path2)
2693 self.assertTrue(hasattr(p,
'a'))
2694 self.assertTrue(hasattr(p,
'b'))
2695 self.assertTrue(
not hasattr(p,
'c'))
2696 self.assertTrue(hasattr(p,
'path1'))
2697 self.assertTrue(hasattr(p,
'path2'))
2706 self.assertTrue(p.schedule
is None)
2709 self.assertEqual(pths[keys[1]],p.path1)
2710 self.assertEqual(pths[keys[0]],p.path2)
2717 self.assertEqual(p.modu.a.value(),1)
2718 self.assertEqual(p.modu.b.value(),2)
2723 self.assertTrue(
not a.isModified())
2725 self.assertTrue(a.isModified())
2727 self.assertEqual(p.a.a1.value(), 1)
2731 self.assertEqual(p.a.a1.value(), 2)
2740 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
2741 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
2745 self.assertEqual(p.options.numberOfThreads.value(),1)
2746 p.options.numberOfThreads = 8
2747 self.assertEqual(p.options.numberOfThreads.value(),8)
2749 self.assertEqual(p.options.numberOfThreads.value(),1)
2750 p.options = dict(numberOfStreams =2,
2752 self.assertEqual(p.options.numberOfThreads.value(),2)
2753 self.assertEqual(p.options.numberOfStreams.value(),2)
2757 p.maxEvents.input = 10
2758 self.assertEqual(p.maxEvents.input.value(),10)
2760 p.maxEvents.output = 10
2761 self.assertEqual(p.maxEvents.output.value(),10)
2763 p.maxEvents.output =
PSet(out=untracked.int32(10))
2764 self.assertEqual(p.maxEvents.output.out.value(), 10)
2766 p.maxEvents = untracked.PSet(input = untracked.int32(5))
2767 self.assertEqual(p.maxEvents.input.value(), 5)
2776 p.bars.foos =
'Foosball' 2777 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
2778 p.p =
Path(p.foos*p.bars)
2780 p.add_(
Service(
"MessageLogger"))
2786 p.prefer(
"ForceSource")
2789 """process.juicer = cms.ESProducer("JuicerProducer") 2790 process.ForceSource = cms.ESSource("ForceSource") 2791 process.prefer("ForceSource") 2792 process.prefer("juicer")""")
2793 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
2795 """process.juicer = cms.ESProducer("JuicerProducer") 2796 process.ForceSource = cms.ESSource("ForceSource") 2797 process.prefer("ForceSource") 2798 process.prefer("juicer", 2799 fooRcd = cms.vstring('Foo') 2814 self.assertEqual(process.m.p.i.value(), 4)
2824 subProcess.p =
Path(subProcess.a)
2825 subProcess.add_(
Service(
"Foo"))
2826 process.addSubProcess(
SubProcess(subProcess))
2827 d = process.dumpPython()
2828 equalD =
"""parentProcess = process 2829 process.a = cms.EDProducer("A") 2830 process.Foo = cms.Service("Foo") 2831 process.p = cms.Path(process.a) 2832 childProcess = process 2833 process = parentProcess 2834 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 2835 ), outputCommands = cms.untracked.vstring()))""" 2836 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
2839 process.fillProcessDesc(p)
2840 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
2841 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
2842 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
2852 proc.fillProcessDesc(p)
2853 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
2854 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
2855 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
2856 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
2857 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
2858 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
2868 proc.s =
Sequence(proc.a + proc.sp)
2869 proc.t =
Task(proc.a, proc.sp)
2871 proc.p.associate(proc.t)
2873 proc.fillProcessDesc(p)
2874 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2875 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2876 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2877 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
2878 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2879 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
2880 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2881 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
2882 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2883 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
2884 dump = proc.dumpPython()
2885 self.assertEqual(dump.find(
'@'), -1)
2886 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
2887 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
2896 proc.s =
Sequence(proc.a + proc.sp)
2897 proc.t =
Task(proc.a, proc.sp)
2899 proc.p.associate(proc.t)
2901 proc.fillProcessDesc(p)
2902 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2903 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2904 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2905 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
2906 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2907 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
2908 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
2909 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2910 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
2911 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2912 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
2921 proc.s =
Sequence(proc.a + proc.sp)
2922 proc.t =
Task(proc.a, proc.sp)
2924 proc.p.associate(proc.t)
2926 proc.fillProcessDesc(p)
2927 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
2928 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
2929 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
2930 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
2931 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
2932 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
2933 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
2934 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
2935 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
2936 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
2937 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
2951 p.t3 =
Task(p.g, p.t1)
2952 p.path1 =
Path(p.a, p.t3)
2954 self.assertTrue(p.schedule
is None)
2957 self.assertEqual(pths[keys[0]],p.path1)
2958 self.assertEqual(pths[keys[1]],p.path2)
2960 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
2962 p.vpset2 = untracked.VPSet()
2964 self.assertTrue(hasattr(p,
'a'))
2965 self.assertTrue(hasattr(p,
'b'))
2966 self.assertTrue(
not hasattr(p,
'c'))
2967 self.assertTrue(
not hasattr(p,
'd'))
2968 self.assertTrue(hasattr(p,
'e'))
2969 self.assertTrue(
not hasattr(p,
'f'))
2970 self.assertTrue(hasattr(p,
'g'))
2971 self.assertTrue(
not hasattr(p,
's'))
2972 self.assertTrue(hasattr(p,
't1'))
2973 self.assertTrue(
not hasattr(p,
't2'))
2974 self.assertTrue(hasattr(p,
't3'))
2975 self.assertTrue(hasattr(p,
'path1'))
2976 self.assertTrue(hasattr(p,
'path2'))
2999 p.path1 =
Path(p.a, p.t3)
3001 p.path3 =
Path(p.b+p.s2)
3002 p.path4 =
Path(p.b+p.s3)
3003 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3004 p.schedule.associate(p.t4)
3007 self.assertEqual(pths[keys[0]],p.path1)
3008 self.assertEqual(pths[keys[1]],p.path2)
3010 self.assertTrue(hasattr(p,
'a'))
3011 self.assertTrue(hasattr(p,
'b'))
3012 self.assertTrue(
not hasattr(p,
'c'))
3013 self.assertTrue(
not hasattr(p,
'd'))
3014 self.assertTrue(
not hasattr(p,
'e'))
3015 self.assertTrue(
not hasattr(p,
'f'))
3016 self.assertTrue(hasattr(p,
'g'))
3017 self.assertTrue(hasattr(p,
'h'))
3018 self.assertTrue(hasattr(p,
'i'))
3019 self.assertTrue(
not hasattr(p,
't1'))
3020 self.assertTrue(hasattr(p,
't2'))
3021 self.assertTrue(hasattr(p,
't3'))
3022 self.assertTrue(hasattr(p,
't4'))
3023 self.assertTrue(
not hasattr(p,
's'))
3024 self.assertTrue(hasattr(p,
's2'))
3025 self.assertTrue(
not hasattr(p,
's3'))
3026 self.assertTrue(hasattr(p,
'path1'))
3027 self.assertTrue(hasattr(p,
'path2'))
3028 self.assertTrue(hasattr(p,
'path3'))
3029 self.assertTrue(
not hasattr(p,
'path4'))
3037 self.assertTrue(hasattr(p,
'a'))
3038 self.assertTrue(hasattr(p,
'b'))
3039 self.assertTrue(hasattr(p,
's'))
3040 self.assertTrue(hasattr(p,
'pth'))
3046 p.prune(keepUnresolvedSequencePlaceholders=
True)
3047 self.assertTrue(hasattr(p,
'b'))
3048 self.assertTrue(hasattr(p,
's'))
3049 self.assertTrue(hasattr(p,
'pth'))
3050 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3058 self.assertTrue(hasattr(p,
'a'))
3059 self.assertTrue(hasattr(p,
'b'))
3060 self.assertTrue(hasattr(p,
's'))
3061 self.assertTrue(hasattr(p,
'pth'))
3067 p.prune(keepUnresolvedSequencePlaceholders=
True)
3068 self.assertTrue(hasattr(p,
'b'))
3069 self.assertTrue(hasattr(p,
's'))
3070 self.assertTrue(hasattr(p,
'pth'))
3071 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
3079 p.path1 =
Path(p.b, p.t2, p.t3)
3082 p.endpath1 =
EndPath(p.b, p.t5)
3086 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3096 """process.a = cms.EDProducer("ma") 3097 process.c = cms.EDProducer("mc") 3098 process.d = cms.EDProducer("md") 3099 process.e = cms.EDProducer("me") 3100 process.f = cms.EDProducer("mf") 3101 process.g = cms.EDProducer("mg") 3102 process.h = cms.EDProducer("mh") 3103 process.i = cms.EDProducer("mi") 3104 process.j = cms.EDProducer("mj") 3105 process.b = cms.EDAnalyzer("mb") 3106 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 3107 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 3108 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 3109 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 3110 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 3111 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 3112 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 3113 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 3114 process.path1 = cms.Path(process.b, process.t2, process.t3) 3115 process.endpath1 = cms.EndPath(process.b, process.t5) 3116 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3119 """process.a = cms.EDProducer("ma") 3120 process.c = cms.EDProducer("mc") 3121 process.d = cms.EDProducer("md") 3122 process.e = cms.EDProducer("me") 3123 process.f = cms.EDProducer("mf") 3124 process.g = cms.EDProducer("mg") 3125 process.h = cms.EDProducer("mh") 3126 process.i = cms.EDProducer("mi") 3127 process.j = cms.EDProducer("mj") 3128 process.b = cms.EDAnalyzer("mb") 3129 process.t8 = cms.Task(process.j) 3130 process.t6 = cms.Task(process.h) 3131 process.t7 = cms.Task(process.a, process.i, process.t6) 3132 process.t4 = cms.Task(process.f) 3133 process.t5 = cms.Task(process.a, process.g, process.t4) 3134 process.t3 = cms.Task(process.e) 3135 process.t1 = cms.Task(process.c) 3136 process.t2 = cms.Task(process.a, process.d, process.t1) 3137 process.path1 = cms.Path(process.b, process.t2, process.t3) 3138 process.endpath1 = cms.EndPath(process.b, process.t5) 3139 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3151 p.t1 =
Task(p.g, p.h)
3155 p.path1 =
Path(p.a+p.f+p.s,t2)
3158 self.assertTrue(hasattr(p,
'f'))
3159 self.assertTrue(hasattr(p,
'g'))
3163 self.assertFalse(hasattr(p,
'f'))
3164 self.assertFalse(hasattr(p,
'g'))
3165 self.assertTrue(p.t1.dumpPython() ==
'cms.Task(process.h)\n')
3166 self.assertTrue(p.s.dumpPython() ==
'cms.Sequence(process.d)\n')
3167 self.assertTrue(p.path1.dumpPython() ==
'cms.Path(process.a+process.s, cms.Task(process.h))\n')
3168 self.assertTrue(p.endpath1.dumpPython() ==
'cms.EndPath(process.b)\n')
3170 self.assertTrue(p.path1.dumpPython() ==
'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
3171 self.assertTrue(p.schedule_().
dumpPython() ==
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
3178 m1.toModify(p.a,_mod_fred)
3179 self.assertEqual(p.a.fred.value(),2)
3181 m1.toModify(p.b, wilma = 2)
3182 self.assertEqual(p.b.wilma.value(),2)
3183 self.assertTrue(p.isUsingModifier(m1))
3188 m1.toModify(p.a,_mod_fred)
3190 m1.toModify(p.b, wilma = 2)
3191 self.assertEqual(p.a.fred.value(),1)
3192 self.assertEqual(p.b.wilma.value(),1)
3193 self.assertEqual(p.isUsingModifier(m1),
False)
3198 m1.toModify(p.a, fred =
int32(2))
3199 p.b = p.a.clone(wilma =
int32(3))
3200 self.assertEqual(p.a.fred.value(),2)
3201 self.assertEqual(p.a.wilma.value(),1)
3202 self.assertEqual(p.b.fred.value(),2)
3203 self.assertEqual(p.b.wilma.value(),3)
3208 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
3209 self.assertEqual(hasattr(p.a,
"fred"),
False)
3210 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
3211 self.assertEqual(p.a.wilma.value(),1)
3216 m1.toModify(p.a, wilma =
int32(2))
3217 self.assertEqual(p.a.fred.value(), 1)
3218 self.assertEqual(p.a.wilma.value(),2)
3223 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
3224 self.assertEqual(p.a.flintstones.fred.value(),2)
3225 self.assertEqual(p.a.flintstones.wilma.value(),1)
3230 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
3231 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
3236 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
3237 self.assertEqual(p.a.flintstones[0].fred.value(),1)
3238 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3243 m1.toModify(p.a, fred = {1:7})
3244 self.assertEqual(p.a.fred[0],1)
3245 self.assertEqual(p.a.fred[1],7)
3246 self.assertEqual(p.a.fred[2],3)
3252 try: m1.toModify(p.a, fred = {5:7})
3253 except IndexError
as e: raised =
True 3254 self.assertEqual(raised,
True)
3260 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
3261 except TypeError
as e: raised =
True 3262 self.assertEqual(raised,
True)
3266 class ProcModifierMod(
object):
3267 def __init__(self,modifier,func):
3272 testMod = DummyMod()
3274 self.assertTrue(hasattr(p,
"a"))
3277 testProcMod = ProcModifierMod(m1,_rem_a)
3279 p.extend(testProcMod)
3280 self.assertTrue(
not hasattr(p,
"a"))
3285 self.assertTrue(p.isUsingModifier(m1))
3286 self.assertTrue(p.isUsingModifier(mc))
3287 testMod = DummyMod()
3289 m1.toModify(p.b, fred =
int32(3))
3291 testProcMod = ProcModifierMod(m1,_rem_a)
3292 p.extend(testProcMod)
3293 self.assertTrue(
not hasattr(p,
"a"))
3294 self.assertEqual(p.b.fred.value(),3)
3299 mclone = mc.copyAndExclude([m2])
3300 self.assertTrue(
not mclone._isOrContains(m2))
3301 self.assertTrue(mclone._isOrContains(m1))
3304 mclone = mc2.copyAndExclude([m2])
3305 self.assertTrue(
not mclone._isOrContains(m2))
3306 self.assertTrue(mclone._isOrContains(m1))
3307 self.assertTrue(mclone._isOrContains(m3))
3313 (m1 & m2).toModify(p.a, fred =
int32(2))
3314 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3315 self.assertEqual(p.a.fred, 1)
3320 (m1 & m2).toModify(p.a, fred =
int32(2))
3321 self.assertEqual(p.a.fred, 2)
3327 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3328 self.assertEqual(p.a.fred, 2)
3329 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3330 self.assertEqual(p.a.fred, 3)
3331 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3332 self.assertEqual(p.a.fred, 4)
3338 (~m1).toModify(p.a, fred=2)
3339 self.assertEqual(p.a.fred, 1)
3340 (~m2).toModify(p.a, wilma=2)
3341 self.assertEqual(p.a.wilma, 2)
3342 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3343 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3350 (m1 | m2).toModify(p.a, fred=2)
3351 self.assertEqual(p.a.fred, 2)
3352 (m1 | m2 | m3).toModify(p.a, fred=3)
3353 self.assertEqual(p.a.fred, 3)
3354 (m3 | m2 | m1).toModify(p.a, fred=4)
3355 self.assertEqual(p.a.fred, 4)
3356 ((m1 | m2) | m3).toModify(p.a, fred=5)
3357 self.assertEqual(p.a.fred, 5)
3358 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3359 self.assertEqual(p.a.fred, 6)
3360 (m2 | m3).toModify(p.a, fred=7)
3361 self.assertEqual(p.a.fred, 6)
3362 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3363 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3371 (m1 & ~m2).toModify(p.a, fred=2)
3372 self.assertEqual(p.a.fred, 1)
3373 (m1 & ~m3).toModify(p.a, fred=2)
3374 self.assertEqual(p.a.fred, 2)
3375 (m1 | ~m2).toModify(p.a, fred=3)
3376 self.assertEqual(p.a.fred, 3)
3377 (~m1 | ~m2).toModify(p.a, fred=4)
3378 self.assertEqual(p.a.fred, 3)
3379 (~m3 & ~m4).toModify(p.a, fred=4)
3380 self.assertEqual(p.a.fred, 4)
3381 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3382 self.assertEqual(p.a.fred, 5)
3388 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3395 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3396 self.assertEqual(p.a.wilma.value(),3)
3397 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3398 self.assertEqual(hasattr(p,
"fred"),
False)
3399 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
3401 m1.toReplaceWith(p.td,
Task(p.e))
3402 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3408 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3416 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3417 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3418 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3419 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3420 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3421 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3422 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3423 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3424 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3425 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3426 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3427 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3428 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3429 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3430 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3431 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3432 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3433 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3440 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
3441 self.assertEqual(a.foo2[0].type,
"Foo3")
3444 self.assertEqual(a.foo2[0].type,
"Foo3")
3445 self.assertEqual(a.foo4[0].type,
"Foo4")
3447 m.toModify(a, foo2 =
None)
3448 self.assertFalse(hasattr(a,
"foo2"))
3449 self.assertEqual(a.foo4[0].type,
"Foo4")
3452 self.assertFalse(hasattr(a,
"foo2"))
3453 self.assertFalse(hasattr(a,
"foo4"))
3454 self.assertTrue(hasattr(a,
"bar"))
3455 self.assertEqual(a.bar[0].type,
"Bar")
3468 test1 = dict(a = 4, b = dict(c =
None)),
3469 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
3470 self.assertEqual(sp.test1.a.value(), 4)
3471 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
3472 self.assertEqual(sp.test2.aa.value(), 15)
3473 self.assertEqual(sp.test2.bb.cc.value(), 45)
3474 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
3477 self.assertEqual(sp.test1.type_(),
"Fred")
3478 self.assertEqual(sp.test1.x.value(), 42)
3479 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
3482 self.assertEqual(sp.test2.type_(),
"Xyzzy")
3483 self.assertEqual(sp.test2.x.value(), 24)
3484 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
3487 self.assertEqual(sp.test3.type_(),
"Wilma")
3488 self.assertEqual(sp.test3.y.value(), 24)
3489 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
3491 m.toModify(sp, test2 =
None)
3492 self.assertEqual(hasattr(sp,
"test2"),
False)
3495 self.assertTrue(hasattr(sp.test2,
"foo"))
3498 self.assertTrue(hasattr(sp.test2,
"bar"))
3501 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
3503 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
3509 p.maxEvents.input = 10
3510 p.options.numberOfThreads = 4
3511 p.maxLuminosityBlocks.input = 2
3513 self.assertEqual(p.maxEvents.input.value(),10)
3514 self.assertEqual(p.options.numberOfThreads.value(), 4)
3515 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
3521 self.assertTrue(hasattr(p,
'fltr'))
def __setstate__(self, pkldict)
def addVString(self, tracked, label, value)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def __getattribute__(self, name)
def _place(self, label, process)
def testServiceInProcess(self)
def _dumpConfigUnnamedList(self, items, typeName, options)
def _placeAnalyzer(self, name, mod)
def addString(self, tracked, label, value)
def __findFirstUsingModule(self, seqsOrTasks, mod)
def _pruneModules(self, d, scheduledNames)
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
def _placeESPrefer(self, name, mod)
def __updateMaxEvents(self, ps)
def _placeSwitchProducer(self, name, mod)
def _insertPaths(self, processPSet, nodeVisitor)
def _placeESProducer(self, name, mod)
def _splitPythonList(self, subfolder, d, options)
def addVESInputTag(self, tracked, label, value)
def _placeSequence(self, name, mod)
def _validateSequence(self, sequence, label)
def __getattr__(self, attr)
def setStrict(self, value)
def addDouble(self, tracked, label, value)
def _findPreferred(self, esname, d, args, kargs)
def _insertOneInto(self, parameterSet, label, item, tracked)
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, name, Mods)
S & print(S &os, JobReport::InputFile const &f)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def testTypedParameterizable(self)
def addUInt64(self, tracked, label, value)
def _itemsInDependencyOrder(self, processDictionaryOfItems)
def addVPSet(self, tracked, label, value)
def nameInProcessDesc_(self, label)
def _lineDiff(newString, oldString)
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 _replaceInTasks(self, label, new)
def addVInt32(self, tracked, label, value)
def _placeFilter(self, name, mod)
def addVInputTag(self, tracked, label, value)
def _applyNewProcessModifiers(self, process)
def addLuminosityBlockID(self, tracked, label, value)
def addESInputTag(self, tracked, label, value)
def __new__(cls, args, kw)
def toModify(self, obj, func=None, kw)
def __setattr__(self, name, value)
def _placeESSource(self, name, mod)
def addVInt64(self, tracked, label, value)
def addVEventID(self, tracked, label, value)
def toModify(self, obj, func=None, kw)
def testGlobalReplace(self)
def testSwitchProducer(self)
def getVString(self, tracked, label)
def defaultMaxLuminosityBlocks_()
def testProcessFragment(self)
def toReplaceWith(self, toObj, fromObj)
def _placeOutputModule(self, name, mod)
def addFileInPath(self, tracked, label, value)
def _placeSource(self, name, mod)
def __init__(self, lhs, rhs=None)
def _dumpPythonSubProcesses(self, l, options)
def _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 _validateTask(self, task, label)
def testParameterizable(self)
def _placeSubProcess(self, name, mod)
def setPartialSchedule_(self, sch, label)
def addPSet(self, tracked, label, value)
def testProcessDumpPython(self)
def _placeService(self, typeName, mod)
def resolve(self, keepUnresolvedSequencePlaceholders=False)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def _splitPython(self, subfolder, d, options)
def __init__(self, lhs, rhs)
def dumpPython(process, name)
def __setObjectLabel(self, object, newLabel)
def _delHelper(self, name)
def _placeAlias(self, name, mod)
def dumpPython(self, options=PrintOptions())
def _replaceInSequences(self, label, new)
def setSchedule_(self, sch)
def _toReplaceWithCheck(toObj, fromObj)
def 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)
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 _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def _place(self, name, mod, d)
def testProcessExtend(self)
def _dumpPythonList(self, d, options)
def __insertValue(self, tracked, label, value)
def splitPython(self, options=PrintOptions())
def __init__(self, kargs)
def __getValue(self, tracked, label)
def _placeVPSet(self, name, mod)
def globalReplace(self, label, new)
def addBool(self, tracked, label, value)
def addEventID(self, tracked, label, value)
def _placeLooper(self, name, mod)
def testImplicitSchedule(self)
def prune(self, verbose=False, keepUnresolvedSequencePlaceholders=False)
def addVDouble(self, tracked, label, value)
def _insertInto(self, parameterSet, itemDict)
def _delattrFromSetattr(self, name)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def _replaceInSchedule(self, label, new)
def _dumpPython(self, d, options)
def addInt32(self, tracked, label, value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)