4 from __future__
import print_function
5 from __future__
import absolute_import
7 from .Options
import Options
13 from .Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
16 from .Modules
import *
17 from .Modules
import _Module
18 from .SequenceTypes
import *
19 from .SequenceTypes
import _ModuleSequenceType, _Sequenceable
20 from .SequenceVisitors
import PathValidator, EndPathValidator, FinalPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
21 from .MessageLogger
import MessageLogger
22 from .
import DictTypes
24 from .ExceptionHandling
import *
27 if sys.getrecursionlimit()<5000:
28 sys.setrecursionlimit(5000)
33 Configuration =
"{Configuration}" 34 UnavailableAccelerator =
"{UnavailableAccelerator}" 43 Raise an exception if called by special config files. This checks 44 the call or import stack for the importing file. An exception is raised if 45 the importing module is not in allowedPatterns and if it is called too deeply: 46 minLevel = 2: inclusion by top lvel cfg only 47 minLevel = 1: No inclusion allowed 48 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 49 by any module in Module1 or Submodule1 55 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'FWCore/ParameterSet/python/Config.py',
'<string>',
'<frozen ']
56 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
60 for item
in inspect.stack():
64 for pattern
in CMSSWPath:
65 if item[1].
find(pattern) != -1:
68 if item[1].
find(
'/') == -1:
71 for pattern
in ignorePatterns:
72 if item[1].
find(pattern) != -1:
76 if inPath
and not ignore:
77 trueStack.append(item[1])
79 importedFile = trueStack[0]
81 if len(trueStack) > 1:
82 importedBy = trueStack[1]
84 for pattern
in allowedPatterns:
85 if importedBy.find(pattern) > -1:
88 if len(trueStack) <= minLevel:
91 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 95 """Look inside the module and find the Processes it contains""" 99 if isinstance(module,dict):
100 if 'process' in module:
101 p = module[
'process']
104 if hasattr(module,
'process'):
105 if isinstance(module.process,Process):
106 process = module.process
108 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
110 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
114 """Root class for a CMS configuration process""" 117 """The argument 'name' will be the name applied to this Process 118 Can optionally pass as additional arguments cms.Modifier instances 119 that will be used to modify the Process as it is built 121 self.__dict__[
'_Process__name'] = name
122 if not name.isalnum():
123 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
124 self.__dict__[
'_Process__filters'] = {}
125 self.__dict__[
'_Process__producers'] = {}
126 self.__dict__[
'_Process__switchproducers'] = {}
127 self.__dict__[
'_Process__source'] =
None 128 self.__dict__[
'_Process__looper'] =
None 129 self.__dict__[
'_Process__subProcesses'] = []
130 self.__dict__[
'_Process__schedule'] =
None 131 self.__dict__[
'_Process__analyzers'] = {}
132 self.__dict__[
'_Process__outputmodules'] = {}
136 self.__dict__[
'_Process__sequences'] = {}
137 self.__dict__[
'_Process__tasks'] = {}
138 self.__dict__[
'_Process__conditionaltasks'] = {}
139 self.__dict__[
'_Process__services'] = {}
140 self.__dict__[
'_Process__essources'] = {}
141 self.__dict__[
'_Process__esproducers'] = {}
142 self.__dict__[
'_Process__esprefers'] = {}
143 self.__dict__[
'_Process__aliases'] = {}
144 self.__dict__[
'_Process__psets']={}
145 self.__dict__[
'_Process__vpsets']={}
146 self.__dict__[
'_cloneToObjectDict'] = {}
148 self.__dict__[
'_Process__InExtendCall'] =
False 149 self.__dict__[
'_Process__partialschedules'] = {}
151 self.__dict__[
'_Process__modifiers'] = Mods
152 self.__dict__[
'_Process__accelerators'] = {}
161 if Process._firstProcess:
162 Process._firstProcess =
False 165 for m
in self.__modifiers:
166 if not m._isChosen():
167 raise RuntimeError(
"The Process {} tried to redefine which Modifiers to use after another Process was already started".
format(name))
168 for m
in self.__modifiers:
173 _Module.__isStrict__ =
True 177 """Returns a string containing all the EDProducer labels separated by a blank""" 180 """Returns a string containing all the SwitchProducer labels separated by a blank""" 183 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 186 """Returns a string containing all the EDFilter labels separated by a blank""" 189 """Returns a string containing all the Path names separated by a blank""" 196 Since cloneToObjectDict stores a hash of objects by their 197 id() it needs to be updated when unpickling to use the 198 new object id values instantiated during the unpickle. 201 self.__dict__.
update(pkldict)
203 for value
in self._cloneToObjectDict.
values():
204 tmpDict[
id(value)] = value
205 self.__dict__[
'_cloneToObjectDict'] = tmpDict
210 """returns a dict of the filters that have been added to the Process""" 212 filters = property(filters_, doc=
"dictionary containing the filters for the process")
216 if not name.isalnum():
217 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
218 self.__dict__[
'_Process__name'] = name
219 process = property(name_,setName_, doc=
"name of the process")
221 """returns a dict of the producers that have been added to the Process""" 223 producers = property(producers_,doc=
"dictionary containing the producers for the process")
225 """returns a dict of the SwitchProducers that have been added to the Process""" 227 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
229 """returns the source that has been added to the Process or None if none have been added""" 233 source = property(source_,setSource_,doc=
'the main source or None if not set')
235 """returns the looper that has been added to the Process or None if none have been added""" 239 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
242 return untracked.PSet(numberOfThreads = untracked.uint32(1),
243 numberOfStreams = untracked.uint32(0),
244 numberOfConcurrentRuns = untracked.uint32(1),
245 numberOfConcurrentLuminosityBlocks = untracked.uint32(0),
246 eventSetup = untracked.PSet(
247 numberOfConcurrentIOVs = untracked.uint32(0),
248 forceNumberOfConcurrentIOVs = untracked.PSet(
249 allowAnyLabel_ = required.untracked.uint32
252 accelerators = untracked.vstring(
'*'),
253 wantSummary = untracked.bool(
False),
254 fileMode = untracked.string(
'FULLMERGE'),
255 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
256 throwIfIllegalParameter = untracked.bool(
True),
257 printDependencies = untracked.bool(
False),
258 deleteNonConsumedUnscheduledModules = untracked.bool(
True),
259 sizeOfStackForThreadsInKB = optional.untracked.uint32,
260 Rethrow = untracked.vstring(),
261 TryToContinue = untracked.vstring(),
262 IgnoreCompletely = untracked.vstring(),
263 modulesToCallForTryToContinue = untracked.vstring(),
264 canDeleteEarly = untracked.vstring(),
265 holdsReferencesToDeleteEarly = untracked.VPSet(),
266 modulesToIgnoreForDeleteEarly = untracked.vstring(),
267 dumpOptions = untracked.bool(
False),
268 allowUnscheduled = obsolete.untracked.bool,
269 emptyRunLumiMode = obsolete.untracked.string,
270 makeTriggerResults = obsolete.untracked.bool,
274 if isinstance(opt,dict):
275 for k,v
in opt.items():
278 for p
in opt.parameters_():
279 setattr(newOpts, p, getattr(opt,p))
283 return untracked.PSet(input=optional.untracked.int32,
284 output=optional.untracked.allowed(int32,PSet))
287 if isinstance(ps,dict):
288 for k,v
in ps.items():
291 for p
in ps.parameters_():
292 setattr(newMax, p, getattr(ps,p))
296 return untracked.PSet(input=untracked.int32(-1))
298 """returns a list of the subProcesses that have been added to the Process""" 299 return self.__subProcesses
300 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
302 """returns a dict of the analyzers that have been added to the Process""" 304 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
306 """returns a dict of the output modules that have been added to the Process""" 308 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
310 """returns a dict of the paths that have been added to the Process""" 312 paths = property(paths_,doc=
"dictionary containing the paths for the process")
314 """returns a dict of the endpaths that have been added to the Process""" 316 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
318 """returns a dict of the finalpaths that have been added to the Process""" 320 finalpaths = property(finalpaths_,doc=
"dictionary containing the finalpaths for the process")
322 """returns a dict of the sequences that have been added to the Process""" 324 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
326 """returns a dict of the tasks that have been added to the Process""" 328 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
330 """returns a dict of the conditionaltasks that have been added to the Process""" 332 conditionaltasks = property(conditionaltasks_,doc=
"dictionary containing the conditionatasks for the process")
334 """returns the schedule that has been added to the Process or None if none have been added""" 335 return self.__schedule
337 if label ==
"schedule":
340 self.
_place(label, sch, self.__partialschedules)
349 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
350 self.__dict__[
'_Process__schedule'] = sch
351 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
353 """returns a dict of the services that have been added to the Process""" 355 services = property(services_,doc=
"dictionary containing the services for the process")
357 """returns a dict of the ProcessAccelerators that have been added to the Process""" 359 processAccelerators = property(processAccelerators_,doc=
"dictionary containing the ProcessAccelerators for the process")
361 """returns a dict of the esproducers that have been added to the Process""" 363 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
365 """returns a the es_sources that have been added to the Process""" 367 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
369 """returns a dict of the es_prefers that have been added to the Process""" 371 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
373 """returns a dict of the aliases that have been added to the Process""" 375 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
377 """returns a dict of the PSets that have been added to the Process""" 379 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
381 """returns a dict of the VPSets that have been added to the Process""" 383 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
386 """returns True if the Modifier is in used by this Process""" 388 for m
in self.__modifiers:
389 if m._isOrContains(mod):
394 if not object.hasLabel_() :
395 object.setLabel(newLabel)
397 if newLabel == object.label_() :
399 if newLabel
is None :
400 object.setLabel(
None)
402 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
403 msg100 =
"Attempting to change the label of an attribute of the Process\n" 404 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 405 msg102 =
"Type = "+
str(type(object))+
"\n" 406 msg103 =
"Some possible solutions:\n" 407 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 408 msg105 =
" also preferred for other types when possible.\n" 409 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 410 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 411 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 412 msg109 =
" the name.\n" 413 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 414 msg111 =
" name to the same object usually causes confusion and problems.\n" 415 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 416 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
417 object.setLabel(
None)
418 object.setLabel(newLabel)
422 if not name.replace(
'_',
'').isalnum():
423 raise ValueError(
'The label '+name+
' contains forbiden characters')
425 if name ==
'options':
427 if name ==
'maxEvents':
431 if name.startswith(
'_Process__'):
432 self.__dict__[name]=value
434 if not isinstance(value,_ConfigureComponent):
435 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 436 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
437 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
438 if name == value.type_():
439 if hasattr(self,name)
and (getattr(self,name)!=value):
446 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
447 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
450 newValue =value.copy()
452 newValue._filename = value._filename
458 if not self.
_okToPlace(name, value, self.__dict__):
459 newFile=
'top level config' 460 if hasattr(value,
'_filename'):
461 newFile = value._filename
462 oldFile=
'top level config' 463 oldValue = getattr(self,name)
464 if hasattr(oldValue,
'_filename'):
465 oldFile = oldValue._filename
466 msg =
"Trying to override definition of process."+name
467 msg +=
"\n new object defined in: "+newFile
468 msg +=
"\n existing object defined in: "+oldFile
469 raise ValueError(msg)
471 if hasattr(self,name)
and not (getattr(self,name)==newValue):
475 if newValue._isTaskComponent():
476 if not self.__InExtendCall:
481 if not isinstance(newValue, Task):
483 newFile=
'top level config' 484 if hasattr(value,
'_filename'):
485 newFile = value._filename
486 oldFile=
'top level config' 487 oldValue = getattr(self,name)
488 if hasattr(oldValue,
'_filename'):
489 oldFile = oldValue._filename
490 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 491 msg2 =
"\n new object defined in: "+newFile
492 msg2 +=
"\n existing object defined in: "+oldFile
495 raise ValueError(msg1+s.label_()+msg2)
497 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent()
or isinstance(newValue, ConditionalTask):
498 if not self.__InExtendCall:
499 if isinstance(newValue, ConditionalTask):
504 newFile=
'top level config' 505 if hasattr(value,
'_filename'):
506 newFile = value._filename
507 oldFile=
'top level config' 508 oldValue = getattr(self,name)
509 if hasattr(oldValue,
'_filename'):
510 oldFile = oldValue._filename
511 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 512 msg2 =
"\n new object defined in: "+newFile
513 msg2 +=
"\n existing object defined in: "+oldFile
516 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
519 raise ValueError(msg1+
"path "+s.label_()+msg2)
522 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
525 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
528 if isinstance(newValue, EDAlias):
529 oldValue = getattr(self, name)
531 newFile=
'top level config' 532 if hasattr(value,
'_filename'):
533 newFile = value._filename
534 oldFile=
'top level config' 535 if hasattr(oldValue,
'_filename'):
536 oldFile = oldValue._filename
537 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the " 538 msg2 =
"\n new object defined in: "+newFile
539 msg2 +=
"\n existing object defined in: "+oldFile
542 raise ValueError(msg1+
"task "+s.label_()+msg2)
545 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
548 raise ValueError(msg1+
"path "+s.label_()+msg2)
551 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
554 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
556 if not self.__InExtendCall
and (Schedule._itemIsValid(newValue)
or isinstance(newValue, Task)):
564 self.__dict__[name]=newValue
565 if isinstance(newValue,_Labelable):
567 self._cloneToObjectDict[
id(value)] = newValue
568 self._cloneToObjectDict[
id(newValue)] = newValue
570 newValue._place(name,self)
572 """Given a container of sequences or tasks, find the first sequence or task 573 containing mod and return it. If none is found, return None""" 576 for seqOrTask
in seqsOrTasks.values():
585 if not hasattr(self,name):
586 raise KeyError(
'process does not know about '+name)
587 elif name.startswith(
'_Process__'):
588 raise ValueError(
'this attribute cannot be deleted')
593 if name
in reg: del reg[name]
595 obj = getattr(self,name)
596 if isinstance(obj,_Labelable):
598 if isinstance(obj,Service):
599 obj._inProcess =
False 603 obj = getattr(self,name)
605 if not isinstance(obj, Sequence)
and not isinstance(obj, Task)
and not isinstance(obj,ConditionalTask):
615 if obj._isTaskComponent():
619 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
621 if Schedule._itemIsValid(obj)
or isinstance(obj, Task):
625 del self.__dict__[name]
630 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 634 del self.__dict__[name]
639 """Allows addition of components that do not have to have a label, e.g. Services""" 640 if not isinstance(value,_ConfigureComponent):
642 if not isinstance(value,_Unlabelable):
646 newValue =value.copy()
650 newValue._place(
'',self)
653 if not self.__InExtendCall:
664 if d[name]._isModified:
675 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
676 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
679 if isinstance(mod,_Labelable):
682 self.
_place(name, mod, self.__outputmodules)
684 self.
_place(name, mod, self.__producers)
686 self.
_place(name, mod, self.__switchproducers)
688 self.
_place(name, mod, self.__filters)
690 self.
_place(name, mod, self.__analyzers)
694 self.
_place(name, mod, self.__paths)
695 except ModuleCloneError
as msg:
697 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
701 self.
_place(name, mod, self.__endpaths)
702 except ModuleCloneError
as msg:
704 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
708 self.
_place(name, mod, self.__finalpaths)
709 except ModuleCloneError
as msg:
711 raise Exception(
"%sThe module %s in finalpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
714 self.
_place(name, mod, self.__sequences)
716 self.
_place(name, mod, self.__esproducers)
718 self.
_place(name, mod, self.__esprefers)
720 self.
_place(name, mod, self.__essources)
723 self.
_place(name, task, self.__tasks)
726 self.
_place(name, task, self.__conditionaltasks)
728 self.
_place(name, mod, self.__aliases)
730 self.
_place(name, mod, self.__psets)
732 self.
_place(name, mod, self.__vpsets)
734 """Allow the source to be referenced by 'source' or by type name""" 736 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
737 if self.__dict__[
'_Process__source']
is not None :
738 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
739 self.__dict__[
'_Process__source'] = mod
740 self.__dict__[mod.type_()] = mod
743 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
744 self.__dict__[
'_Process__looper'] = mod
745 self.__dict__[mod.type_()] = mod
747 self.__dict__[
'_Process__subProcess'] = mod
748 self.__dict__[mod.type_()] = mod
750 self.__subProcesses.
append(mod)
752 self.
_place(typeName, mod, self.__services)
753 if typeName
in self.__dict__:
754 self.__dict__[typeName]._inProcess =
False 755 self.__dict__[typeName]=mod
757 self.
_place(typeName, mod, self.__accelerators)
758 self.__dict__[typeName]=mod
760 moduleName = moduleName.replace(
"/",
".")
761 module = __import__(moduleName)
762 self.
extend(sys.modules[moduleName])
764 """Look in other and find types that we can use""" 766 self.__dict__[
'_Process__InExtendCall'] =
True 769 tasksToAttach = dict()
771 for name
in dir(other):
773 if name.startswith(
'_'):
775 item = getattr(other,name)
776 if name ==
"source" or name ==
"looper":
780 elif isinstance(item,_ModuleSequenceType):
782 elif isinstance(item,Task)
or isinstance(item, ConditionalTask):
783 tasksToAttach[name] = item
784 elif isinstance(item,_Labelable):
786 if not item.hasLabel_() :
788 elif isinstance(item,Schedule):
790 elif isinstance(item,_Unlabelable):
792 elif isinstance(item,ProcessModifier):
794 elif isinstance(item,ProcessFragment):
798 for name,seq
in seqs.items():
799 if id(seq)
not in self._cloneToObjectDict:
802 newSeq = self._cloneToObjectDict[
id(seq)]
803 self.__dict__[name]=newSeq
806 newSeq._place(name,self)
808 for name, task
in tasksToAttach.items():
815 self.__dict__[
'_Process__InExtendCall'] =
False 819 for name,item
in items:
820 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
825 for name,item
in items:
826 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
831 for name,item
in items:
832 if name == item.type_():
834 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
838 """return a string containing the equivalent process defined using the old configuration language""" 839 config =
"process "+self.__name+
" = {\n" 892 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
894 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
896 pathNames = [p.label_()
for p
in self.
schedule]
897 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 909 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
915 returnValue += item.dumpPython(options)+
'\n\n' 921 for name,item
in d.items():
922 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 924 for name,item
in sorted(d.items()):
925 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 932 dependencies = item.directDependencies()
933 for module_subfolder, module
in dependencies:
934 module = module +
'_cfi' 935 if options.useSubdirectories
and module_subfolder:
936 module = module_subfolder +
'.' + module
937 if options.targetDirectory
is not None:
938 if options.useSubdirectories
and subfolder:
939 module =
'..' + module
941 module =
'.' + module
942 code +=
'from ' + module +
' import *\n' 945 code += name +
' = ' + item.dumpPython(options)
946 parts[name] = subfolder, code
954 sequence.visit(visitor)
955 except Exception
as e:
956 raise RuntimeError(
"An entry in sequence {} has no label\n Seen entries: {}\n Error: {}".
format(label, l, e))
965 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
973 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
985 for label,item
in processDictionaryOfItems.items():
987 if isinstance(item, Task):
989 elif isinstance(item, ConditionalTask):
996 if isinstance(item, Task):
997 raise RuntimeError(
"Failed in a Task visitor. Probably " \
998 "a circular dependency discovered in Task with label " + label)
999 elif isinstance(item, ConditionalTask):
1000 raise RuntimeError(
"Failed in a ConditionalTask visitor. Probably " \
1001 "a circular dependency discovered in ConditionalTask with label " + label)
1003 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
1004 "circular dependency discovered in Sequence with label " + label)
1005 for containedItem
in containedItems:
1011 if containedItem.hasLabel_():
1012 testItem = processDictionaryOfItems.get(containedItem.label_())
1013 if testItem
is None or containedItem != testItem:
1014 if isinstance(item, Task):
1015 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
1016 " from the process yields a different object or None\n"+
1017 "label = " + containedItem.label_())
1018 if isinstance(item, ConditionalTask):
1019 raise RuntimeError(
"ConditionalTask has a label, but using its label to get an attribute" \
1020 " from the process yields a different object or None\n"+
1021 "label = " + containedItem.label_())
1023 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
1024 " from the process yields a different object or None\n"+
1025 "label = " + containedItem.label_())
1026 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
1030 oldDeps = dict(dependencies)
1031 for label,deps
in oldDeps.items():
1033 returnValue[label]=processDictionaryOfItems[label]
1035 del dependencies[label]
1036 for lb2,deps2
in dependencies.items():
1037 while deps2.count(label):
1043 for name, value
in sorted(d.items()):
1044 result += value.dumpPythonAs(name,options)+
'\n' 1049 for name, value
in sorted(d.items()):
1050 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n' 1054 """return a string containing the equivalent process defined using python""" 1055 specialImportRegistry._reset()
1056 header =
"import FWCore.ParameterSet.Config as cms" 1057 result =
"process = cms.Process(\""+self.__name+
"\")\n\n" 1084 imports = specialImportRegistry.getSpecialImports()
1085 if len(imports) > 0:
1086 header +=
"\n" +
"\n".
join(imports)
1088 return header+result
1091 """return a map of file names to python configuration fragments""" 1092 specialImportRegistry._reset()
1094 options.isCfg =
False 1095 header =
"import FWCore.ParameterSet.Config as cms" 1100 result =
'process = cms.Process("' + self.__name +
'")\n\n' 1113 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1130 if options.targetDirectory
is not None:
1131 files[options.targetDirectory +
'/__init__.py'] =
'' 1133 if options.useSubdirectories:
1134 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1135 if options.targetDirectory
is not None:
1136 sub = options.targetDirectory +
'/' + sub
1137 files[sub +
'/__init__.py'] =
'' 1140 parts = sorted(parts.items(), key =
lambda nsc: (nsc[1][0].lower()
if nsc[1][0]
else '', nsc[0].lower()))
1142 for (name, (subfolder, code))
in parts:
1143 filename = name +
'_cfi' 1144 if options.useSubdirectories
and subfolder:
1145 filename = subfolder +
'/' + filename
1146 if options.targetDirectory
is not None:
1147 filename = options.targetDirectory +
'/' + filename
1148 result +=
'process.load("%s")\n' % filename
1149 files[filename +
'.py'] = header +
'\n\n' + code
1152 options.isCfg =
True 1155 imports = specialImportRegistry.getSpecialImports()
1156 if len(imports) > 0:
1157 header +=
'\n' +
'\n'.
join(imports)
1158 files[
'-'] = header +
'\n\n' + result
1162 old = getattr(self,label)
1169 sequenceable._replaceIfHeldDirectly(old,new)
1171 sequenceable.replace(old,new)
1173 sequenceable.replace(old,new)
1175 sequenceable.replace(old,new)
1177 sequenceable.replace(old,new)
1179 old = getattr(self,label)
1181 task.replace(old, new)
1183 old = getattr(self,label)
1185 task.replace(old, new)
1189 old = getattr(self,label)
1191 task.replace(old, new)
1195 old = getattr(self,label)
1196 self.
schedule_()._replaceIfHeldDirectly(old, new)
1198 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 1199 if not hasattr(self,label):
1200 raise LookupError(
"process has no item of label "+label)
1201 setattr(self,label,new)
1203 for name,value
in itemDict.items():
1204 value.insertInto(parameterSet, name)
1207 if not item ==
None:
1208 newlabel = item.nameInProcessDesc_(label)
1210 item.insertInto(parameterSet, newlabel)
1211 parameterSet.addVString(tracked, label, vitems)
1214 for name,value
in itemDict.items():
1215 value.appendToProcessDescList_(l, name)
1216 value.insertInto(parameterSet, name)
1219 parameterSet.addVString(tracked, label, l)
1221 modules = parameterSet.getVString(tracked, labelModules)
1222 aliases = parameterSet.getVString(tracked, labelAliases)
1223 accelerators = parameterSet.getVString(
False,
"@selected_accelerators")
1224 for name,value
in itemDict.items():
1225 value.appendToProcessDescLists_(modules, aliases, name)
1226 value.insertInto(parameterSet, name, accelerators)
1229 parameterSet.addVString(tracked, labelModules, modules)
1230 parameterSet.addVString(tracked, labelAliases, aliases)
1234 for value
in itemList:
1235 name = value.getProcessName()
1236 newLabel = value.nameInProcessDesc_(name)
1238 pset = value.getSubProcessPSet(parameterSet)
1239 subprocs.append(pset)
1242 parameterSet.addVString(tracked, label, l)
1243 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1251 for name
in self.
paths_():
1252 scheduledPaths.append(name)
1253 triggerPaths.append(name)
1255 scheduledPaths.append(name)
1256 endpaths.append(name)
1258 finalpaths.append(name)
1261 pathname = path.label_()
1263 endpaths.append(pathname)
1264 scheduledPaths.append(pathname)
1266 finalpaths.append(pathname)
1268 scheduledPaths.append(pathname)
1269 triggerPaths.append(pathname)
1271 task.resolve(self.__dict__)
1273 task.visit(scheduleTaskValidator)
1274 task.visit(nodeVisitor)
1276 endPathWithFinalPathModulesName =
"@finalPath" 1279 endpaths.append(endPathWithFinalPathModulesName)
1280 scheduledPaths.append(endPathWithFinalPathModulesName)
1282 modulesOnFinalPath = []
1283 for finalpathname
in finalpaths:
1285 iFinalPath.resolve(self.__dict__)
1286 finalpathValidator.setLabel(finalpathname)
1287 iFinalPath.visit(finalpathValidator)
1288 if finalpathValidator.filtersOnFinalpaths
or finalpathValidator.producersOnFinalpaths:
1289 names = [p.label_
for p
in finalpathValidator.filtersOnFinalpaths]
1290 names.extend( [p.label_
for p
in finalpathValidator.producersOnFinalpaths])
1291 raise RuntimeError(
"FinalPath %s has non OutputModules %s" % (finalpathname,
",".
join(names)))
1292 modulesOnFinalPath.extend(iFinalPath.moduleNames())
1293 for m
in modulesOnFinalPath:
1294 mod = getattr(self, m)
1295 setattr(mod,
"@onFinalPath", untracked.bool(
True))
1296 finalPathEndPath += mod
1298 processPSet.addVString(
True,
"@end_paths", endpaths)
1299 processPSet.addVString(
True,
"@paths", scheduledPaths)
1301 p = processPSet.newPSet()
1302 p.addVString(
True,
"@trigger_paths", triggerPaths)
1303 processPSet.addPSet(
True,
"@trigger_paths", p)
1309 condTaskModules = []
1311 pathCompositeVisitor =
CompositeVisitor(pathValidator, nodeVisitor, lister, condTaskVistor)
1312 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
1313 for triggername
in triggerPaths:
1314 iPath = self.
paths_()[triggername]
1315 iPath.resolve(self.__dict__)
1316 pathValidator.setLabel(triggername)
1318 condTaskModules[:] = []
1319 iPath.visit(pathCompositeVisitor)
1321 decoratedList.append(
"#")
1322 l = list({x.label_()
for x
in condTaskModules})
1324 decoratedList.extend(l)
1325 decoratedList.append(
"@")
1326 iPath.insertInto(processPSet, triggername, decoratedList[:])
1327 for endpathname
in endpaths:
1328 if endpathname
is not endPathWithFinalPathModulesName:
1329 iEndPath = self.
endpaths_()[endpathname]
1331 iEndPath = finalPathEndPath
1332 iEndPath.resolve(self.__dict__)
1333 endpathValidator.setLabel(endpathname)
1335 iEndPath.visit(endpathCompositeVisitor)
1336 iEndPath.insertInto(processPSet, endpathname, decoratedList[:])
1337 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1340 def resolve(self,keepUnresolvedSequencePlaceholders=False):
1342 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1344 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1346 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1349 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1351 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1352 """ Remove clutter from the process that we think is unnecessary: 1353 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 1354 not in the schedule will also be removed, along with an modules and sequences used only by 1355 those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders.""" 1364 self.
resolve(keepUnresolvedSequencePlaceholders)
1366 unneededPaths = set()
1370 usedModules=set(self.
schedule_().moduleNames())
1372 schedNames = set(( x.label_()
for x
in self.
schedule_()))
1373 names = set(self.
paths)
1376 unneededPaths = names - schedNames
1377 for n
in unneededPaths:
1388 usedModules=set(temp.moduleNames())
1405 def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1406 _keepSet = set(( s
for s
in seqOrTasks
if s.hasLabel_()))
1407 _availableSet = set(allSequencesOrTasks.values())
1408 _unneededSet = _availableSet-_keepSet
1409 _unneededLabels = []
1410 for s
in _unneededSet:
1411 _unneededLabels.append(s.label_())
1412 delattr(self,s.label_())
1413 return _unneededLabels
1414 unneededSeqLabels = removeUnneeded(seqs, self.
sequences)
1415 unneededTaskLabels = removeUnneeded(tasks, self.
tasks)
1417 print(
"prune removed the following:")
1418 print(
" modules:"+
",".
join(unneededModules))
1419 print(
" tasks:"+
",".
join(unneededTaskLabels))
1420 print(
" sequences:"+
",".
join(unneededSeqLabels))
1421 print(
" paths/endpaths/finalpaths:"+
",".
join(unneededPaths))
1423 moduleNames = set(d.keys())
1424 junk = moduleNames - scheduledNames
1430 """Used by the framework to convert python to C++ objects""" 1431 class ServiceInjectorAdaptor(
object):
1442 class TopLevelPSetAcessorAdaptor(
object):
1446 def __getattr__(self,attr):
1447 return getattr(self.
__ppset,attr)
1448 def getTopPSet_(self,label):
1452 def addPSet(self,tracked,name,ppset):
1453 return self.
__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1454 def addVPSet(self,tracked,name,vpset):
1455 return self.
__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1456 def __extractPSet(self,pset):
1457 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1462 processPSet.addString(
True,
"@process_name", self.
name_())
1465 all_modules.update(self.
filters_())
1468 if hasattr(self.options,
"modulesToCallForTryToContinue") :
1469 shouldTryToContinue = set(self.options.modulesToCallForTryToContinue)
1470 for m
in all_modules:
1471 if m
in shouldTryToContinue:
1472 setattr(getattr(self,m),
"@shouldTryToContinue",untracked.bool(
True))
1473 missing = shouldTryToContinue.difference(all_modules)
1475 print(
"Warning: The following modules appear in options.modulesToCallForTryToContinue but are not in the Process: {} ".
format(
",".
join(missing)))
1476 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1489 all_modules_onTasksOrScheduled = { key:value
for key, value
in all_modules.items()
if value
in nodeVisitor.modules }
1490 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1492 all_switches_onTasksOrScheduled = {key:value
for key, value
in all_switches.items()
if value
in nodeVisitor.modules }
1498 pTask.visit(processNodeVisitor)
1499 esProducersToEnable = {}
1501 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1502 esProducersToEnable[esProducerName] = esProducer
1503 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1504 esSourcesToEnable = {}
1506 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1507 esSourcesToEnable[esSourceName] = esSource
1508 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1512 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1513 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1514 adaptor.addVPSet(
False,
"services",services)
1526 allAccelerators = set([
"cpu"])
1527 availableAccelerators = set([
"cpu"])
1528 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1529 allAccelerators.update(acc.labels())
1530 availableAccelerators.update(acc.enabledLabels())
1531 availableAccelerators = sorted(list(availableAccelerators))
1532 parameterSet.addVString(
False,
"@available_accelerators", availableAccelerators)
1535 selectedAccelerators = []
1536 if "*" in self.options.accelerators:
1537 if len(self.options.accelerators) >= 2:
1538 raise ValueError(
"process.options.accelerators may contain '*' only as the only element, now it has {} elements".
format(len(self.options.accelerators)))
1539 selectedAccelerators = availableAccelerators
1544 for pattern
in self.options.accelerators:
1545 acc = [a
for a
in availableAccelerators
if fnmatch.fnmatchcase(a, pattern)]
1547 if not any(fnmatch.fnmatchcase(a, pattern)
for a
in allAccelerators):
1548 invalid.append(pattern)
1550 resolved.update(acc)
1552 if len(invalid) != 0:
1553 raise ValueError(
"Invalid pattern{} of '{}' in process.options.accelerators, valid values are '{}' or a pattern matching some of them.".
format(
1554 "s" if len(invalid) > 2
else "",
1555 "', '".
join(invalid),
1556 "', '".
join(sorted(list(allAccelerators)))))
1557 selectedAccelerators = sorted(list(resolved))
1558 parameterSet.addVString(
False,
"@selected_accelerators", selectedAccelerators)
1561 moduleTypeResolver =
None 1562 moduleTypeResolverPlugin =
"" 1563 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1564 resolver = acc.moduleTypeResolver(selectedAccelerators)
1565 if resolver
is not None:
1566 if moduleTypeResolver
is not None:
1567 raise RuntimeError(
"Module type resolver was already set to {} when {} tried to set it to {}. A job can have at most one ProcessAccelerator that sets module type resolver.".
format(
1568 moduleTypeResolver.__class__.__name__,
1569 acc.__class__.__name__,
1570 resolver.__class__.__name__))
1571 moduleTypeResolver = resolver
1572 if moduleTypeResolver
is not None:
1574 moduleTypeResolverPlugin = moduleTypeResolver.plugin()
1577 for modlist
in [self.producers_, self.filters_, self.analyzers_,
1578 self.es_producers_, self.es_sources_]:
1579 for module
in modlist().
values():
1580 moduleTypeResolver.setModuleVariant(module)
1582 parameterSet.addString(
False,
"@module_type_resolver", moduleTypeResolverPlugin)
1585 wrapped = ProcessForProcessAccelerator(self)
1586 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1587 acc.apply(wrapped, selectedAccelerators)
1590 """Prefer this ES source or producer. The argument can 1591 either be an object label, e.g., 1592 process.prefer(process.juicerProducer) (not supported yet) 1593 or a name of an ESSource or ESProducer 1594 process.prefer("juicer") 1595 or a type of unnamed ESSource or ESProducer 1596 process.prefer("JuicerProducer") 1597 In addition, you can pass as a labelled arguments the name of the Record you wish to 1598 prefer where the type passed is a cms.vstring and that vstring can contain the 1599 name of the C++ types in the Record that are being preferred, e.g., 1600 #prefer all data in record 'OrangeRecord' from 'juicer' 1601 process.prefer("juicer", OrangeRecord=cms.vstring()) 1603 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1604 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1606 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1607 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1610 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1611 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1616 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1621 typ = d[esname].type_()
1630 for name, value
in d.items():
1631 if value.type_() == esname:
1633 raise RuntimeError(
"More than one ES module for "+esname)
1641 if isinstance(process, Process):
1643 elif isinstance(process, str):
1650 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1652 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1654 if name ==
'_ProcessFragment__process':
1655 return object.__getattribute__(self,
'_ProcessFragment__process')
1659 if name ==
'_ProcessFragment__process':
1660 object.__setattr__(self, name, value)
1664 if name ==
'_ProcessFragment__process':
1671 """a dictionary with fixed keys""" 1673 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1674 _blocked_attribute = property(_blocked_attribute)
1675 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1676 pop = popitem = setdefault = update = _blocked_attribute
1678 new = dict.__new__(cls)
1679 dict.__init__(new, *args, **kw)
1680 keys = sorted(kw.keys())
1681 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1682 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1683 if not isinstance(kw[
'name'],str):
1684 raise ValueError(
"name must be of type string")
1685 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1686 raise ValueError(
"content must be of type vstring or string")
1687 if not isinstance(kw[
'dataTier'], string):
1688 raise ValueError(
"dataTier must be of type string")
1689 if not isinstance(kw[
'selectEvents'], PSet):
1690 raise ValueError(
"selectEvents must be of type PSet")
1691 if not isinstance(kw[
'paths'],(tuple, Path)):
1692 raise ValueError(
"'paths' must be a tuple of paths")
1697 return "FilteredStream object: %s" %self[
"name"]
1702 """Allows embedding another process within a parent process. This allows one to 1703 chain processes together directly in one cmsRun job rather than having to run 1704 separate jobs that are connected via a temporary file. 1706 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1709 if not isinstance(process, Process):
1710 raise ValueError(
"the 'process' argument must be of type cms.Process")
1711 if not isinstance(SelectEvents,PSet):
1712 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1713 if not isinstance(outputCommands,vstring):
1714 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1719 if self.
__process.MessageLogger
is not MessageLogger:
1720 print(
"""Warning: You have reconfigured service 1721 'edm::MessageLogger' in a subprocess. 1722 This service has already been configured. 1723 This particular service may not be reconfigured in a subprocess. 1724 The reconfiguration will be ignored.""")
1727 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1729 out +=
"childProcess = process\n" 1730 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1746 process._placeSubProcess(
'subProcess',self)
1748 topPSet = parameterSet.newPSet()
1750 subProcessPSet = parameterSet.newPSet()
1753 subProcessPSet.addPSet(
False,
"process",topPSet)
1754 return subProcessPSet
1757 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1764 params[k] = getattr(obj,k)
1768 setattr(obj,k,params[k])
1774 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1777 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1783 Modifier._toModifyCheck(obj,func,**kw)
1784 if self._isChosen():
1785 Modifier._toModify(obj,func,**kw)
1788 Modifier._toReplaceWithCheck(toObj,fromObj)
1789 if self._isChosen():
1790 Modifier._toReplaceWith(toObj,fromObj)
1793 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1794 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1795 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1805 """A modifier which only applies if multiple Modifiers are chosen""" 1807 super(_AndModifier,self).
__init__(lhs, rhs)
1812 """A modifier which only applies if a Modifier is not chosen""" 1814 super(_InvertModifier,self).
__init__(lhs)
1819 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1821 super(_OrModifier,self).
__init__(lhs, rhs)
1827 """This class is used to define standard modifications to a Process. 1828 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1829 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1830 these Modifier instances are imported into a configuration and items that need to be modified 1831 are then associated with the Modifier and with the action to do the modification. 1832 The registered modifications will only occur if the Modifier was passed to 1833 the cms.Process' constructor. 1839 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1840 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1841 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1846 if func
is not None and len(kw) != 0:
1847 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1849 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1850 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1851 that will be the object passed in as the first argument. 1852 Form 2: A list of parameter name, value pairs can be passed 1853 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1854 This form can also be used to remove a parameter by passing the value of None 1855 #remove the parameter foo.fred 1856 mod.toModify(foo, fred = None) 1857 Additionally, parameters embedded within PSets can also be modified using a dictionary 1858 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1859 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1861 Modifier._toModifyCheck(obj,func,**kw)
1863 Modifier._toModify(obj,func,**kw)
1867 if func
is not None:
1874 if not isinstance(fromObj, type(toObj)):
1875 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1877 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1879 Modifier._toReplaceWithCheck(toObj,fromObj)
1881 Modifier._toReplaceWith(toObj,fromObj)
1885 if isinstance(fromObj,_ModuleSequenceType):
1886 toObj._seq = fromObj._seq
1887 toObj._tasks = fromObj._tasks
1888 elif isinstance(fromObj,Task):
1889 toObj._collection = fromObj._collection
1890 elif isinstance(fromObj,ConditionalTask):
1891 toObj._collection = fromObj._collection
1892 elif isinstance(fromObj,_Parameterizable):
1894 for p
in toObj.parameterNames_():
1896 for p
in fromObj.parameterNames_():
1897 setattr(toObj,p,getattr(fromObj,p))
1898 if isinstance(fromObj,_TypedParameterizable):
1899 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1902 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1905 """Should only be called by cms.Process instances""" 1916 return self == other
1920 """A Modifier made up of a list of Modifiers 1926 """Should only be called by cms.Process instances 1927 applies list of accumulated changes to the process""" 1929 m._applyNewProcessModifiers(process)
1931 """Should only be called by cms.Process instances""" 1938 """Creates a new ModifierChain which is a copy of 1939 this ModifierChain but excludes any Modifier or 1940 ModifierChain in the list toExclude. 1941 The exclusion is done recursively down the chain. 1945 if m
not in toExclude:
1947 if isinstance(m,ModifierChain):
1948 s = m.__copyIfExclude(toExclude)
1964 if m._isOrContains(other):
1969 """A class used by a Modifier to affect an entire Process instance. 1970 When a Process 'loads' a module containing a ProcessModifier, that 1971 ProcessModifier will be applied to the Process if and only if the 1972 Modifier passed to the constructor has been chosen. 1985 """A class used to specify possible compute accelerators in a Process 1986 instance. It is intended to be derived for any 1987 accelerator/portability technology, and provides hooks such that a 1988 specific customization can be applied to the Process on a worker 1989 node at the point where the python configuration is serialized for C++. 1991 The customization must not change the configuration hash. To 1992 enforce this reuirement, the customization gets a 1993 ProcessForProcessAccelerator wrapper that gives access to only 1994 those parts of the configuration that can be changed. Nevertheless 1995 it would be good to have specific unit test for each deriving 1996 class to ensure that all combinations of the enabled accelerators 1997 give the same configuration hash. 1999 The deriving class must do its checks for hardware availability 2000 only in enabledLabels(), and possibly in apply() if any further 2001 fine-tuning is needed, because those two are the only functions 2002 that are guaranteed to be called at the worker node. 2007 proc._placeAccelerator(self.type_(), self)
2009 return type(self).__name__
2011 specialImportRegistry.registerUse(self)
2012 result = self.__class__.__name__+
"(" 2017 result +=
"\n"+res+
"\n" 2023 """Override if need to add any 'body' content to dumpPython(). Returns a string.""" 2026 """Override to return a list of strings for the accelerator labels.""" 2029 """Override to return a list of strings for the accelerator labels 2030 that are enabled in the system the job is being run on.""" 2033 """Override to return an object that implements "module type resolver" 2034 in python. The object should have the following methods 2035 - __init__(self, accelerators) 2036 * accelerators = list of selected accelerators 2038 * should return a string for the type resolver plugin name 2039 - setModuleVariant(self, module): 2040 * Called for each ED and ES module. Should act only if 2041 module.type_() contains the magic identifier 2043 At most one of the ProcessAccelerators in a job can return a 2048 """Override if need to customize the Process at worker node. The 2049 selected available accelerator labels are given in the 2050 'accelerators' argument (the patterns, e.g. '*' have been 2051 expanded to concrete labels). 2053 This function may touch only untracked parameters. 2058 """This class is inteded to wrap the Process object to constrain the 2059 available functionality for ProcessAccelerator.apply()""" 2064 if not isinstance(value, Service):
2065 raise TypeError(
"ProcessAccelerator.apply() can get only Services. Tried to get {} with label {}".
format(
str(type(value)), label))
2068 if label ==
"_ProcessForProcessAccelerator__process":
2071 if not isinstance(value, Service):
2072 raise TypeError(
"ProcessAccelerator.apply() can only set Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2076 if not isinstance(value, Service):
2077 raise TypeError(
"ProcessAccelerator.apply() can delete only Services. Tried to del {} with label {}".
format(
str(type(value)), label))
2080 if not isinstance(value, Service):
2081 raise TypeError(
"ProcessAccelerator.apply() can only add Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2087 return (
"test1" in accelerators, -10)
2089 return (
"test2" in accelerators, -9)
2091 if __name__==
"__main__":
2096 newString = ( x
for x
in newString.split(
'\n')
if len(x) > 0)
2097 oldString = [ x
for x
in oldString.split(
'\n')
if len(x) > 0]
2101 if oldStringLine >= len(oldString):
2104 if l == oldString[oldStringLine]:
2108 return "\n".
join( diff )
2111 """Has same interface as the C++ object that creates PSets 2116 self.
values[label]=(tracked,value)
2118 pair = self.
values[label]
2119 if pair[0] != tracked:
2120 raise Exception(
"Asked for %s parameter '%s', but it is %s" % (
"tracked" if tracked
else "untracked",
2122 "tracked" if pair[0]
else "untracked"))
2183 super(SwitchProducerTest,self).
__init__(
2185 test1 =
lambda accelerators: (
True, -10),
2186 test2 =
lambda accelerators: (
True, -9),
2187 test3 =
lambda accelerators: (
True, -8),
2188 test4 =
lambda accelerators: (
True, -7)
2190 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest,
"from test import SwitchProducerTest")
2194 super(SwitchProducerTest2,self).
__init__(
2196 test1 = _switchproducer_test2_case1,
2197 test2 = _switchproducer_test2_case2,
2199 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest2,
"from test import SwitchProducerTest2")
2205 if "test1" in accelerators:
2207 if "test2" in accelerators:
2210 raise EDMException(edm.errors.UnavailableAccelerator,
"Machine has no accelerators that Test supports (has {})".
format(
", ".
join(accelerators)))
2213 return "TestModuleTypeResolver" 2216 if "@test" in module.type_():
2218 if hasattr(module,
"test"):
2219 if hasattr(module.test,
"backend"):
2221 raise EDMException(edm.errors.UnavailableAccelerator,
"Module {} has the Test backend set explicitly, but its accelerator is not available for the job".
format(module.label_()))
2223 module.test.backend = untracked.string(defaultBackend)
2225 module.test = untracked.PSet(
2226 backend = untracked.string(defaultBackend)
2230 def __init__(self, enabled=["test1", "test2", "anothertest3"], moduleTypeResolverMaker=None):
2236 invalid = set(enabled).difference(set(self.
_labels))
2237 if len(invalid) > 0:
2238 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2241 result =
"{}enabled = [{}]".
format(options.indentation(),
2253 process.AcceleratorTestService =
Service(
"AcceleratorTestService")
2254 if hasattr(process,
"AcceleratorTestServiceRemove"):
2255 del process.AcceleratorTestServiceRemove
2256 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest,
"from test import ProcessAcceleratorTest")
2259 def __init__(self, enabled=["anothertest3", "anothertest4"], moduleTypeResolverMaker=None):
2265 invalid = set(enabled).difference(set(self.
_labels))
2266 if len(invalid) > 0:
2267 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2270 result =
"{}enabled = [{}]".
format(options.indentation(),
2283 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest2,
"from test import ProcessAcceleratorTest2")
2287 """Nothing to do """ 2291 self.assertEqual(len(p.parameterNames_()),0)
2293 self.assertTrue(
'a' in p.parameterNames_())
2294 self.assertEqual(p.a.value(), 1)
2296 self.assertEqual(p.a.value(), 10)
2298 self.assertEqual(p.a.value(), 1)
2299 self.assertFalse(p.a.isTracked())
2300 p.a = untracked.int32(1)
2301 self.assertEqual(p.a.value(), 1)
2302 self.assertFalse(p.a.isTracked())
2304 self.assertEqual(p.foo.value(), 10)
2305 self.assertEqual(p.bar.value(),1.0)
2306 self.assertFalse(p.bar.isTracked())
2307 self.assertRaises(TypeError,setattr,(p,
'c',1))
2309 self.assertEqual(p.a.foo.value(),10)
2310 self.assertEqual(p.a.bar.value(),1.0)
2312 self.assertEqual(p.b.fii.value(),1)
2313 self.assertFalse(p.b.isTracked())
2318 self.assertEqual(p.a.value(),11)
2320 self.assertEqual(p.a.value(),12)
2321 self.assertEqual(v.value(),12)
2327 self.assertNotEqual(p.b,other.b)
2332 self.assertTrue(
'a' in p.analyzers_() )
2333 self.assertTrue(
'a' in p.analyzers)
2334 p.add_(
Service(
"SomeService"))
2335 self.assertTrue(
'SomeService' in p.services_())
2336 self.assertEqual(p.SomeService.type_(),
"SomeService")
2338 self.assertTrue(
'Tracer' in p.services_())
2339 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
2340 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
2341 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
2343 self.assertEqual(p.out.type_(),
'Outer')
2344 self.assertTrue(
'out' in p.outputModules_() )
2347 self.assertTrue(
'geom' in p.es_sources_())
2349 self.assertTrue(
'ConfigDB' in p.es_sources_())
2352 self.assertTrue(
'aliasfoo1' in p.aliases_())
2357 for name
in args.keys():
2358 self.__dict__[name]=args[name]
2377 self.assertEqual(p.a.type_(),
"MyAnalyzer")
2378 self.assertEqual(p.a.label_(),
"a")
2379 self.assertRaises(AttributeError,getattr,p,
'b')
2380 self.assertEqual(p.Full.type_(),
"Full")
2381 self.assertEqual(
str(p.c),
'a')
2382 self.assertEqual(
str(p.d),
'a')
2397 self.assertRaises(ValueError, p1.extend, z1)
2406 aaa=copy.deepcopy(a),
2407 s4=copy.deepcopy(s3),
2414 self.assertEqual(p2.s4.label_(),
"s4")
2416 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
2417 p2.s4.setLabel(
"s4")
2418 p2.s4.setLabel(
None)
2419 p2.s4.setLabel(
"foo")
2420 p2._Process__setObjectLabel(p2.s4,
"foo")
2421 p2._Process__setObjectLabel(p2.s4,
None)
2422 p2._Process__setObjectLabel(p2.s4,
"bar")
2429 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2430 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2431 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2437 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2438 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2439 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2445 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2446 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2447 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2451 """import FWCore.ParameterSet.Config as cms 2453 process = cms.Process("test") 2455 process.maxEvents = cms.untracked.PSet( 2456 input = cms.optional.untracked.int32, 2457 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 2460 process.maxLuminosityBlocks = cms.untracked.PSet( 2461 input = cms.untracked.int32(-1) 2464 process.options = cms.untracked.PSet( 2465 IgnoreCompletely = cms.untracked.vstring(), 2466 Rethrow = cms.untracked.vstring(), 2467 TryToContinue = cms.untracked.vstring(), 2468 accelerators = cms.untracked.vstring('*'), 2469 allowUnscheduled = cms.obsolete.untracked.bool, 2470 canDeleteEarly = cms.untracked.vstring(), 2471 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 2472 dumpOptions = cms.untracked.bool(False), 2473 emptyRunLumiMode = cms.obsolete.untracked.string, 2474 eventSetup = cms.untracked.PSet( 2475 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 2476 allowAnyLabel_=cms.required.untracked.uint32 2478 numberOfConcurrentIOVs = cms.untracked.uint32(0) 2480 fileMode = cms.untracked.string('FULLMERGE'), 2481 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 2482 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 2483 makeTriggerResults = cms.obsolete.untracked.bool, 2484 modulesToCallForTryToContinue = cms.untracked.vstring(), 2485 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 2486 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 2487 numberOfConcurrentRuns = cms.untracked.uint32(1), 2488 numberOfStreams = cms.untracked.uint32(0), 2489 numberOfThreads = cms.untracked.uint32(1), 2490 printDependencies = cms.untracked.bool(False), 2491 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 2492 throwIfIllegalParameter = cms.untracked.bool(True), 2493 wantSummary = cms.untracked.bool(False) 2496 process.MessageLogger = cms.Service("MessageLogger", 2497 cerr = cms.untracked.PSet( 2498 FwkReport = cms.untracked.PSet( 2499 limit = cms.untracked.int32(10000000), 2500 reportEvery = cms.untracked.int32(1) 2502 FwkSummary = cms.untracked.PSet( 2503 limit = cms.untracked.int32(10000000), 2504 reportEvery = cms.untracked.int32(1) 2506 INFO = cms.untracked.PSet( 2507 limit = cms.untracked.int32(0) 2509 Root_NoDictionary = cms.untracked.PSet( 2510 limit = cms.untracked.int32(0) 2512 default = cms.untracked.PSet( 2513 limit = cms.untracked.int32(10000000) 2515 enable = cms.untracked.bool(True), 2516 enableStatistics = cms.untracked.bool(False), 2517 lineLength = cms.optional.untracked.int32, 2518 noLineBreaks = cms.optional.untracked.bool, 2519 noTimeStamps = cms.untracked.bool(False), 2520 resetStatistics = cms.untracked.bool(False), 2521 statisticsThreshold = cms.untracked.string('WARNING'), 2522 threshold = cms.untracked.string('INFO'), 2523 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2524 limit = cms.optional.untracked.int32, 2525 reportEvery = cms.untracked.int32(1), 2526 timespan = cms.optional.untracked.int32 2529 cout = cms.untracked.PSet( 2530 enable = cms.untracked.bool(False), 2531 enableStatistics = cms.untracked.bool(False), 2532 lineLength = cms.optional.untracked.int32, 2533 noLineBreaks = cms.optional.untracked.bool, 2534 noTimeStamps = cms.optional.untracked.bool, 2535 resetStatistics = cms.untracked.bool(False), 2536 statisticsThreshold = cms.optional.untracked.string, 2537 threshold = cms.optional.untracked.string, 2538 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2539 limit = cms.optional.untracked.int32, 2540 reportEvery = cms.untracked.int32(1), 2541 timespan = cms.optional.untracked.int32 2544 debugModules = cms.untracked.vstring(), 2545 default = cms.untracked.PSet( 2546 limit = cms.optional.untracked.int32, 2547 lineLength = cms.untracked.int32(80), 2548 noLineBreaks = cms.untracked.bool(False), 2549 noTimeStamps = cms.untracked.bool(False), 2550 reportEvery = cms.untracked.int32(1), 2551 statisticsThreshold = cms.untracked.string('INFO'), 2552 threshold = cms.untracked.string('INFO'), 2553 timespan = cms.optional.untracked.int32, 2554 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2555 limit = cms.optional.untracked.int32, 2556 reportEvery = cms.untracked.int32(1), 2557 timespan = cms.optional.untracked.int32 2560 files = cms.untracked.PSet( 2561 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2562 enableStatistics = cms.untracked.bool(False), 2563 extension = cms.optional.untracked.string, 2564 filename = cms.optional.untracked.string, 2565 lineLength = cms.optional.untracked.int32, 2566 noLineBreaks = cms.optional.untracked.bool, 2567 noTimeStamps = cms.optional.untracked.bool, 2568 output = cms.optional.untracked.string, 2569 resetStatistics = cms.untracked.bool(False), 2570 statisticsThreshold = cms.optional.untracked.string, 2571 threshold = cms.optional.untracked.string, 2572 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2573 limit = cms.optional.untracked.int32, 2574 reportEvery = cms.untracked.int32(1), 2575 timespan = cms.optional.untracked.int32 2579 suppressDebug = cms.untracked.vstring(), 2580 suppressFwkInfo = cms.untracked.vstring(), 2581 suppressInfo = cms.untracked.vstring(), 2582 suppressWarning = cms.untracked.vstring(), 2583 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2584 limit = cms.optional.untracked.int32, 2585 reportEvery = cms.untracked.int32(1), 2586 timespan = cms.optional.untracked.int32 2601 """process.a = cms.EDAnalyzer("MyAnalyzer") 2602 process.s = cms.Sequence(process.a) 2603 process.r = cms.Sequence(process.s) 2604 process.p = cms.Path(process.a) 2605 process.p2 = cms.Path(process.s) 2606 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2618 """process.a = cms.EDAnalyzer("MyAnalyzer") 2619 process.b = cms.EDAnalyzer("YourAnalyzer") 2620 process.r = cms.Sequence(process.a) 2621 process.s = cms.Sequence(process.r) 2622 process.p = cms.Path(process.a) 2623 process.p2 = cms.Path(process.r) 2624 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2635 """process.a = cms.EDAnalyzer("MyAnalyzer") 2636 process.r = cms.Sequence((process.a)) 2637 process.p = cms.Path(process.a) 2638 process.p2 = cms.Path(process.r) 2639 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2655 p.task3.add(p.task1)
2659 p.p2 =
Path(p.r, p.task1, p.task2)
2660 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2663 """process.b = cms.EDProducer("bProducer") 2664 process.c = cms.EDProducer("cProducer") 2665 process.d = cms.EDProducer("dProducer") 2666 process.e = cms.EDProducer("eProducer") 2667 process.f = cms.EDProducer("fProducer") 2668 process.g = cms.EDProducer("gProducer") 2669 process.a = cms.EDAnalyzer("MyAnalyzer") 2670 process.task5 = cms.Task() 2671 process.task1 = cms.Task(process.task5) 2672 process.task3 = cms.Task(process.task1) 2673 process.task2 = cms.Task(process.c, process.task3) 2674 process.task4 = cms.Task(process.f, process.task2) 2675 process.r = cms.Sequence((process.a)) 2676 process.p = cms.Path(process.a) 2677 process.p2 = cms.Path(process.r, process.task1, process.task2) 2678 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2695 p.p2 =
Path(p.r, p.task1, p.task2)
2696 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task5])
2699 """process.b = cms.EDProducer("bProducer") 2700 process.c = cms.EDProducer("cProducer") 2701 process.d = cms.EDProducer("dProducer") 2702 process.e = cms.EDProducer("eProducer") 2703 process.f = cms.EDProducer("fProducer") 2704 process.g = cms.EDProducer("gProducer") 2705 process.a = cms.EDAnalyzer("MyAnalyzer") 2706 process.task5 = cms.Task() 2707 process.task3 = cms.Task() 2708 process.task2 = cms.ConditionalTask(process.c, process.task3) 2709 process.task1 = cms.ConditionalTask(process.task5) 2710 process.r = cms.Sequence((process.a)) 2711 process.p = cms.Path(process.a) 2712 process.p2 = cms.Path(process.r, process.task1, process.task2) 2713 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task5])""")
2720 p.task1 =
Task(p.d, p.e)
2721 task2 =
Task(p.f, p.g)
2722 p.schedule =
Schedule(tasks=[p.task1,task2])
2725 """process.d = cms.EDProducer("dProducer") 2726 process.e = cms.EDProducer("eProducer") 2727 process.f = cms.EDProducer("fProducer") 2728 process.g = cms.EDProducer("gProducer") 2729 process.task1 = cms.Task(process.d, process.e) 2730 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2736 """process.schedule = cms.Schedule()""")
2745 d=process.dumpPython()
2747 """process.a = cms.EDProducer("A") 2748 process.s2 = cms.Sequence(process.a)""")
2758 d=process.dumpPython()
2760 """process.a = cms.EDProducer("A") 2761 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2787 p.p =
Path(p.c+s+p.a)
2788 p.p2 =
Path(p.c+p.s4+p.a, p.ct1)
2794 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2796 p.globalReplace(
"a",new)
2797 p.globalReplace(
"d",new2)
2800 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2801 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2803 p.p2.visit(visitor_p2)
2804 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2805 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a, process.ct1)")
2807 p.e3.visit(visitor3)
2808 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2810 p.s4.visit(visitor4)
2811 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2812 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d), process.ct1)")
2814 p.t1.visit(visitor5)
2815 self.assertTrue(visitor5.modules == set([new2]))
2817 listOfTasks = list(p.schedule._tasks)
2818 listOfTasks[0].visit(visitor6)
2819 self.assertTrue(visitor6.modules == set([new2]))
2821 p.ct1.visit(visitor7)
2822 self.assertTrue(visitor7.modules == set([new2]))
2824 listOfConditionalTasks = list(p.conditionaltasks.values())
2825 listOfConditionalTasks[0].visit(visitor8)
2826 self.assertTrue(visitor8.modules == set([new2]))
2830 p.schedule =
Schedule(p.p, p.p2, p.e3, tasks=[p.t1])
2831 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2833 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2835 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2837 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2845 self.assertEqual(
str(p.s),
'a+b')
2846 self.assertEqual(p.s.label_(),
's')
2847 path =
Path(p.c+p.s)
2848 self.assertEqual(
str(path),
'c+a+b')
2849 p._validateSequence(path,
'p1')
2851 p2 =
Path(p.c+p.s*notInProcess)
2852 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2862 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2866 self.assertFalse(service._inProcess)
2869 self.assertTrue(service._inProcess)
2871 process.d = service2
2872 self.assertFalse(service._inProcess)
2873 self.assertTrue(service2._inProcess)
2875 self.assertFalse(service2._inProcess)
2889 service3 =
Service(
"d", v = untracked.uint32(3))
2895 testTask1 =
Task(edproducer, edfilter)
2896 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2897 testTask1.add(essource, service)
2898 testTask1.add(essource, esproducer)
2899 testTask1.add(testTask2)
2900 coll = testTask1._collection
2901 self.assertTrue(edproducer
in coll)
2902 self.assertTrue(edfilter
in coll)
2903 self.assertTrue(service
in coll)
2904 self.assertTrue(essource
in coll)
2905 self.assertTrue(esproducer
in coll)
2906 self.assertTrue(testTask2
in coll)
2907 self.assertTrue(len(coll) == 6)
2908 self.assertTrue(len(testTask2._collection) == 0)
2912 taskContents.append(i)
2913 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2918 process.mproducer = edproducer
2919 process.mproducer2 = edproducer2
2920 process.mfilter = edfilter
2921 process.messource = essource
2922 process.mesproducer = esproducer
2925 testTask3 =
Task(edproducer, edproducer2)
2926 testTask1.add(testTask3)
2927 process.myTask1 = testTask1
2934 testTask1.visit(visitor)
2935 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2936 l2 = testTask1.moduleNames
2937 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2939 testTask4 =
Task(edproducer3)
2941 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2943 process.myTask4 = testTask4
2944 self.assertTrue(
False)
2945 except RuntimeError:
2948 testTask5 =
Task(service3)
2950 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2952 process.myTask5 = testTask5
2953 self.assertTrue(
False)
2954 except RuntimeError:
2957 process.d = service3
2958 process.myTask5 = testTask5
2961 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2963 self.assertTrue(process.tasks == expectedFixedDict)
2964 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2965 self.assertTrue(process.myTask1 == testTask1)
2969 process.mproducer2 = edproducer4
2973 testTask1.visit(visitor1)
2974 l.sort(key=
lambda mod: mod.__str__())
2975 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2976 self.assertTrue(expectedList == l)
2977 process.myTask6 =
Task()
2978 process.myTask7 =
Task()
2979 process.mproducer8 = edproducer8
2980 process.myTask8 =
Task(process.mproducer8)
2981 process.myTask6.add(process.myTask7)
2982 process.myTask7.add(process.myTask8)
2983 process.myTask1.add(process.myTask6)
2984 process.myTask8.add(process.myTask5)
2986 testDict = process._itemsInDependencyOrder(process.tasks)
2987 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2988 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2990 for testLabel, testTask
in testDict.items():
2991 self.assertTrue(testLabel == expectedLabels[index])
2992 self.assertTrue(testTask == expectedTasks[index])
2998 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2999 self.assertTrue(pythonDump == expectedPythonDump)
3001 process.myTask5 =
Task()
3002 process.myTask100 =
Task()
3003 process.mproducer9 = edproducer9
3004 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3005 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3006 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3008 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3009 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3010 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3011 process.path2 =
Path(process.mproducer)
3012 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3014 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')
3016 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')
3021 process.path1.visit(nameVisitor)
3022 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3023 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3027 process.path21 = process.path11.copy()
3028 process.path21.replace(process.mproducer, process.mproducer10)
3030 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')
3039 self.assertTrue(process.path21.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
3041 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3042 self.assertTrue(process.path22.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
3044 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3045 self.assertTrue(process.path23.dumpPython(
PrintOptions()) ==
'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
3054 process.path24 =
Path(process.a+process.b+process.c+process.d)
3055 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
3056 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
3061 process.path200.replace(process.c,process.b)
3062 process.path200.replace(process.e,process.f)
3063 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
3064 process.path200.replace(process.b,process.c)
3065 process.path200.replace(process.f,process.e)
3066 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3067 process.path200.replace(process.c,process.a)
3068 process.path200.replace(process.e,process.g)
3069 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
3070 process.path200.replace(process.a,process.c)
3071 process.path200.replace(process.g,process.e)
3072 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3086 service3 =
Service(
"d", v = untracked.uint32(3))
3094 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
3095 testTask1.add(essource, service)
3096 testTask1.add(essource, esproducer)
3097 testTask1.add(testTask2)
3098 testTask1.add(testCTask2)
3099 coll = testTask1._collection
3100 self.assertTrue(edproducer
in coll)
3101 self.assertTrue(edfilter
in coll)
3102 self.assertTrue(service
in coll)
3103 self.assertTrue(essource
in coll)
3104 self.assertTrue(esproducer
in coll)
3105 self.assertTrue(testTask2
in coll)
3106 self.assertTrue(testCTask2
in coll)
3107 self.assertTrue(len(coll) == 7)
3108 self.assertTrue(len(testTask2._collection) == 0)
3112 taskContents.append(i)
3113 self.assertEqual(taskContents, [edproducer, edfilter, essource, service, esproducer, testTask2, testCTask2])
3118 process.mproducer = edproducer
3119 process.mproducer2 = edproducer2
3120 process.mfilter = edfilter
3121 process.messource = essource
3122 process.mesproducer = esproducer
3126 testTask1.add(testTask3)
3127 process.myTask1 = testTask1
3134 testTask1.visit(visitor)
3135 self.assertEqual(l, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3136 l2 = testTask1.moduleNames()
3137 self.assertEqual(l2, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3141 self.assertRaises(RuntimeError, testTask4.visit, visitor)
3143 process.myTask4 = testTask4
3144 self.assertTrue(
False)
3145 except RuntimeError:
3150 self.assertRaises(RuntimeError, testTask5.visit, visitor)
3152 process.myTask5 = testTask5
3153 self.assertTrue(
False)
3154 except RuntimeError:
3157 process.d = service3
3158 process.myTask5 = testTask5
3161 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
3163 self.assertEqual(process.conditionaltasks, expectedFixedDict)
3164 self.assertEqual(process.conditionaltasks[
'myTask1'], testTask1)
3165 self.assertEqual(process.myTask1, testTask1)
3169 process.mproducer2 = edproducer4
3173 testTask1.visit(visitor1)
3174 l.sort(key=
lambda mod: mod.__str__())
3175 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
3176 self.assertEqual(expectedList, l)
3179 process.mproducer8 = edproducer8
3181 process.myTask6.add(process.myTask7)
3182 process.myTask7.add(process.myTask8)
3183 process.myTask1.add(process.myTask6)
3184 process.myTask8.add(process.myTask5)
3185 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3187 testDict = process._itemsInDependencyOrder(process.conditionaltasks)
3188 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
3189 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
3191 for testLabel, testTask
in testDict.items():
3192 self.assertEqual(testLabel, expectedLabels[index])
3193 self.assertEqual(testTask, expectedTasks[index])
3199 expectedPythonDump =
'cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 3200 self.assertEqual(pythonDump, expectedPythonDump)
3203 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3205 process.mproducer9 = edproducer9
3206 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3207 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3208 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3210 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3211 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3212 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3213 process.path2 =
Path(process.mproducer)
3214 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3216 self.assertEqual(process.path1.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)\n')
3218 self.assertEqual(process.path11.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3223 process.path1.visit(nameVisitor)
3224 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3225 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3229 process.path21 = process.path11.copy()
3230 process.path21.replace(process.mproducer, process.mproducer10)
3232 self.assertEqual(process.path11.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3241 self.assertEqual(process.path21.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3243 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3244 self.assertEqual(process.path22.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3246 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3247 self.assertEqual(process.path23.dumpPython(
PrintOptions()),
'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None), cms.ConditionalTask(process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3256 process.fillProcessDesc(p)
3257 self.assertEqual(p.values[
"@all_modules"], (
True, [
'b',
'b2',
'b3']))
3258 self.assertEqual(p.values[
"@paths"], (
True, [
'p']))
3259 self.assertEqual(p.values[
"p"], (
True, [
'b',
'#',
'b2',
'b3',
'@']))
3270 self.assertEqual(
str(path),
'a+b+c')
3271 path =
Path(p.a*p.b+p.c)
3272 self.assertEqual(
str(path),
'a+b+c')
3275 path =
Path(p.a+ p.b*p.c)
3276 self.assertEqual(
str(path),
'a+b+c')
3277 path =
Path(p.a*(p.b+p.c))
3278 self.assertEqual(
str(path),
'a+b+c')
3279 path =
Path(p.a*(p.b+~p.c))
3281 self.assertEqual(
str(path),
'a+b+~c')
3283 self.assertRaises(TypeError,Path,p.es)
3286 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path()\n')
3289 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a)\n')
3292 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.Task())\n')
3295 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task())\n')
3300 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3303 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.ConditionalTask())\n')
3306 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.ConditionalTask())\n')
3311 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3321 self.assertEqual(
str(path),
'a+b+c')
3323 self.assertEqual(
str(path),
'a+b+c')
3325 self.assertEqual(
str(path),
'a+b+c')
3327 self.assertEqual(
str(path),
'a+b+c')
3329 self.assertRaises(TypeError,FinalPath,p.es)
3332 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath()\n')
3335 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3337 self.assertRaises(TypeError, FinalPath,
Task())
3338 self.assertRaises(TypeError, FinalPath, p.a,
Task())
3342 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
Task(), p.t1)
3346 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
ConditionalTask(), p.t1)
3350 self.assertEqual(p.t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3361 p.path =
Path(p.a*p.b)
3362 lookuptable = {
id(a): p.a,
id(b): p.b}
3366 self.assertEqual(
str(path),
str(p.path))
3388 path =
Path(a * c * seq1, task1, ctask1)
3390 self.assertTrue(path.contains(a))
3391 self.assertFalse(path.contains(b))
3392 self.assertTrue(path.contains(c))
3393 self.assertFalse(path.contains(d))
3394 self.assertTrue(path.contains(e))
3395 self.assertFalse(path.contains(f))
3396 self.assertTrue(path.contains(g))
3397 self.assertTrue(path.contains(h))
3400 self.assertFalse(endpath.contains(b))
3401 self.assertTrue(endpath.contains(i))
3404 self.assertFalse(seq.contains(b))
3405 self.assertTrue(seq.contains(c))
3408 task =
Task(j, k, task2)
3409 self.assertFalse(task.contains(b))
3410 self.assertTrue(task.contains(j))
3411 self.assertTrue(task.contains(k))
3412 self.assertTrue(task.contains(l))
3416 sch =
Schedule(path, path2, tasks=[task,task3])
3417 self.assertFalse(sch.contains(b))
3418 self.assertTrue(sch.contains(a))
3419 self.assertTrue(sch.contains(c))
3420 self.assertTrue(sch.contains(e))
3421 self.assertTrue(sch.contains(g))
3422 self.assertTrue(sch.contains(n))
3423 self.assertTrue(sch.contains(j))
3424 self.assertTrue(sch.contains(k))
3425 self.assertTrue(sch.contains(l))
3426 self.assertTrue(sch.contains(m))
3430 self.assertFalse(ctask.contains(b))
3431 self.assertTrue(ctask.contains(j))
3432 self.assertTrue(ctask.contains(k))
3433 self.assertTrue(ctask.contains(l))
3434 self.assertTrue(ctask.contains(g))
3447 self.assertEqual(s[0],p.path1)
3448 self.assertEqual(s[1],p.path2)
3450 self.assertTrue(
'b' in p.schedule.moduleNames())
3451 self.assertTrue(hasattr(p,
'b'))
3452 self.assertTrue(hasattr(p,
'c'))
3453 self.assertTrue(hasattr(p,
'd'))
3454 self.assertTrue(hasattr(p,
'path1'))
3455 self.assertTrue(hasattr(p,
'path2'))
3456 self.assertTrue(hasattr(p,
'path3'))
3458 self.assertTrue(
'b' in p.schedule.moduleNames())
3459 self.assertTrue(hasattr(p,
'b'))
3460 self.assertTrue(
not hasattr(p,
'c'))
3461 self.assertTrue(
not hasattr(p,
'd'))
3462 self.assertTrue(hasattr(p,
'path1'))
3463 self.assertTrue(hasattr(p,
'path2'))
3464 self.assertTrue(
not hasattr(p,
'path3'))
3466 self.assertTrue(len(p.schedule._tasks) == 0)
3480 p.task2 =
Task(p.f, p.Tracer)
3481 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
3482 self.assertEqual(s[0],p.path1)
3483 self.assertEqual(s[1],p.path2)
3484 self.assertTrue(len(s._tasks) == 2)
3485 self.assertTrue(p.task1
in s._tasks)
3486 self.assertTrue(p.task2
in s._tasks)
3487 listOfTasks = list(s._tasks)
3488 self.assertTrue(len(listOfTasks) == 2)
3489 self.assertTrue(p.task1 == listOfTasks[0])
3490 self.assertTrue(p.task2 == listOfTasks[1])
3492 self.assertTrue(
'b' in p.schedule.moduleNames())
3497 process2.path1 =
Path(process2.a)
3498 process2.task1 =
Task(process2.e)
3499 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
3500 listOfTasks = list(process2.schedule._tasks)
3501 self.assertTrue(listOfTasks[0] == process2.task1)
3505 self.assertEqual(s2[0],p.path1)
3506 self.assertEqual(s2[1],p.path2)
3507 self.assertTrue(len(s2._tasks) == 2)
3508 self.assertTrue(p.task1
in s2._tasks)
3509 self.assertTrue(p.task2
in s2._tasks)
3510 listOfTasks = list(s2._tasks)
3511 self.assertTrue(len(listOfTasks) == 2)
3512 self.assertTrue(p.task1 == listOfTasks[0])
3513 self.assertTrue(p.task2 == listOfTasks[1])
3515 names = s.moduleNames()
3516 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
3522 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
3531 self.assertTrue(
'a' in s.moduleNames())
3532 self.assertTrue(
'b' in s.moduleNames())
3533 self.assertTrue(
'c' in s.moduleNames())
3537 self.assertTrue(
'a' in s.moduleNames())
3538 self.assertTrue(
'b' in s.moduleNames())
3539 self.assertTrue(
'c' in s.moduleNames())
3548 self.assertTrue(p.schedule
is None)
3551 self.assertEqual(pths[keys[0]],p.path1)
3552 self.assertEqual(pths[keys[1]],p.path2)
3554 self.assertTrue(hasattr(p,
'a'))
3555 self.assertTrue(hasattr(p,
'b'))
3556 self.assertTrue(
not hasattr(p,
'c'))
3557 self.assertTrue(hasattr(p,
'path1'))
3558 self.assertTrue(hasattr(p,
'path2'))
3567 self.assertTrue(p.schedule
is None)
3570 self.assertEqual(pths[keys[1]],p.path1)
3571 self.assertEqual(pths[keys[0]],p.path2)
3578 self.assertEqual(p.modu.a.value(),1)
3579 self.assertEqual(p.modu.b.value(),2)
3584 self.assertTrue(
not a.isModified())
3586 self.assertTrue(a.isModified())
3588 self.assertEqual(p.a.a1.value(), 1)
3592 self.assertEqual(p.a.a1.value(), 2)
3601 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
3602 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
3606 self.assertEqual(p.options.numberOfThreads.value(),1)
3607 p.options.numberOfThreads = 8
3608 self.assertEqual(p.options.numberOfThreads.value(),8)
3610 self.assertEqual(p.options.numberOfThreads.value(),1)
3611 p.options = dict(numberOfStreams =2,
3613 self.assertEqual(p.options.numberOfThreads.value(),2)
3614 self.assertEqual(p.options.numberOfStreams.value(),2)
3616 self.assertRaises(TypeError, setattr, p,
'options', untracked.PSet(numberOfThreads =
int32(-1)))
3617 p.options = untracked.PSet(numberOfThreads = untracked.uint32(4))
3618 self.assertEqual(p.options.numberOfThreads.value(), 4)
3622 p.maxEvents.input = 10
3623 self.assertEqual(p.maxEvents.input.value(),10)
3625 p.maxEvents.output = 10
3626 self.assertEqual(p.maxEvents.output.value(),10)
3628 p.maxEvents.output =
PSet(out=untracked.int32(10))
3629 self.assertEqual(p.maxEvents.output.out.value(), 10)
3631 p.maxEvents = untracked.PSet(input = untracked.int32(5))
3632 self.assertEqual(p.maxEvents.input.value(), 5)
3634 self.assertRaises(TypeError, setattr, p,
'maxEvents', untracked.PSet(input = untracked.uint32(1)))
3635 p.maxEvents = untracked.PSet(input = untracked.int32(1))
3636 self.assertEqual(p.maxEvents.input.value(), 1)
3644 p.bars.foos =
'Foosball' 3645 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
3646 p.p =
Path(p.foos*p.bars)
3648 p.add_(
Service(
"MessageLogger"))
3654 p.prefer(
"ForceSource")
3657 """process.juicer = cms.ESProducer("JuicerProducer") 3658 process.ForceSource = cms.ESSource("ForceSource") 3659 process.prefer("ForceSource") 3660 process.prefer("juicer")""")
3661 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
3663 """process.juicer = cms.ESProducer("JuicerProducer") 3664 process.ForceSource = cms.ESSource("ForceSource") 3665 process.prefer("ForceSource") 3666 process.prefer("juicer", 3667 fooRcd = cms.vstring('Foo') 3682 self.assertEqual(process.m.p.i.value(), 4)
3692 subProcess.p =
Path(subProcess.a)
3693 subProcess.add_(
Service(
"Foo"))
3694 process.addSubProcess(
SubProcess(subProcess))
3695 d = process.dumpPython()
3696 equalD =
"""parentProcess = process 3697 process.a = cms.EDProducer("A") 3698 process.Foo = cms.Service("Foo") 3699 process.p = cms.Path(process.a) 3700 childProcess = process 3701 process = parentProcess 3702 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 3703 ), outputCommands = cms.untracked.vstring()))""" 3704 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
3712 messageLoggerSplit =
'process.MessageLogger = cms.Service' 3714 childProcess =
Process(
'Child')
3715 del childProcess.MessageLogger
3716 combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
3717 self.assertEqual(
_lineDiff(d, combinedDump), equalD)
3719 process.fillProcessDesc(p)
3720 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
3721 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
3722 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
3732 proc.fillProcessDesc(p)
3733 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
3734 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
3735 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
3736 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
3737 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
3738 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
3747 self.assertEqual(proc.sp.label_(),
"sp")
3748 self.assertEqual(proc.sp.test1.label_(),
"sp@test1")
3749 self.assertEqual(proc.sp.test2.label_(),
"sp@test2")
3752 proc.s =
Sequence(proc.a + proc.sp)
3753 proc.t =
Task(proc.a, proc.sp)
3755 proc.p.associate(proc.t)
3757 proc.fillProcessDesc(p)
3758 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3759 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3760 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3761 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3763 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3764 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3765 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
3766 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3767 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
3768 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3769 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3770 dump = proc.dumpPython()
3771 self.assertEqual(dump.find(
'@'), -1)
3772 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
3773 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
3782 proc.s =
Sequence(proc.a + proc.sp)
3783 proc.t =
Task(proc.a, proc.sp)
3785 proc.p.associate(proc.t)
3787 proc.fillProcessDesc(p)
3788 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3789 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3790 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3791 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3793 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3794 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3795 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
3796 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
3797 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3798 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3799 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3800 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
3809 proc.s =
Sequence(proc.a + proc.sp)
3810 proc.t =
Task(proc.a, proc.sp)
3812 proc.p.associate(proc.t)
3814 proc.fillProcessDesc(p)
3815 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3816 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3817 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3818 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
3819 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3820 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
3821 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
3822 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3823 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
3824 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3825 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
3836 proc.spp = proc.spct.clone()
3839 proc.p =
Path(proc.a, proc.ct)
3840 proc.pp =
Path(proc.a + proc.spp)
3842 proc.fillProcessDesc(p)
3843 self.assertEqual([
"a",
"spct",
"spct@test1",
"spct@test2",
"spp",
"spp@test1",
"spp@test2"], p.values[
"@all_modules"][1])
3844 self.assertEqual([
"a",
"#",
"spct",
"spct@test1",
"spct@test2",
"@"], p.values[
"p"][1])
3845 self.assertEqual([
"a",
"spp",
"#",
"spp@test1",
"spp@test2",
"@"], p.values[
"pp"][1])
3860 p.t3 =
Task(p.g, p.t1)
3864 p.path1 =
Path(p.a, p.t3, p.ct3)
3866 self.assertTrue(p.schedule
is None)
3869 self.assertEqual(pths[keys[0]],p.path1)
3870 self.assertEqual(pths[keys[1]],p.path2)
3872 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
3874 p.vpset2 = untracked.VPSet()
3876 self.assertTrue(hasattr(p,
'a'))
3877 self.assertTrue(hasattr(p,
'b'))
3878 self.assertTrue(
not hasattr(p,
'c'))
3879 self.assertTrue(
not hasattr(p,
'd'))
3880 self.assertTrue(hasattr(p,
'e'))
3881 self.assertTrue(
not hasattr(p,
'f'))
3882 self.assertTrue(hasattr(p,
'g'))
3883 self.assertTrue(hasattr(p,
'h'))
3884 self.assertTrue(
not hasattr(p,
's'))
3885 self.assertTrue(hasattr(p,
't1'))
3886 self.assertTrue(
not hasattr(p,
't2'))
3887 self.assertTrue(hasattr(p,
't3'))
3888 self.assertTrue(hasattr(p,
'path1'))
3889 self.assertTrue(hasattr(p,
'path2'))
3919 p.path1 =
Path(p.a, p.t3, p.ct3)
3921 p.path3 =
Path(p.b+p.s2)
3922 p.path4 =
Path(p.b+p.s3)
3923 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3924 p.schedule.associate(p.t4)
3927 self.assertEqual(pths[keys[0]],p.path1)
3928 self.assertEqual(pths[keys[1]],p.path2)
3930 self.assertTrue(hasattr(p,
'a'))
3931 self.assertTrue(hasattr(p,
'b'))
3932 self.assertTrue(
not hasattr(p,
'c'))
3933 self.assertTrue(
not hasattr(p,
'd'))
3934 self.assertTrue(
not hasattr(p,
'e'))
3935 self.assertTrue(
not hasattr(p,
'f'))
3936 self.assertTrue(hasattr(p,
'g'))
3937 self.assertTrue(hasattr(p,
'h'))
3938 self.assertTrue(hasattr(p,
'i'))
3939 self.assertTrue(hasattr(p,
'j'))
3940 self.assertTrue(hasattr(p,
'k'))
3941 self.assertTrue(
not hasattr(p,
'l'))
3942 self.assertTrue(
not hasattr(p,
't1'))
3943 self.assertTrue(hasattr(p,
't2'))
3944 self.assertTrue(hasattr(p,
't3'))
3945 self.assertTrue(hasattr(p,
't4'))
3946 self.assertTrue(
not hasattr(p,
'ct1'))
3947 self.assertTrue(hasattr(p,
'ct2'))
3948 self.assertTrue(hasattr(p,
'ct3'))
3949 self.assertTrue(
not hasattr(p,
'ct4'))
3950 self.assertTrue(
not hasattr(p,
's'))
3951 self.assertTrue(hasattr(p,
's2'))
3952 self.assertTrue(
not hasattr(p,
's3'))
3953 self.assertTrue(hasattr(p,
'path1'))
3954 self.assertTrue(hasattr(p,
'path2'))
3955 self.assertTrue(hasattr(p,
'path3'))
3956 self.assertTrue(
not hasattr(p,
'path4'))
3964 self.assertTrue(hasattr(p,
'a'))
3965 self.assertTrue(hasattr(p,
'b'))
3966 self.assertTrue(hasattr(p,
's'))
3967 self.assertTrue(hasattr(p,
'pth'))
3973 p.prune(keepUnresolvedSequencePlaceholders=
True)
3974 self.assertTrue(hasattr(p,
'b'))
3975 self.assertTrue(hasattr(p,
's'))
3976 self.assertTrue(hasattr(p,
'pth'))
3977 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3985 self.assertTrue(hasattr(p,
'a'))
3986 self.assertTrue(hasattr(p,
'b'))
3987 self.assertTrue(hasattr(p,
's'))
3988 self.assertTrue(hasattr(p,
'pth'))
3996 self.assertTrue(hasattr(p,
'a'))
3997 self.assertTrue(hasattr(p,
'b'))
3998 self.assertTrue(hasattr(p,
's'))
3999 self.assertTrue(hasattr(p,
'pth'))
4005 p.prune(keepUnresolvedSequencePlaceholders=
True)
4006 self.assertTrue(hasattr(p,
'b'))
4007 self.assertTrue(hasattr(p,
's'))
4008 self.assertTrue(hasattr(p,
'pth'))
4009 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
4017 p.path1 =
Path(p.b, p.t2, p.t3)
4020 p.endpath1 =
EndPath(p.b, p.t5)
4024 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
4034 """process.a = cms.EDProducer("ma") 4035 process.c = cms.EDProducer("mc") 4036 process.d = cms.EDProducer("md") 4037 process.e = cms.EDProducer("me") 4038 process.f = cms.EDProducer("mf") 4039 process.g = cms.EDProducer("mg") 4040 process.h = cms.EDProducer("mh") 4041 process.i = cms.EDProducer("mi") 4042 process.j = cms.EDProducer("mj") 4043 process.b = cms.EDAnalyzer("mb") 4044 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 4045 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 4046 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 4047 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 4048 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 4049 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 4050 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 4051 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 4052 process.path1 = cms.Path(process.b, process.t2, process.t3) 4053 process.endpath1 = cms.EndPath(process.b, process.t5) 4054 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4057 """process.a = cms.EDProducer("ma") 4058 process.c = cms.EDProducer("mc") 4059 process.d = cms.EDProducer("md") 4060 process.e = cms.EDProducer("me") 4061 process.f = cms.EDProducer("mf") 4062 process.g = cms.EDProducer("mg") 4063 process.h = cms.EDProducer("mh") 4064 process.i = cms.EDProducer("mi") 4065 process.j = cms.EDProducer("mj") 4066 process.b = cms.EDAnalyzer("mb") 4067 process.t1 = cms.Task(process.c) 4068 process.t2 = cms.Task(process.a, process.d, process.t1) 4069 process.t3 = cms.Task(process.e) 4070 process.t4 = cms.Task(process.f) 4071 process.t6 = cms.Task(process.h) 4072 process.t7 = cms.Task(process.a, process.i, process.t6) 4073 process.t8 = cms.Task(process.j) 4074 process.t5 = cms.Task(process.a, process.g, process.t4) 4075 process.path1 = cms.Path(process.b, process.t2, process.t3) 4076 process.endpath1 = cms.EndPath(process.b, process.t5) 4077 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4085 p.path1 =
Path(p.b, p.t2, p.t3)
4088 p.path2 =
Path(p.b, p.t5)
4089 p.schedule =
Schedule(p.path1, p.path2)
4099 """process.a = cms.EDProducer("ma") 4100 process.c = cms.EDProducer("mc") 4101 process.d = cms.EDProducer("md") 4102 process.e = cms.EDProducer("me") 4103 process.f = cms.EDProducer("mf") 4104 process.g = cms.EDProducer("mg") 4105 process.h = cms.EDProducer("mh") 4106 process.i = cms.EDProducer("mi") 4107 process.j = cms.EDProducer("mj") 4108 process.b = cms.EDAnalyzer("mb") 4109 process.t1 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("c")) 4110 process.t2 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("d"), process.a, process.t1) 4111 process.t3 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("e")) 4112 process.t5 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("g"), cms.ConditionalTaskPlaceholder("t4"), process.a) 4113 process.t4 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("f")) 4114 process.path1 = cms.Path(process.b, process.t2, process.t3) 4115 process.path2 = cms.Path(process.b, process.t5) 4116 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4119 """process.a = cms.EDProducer("ma") 4120 process.c = cms.EDProducer("mc") 4121 process.d = cms.EDProducer("md") 4122 process.e = cms.EDProducer("me") 4123 process.f = cms.EDProducer("mf") 4124 process.g = cms.EDProducer("mg") 4125 process.h = cms.EDProducer("mh") 4126 process.i = cms.EDProducer("mi") 4127 process.j = cms.EDProducer("mj") 4128 process.b = cms.EDAnalyzer("mb") 4129 process.t1 = cms.ConditionalTask(process.c) 4130 process.t2 = cms.ConditionalTask(process.a, process.d, process.t1) 4131 process.t3 = cms.ConditionalTask(process.e) 4132 process.t4 = cms.ConditionalTask(process.f) 4133 process.t5 = cms.ConditionalTask(process.a, process.g, process.t4) 4134 process.path1 = cms.Path(process.b, process.t2, process.t3) 4135 process.path2 = cms.Path(process.b, process.t5) 4136 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4152 p.t1 =
Task(p.g, p.h, p.i)
4153 t2 =
Task(p.g, p.h, p.i)
4161 p.path1 =
Path(p.a+p.f+p.s,t2,ct2)
4163 p.path3 =
Path(ct3, p.ct4)
4166 p.schedule =
Schedule(p.path2, p.path3, p.endpath2, tasks=[t3, p.t4])
4167 self.assertTrue(hasattr(p,
'f'))
4168 self.assertTrue(hasattr(p,
'g'))
4169 self.assertTrue(hasattr(p,
'i'))
4174 self.assertFalse(hasattr(p,
'f'))
4175 self.assertFalse(hasattr(p,
'g'))
4176 self.assertEqual(p.t1.dumpPython(),
'cms.Task(process.h)\n')
4177 self.assertEqual(p.ct1.dumpPython(),
'cms.ConditionalTask(process.h)\n')
4178 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(process.d)\n')
4179 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+process.s, cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4180 self.assertEqual(p.endpath1.dumpPython(),
'cms.EndPath(process.b)\n')
4181 self.assertEqual(p.path3.dumpPython(),
'cms.Path(cms.ConditionalTask(process.h), process.ct4)\n')
4183 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+(process.d), cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4184 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path2, process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4186 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4188 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4190 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h), process.t4])\n')
4192 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
4195 Process._firstProcess =
True 4197 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4199 Process._firstProcess =
True 4204 m1.toModify(p.a,_mod_fred)
4205 self.assertEqual(p.a.fred.value(),2)
4207 m1.toModify(p.b, wilma = 2)
4208 self.assertEqual(p.b.wilma.value(),2)
4209 self.assertTrue(p.isUsingModifier(m1))
4212 Process._firstProcess =
True 4215 m1.toModify(p.a,_mod_fred)
4217 m1.toModify(p.b, wilma = 2)
4218 self.assertEqual(p.a.fred.value(),1)
4219 self.assertEqual(p.b.wilma.value(),1)
4220 self.assertEqual(p.isUsingModifier(m1),
False)
4223 Process._firstProcess =
True 4226 m1.toModify(p.a, fred =
int32(2))
4227 p.b = p.a.clone(wilma =
int32(3))
4228 self.assertEqual(p.a.fred.value(),2)
4229 self.assertEqual(p.a.wilma.value(),1)
4230 self.assertEqual(p.b.fred.value(),2)
4231 self.assertEqual(p.b.wilma.value(),3)
4234 Process._firstProcess =
True 4237 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4238 self.assertEqual(hasattr(p.a,
"fred"),
False)
4239 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4240 self.assertEqual(p.a.wilma.value(),1)
4243 Process._firstProcess =
True 4246 m1.toModify(p.a, wilma =
int32(2))
4247 self.assertEqual(p.a.fred.value(), 1)
4248 self.assertEqual(p.a.wilma.value(),2)
4251 Process._firstProcess =
True 4254 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
4255 self.assertEqual(p.a.flintstones.fred.value(),2)
4256 self.assertEqual(p.a.flintstones.wilma.value(),1)
4259 Process._firstProcess =
True 4262 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4263 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4266 Process._firstProcess =
True 4269 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
4270 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4271 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4274 Process._firstProcess =
True 4277 m1.toModify(p.a, fred = {1:7})
4278 self.assertEqual(p.a.fred[0],1)
4279 self.assertEqual(p.a.fred[1],7)
4280 self.assertEqual(p.a.fred[2],3)
4283 Process._firstProcess =
True 4287 try: m1.toModify(p.a, fred = {5:7})
4288 except IndexError
as e: raised =
True 4289 self.assertEqual(raised,
True)
4292 Process._firstProcess =
True 4296 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
4297 except TypeError
as e: raised =
True 4298 self.assertEqual(raised,
True)
4302 class ProcModifierMod(
object):
4308 testMod = DummyMod()
4310 self.assertTrue(hasattr(p,
"a"))
4312 Process._firstProcess =
True 4314 testProcMod = ProcModifierMod(m1,_rem_a)
4316 p.extend(testProcMod)
4317 self.assertTrue(
not hasattr(p,
"a"))
4321 Process._firstProcess =
True 4323 self.assertTrue(p.isUsingModifier(m1))
4324 self.assertTrue(p.isUsingModifier(mc))
4325 testMod = DummyMod()
4327 m1.toModify(p.b, fred =
int32(3))
4329 testProcMod = ProcModifierMod(m1,_rem_a)
4330 p.extend(testProcMod)
4331 self.assertTrue(
not hasattr(p,
"a"))
4332 self.assertEqual(p.b.fred.value(),3)
4337 mclone = mc.copyAndExclude([m2])
4338 self.assertTrue(
not mclone._isOrContains(m2))
4339 self.assertTrue(mclone._isOrContains(m1))
4342 mclone = mc2.copyAndExclude([m2])
4343 self.assertTrue(
not mclone._isOrContains(m2))
4344 self.assertTrue(mclone._isOrContains(m1))
4345 self.assertTrue(mclone._isOrContains(m3))
4349 Process._firstProcess =
True 4352 (m1 & m2).toModify(p.a, fred =
int32(2))
4353 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4354 self.assertEqual(p.a.fred, 1)
4357 Process._firstProcess =
True 4360 (m1 & m2).toModify(p.a, fred =
int32(2))
4361 self.assertEqual(p.a.fred, 2)
4365 Process._firstProcess =
True 4368 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
4369 self.assertEqual(p.a.fred, 2)
4370 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
4371 self.assertEqual(p.a.fred, 3)
4372 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
4373 self.assertEqual(p.a.fred, 4)
4377 Process._firstProcess =
True 4380 (~m1).toModify(p.a, fred=2)
4381 self.assertEqual(p.a.fred, 1)
4382 (~m2).toModify(p.a, wilma=2)
4383 self.assertEqual(p.a.wilma, 2)
4384 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4385 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4390 Process._firstProcess =
True 4393 (m1 | m2).toModify(p.a, fred=2)
4394 self.assertEqual(p.a.fred, 2)
4395 (m1 | m2 | m3).toModify(p.a, fred=3)
4396 self.assertEqual(p.a.fred, 3)
4397 (m3 | m2 | m1).toModify(p.a, fred=4)
4398 self.assertEqual(p.a.fred, 4)
4399 ((m1 | m2) | m3).toModify(p.a, fred=5)
4400 self.assertEqual(p.a.fred, 5)
4401 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4402 self.assertEqual(p.a.fred, 6)
4403 (m2 | m3).toModify(p.a, fred=7)
4404 self.assertEqual(p.a.fred, 6)
4405 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4406 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4412 Process._firstProcess =
True 4415 (m1 & ~m2).toModify(p.a, fred=2)
4416 self.assertEqual(p.a.fred, 1)
4417 (m1 & ~m3).toModify(p.a, fred=2)
4418 self.assertEqual(p.a.fred, 2)
4419 (m1 | ~m2).toModify(p.a, fred=3)
4420 self.assertEqual(p.a.fred, 3)
4421 (~m1 | ~m2).toModify(p.a, fred=4)
4422 self.assertEqual(p.a.fred, 3)
4423 (~m3 & ~m4).toModify(p.a, fred=4)
4424 self.assertEqual(p.a.fred, 4)
4425 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4426 self.assertEqual(p.a.fred, 5)
4429 Process._firstProcess =
True 4433 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4441 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4442 self.assertEqual(p.a.wilma.value(),3)
4443 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4444 self.assertEqual(hasattr(p,
"fred"),
False)
4445 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4447 m1.toReplaceWith(p.td,
Task(p.e))
4448 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4458 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4459 self.assertEqual(p.a.wilma.value(),3)
4460 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4461 self.assertEqual(hasattr(p,
"fred"),
False)
4462 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4465 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4468 Process._firstProcess =
True 4472 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4478 Process._firstProcess =
True 4481 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4482 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4483 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4484 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4485 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4486 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4487 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
4488 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4489 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4490 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4491 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4492 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4493 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4494 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4495 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
4496 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4497 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
4498 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4503 Process._firstProcess =
True 4507 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4508 self.assertEqual(p.a.fred, 2)
4509 self.assertEqual(p.a.wilma, 1)
4510 self.assertEqual(p.b.barney, 1)
4511 self.assertEqual(p.b.betty, 3)
4512 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4513 self.assertEqual(p.a.fred, 2)
4514 self.assertEqual(p.a.wilma, 4)
4515 self.assertEqual(p.b.barney, 5)
4516 self.assertEqual(p.b.betty, 3)
4517 (m2 & ~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4518 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4519 self.assertEqual(p.b.barney, 6)
4520 self.assertEqual(p.b.betty, 3)
4521 (m1 & ~m3).toModify(p.a, param=
int32(42)).toReplaceWith(p.b,
EDProducer(
"YourProducer"))
4522 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4523 self.assertEqual(p.a.param, 42)
4524 self.assertEqual(p.b.type_(),
"YourProducer")
4531 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4532 self.assertEqual(a.foo2[0].type,
"Foo3")
4535 self.assertEqual(a.foo2[0].type,
"Foo3")
4536 self.assertEqual(a.foo4[0].type,
"Foo4")
4538 m.toModify(a, foo2 =
None)
4539 self.assertFalse(hasattr(a,
"foo2"))
4540 self.assertEqual(a.foo4[0].type,
"Foo4")
4543 self.assertFalse(hasattr(a,
"foo2"))
4544 self.assertFalse(hasattr(a,
"foo4"))
4545 self.assertTrue(hasattr(a,
"bar"))
4546 self.assertEqual(a.bar[0].type,
"Bar")
4559 test1 = dict(a = 4, b = dict(c =
None)),
4560 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4561 self.assertEqual(sp.test1.a.value(), 4)
4562 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4563 self.assertEqual(sp.test2.aa.value(), 15)
4564 self.assertEqual(sp.test2.bb.cc.value(), 45)
4565 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4568 self.assertEqual(sp.test1.type_(),
"Fred")
4569 self.assertEqual(sp.test1.x.value(), 42)
4570 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
4573 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4574 self.assertEqual(sp.test2.x.value(), 24)
4575 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
4578 self.assertEqual(sp.test3.type_(),
"Wilma")
4579 self.assertEqual(sp.test3.y.value(), 24)
4580 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
4582 m.toModify(sp, test2 =
None)
4583 self.assertEqual(hasattr(sp,
"test2"),
False)
4586 self.assertTrue(hasattr(sp.test2,
"foo"))
4589 self.assertTrue(hasattr(sp.test2,
"bar"))
4592 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4594 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
4600 p.maxEvents.input = 10
4601 p.options.numberOfThreads = 4
4602 p.maxLuminosityBlocks.input = 2
4604 self.assertEqual(p.maxEvents.input.value(),10)
4605 self.assertEqual(p.options.numberOfThreads.value(), 4)
4606 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
4612 self.assertTrue(hasattr(p,
'fltr'))
4616 p.TestService =
Service(
"TestService")
4617 self.assertTrue(hasattr(proc,
"TestService"))
4618 self.assertEqual(proc.TestService.type_(),
"TestService")
4619 self.assertRaises(TypeError, setattr, p,
"a",
EDProducer(
"Foo"))
4620 p.add_(
Service(
"TestServiceTwo"))
4621 self.assertTrue(hasattr(proc,
"TestServiceTwo"))
4622 self.assertEqual(proc.TestServiceTwo.type_(),
"TestServiceTwo")
4623 p.TestService.foo = untracked.uint32(42)
4624 self.assertEqual(proc.TestService.foo.value(), 42)
4626 self.assertRaises(TypeError, getattr, p,
"mod")
4630 proc.fillProcessDesc(p)
4631 self.assertTrue([
"cpu"], p.values[
"@available_accelerators"][1])
4632 self.assertFalse(p.values[
"@selected_accelerators"][0])
4633 self.assertTrue([
"cpu"], p.values[
"@selected_accelerators"][1])
4634 self.assertFalse(p.values[
"@module_type_resolver"][0])
4635 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4640 del proc.MessageLogger
4642 self.assertEqual(proc.dumpPython(),
4643 """import FWCore.ParameterSet.Config as cms 4644 from test import ProcessAcceleratorTest 4646 process = cms.Process("TEST") 4648 process.maxEvents = cms.untracked.PSet( 4649 input = cms.optional.untracked.int32, 4650 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 4653 process.maxLuminosityBlocks = cms.untracked.PSet( 4654 input = cms.untracked.int32(-1) 4657 process.options = cms.untracked.PSet( 4658 IgnoreCompletely = cms.untracked.vstring(), 4659 Rethrow = cms.untracked.vstring(), 4660 TryToContinue = cms.untracked.vstring(), 4661 accelerators = cms.untracked.vstring('*'), 4662 allowUnscheduled = cms.obsolete.untracked.bool, 4663 canDeleteEarly = cms.untracked.vstring(), 4664 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 4665 dumpOptions = cms.untracked.bool(False), 4666 emptyRunLumiMode = cms.obsolete.untracked.string, 4667 eventSetup = cms.untracked.PSet( 4668 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 4669 allowAnyLabel_=cms.required.untracked.uint32 4671 numberOfConcurrentIOVs = cms.untracked.uint32(0) 4673 fileMode = cms.untracked.string('FULLMERGE'), 4674 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 4675 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 4676 makeTriggerResults = cms.obsolete.untracked.bool, 4677 modulesToCallForTryToContinue = cms.untracked.vstring(), 4678 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 4679 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 4680 numberOfConcurrentRuns = cms.untracked.uint32(1), 4681 numberOfStreams = cms.untracked.uint32(0), 4682 numberOfThreads = cms.untracked.uint32(1), 4683 printDependencies = cms.untracked.bool(False), 4684 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 4685 throwIfIllegalParameter = cms.untracked.bool(True), 4686 wantSummary = cms.untracked.bool(False) 4689 process.ProcessAcceleratorTest = ProcessAcceleratorTest( 4690 enabled = ['test1', 'test2', 'anothertest3'] 4696 proc.fillProcessDesc(p)
4697 self.assertEqual([
"*"], p.values[
"options"][1].values[
"accelerators"][1])
4698 self.assertFalse(p.values[
"options"][1].values[
"accelerators"][0])
4699 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4700 self.assertEqual(
"AcceleratorTestService", p.values[
"services"][1][0].values[
"@service_type"][1])
4701 self.assertFalse(p.values[
"@available_accelerators"][0])
4702 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4703 self.assertFalse(p.values[
"@module_type_resolver"][0])
4704 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4708 proc.add_(
Service(
"AcceleratorTestServiceRemove"))
4710 proc.fillProcessDesc(p)
4711 services = [x.values[
"@service_type"][1]
for x
in p.values[
"services"][1]]
4712 self.assertTrue(
"AcceleratorTestService" in services)
4713 self.assertFalse(
"AcceleratorTestServiceRemove" in services)
4718 proc.fillProcessDesc(p)
4719 self.assertEqual([
"cpu",
"test1"], p.values[
"@selected_accelerators"][1])
4720 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4724 proc.options.accelerators = [
"test2"]
4726 proc.fillProcessDesc(p)
4727 self.assertEqual([
"test2"], p.values[
"@selected_accelerators"][1])
4728 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4732 proc.options.accelerators = [
"test*"]
4733 proc.fillProcessDesc(p)
4734 self.assertEqual([
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4735 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4739 proc.options.accelerators = [
"test2"]
4741 proc.fillProcessDesc(p)
4742 self.assertEqual([], p.values[
"@selected_accelerators"][1])
4743 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4747 proc.options.accelerators = [
"cpu*"]
4749 proc.fillProcessDesc(p)
4750 self.assertEqual([
"cpu"], p.values[
"@selected_accelerators"][1])
4751 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4755 proc.options.accelerators = [
"test3"]
4757 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4761 proc.options.accelerators = [
"*",
"test1"]
4763 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4769 proc.fillProcessDesc(p)
4770 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4771 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4776 proc.options.accelerators = [
"*test3",
"c*"]
4778 proc.fillProcessDesc(p)
4779 self.assertEqual([
"anothertest3",
"cpu"], p.values[
"@selected_accelerators"][1])
4780 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4790 proc.p =
Path(proc.sp)
4792 proc.fillProcessDesc(p)
4793 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4803 proc.p =
Path(proc.sp)
4805 proc.fillProcessDesc(p)
4806 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4810 proc.options.accelerators = [
"test1"]
4817 proc.p =
Path(proc.sp)
4819 proc.fillProcessDesc(p)
4820 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4824 proc.options.accelerators = [
"test*"]
4831 proc.p =
Path(proc.sp)
4833 proc.fillProcessDesc(p)
4834 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4838 proc.options.accelerators = [
"anothertest3"]
4845 proc.p =
Path(proc.sp)
4847 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4853 proc.normalProducer =
EDProducer(
"FooProducer")
4854 proc.testProducer =
EDProducer(
"BarProducer@test")
4855 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4856 proc.testAnalyzer =
EDAnalyzer(
"Analyzer@test")
4858 proc.testESProducer =
ESProducer(
"ESProducer@test")
4859 proc.testESSource =
ESSource(
"ESSource@test")
4860 proc.p =
Path(proc.normalProducer+proc.testProducer+proc.test2Producer+proc.testAnalyzer+proc.testFilter)
4862 proc.fillProcessDesc(p)
4863 self.assertEqual(
"TestModuleTypeResolver", p.values[
"@module_type_resolver"][1])
4864 self.assertEqual(
"FooProducer", p.values[
"normalProducer"][1].values[
"@module_type"][1])
4865 self.assertEqual(len(list(
filter(
lambda x:
not "@" in x, p.values[
"normalProducer"][1].values.keys()))), 0)
4866 self.assertEqual(
"BarProducer@test", p.values[
"testProducer"][1].values[
"@module_type"][1])
4867 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][0])
4868 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][0])
4869 self.assertEqual(
"test1_backend", p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][1])
4870 self.assertEqual(
"BarProducer@test", p.values[
"test2Producer"][1].values[
"@module_type"][1])
4871 self.assertEqual(
"test2_backend", p.values[
"test2Producer"][1].values[
"test"][1].values[
"backend"][1])
4872 self.assertEqual(
"Analyzer@test", p.values[
"testAnalyzer"][1].values[
"@module_type"][1])
4873 self.assertEqual(
"test1_backend", p.values[
"testAnalyzer"][1].values[
"test"][1].values[
"backend"][1])
4874 self.assertEqual(
"Filter@test", p.values[
"testFilter"][1].values[
"@module_type"][1])
4875 self.assertEqual(
"test1_backend", p.values[
"testFilter"][1].values[
"test"][1].values[
"backend"][1])
4876 self.assertEqual(
"ESProducer@test", p.values[
"ESProducer@test@testESProducer"][1].values[
"@module_type"][1])
4877 self.assertEqual(
"test1_backend", p.values[
"ESProducer@test@testESProducer"][1].values[
"test"][1].values[
"backend"][1])
4878 self.assertEqual(
"ESSource@test", p.values[
"ESSource@test@testESSource"][1].values[
"@module_type"][1])
4879 self.assertEqual(
"test1_backend", p.values[
"ESSource@test@testESSource"][1].values[
"test"][1].values[
"backend"][1])
4885 proc.options.accelerators = []
4886 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4891 proc.options.accelerators = [
"test1"]
4892 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4893 proc.p =
Path(proc.test2Producer)
4894 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4903 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4914 proc.p =
Path(proc.sp)
4915 pkl = pickle.dumps(proc)
4916 unpkl = pickle.loads(pkl)
4918 unpkl.fillProcessDesc(p)
4919 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4920 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4921 unpkl = pickle.loads(pkl)
4922 unpkl.ProcessAcceleratorTest.setEnabled([
"test1"])
4924 unpkl.fillProcessDesc(p)
4925 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4926 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
def __setstate__(self, pkldict)
def conditionaltasks_(self)
def addVString(self, tracked, label, value)
def testProcessAccelerator(self)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def testConditionalTaskPlaceholder(self)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def __init__(self, enabled=["anothertest3", anothertest4, moduleTypeResolverMaker=None)
def __getattribute__(self, name)
def _place(self, label, process)
def testServiceInProcess(self)
def _dumpConfigUnnamedList(self, items, typeName, options)
def _placeAnalyzer(self, name, mod)
def addString(self, tracked, label, value)
def __findFirstUsingModule(self, seqsOrTasks, mod)
def _pruneModules(self, d, scheduledNames)
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
def _placeESPrefer(self, name, mod)
def __init__(self, process)
def __updateMaxEvents(self, ps)
def _placeSwitchProducer(self, name, mod)
def _insertPaths(self, processPSet, nodeVisitor)
def apply(self, process, accelerators)
def _placeESProducer(self, name, mod)
def _splitPythonList(self, subfolder, d, options)
bool any(const std::vector< T > &v, const T &what)
def addVESInputTag(self, tracked, label, value)
def _switchproducer_test2_case2(accelerators)
def _placeSequence(self, name, mod)
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def _validateSequence(self, sequence, label)
def __getattr__(self, attr)
def setStrict(self, value)
def addDouble(self, tracked, label, value)
def dumpPythonImpl(self, options)
def moduleTypeResolver(self, accelerators)
def _findPreferred(self, esname, d, args, kargs)
def apply(self, process, accelerators)
def __init__(self, kargs)
def apply(self, process, accelerators)
def _insertOneInto(self, parameterSet, label, item, tracked)
def __setattr__(self, label, value)
def __updateOptions(self, opt)
def __delattr__(self, name)
def _placePath(self, name, mod)
def addVUInt64(self, tracked, label, value)
def _placeEndPath(self, name, mod)
def testProcessForProcessAccelerator(self)
def __init__(self, name, Mods)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def testTypedParameterizable(self)
def addUInt64(self, tracked, label, value)
def _itemsInDependencyOrder(self, processDictionaryOfItems)
def addVPSet(self, tracked, label, value)
def nameInProcessDesc_(self, label)
def __init__(self, accelerators)
def _lineDiff(newString, oldString)
def dumpPythonImpl(self, options)
def format_outerframe(number)
def __init__(self, args, kw)
def load(self, moduleName)
def _raiseUnknownKey(key)
def _insertSubProcessesInto(self, parameterSet, label, itemList, tracked)
def addUInt32(self, tracked, label, value)
def __init__(self, error, message)
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 __injectValidValue(self, name, value, newValue=None)
def __getattr__(self, label)
def _replaceInTasks(self, label, new)
def addVInt32(self, tracked, label, value)
def _placeFilter(self, name, mod)
def handleProcessAccelerators(self, parameterSet)
def addVInputTag(self, tracked, label, value)
def _applyNewProcessModifiers(self, process)
def addLuminosityBlockID(self, tracked, label, value)
def addESInputTag(self, tracked, label, value)
def __delattr__(self, label)
def __new__(cls, args, kw)
def toModify(self, obj, func=None, kw)
def setEnabled(self, enabled)
def __setattr__(self, name, value)
def _placeESSource(self, name, mod)
def addVInt64(self, tracked, label, value)
def addVEventID(self, tracked, label, value)
def setEnabled(self, enabled)
def toModify(self, obj, func=None, kw)
def testGlobalReplace(self)
def testSwitchProducer(self)
def getVString(self, tracked, label)
def moduleTypeResolver(self, accelerators)
def defaultMaxLuminosityBlocks_()
def testProcessFragment(self)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def toReplaceWith(self, toObj, fromObj)
def _placeOutputModule(self, name, mod)
def addFileInPath(self, tracked, label, value)
def _placeSource(self, name, mod)
def __init__(self, lhs, rhs=None)
def _dumpPythonSubProcesses(self, l, options)
def _insertSwitchProducersInto(self, parameterSet, labelModules, labelAliases, itemDict, tracked)
def moduleTypeResolver(self, accelerators)
def checkImportPermission(minLevel=2, allowedPatterns=[])
def _toModify(obj, func, kw)
def __init__(self, modifier, func)
def _toReplaceWith(toObj, fromObj)
def _toModifyCheck(obj, func, kw)
def isUsingModifier(self, mod)
def dumpPython(self, options=PrintOptions())
def __copyIfExclude(self, toExclude)
def split(sequence, size)
def _validateTask(self, task, label)
def testParameterizable(self)
def _placeSubProcess(self, name, mod)
def __init__(self, enabled=["test1", test2, anothertest3, moduleTypeResolverMaker=None)
def setPartialSchedule_(self, sch, label)
def addPSet(self, tracked, label, value)
def testProcessDumpPython(self)
def _placeService(self, typeName, mod)
def resolve(self, keepUnresolvedSequencePlaceholders=False)
def _switchproducer_test2_case1(accelerators)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def _validateConditionalTask(self, task, label)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def _splitPython(self, subfolder, d, options)
def __init__(self, lhs, rhs)
def _placeAccelerator(self, typeName, mod)
def dumpPython(process, name)
def __setObjectLabel(self, object, newLabel)
def testConditionalTask(self)
def _delHelper(self, name)
def _placeAlias(self, name, mod)
def dumpPython(self, options=PrintOptions())
def _replaceInSequences(self, label, new)
def setSchedule_(self, sch)
def dumpPython(self, options=PrintOptions())
def _toReplaceWithCheck(toObj, fromObj)
def switchProducerNames(self)
def toReplaceWith(self, toObj, fromObj)
def _placeProducer(self, name, mod)
def prefer(self, esmodule, args, kargs)
def __delattr__(self, name)
def _dumpConfigNamedList(self, items, typeName, options)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def addInputTag(self, tracked, label, value)
def _insertManyInto(self, parameterSet, label, itemDict, tracked)
def dumpConfig(self, options=PrintOptions())
def testCloneSequence(self)
def _placeTask(self, name, task)
def makeProcessModifier(self, func)
def addSubProcess(self, mod)
def switchProducers_(self)
def _placePSet(self, name, mod)
def _placeFinalPath(self, name, mod)
def _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def addService(process, multirun=False)
def _place(self, name, mod, d)
def testProcessExtend(self)
def _dumpPythonList(self, d, options)
def __insertValue(self, tracked, label, value)
def splitPython(self, options=PrintOptions())
def __init__(self, kargs)
def setModuleVariant(self, module)
def __getValue(self, tracked, label)
def _place(self, name, proc)
def _placeVPSet(self, name, mod)
def processAccelerators_(self)
def globalReplace(self, label, new)
def addBool(self, tracked, label, value)
def addEventID(self, tracked, label, value)
def _placeLooper(self, name, mod)
def testImplicitSchedule(self)
def prune(self, verbose=False, keepUnresolvedSequencePlaceholders=False)
def addVDouble(self, tracked, label, value)
def _insertInto(self, parameterSet, itemDict)
def _delattrFromSetattr(self, name)
def _replaceInConditionalTasks(self, label, new)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def _placeConditionalTask(self, name, task)
def _replaceInScheduleDirectly(self, label, new)
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def _replaceInSchedule(self, label, new)
def dumpPythonImpl(self, options)
def _dumpPython(self, d, options)
def addInt32(self, tracked, label, value)
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)