4 from __future__
import print_function
5 from __future__
import absolute_import
7 from .Options
import Options
13 from typing
import Union
14 from .Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
17 from .Modules
import *
18 from .Modules
import _Module
19 from .SequenceTypes
import *
20 from .SequenceTypes
import _ModuleSequenceType, _Sequenceable
21 from .SequenceVisitors
import PathValidator, EndPathValidator, FinalPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
22 from .MessageLogger
import MessageLogger
23 from .
import DictTypes
25 from .ExceptionHandling
import *
28 if sys.getrecursionlimit()<5000:
29 sys.setrecursionlimit(5000)
34 Configuration =
"{Configuration}" 35 UnavailableAccelerator =
"{UnavailableAccelerator}" 44 Raise an exception if called by special config files. This checks 45 the call or import stack for the importing file. An exception is raised if 46 the importing module is not in allowedPatterns and if it is called too deeply: 47 minLevel = 2: inclusion by top lvel cfg only 48 minLevel = 1: No inclusion allowed 49 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 50 by any module in Module1 or Submodule1 56 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'FWCore/ParameterSet/python/Config.py',
'<string>',
'<frozen ']
57 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
61 for item
in inspect.stack():
65 for pattern
in CMSSWPath:
66 if item[1].
find(pattern) != -1:
69 if item[1].
find(
'/') == -1:
72 for pattern
in ignorePatterns:
73 if item[1].
find(pattern) != -1:
77 if inPath
and not ignore:
78 trueStack.append(item[1])
80 importedFile = trueStack[0]
82 if len(trueStack) > 1:
83 importedBy = trueStack[1]
85 for pattern
in allowedPatterns:
86 if importedBy.find(pattern) > -1:
89 if len(trueStack) <= minLevel:
92 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 96 """Look inside the module and find the Processes it contains""" 100 if isinstance(module,dict):
101 if 'process' in module:
102 p = module[
'process']
105 if hasattr(module,
'process'):
106 if isinstance(module.process,Process):
107 process = module.process
109 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
111 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
115 """Root class for a CMS configuration process""" 118 """The argument 'name' will be the name applied to this Process 119 Can optionally pass as additional arguments cms.Modifier instances 120 that will be used to modify the Process as it is built 122 self.__dict__[
'_Process__name'] = name
123 if not name.isalnum():
124 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
125 self.__dict__[
'_Process__filters'] = {}
126 self.__dict__[
'_Process__producers'] = {}
127 self.__dict__[
'_Process__switchproducers'] = {}
128 self.__dict__[
'_Process__source'] =
None 129 self.__dict__[
'_Process__looper'] =
None 130 self.__dict__[
'_Process__subProcesses'] = []
131 self.__dict__[
'_Process__schedule'] =
None 132 self.__dict__[
'_Process__analyzers'] = {}
133 self.__dict__[
'_Process__outputmodules'] = {}
137 self.__dict__[
'_Process__sequences'] = {}
138 self.__dict__[
'_Process__tasks'] = {}
139 self.__dict__[
'_Process__conditionaltasks'] = {}
140 self.__dict__[
'_Process__services'] = {}
141 self.__dict__[
'_Process__essources'] = {}
142 self.__dict__[
'_Process__esproducers'] = {}
143 self.__dict__[
'_Process__esprefers'] = {}
144 self.__dict__[
'_Process__aliases'] = {}
145 self.__dict__[
'_Process__psets']={}
146 self.__dict__[
'_Process__vpsets']={}
147 self.__dict__[
'_cloneToObjectDict'] = {}
149 self.__dict__[
'_Process__InExtendCall'] =
False 150 self.__dict__[
'_Process__partialschedules'] = {}
152 self.__dict__[
'_Process__modifiers'] = Mods
153 self.__dict__[
'_Process__accelerators'] = {}
162 if Process._firstProcess:
163 Process._firstProcess =
False 166 for m
in self.__modifiers:
167 if not m._isChosen():
168 raise RuntimeError(
"The Process {} tried to redefine which Modifiers to use after another Process was already started".
format(name))
169 for m
in self.__modifiers:
174 _Module.__isStrict__ =
True 178 """Returns a string containing all the EDProducer labels separated by a blank""" 181 """Returns a string containing all the SwitchProducer labels separated by a blank""" 184 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 187 """Returns a string containing all the EDFilter labels separated by a blank""" 190 """Returns a string containing all the Path names separated by a blank""" 197 Since cloneToObjectDict stores a hash of objects by their 198 id() it needs to be updated when unpickling to use the 199 new object id values instantiated during the unpickle. 202 self.__dict__.
update(pkldict)
204 for value
in self._cloneToObjectDict.
values():
205 tmpDict[
id(value)] = value
206 self.__dict__[
'_cloneToObjectDict'] = tmpDict
211 """returns a dict of the filters that have been added to the Process""" 213 filters = property(filters_, doc=
"dictionary containing the filters for the process")
217 if not name.isalnum():
218 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
219 self.__dict__[
'_Process__name'] = name
220 process = property(name_,setName_, doc=
"name of the process")
222 """returns a dict of the producers that have been added to the Process""" 224 producers = property(producers_,doc=
"dictionary containing the producers for the process")
226 """returns a dict of the SwitchProducers that have been added to the Process""" 228 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
230 """returns the source that has been added to the Process or None if none have been added""" 234 source = property(source_,setSource_,doc=
'the main source or None if not set')
236 """returns the looper that has been added to the Process or None if none have been added""" 240 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
243 return untracked.PSet(numberOfThreads = untracked.uint32(1),
244 numberOfStreams = untracked.uint32(0),
245 numberOfConcurrentRuns = untracked.uint32(1),
246 numberOfConcurrentLuminosityBlocks = untracked.uint32(0),
247 eventSetup = untracked.PSet(
248 numberOfConcurrentIOVs = untracked.uint32(0),
249 forceNumberOfConcurrentIOVs = untracked.PSet(
250 allowAnyLabel_ = required.untracked.uint32
253 accelerators = untracked.vstring(
'*'),
254 wantSummary = untracked.bool(
False),
255 fileMode = untracked.string(
'FULLMERGE'),
256 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
257 throwIfIllegalParameter = untracked.bool(
True),
258 printDependencies = untracked.bool(
False),
259 deleteNonConsumedUnscheduledModules = untracked.bool(
True),
260 sizeOfStackForThreadsInKB = optional.untracked.uint32,
261 Rethrow = untracked.vstring(),
262 TryToContinue = untracked.vstring(),
263 IgnoreCompletely = untracked.vstring(),
264 modulesToCallForTryToContinue = untracked.vstring(),
265 canDeleteEarly = untracked.vstring(),
266 holdsReferencesToDeleteEarly = untracked.VPSet(),
267 modulesToIgnoreForDeleteEarly = untracked.vstring(),
268 dumpOptions = untracked.bool(
False),
269 allowUnscheduled = obsolete.untracked.bool,
270 emptyRunLumiMode = obsolete.untracked.string,
271 makeTriggerResults = obsolete.untracked.bool,
275 if isinstance(opt,dict):
276 for k,v
in opt.items():
279 for p
in opt.parameters_():
280 setattr(newOpts, p, getattr(opt,p))
284 return untracked.PSet(input=optional.untracked.int32,
285 output=optional.untracked.allowed(int32,PSet))
288 if isinstance(ps,dict):
289 for k,v
in ps.items():
292 for p
in ps.parameters_():
293 setattr(newMax, p, getattr(ps,p))
297 return untracked.PSet(input=untracked.int32(-1))
299 """returns a list of the subProcesses that have been added to the Process""" 300 return self.__subProcesses
301 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
303 """returns a dict of the analyzers that have been added to the Process""" 305 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
307 """returns a dict of the output modules that have been added to the Process""" 309 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
311 """returns a dict of the paths that have been added to the Process""" 313 paths = property(paths_,doc=
"dictionary containing the paths for the process")
315 """returns a dict of the endpaths that have been added to the Process""" 317 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
319 """returns a dict of the finalpaths that have been added to the Process""" 321 finalpaths = property(finalpaths_,doc=
"dictionary containing the finalpaths for the process")
323 """returns a dict of the sequences that have been added to the Process""" 325 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
327 """returns a dict of the tasks that have been added to the Process""" 329 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
331 """returns a dict of the conditionaltasks that have been added to the Process""" 333 conditionaltasks = property(conditionaltasks_,doc=
"dictionary containing the conditionatasks for the process")
335 """returns the schedule that has been added to the Process or None if none have been added""" 336 return self.__schedule
338 if label ==
"schedule":
341 self.
_place(label, sch, self.__partialschedules)
350 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
351 self.__dict__[
'_Process__schedule'] = sch
352 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
354 """returns a dict of the services that have been added to the Process""" 356 services = property(services_,doc=
"dictionary containing the services for the process")
358 """returns a dict of the ProcessAccelerators that have been added to the Process""" 360 processAccelerators = property(processAccelerators_,doc=
"dictionary containing the ProcessAccelerators for the process")
362 """returns a dict of the esproducers that have been added to the Process""" 364 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
366 """returns a the es_sources that have been added to the Process""" 368 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
370 """returns a dict of the es_prefers that have been added to the Process""" 372 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
374 """returns a dict of the aliases that have been added to the Process""" 376 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
378 """returns a dict of the PSets that have been added to the Process""" 380 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
382 """returns a dict of the VPSets that have been added to the Process""" 384 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
387 """returns True if the Modifier is in used by this Process""" 389 for m
in self.__modifiers:
390 if m._isOrContains(mod):
395 if not object.hasLabel_() :
396 object.setLabel(newLabel)
398 if newLabel == object.label_() :
400 if newLabel
is None :
401 object.setLabel(
None)
403 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
404 msg100 =
"Attempting to change the label of an attribute of the Process\n" 405 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 406 msg102 =
"Type = "+
str(type(object))+
"\n" 407 msg103 =
"Some possible solutions:\n" 408 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 409 msg105 =
" also preferred for other types when possible.\n" 410 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 411 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 412 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 413 msg109 =
" the name.\n" 414 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 415 msg111 =
" name to the same object usually causes confusion and problems.\n" 416 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 417 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
418 object.setLabel(
None)
419 object.setLabel(newLabel)
423 if not name.replace(
'_',
'').isalnum():
424 raise ValueError(
'The label '+name+
' contains forbiden characters')
426 if name ==
'options':
428 if name ==
'maxEvents':
432 if name.startswith(
'_Process__'):
433 self.__dict__[name]=value
435 if not isinstance(value,_ConfigureComponent):
436 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 437 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
438 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
439 if name == value.type_():
440 if hasattr(self,name)
and (getattr(self,name)!=value):
447 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
448 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
451 newValue =value.copy()
453 newValue._filename = value._filename
459 if not self.
_okToPlace(name, value, self.__dict__):
460 newFile=
'top level config' 461 if hasattr(value,
'_filename'):
462 newFile = value._filename
463 oldFile=
'top level config' 464 oldValue = getattr(self,name)
465 if hasattr(oldValue,
'_filename'):
466 oldFile = oldValue._filename
467 msg =
"Trying to override definition of process."+name
468 msg +=
"\n new object defined in: "+newFile
469 msg +=
"\n existing object defined in: "+oldFile
470 raise ValueError(msg)
472 if hasattr(self,name)
and not (getattr(self,name)==newValue):
476 if newValue._isTaskComponent():
477 if not self.__InExtendCall:
482 if not isinstance(newValue, Task):
484 newFile=
'top level config' 485 if hasattr(value,
'_filename'):
486 newFile = value._filename
487 oldFile=
'top level config' 488 oldValue = getattr(self,name)
489 if hasattr(oldValue,
'_filename'):
490 oldFile = oldValue._filename
491 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 492 msg2 =
"\n new object defined in: "+newFile
493 msg2 +=
"\n existing object defined in: "+oldFile
496 raise ValueError(msg1+s.label_()+msg2)
498 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent()
or isinstance(newValue, ConditionalTask):
499 if not self.__InExtendCall:
500 if isinstance(newValue, ConditionalTask):
505 newFile=
'top level config' 506 if hasattr(value,
'_filename'):
507 newFile = value._filename
508 oldFile=
'top level config' 509 oldValue = getattr(self,name)
510 if hasattr(oldValue,
'_filename'):
511 oldFile = oldValue._filename
512 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 513 msg2 =
"\n new object defined in: "+newFile
514 msg2 +=
"\n existing object defined in: "+oldFile
517 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
520 raise ValueError(msg1+
"path "+s.label_()+msg2)
523 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
526 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
529 if isinstance(newValue, EDAlias):
530 oldValue = getattr(self, name)
532 newFile=
'top level config' 533 if hasattr(value,
'_filename'):
534 newFile = value._filename
535 oldFile=
'top level config' 536 if hasattr(oldValue,
'_filename'):
537 oldFile = oldValue._filename
538 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the " 539 msg2 =
"\n new object defined in: "+newFile
540 msg2 +=
"\n existing object defined in: "+oldFile
543 raise ValueError(msg1+
"task "+s.label_()+msg2)
546 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
549 raise ValueError(msg1+
"path "+s.label_()+msg2)
552 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
555 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
557 if not self.__InExtendCall
and (Schedule._itemIsValid(newValue)
or isinstance(newValue, Task)):
565 self.__dict__[name]=newValue
566 if isinstance(newValue,_Labelable):
568 self._cloneToObjectDict[
id(value)] = newValue
569 self._cloneToObjectDict[
id(newValue)] = newValue
571 newValue._place(name,self)
573 """Given a container of sequences or tasks, find the first sequence or task 574 containing mod and return it. If none is found, return None""" 577 for seqOrTask
in seqsOrTasks.values():
586 if not hasattr(self,name):
587 raise KeyError(
'process does not know about '+name)
588 elif name.startswith(
'_Process__'):
589 raise ValueError(
'this attribute cannot be deleted')
594 if name
in reg: del reg[name]
596 obj = getattr(self,name)
597 if isinstance(obj,_Labelable):
599 if isinstance(obj,Service):
600 obj._inProcess =
False 604 obj = getattr(self,name)
606 if not isinstance(obj, Sequence)
and not isinstance(obj, Task)
and not isinstance(obj,ConditionalTask):
616 if obj._isTaskComponent():
620 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
622 if Schedule._itemIsValid(obj)
or isinstance(obj, Task):
626 del self.__dict__[name]
631 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 635 del self.__dict__[name]
640 """Allows addition of components that do not have to have a label, e.g. Services""" 641 if not isinstance(value,_ConfigureComponent):
643 if not isinstance(value,_Unlabelable):
647 newValue =value.copy()
651 newValue._place(
'',self)
654 if not self.__InExtendCall:
665 if d[name]._isModified:
676 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
677 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
680 if isinstance(mod,_Labelable):
683 self.
_place(name, mod, self.__outputmodules)
685 self.
_place(name, mod, self.__producers)
687 self.
_place(name, mod, self.__switchproducers)
689 self.
_place(name, mod, self.__filters)
691 self.
_place(name, mod, self.__analyzers)
695 self.
_place(name, mod, self.__paths)
696 except ModuleCloneError
as msg:
698 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
702 self.
_place(name, mod, self.__endpaths)
703 except ModuleCloneError
as msg:
705 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
709 self.
_place(name, mod, self.__finalpaths)
710 except ModuleCloneError
as msg:
712 raise Exception(
"%sThe module %s in finalpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
715 self.
_place(name, mod, self.__sequences)
717 self.
_place(name, mod, self.__esproducers)
719 self.
_place(name, mod, self.__esprefers)
721 self.
_place(name, mod, self.__essources)
724 self.
_place(name, task, self.__tasks)
727 self.
_place(name, task, self.__conditionaltasks)
729 self.
_place(name, mod, self.__aliases)
731 self.
_place(name, mod, self.__psets)
733 self.
_place(name, mod, self.__vpsets)
735 """Allow the source to be referenced by 'source' or by type name""" 737 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
738 if self.__dict__[
'_Process__source']
is not None :
739 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
740 self.__dict__[
'_Process__source'] = mod
741 self.__dict__[mod.type_()] = mod
744 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
745 self.__dict__[
'_Process__looper'] = mod
746 self.__dict__[mod.type_()] = mod
748 self.__dict__[
'_Process__subProcess'] = mod
749 self.__dict__[mod.type_()] = mod
751 self.__subProcesses.
append(mod)
753 self.
_place(typeName, mod, self.__services)
754 if typeName
in self.__dict__:
755 self.__dict__[typeName]._inProcess =
False 756 self.__dict__[typeName]=mod
758 self.
_place(typeName, mod, self.__accelerators)
759 self.__dict__[typeName]=mod
760 def load(self, moduleName:str):
761 moduleName = moduleName.replace(
"/",
".")
762 module = __import__(moduleName)
763 self.
extend(sys.modules[moduleName])
765 """Look in other and find types that we can use""" 767 self.__dict__[
'_Process__InExtendCall'] =
True 770 tasksToAttach = dict()
772 for name
in dir(other):
774 if name.startswith(
'_'):
776 item = getattr(other,name)
777 if name ==
"source" or name ==
"looper":
781 elif isinstance(item,_ModuleSequenceType):
783 elif isinstance(item,Task)
or isinstance(item, ConditionalTask):
784 tasksToAttach[name] = item
785 elif isinstance(item,_Labelable):
787 if not item.hasLabel_() :
789 elif isinstance(item,Schedule):
791 elif isinstance(item,_Unlabelable):
793 elif isinstance(item,ProcessModifier):
795 elif isinstance(item,ProcessFragment):
799 for name,seq
in seqs.items():
800 if id(seq)
not in self._cloneToObjectDict:
803 newSeq = self._cloneToObjectDict[
id(seq)]
804 self.__dict__[name]=newSeq
807 newSeq._place(name,self)
809 for name, task
in tasksToAttach.items():
816 self.__dict__[
'_Process__InExtendCall'] =
False 820 for name,item
in items:
821 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
826 for name,item
in items:
827 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
832 for name,item
in items:
833 if name == item.type_():
835 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
839 """return a string containing the equivalent process defined using the old configuration language""" 840 config =
"process "+self.__name+
" = {\n" 893 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
895 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
897 pathNames = [p.label_()
for p
in self.
schedule]
898 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 910 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
916 returnValue += item.dumpPython(options)+
'\n\n' 922 for name,item
in d.items():
923 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 925 for name,item
in sorted(d.items()):
926 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 933 dependencies = item.directDependencies()
934 for module_subfolder, module
in dependencies:
935 module = module +
'_cfi' 936 if options.useSubdirectories
and module_subfolder:
937 module = module_subfolder +
'.' + module
938 if options.targetDirectory
is not None:
939 if options.useSubdirectories
and subfolder:
940 module =
'..' + module
942 module =
'.' + module
943 code +=
'from ' + module +
' import *\n' 946 code += name +
' = ' + item.dumpPython(options)
947 parts[name] = subfolder, code
955 sequence.visit(visitor)
956 except Exception
as e:
957 raise RuntimeError(
"An entry in sequence {} has no label\n Seen entries: {}\n Error: {}".
format(label, l, e))
966 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
974 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
986 for label,item
in processDictionaryOfItems.items():
988 if isinstance(item, Task):
990 elif isinstance(item, ConditionalTask):
997 if isinstance(item, Task):
998 raise RuntimeError(
"Failed in a Task visitor. Probably " \
999 "a circular dependency discovered in Task with label " + label)
1000 elif isinstance(item, ConditionalTask):
1001 raise RuntimeError(
"Failed in a ConditionalTask visitor. Probably " \
1002 "a circular dependency discovered in ConditionalTask with label " + label)
1004 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
1005 "circular dependency discovered in Sequence with label " + label)
1006 for containedItem
in containedItems:
1012 if containedItem.hasLabel_():
1013 testItem = processDictionaryOfItems.get(containedItem.label_())
1014 if testItem
is None or containedItem != testItem:
1015 if isinstance(item, Task):
1016 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
1017 " from the process yields a different object or None\n"+
1018 "label = " + containedItem.label_())
1019 if isinstance(item, ConditionalTask):
1020 raise RuntimeError(
"ConditionalTask has a label, but using its label to get an attribute" \
1021 " from the process yields a different object or None\n"+
1022 "label = " + containedItem.label_())
1024 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
1025 " from the process yields a different object or None\n"+
1026 "label = " + containedItem.label_())
1027 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
1031 oldDeps = dict(dependencies)
1032 for label,deps
in oldDeps.items():
1034 returnValue[label]=processDictionaryOfItems[label]
1036 del dependencies[label]
1037 for lb2,deps2
in dependencies.items():
1038 while deps2.count(label):
1044 for name, value
in sorted(d.items()):
1045 result += value.dumpPythonAs(name,options)+
'\n' 1050 for name, value
in sorted(d.items()):
1051 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n' 1055 """return a string containing the equivalent process defined using python""" 1056 specialImportRegistry._reset()
1057 header =
"import FWCore.ParameterSet.Config as cms" 1058 result =
"process = cms.Process(\""+self.__name+
"\")\n\n" 1085 imports = specialImportRegistry.getSpecialImports()
1086 if len(imports) > 0:
1087 header +=
"\n" +
"\n".
join(imports)
1089 return header+result
1092 """return a map of file names to python configuration fragments""" 1093 specialImportRegistry._reset()
1095 options.isCfg =
False 1096 header =
"import FWCore.ParameterSet.Config as cms" 1101 result =
'process = cms.Process("' + self.__name +
'")\n\n' 1114 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1131 if options.targetDirectory
is not None:
1132 files[options.targetDirectory +
'/__init__.py'] =
'' 1134 if options.useSubdirectories:
1135 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1136 if options.targetDirectory
is not None:
1137 sub = options.targetDirectory +
'/' + sub
1138 files[sub +
'/__init__.py'] =
'' 1141 parts = sorted(parts.items(), key =
lambda nsc: (nsc[1][0].lower()
if nsc[1][0]
else '', nsc[0].lower()))
1143 for (name, (subfolder, code))
in parts:
1144 filename = name +
'_cfi' 1145 if options.useSubdirectories
and subfolder:
1146 filename = subfolder +
'/' + filename
1147 if options.targetDirectory
is not None:
1148 filename = options.targetDirectory +
'/' + filename
1149 result +=
'process.load("%s")\n' % filename
1150 files[filename +
'.py'] = header +
'\n\n' + code
1153 options.isCfg =
True 1156 imports = specialImportRegistry.getSpecialImports()
1157 if len(imports) > 0:
1158 header +=
'\n' +
'\n'.
join(imports)
1159 files[
'-'] = header +
'\n\n' + result
1163 old = getattr(self,label)
1170 sequenceable._replaceIfHeldDirectly(old,new)
1172 sequenceable.replace(old,new)
1174 sequenceable.replace(old,new)
1176 sequenceable.replace(old,new)
1178 sequenceable.replace(old,new)
1180 old = getattr(self,label)
1182 task.replace(old, new)
1184 old = getattr(self,label)
1186 task.replace(old, new)
1190 old = getattr(self,label)
1192 task.replace(old, new)
1196 old = getattr(self,label)
1197 self.
schedule_()._replaceIfHeldDirectly(old, new)
1199 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 1200 if not hasattr(self,label):
1201 raise LookupError(
"process has no item of label "+label)
1202 setattr(self,label,new)
1204 for name,value
in itemDict.items():
1205 value.insertInto(parameterSet, name)
1208 if not item ==
None:
1209 newlabel = item.nameInProcessDesc_(label)
1211 item.insertInto(parameterSet, newlabel)
1212 parameterSet.addVString(tracked, label, vitems)
1215 for name,value
in itemDict.items():
1216 value.appendToProcessDescList_(l, name)
1217 value.insertInto(parameterSet, name)
1220 parameterSet.addVString(tracked, label, l)
1222 modules = parameterSet.getVString(tracked, labelModules)
1223 aliases = parameterSet.getVString(tracked, labelAliases)
1224 accelerators = parameterSet.getVString(
False,
"@selected_accelerators")
1225 for name,value
in itemDict.items():
1226 value.appendToProcessDescLists_(modules, aliases, name)
1227 value.insertInto(parameterSet, name, accelerators)
1230 parameterSet.addVString(tracked, labelModules, modules)
1231 parameterSet.addVString(tracked, labelAliases, aliases)
1235 for value
in itemList:
1236 name = value.getProcessName()
1237 newLabel = value.nameInProcessDesc_(name)
1239 pset = value.getSubProcessPSet(parameterSet)
1240 subprocs.append(pset)
1243 parameterSet.addVString(tracked, label, l)
1244 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1252 for name
in self.
paths_():
1253 scheduledPaths.append(name)
1254 triggerPaths.append(name)
1256 scheduledPaths.append(name)
1257 endpaths.append(name)
1259 finalpaths.append(name)
1262 pathname = path.label_()
1264 endpaths.append(pathname)
1265 scheduledPaths.append(pathname)
1267 finalpaths.append(pathname)
1269 scheduledPaths.append(pathname)
1270 triggerPaths.append(pathname)
1272 task.resolve(self.__dict__)
1274 task.visit(scheduleTaskValidator)
1275 task.visit(nodeVisitor)
1277 endPathWithFinalPathModulesName =
"@finalPath" 1280 endpaths.append(endPathWithFinalPathModulesName)
1281 scheduledPaths.append(endPathWithFinalPathModulesName)
1283 modulesOnFinalPath = []
1284 for finalpathname
in finalpaths:
1286 iFinalPath.resolve(self.__dict__)
1287 finalpathValidator.setLabel(finalpathname)
1288 iFinalPath.visit(finalpathValidator)
1289 invalidModules = finalpathValidator.invalidModulesOnFinalpaths
1291 raise RuntimeError(
"FinalPath %s has non OutputModules %s" % (finalpathname,
",".
join(invalidModules)))
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:bool=
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:bool=
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())
2452 """import FWCore.ParameterSet.Config as cms 2454 process = cms.Process("test") 2456 process.maxEvents = cms.untracked.PSet( 2457 input = cms.optional.untracked.int32, 2458 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 2461 process.maxLuminosityBlocks = cms.untracked.PSet( 2462 input = cms.untracked.int32(-1) 2465 process.options = cms.untracked.PSet( 2466 IgnoreCompletely = cms.untracked.vstring(), 2467 Rethrow = cms.untracked.vstring(), 2468 TryToContinue = cms.untracked.vstring(), 2469 accelerators = cms.untracked.vstring('*'), 2470 allowUnscheduled = cms.obsolete.untracked.bool, 2471 canDeleteEarly = cms.untracked.vstring(), 2472 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 2473 dumpOptions = cms.untracked.bool(False), 2474 emptyRunLumiMode = cms.obsolete.untracked.string, 2475 eventSetup = cms.untracked.PSet( 2476 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 2477 allowAnyLabel_=cms.required.untracked.uint32 2479 numberOfConcurrentIOVs = cms.untracked.uint32(0) 2481 fileMode = cms.untracked.string('FULLMERGE'), 2482 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 2483 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 2484 makeTriggerResults = cms.obsolete.untracked.bool, 2485 modulesToCallForTryToContinue = cms.untracked.vstring(), 2486 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 2487 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 2488 numberOfConcurrentRuns = cms.untracked.uint32(1), 2489 numberOfStreams = cms.untracked.uint32(0), 2490 numberOfThreads = cms.untracked.uint32(1), 2491 printDependencies = cms.untracked.bool(False), 2492 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 2493 throwIfIllegalParameter = cms.untracked.bool(True), 2494 wantSummary = cms.untracked.bool(False) 2497 process.MessageLogger = cms.Service("MessageLogger", 2498 cerr = cms.untracked.PSet( 2499 FwkReport = cms.untracked.PSet( 2500 limit = cms.untracked.int32(10000000), 2501 reportEvery = cms.untracked.int32(1) 2503 FwkSummary = cms.untracked.PSet( 2504 limit = cms.untracked.int32(10000000), 2505 reportEvery = cms.untracked.int32(1) 2507 INFO = cms.untracked.PSet( 2508 limit = cms.untracked.int32(0) 2510 Root_NoDictionary = cms.untracked.PSet( 2511 limit = cms.untracked.int32(0) 2513 default = cms.untracked.PSet( 2514 limit = cms.untracked.int32(10000000) 2516 enable = cms.untracked.bool(True), 2517 enableStatistics = cms.untracked.bool(False), 2518 lineLength = cms.optional.untracked.int32, 2519 noLineBreaks = cms.optional.untracked.bool, 2520 noTimeStamps = cms.untracked.bool(False), 2521 resetStatistics = cms.untracked.bool(False), 2522 statisticsThreshold = cms.untracked.string('WARNING'), 2523 threshold = cms.untracked.string('INFO'), 2524 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2525 limit = cms.optional.untracked.int32, 2526 reportEvery = cms.untracked.int32(1), 2527 timespan = cms.optional.untracked.int32 2530 cout = cms.untracked.PSet( 2531 enable = cms.untracked.bool(False), 2532 enableStatistics = cms.untracked.bool(False), 2533 lineLength = cms.optional.untracked.int32, 2534 noLineBreaks = cms.optional.untracked.bool, 2535 noTimeStamps = cms.optional.untracked.bool, 2536 resetStatistics = cms.untracked.bool(False), 2537 statisticsThreshold = cms.optional.untracked.string, 2538 threshold = cms.optional.untracked.string, 2539 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2540 limit = cms.optional.untracked.int32, 2541 reportEvery = cms.untracked.int32(1), 2542 timespan = cms.optional.untracked.int32 2545 debugModules = cms.untracked.vstring(), 2546 default = cms.untracked.PSet( 2547 limit = cms.optional.untracked.int32, 2548 lineLength = cms.untracked.int32(80), 2549 noLineBreaks = cms.untracked.bool(False), 2550 noTimeStamps = cms.untracked.bool(False), 2551 reportEvery = cms.untracked.int32(1), 2552 statisticsThreshold = cms.untracked.string('INFO'), 2553 threshold = cms.untracked.string('INFO'), 2554 timespan = cms.optional.untracked.int32, 2555 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2556 limit = cms.optional.untracked.int32, 2557 reportEvery = cms.untracked.int32(1), 2558 timespan = cms.optional.untracked.int32 2561 files = cms.untracked.PSet( 2562 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2563 enableStatistics = cms.untracked.bool(False), 2564 extension = cms.optional.untracked.string, 2565 filename = cms.optional.untracked.string, 2566 lineLength = cms.optional.untracked.int32, 2567 noLineBreaks = cms.optional.untracked.bool, 2568 noTimeStamps = cms.optional.untracked.bool, 2569 output = cms.optional.untracked.string, 2570 resetStatistics = cms.untracked.bool(False), 2571 statisticsThreshold = cms.optional.untracked.string, 2572 threshold = cms.optional.untracked.string, 2573 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2574 limit = cms.optional.untracked.int32, 2575 reportEvery = cms.untracked.int32(1), 2576 timespan = cms.optional.untracked.int32 2580 suppressDebug = cms.untracked.vstring(), 2581 suppressFwkInfo = cms.untracked.vstring(), 2582 suppressInfo = cms.untracked.vstring(), 2583 suppressWarning = cms.untracked.vstring(), 2584 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2585 limit = cms.optional.untracked.int32, 2586 reportEvery = cms.untracked.int32(1), 2587 timespan = cms.optional.untracked.int32 2602 """process.a = cms.EDAnalyzer("MyAnalyzer") 2603 process.s = cms.Sequence(process.a) 2604 process.r = cms.Sequence(process.s) 2605 process.p = cms.Path(process.a) 2606 process.p2 = cms.Path(process.s) 2607 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2619 """process.a = cms.EDAnalyzer("MyAnalyzer") 2620 process.b = cms.EDAnalyzer("YourAnalyzer") 2621 process.r = cms.Sequence(process.a) 2622 process.s = cms.Sequence(process.r) 2623 process.p = cms.Path(process.a) 2624 process.p2 = cms.Path(process.r) 2625 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2636 """process.a = cms.EDAnalyzer("MyAnalyzer") 2637 process.r = cms.Sequence((process.a)) 2638 process.p = cms.Path(process.a) 2639 process.p2 = cms.Path(process.r) 2640 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2656 p.task3.add(p.task1)
2660 p.p2 =
Path(p.r, p.task1, p.task2)
2661 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2664 """process.b = cms.EDProducer("bProducer") 2665 process.c = cms.EDProducer("cProducer") 2666 process.d = cms.EDProducer("dProducer") 2667 process.e = cms.EDProducer("eProducer") 2668 process.f = cms.EDProducer("fProducer") 2669 process.g = cms.EDProducer("gProducer") 2670 process.a = cms.EDAnalyzer("MyAnalyzer") 2671 process.task5 = cms.Task() 2672 process.task1 = cms.Task(process.task5) 2673 process.task3 = cms.Task(process.task1) 2674 process.task2 = cms.Task(process.c, process.task3) 2675 process.task4 = cms.Task(process.f, process.task2) 2676 process.r = cms.Sequence((process.a)) 2677 process.p = cms.Path(process.a) 2678 process.p2 = cms.Path(process.r, process.task1, process.task2) 2679 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2696 p.p2 =
Path(p.r, p.task1, p.task2)
2697 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task5])
2700 """process.b = cms.EDProducer("bProducer") 2701 process.c = cms.EDProducer("cProducer") 2702 process.d = cms.EDProducer("dProducer") 2703 process.e = cms.EDProducer("eProducer") 2704 process.f = cms.EDProducer("fProducer") 2705 process.g = cms.EDProducer("gProducer") 2706 process.a = cms.EDAnalyzer("MyAnalyzer") 2707 process.task5 = cms.Task() 2708 process.task3 = cms.Task() 2709 process.task2 = cms.ConditionalTask(process.c, process.task3) 2710 process.task1 = cms.ConditionalTask(process.task5) 2711 process.r = cms.Sequence((process.a)) 2712 process.p = cms.Path(process.a) 2713 process.p2 = cms.Path(process.r, process.task1, process.task2) 2714 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task5])""")
2721 p.task1 =
Task(p.d, p.e)
2722 task2 =
Task(p.f, p.g)
2723 p.schedule =
Schedule(tasks=[p.task1,task2])
2726 """process.d = cms.EDProducer("dProducer") 2727 process.e = cms.EDProducer("eProducer") 2728 process.f = cms.EDProducer("fProducer") 2729 process.g = cms.EDProducer("gProducer") 2730 process.task1 = cms.Task(process.d, process.e) 2731 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2737 """process.schedule = cms.Schedule()""")
2746 d=process.dumpPython()
2748 """process.a = cms.EDProducer("A") 2749 process.s2 = cms.Sequence(process.a)""")
2759 d=process.dumpPython()
2761 """process.a = cms.EDProducer("A") 2762 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2788 p.p =
Path(p.c+s+p.a)
2789 p.p2 =
Path(p.c+p.s4+p.a, p.ct1)
2795 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2797 p.globalReplace(
"a",new)
2798 p.globalReplace(
"d",new2)
2801 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2802 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2804 p.p2.visit(visitor_p2)
2805 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2806 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a, process.ct1)")
2808 p.e3.visit(visitor3)
2809 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2811 p.s4.visit(visitor4)
2812 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2813 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d), process.ct1)")
2815 p.t1.visit(visitor5)
2816 self.assertTrue(visitor5.modules == set([new2]))
2818 listOfTasks = list(p.schedule._tasks)
2819 listOfTasks[0].visit(visitor6)
2820 self.assertTrue(visitor6.modules == set([new2]))
2822 p.ct1.visit(visitor7)
2823 self.assertTrue(visitor7.modules == set([new2]))
2825 listOfConditionalTasks = list(p.conditionaltasks.values())
2826 listOfConditionalTasks[0].visit(visitor8)
2827 self.assertTrue(visitor8.modules == set([new2]))
2831 p.schedule =
Schedule(p.p, p.p2, p.e3, tasks=[p.t1])
2832 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2834 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2836 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2838 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2846 self.assertEqual(
str(p.s),
'a+b')
2847 self.assertEqual(p.s.label_(),
's')
2848 path =
Path(p.c+p.s)
2849 self.assertEqual(
str(path),
'c+a+b')
2850 p._validateSequence(path,
'p1')
2852 p2 =
Path(p.c+p.s*notInProcess)
2853 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2863 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2867 self.assertFalse(service._inProcess)
2870 self.assertTrue(service._inProcess)
2872 process.d = service2
2873 self.assertFalse(service._inProcess)
2874 self.assertTrue(service2._inProcess)
2876 self.assertFalse(service2._inProcess)
2890 service3 =
Service(
"d", v = untracked.uint32(3))
2896 testTask1 =
Task(edproducer, edfilter)
2897 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2898 testTask1.add(essource, service)
2899 testTask1.add(essource, esproducer)
2900 testTask1.add(testTask2)
2901 coll = testTask1._collection
2902 self.assertTrue(edproducer
in coll)
2903 self.assertTrue(edfilter
in coll)
2904 self.assertTrue(service
in coll)
2905 self.assertTrue(essource
in coll)
2906 self.assertTrue(esproducer
in coll)
2907 self.assertTrue(testTask2
in coll)
2908 self.assertTrue(len(coll) == 6)
2909 self.assertTrue(len(testTask2._collection) == 0)
2913 taskContents.append(i)
2914 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2919 process.mproducer = edproducer
2920 process.mproducer2 = edproducer2
2921 process.mfilter = edfilter
2922 process.messource = essource
2923 process.mesproducer = esproducer
2926 testTask3 =
Task(edproducer, edproducer2)
2927 testTask1.add(testTask3)
2928 process.myTask1 = testTask1
2935 testTask1.visit(visitor)
2936 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2937 l2 = testTask1.moduleNames
2938 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2940 testTask4 =
Task(edproducer3)
2942 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2944 process.myTask4 = testTask4
2945 self.assertTrue(
False)
2946 except RuntimeError:
2949 testTask5 =
Task(service3)
2951 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2953 process.myTask5 = testTask5
2954 self.assertTrue(
False)
2955 except RuntimeError:
2958 process.d = service3
2959 process.myTask5 = testTask5
2962 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2964 self.assertTrue(process.tasks == expectedFixedDict)
2965 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2966 self.assertTrue(process.myTask1 == testTask1)
2970 process.mproducer2 = edproducer4
2974 testTask1.visit(visitor1)
2975 l.sort(key=
lambda mod: mod.__str__())
2976 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2977 self.assertTrue(expectedList == l)
2978 process.myTask6 =
Task()
2979 process.myTask7 =
Task()
2980 process.mproducer8 = edproducer8
2981 process.myTask8 =
Task(process.mproducer8)
2982 process.myTask6.add(process.myTask7)
2983 process.myTask7.add(process.myTask8)
2984 process.myTask1.add(process.myTask6)
2985 process.myTask8.add(process.myTask5)
2987 testDict = process._itemsInDependencyOrder(process.tasks)
2988 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2989 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2991 for testLabel, testTask
in testDict.items():
2992 self.assertTrue(testLabel == expectedLabels[index])
2993 self.assertTrue(testTask == expectedTasks[index])
2999 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 3000 self.assertTrue(pythonDump == expectedPythonDump)
3002 process.myTask5 =
Task()
3003 process.myTask100 =
Task()
3004 process.mproducer9 = edproducer9
3005 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3006 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3007 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3009 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3010 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3011 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3012 process.path2 =
Path(process.mproducer)
3013 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3015 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')
3017 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')
3022 process.path1.visit(nameVisitor)
3023 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3024 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3028 process.path21 = process.path11.copy()
3029 process.path21.replace(process.mproducer, process.mproducer10)
3031 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')
3040 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')
3042 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3043 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')
3045 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3046 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')
3055 process.path24 =
Path(process.a+process.b+process.c+process.d)
3056 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
3057 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
3062 process.path200.replace(process.c,process.b)
3063 process.path200.replace(process.e,process.f)
3064 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
3065 process.path200.replace(process.b,process.c)
3066 process.path200.replace(process.f,process.e)
3067 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3068 process.path200.replace(process.c,process.a)
3069 process.path200.replace(process.e,process.g)
3070 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
3071 process.path200.replace(process.a,process.c)
3072 process.path200.replace(process.g,process.e)
3073 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3087 service3 =
Service(
"d", v = untracked.uint32(3))
3095 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
3096 testTask1.add(essource, service)
3097 testTask1.add(essource, esproducer)
3098 testTask1.add(testTask2)
3099 testTask1.add(testCTask2)
3100 coll = testTask1._collection
3101 self.assertTrue(edproducer
in coll)
3102 self.assertTrue(edfilter
in coll)
3103 self.assertTrue(service
in coll)
3104 self.assertTrue(essource
in coll)
3105 self.assertTrue(esproducer
in coll)
3106 self.assertTrue(testTask2
in coll)
3107 self.assertTrue(testCTask2
in coll)
3108 self.assertTrue(len(coll) == 7)
3109 self.assertTrue(len(testTask2._collection) == 0)
3113 taskContents.append(i)
3114 self.assertEqual(taskContents, [edproducer, edfilter, essource, service, esproducer, testTask2, testCTask2])
3119 process.mproducer = edproducer
3120 process.mproducer2 = edproducer2
3121 process.mfilter = edfilter
3122 process.messource = essource
3123 process.mesproducer = esproducer
3127 testTask1.add(testTask3)
3128 process.myTask1 = testTask1
3135 testTask1.visit(visitor)
3136 self.assertEqual(l, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3137 l2 = testTask1.moduleNames()
3138 self.assertEqual(l2, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3142 self.assertRaises(RuntimeError, testTask4.visit, visitor)
3144 process.myTask4 = testTask4
3145 self.assertTrue(
False)
3146 except RuntimeError:
3151 self.assertRaises(RuntimeError, testTask5.visit, visitor)
3153 process.myTask5 = testTask5
3154 self.assertTrue(
False)
3155 except RuntimeError:
3158 process.d = service3
3159 process.myTask5 = testTask5
3162 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
3164 self.assertEqual(process.conditionaltasks, expectedFixedDict)
3165 self.assertEqual(process.conditionaltasks[
'myTask1'], testTask1)
3166 self.assertEqual(process.myTask1, testTask1)
3170 process.mproducer2 = edproducer4
3174 testTask1.visit(visitor1)
3175 l.sort(key=
lambda mod: mod.__str__())
3176 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
3177 self.assertEqual(expectedList, l)
3180 process.mproducer8 = edproducer8
3182 process.myTask6.add(process.myTask7)
3183 process.myTask7.add(process.myTask8)
3184 process.myTask1.add(process.myTask6)
3185 process.myTask8.add(process.myTask5)
3186 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3188 testDict = process._itemsInDependencyOrder(process.conditionaltasks)
3189 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
3190 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
3192 for testLabel, testTask
in testDict.items():
3193 self.assertEqual(testLabel, expectedLabels[index])
3194 self.assertEqual(testTask, expectedTasks[index])
3200 expectedPythonDump =
'cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 3201 self.assertEqual(pythonDump, expectedPythonDump)
3204 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3206 process.mproducer9 = edproducer9
3207 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3208 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3209 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3211 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3212 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3213 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3214 process.path2 =
Path(process.mproducer)
3215 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3217 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')
3219 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')
3224 process.path1.visit(nameVisitor)
3225 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3226 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3230 process.path21 = process.path11.copy()
3231 process.path21.replace(process.mproducer, process.mproducer10)
3233 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')
3242 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')
3244 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3245 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')
3247 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3248 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')
3257 process.fillProcessDesc(p)
3258 self.assertEqual(p.values[
"@all_modules"], (
True, [
'b',
'b2',
'b3']))
3259 self.assertEqual(p.values[
"@paths"], (
True, [
'p']))
3260 self.assertEqual(p.values[
"p"], (
True, [
'b',
'#',
'b2',
'b3',
'@']))
3271 self.assertEqual(
str(path),
'a+b+c')
3272 path =
Path(p.a*p.b+p.c)
3273 self.assertEqual(
str(path),
'a+b+c')
3276 path =
Path(p.a+ p.b*p.c)
3277 self.assertEqual(
str(path),
'a+b+c')
3278 path =
Path(p.a*(p.b+p.c))
3279 self.assertEqual(
str(path),
'a+b+c')
3280 path =
Path(p.a*(p.b+~p.c))
3282 self.assertEqual(
str(path),
'a+b+~c')
3284 self.assertRaises(TypeError,Path,p.es)
3287 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path()\n')
3290 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a)\n')
3293 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.Task())\n')
3296 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task())\n')
3301 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3304 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.ConditionalTask())\n')
3307 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.ConditionalTask())\n')
3312 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3322 self.assertEqual(
str(path),
'a+b+c')
3324 self.assertEqual(
str(path),
'a+b+c')
3326 self.assertEqual(
str(path),
'a+b+c')
3328 self.assertEqual(
str(path),
'a+b+c')
3330 self.assertRaises(TypeError,FinalPath, p.es)
3333 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath()\n')
3336 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3338 self.assertRaises(TypeError, FinalPath,
Task())
3339 self.assertRaises(TypeError, FinalPath, p.a,
Task())
3343 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
Task(), p.t1)
3347 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
ConditionalTask(), p.t1)
3351 self.assertEqual(p.t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3356 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3361 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3366 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3371 p.fillProcessDesc(pset)
3382 p.path =
Path(p.a*p.b)
3383 lookuptable = {
id(a): p.a,
id(b): p.b}
3387 self.assertEqual(
str(path),
str(p.path))
3409 path =
Path(a * c * seq1, task1, ctask1)
3411 self.assertTrue(path.contains(a))
3412 self.assertFalse(path.contains(b))
3413 self.assertTrue(path.contains(c))
3414 self.assertFalse(path.contains(d))
3415 self.assertTrue(path.contains(e))
3416 self.assertFalse(path.contains(f))
3417 self.assertTrue(path.contains(g))
3418 self.assertTrue(path.contains(h))
3421 self.assertFalse(endpath.contains(b))
3422 self.assertTrue(endpath.contains(i))
3425 self.assertFalse(seq.contains(b))
3426 self.assertTrue(seq.contains(c))
3429 task =
Task(j, k, task2)
3430 self.assertFalse(task.contains(b))
3431 self.assertTrue(task.contains(j))
3432 self.assertTrue(task.contains(k))
3433 self.assertTrue(task.contains(l))
3437 sch =
Schedule(path, path2, tasks=[task,task3])
3438 self.assertFalse(sch.contains(b))
3439 self.assertTrue(sch.contains(a))
3440 self.assertTrue(sch.contains(c))
3441 self.assertTrue(sch.contains(e))
3442 self.assertTrue(sch.contains(g))
3443 self.assertTrue(sch.contains(n))
3444 self.assertTrue(sch.contains(j))
3445 self.assertTrue(sch.contains(k))
3446 self.assertTrue(sch.contains(l))
3447 self.assertTrue(sch.contains(m))
3451 self.assertFalse(ctask.contains(b))
3452 self.assertTrue(ctask.contains(j))
3453 self.assertTrue(ctask.contains(k))
3454 self.assertTrue(ctask.contains(l))
3455 self.assertTrue(ctask.contains(g))
3468 self.assertEqual(s[0],p.path1)
3469 self.assertEqual(s[1],p.path2)
3471 self.assertTrue(
'b' in p.schedule.moduleNames())
3472 self.assertTrue(hasattr(p,
'b'))
3473 self.assertTrue(hasattr(p,
'c'))
3474 self.assertTrue(hasattr(p,
'd'))
3475 self.assertTrue(hasattr(p,
'path1'))
3476 self.assertTrue(hasattr(p,
'path2'))
3477 self.assertTrue(hasattr(p,
'path3'))
3479 self.assertTrue(
'b' in p.schedule.moduleNames())
3480 self.assertTrue(hasattr(p,
'b'))
3481 self.assertTrue(
not hasattr(p,
'c'))
3482 self.assertTrue(
not hasattr(p,
'd'))
3483 self.assertTrue(hasattr(p,
'path1'))
3484 self.assertTrue(hasattr(p,
'path2'))
3485 self.assertTrue(
not hasattr(p,
'path3'))
3487 self.assertTrue(len(p.schedule._tasks) == 0)
3501 p.task2 =
Task(p.f, p.Tracer)
3502 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
3503 self.assertEqual(s[0],p.path1)
3504 self.assertEqual(s[1],p.path2)
3505 self.assertTrue(len(s._tasks) == 2)
3506 self.assertTrue(p.task1
in s._tasks)
3507 self.assertTrue(p.task2
in s._tasks)
3508 listOfTasks = list(s._tasks)
3509 self.assertTrue(len(listOfTasks) == 2)
3510 self.assertTrue(p.task1 == listOfTasks[0])
3511 self.assertTrue(p.task2 == listOfTasks[1])
3513 self.assertTrue(
'b' in p.schedule.moduleNames())
3518 process2.path1 =
Path(process2.a)
3519 process2.task1 =
Task(process2.e)
3520 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
3521 listOfTasks = list(process2.schedule._tasks)
3522 self.assertTrue(listOfTasks[0] == process2.task1)
3526 self.assertEqual(s2[0],p.path1)
3527 self.assertEqual(s2[1],p.path2)
3528 self.assertTrue(len(s2._tasks) == 2)
3529 self.assertTrue(p.task1
in s2._tasks)
3530 self.assertTrue(p.task2
in s2._tasks)
3531 listOfTasks = list(s2._tasks)
3532 self.assertTrue(len(listOfTasks) == 2)
3533 self.assertTrue(p.task1 == listOfTasks[0])
3534 self.assertTrue(p.task2 == listOfTasks[1])
3536 names = s.moduleNames()
3537 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
3543 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
3552 self.assertTrue(
'a' in s.moduleNames())
3553 self.assertTrue(
'b' in s.moduleNames())
3554 self.assertTrue(
'c' in s.moduleNames())
3558 self.assertTrue(
'a' in s.moduleNames())
3559 self.assertTrue(
'b' in s.moduleNames())
3560 self.assertTrue(
'c' in s.moduleNames())
3569 self.assertTrue(p.schedule
is None)
3572 self.assertEqual(pths[keys[0]],p.path1)
3573 self.assertEqual(pths[keys[1]],p.path2)
3575 self.assertTrue(hasattr(p,
'a'))
3576 self.assertTrue(hasattr(p,
'b'))
3577 self.assertTrue(
not hasattr(p,
'c'))
3578 self.assertTrue(hasattr(p,
'path1'))
3579 self.assertTrue(hasattr(p,
'path2'))
3588 self.assertTrue(p.schedule
is None)
3591 self.assertEqual(pths[keys[1]],p.path1)
3592 self.assertEqual(pths[keys[0]],p.path2)
3599 self.assertEqual(p.modu.a.value(),1)
3600 self.assertEqual(p.modu.b.value(),2)
3605 self.assertTrue(
not a.isModified())
3607 self.assertTrue(a.isModified())
3609 self.assertEqual(p.a.a1.value(), 1)
3613 self.assertEqual(p.a.a1.value(), 2)
3622 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
3623 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
3627 self.assertEqual(p.options.numberOfThreads.value(),1)
3628 p.options.numberOfThreads = 8
3629 self.assertEqual(p.options.numberOfThreads.value(),8)
3631 self.assertEqual(p.options.numberOfThreads.value(),1)
3632 p.options = dict(numberOfStreams =2,
3634 self.assertEqual(p.options.numberOfThreads.value(),2)
3635 self.assertEqual(p.options.numberOfStreams.value(),2)
3637 self.assertRaises(TypeError, setattr, p,
'options', untracked.PSet(numberOfThreads =
int32(-1)))
3638 p.options = untracked.PSet(numberOfThreads = untracked.uint32(4))
3639 self.assertEqual(p.options.numberOfThreads.value(), 4)
3643 p.maxEvents.input = 10
3644 self.assertEqual(p.maxEvents.input.value(),10)
3646 p.maxEvents.output = 10
3647 self.assertEqual(p.maxEvents.output.value(),10)
3649 p.maxEvents.output =
PSet(out=untracked.int32(10))
3650 self.assertEqual(p.maxEvents.output.out.value(), 10)
3652 p.maxEvents = untracked.PSet(input = untracked.int32(5))
3653 self.assertEqual(p.maxEvents.input.value(), 5)
3655 self.assertRaises(TypeError, setattr, p,
'maxEvents', untracked.PSet(input = untracked.uint32(1)))
3656 p.maxEvents = untracked.PSet(input = untracked.int32(1))
3657 self.assertEqual(p.maxEvents.input.value(), 1)
3665 p.bars.foos =
'Foosball' 3666 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
3667 p.p =
Path(p.foos*p.bars)
3669 p.add_(
Service(
"MessageLogger"))
3675 p.prefer(
"ForceSource")
3678 """process.juicer = cms.ESProducer("JuicerProducer") 3679 process.ForceSource = cms.ESSource("ForceSource") 3680 process.prefer("ForceSource") 3681 process.prefer("juicer")""")
3682 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
3684 """process.juicer = cms.ESProducer("JuicerProducer") 3685 process.ForceSource = cms.ESSource("ForceSource") 3686 process.prefer("ForceSource") 3687 process.prefer("juicer", 3688 fooRcd = cms.vstring('Foo') 3703 self.assertEqual(process.m.p.i.value(), 4)
3713 subProcess.p =
Path(subProcess.a)
3714 subProcess.add_(
Service(
"Foo"))
3715 process.addSubProcess(
SubProcess(subProcess))
3716 d = process.dumpPython()
3717 equalD =
"""parentProcess = process 3718 process.a = cms.EDProducer("A") 3719 process.Foo = cms.Service("Foo") 3720 process.p = cms.Path(process.a) 3721 childProcess = process 3722 process = parentProcess 3723 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 3724 ), outputCommands = cms.untracked.vstring()))""" 3725 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
3733 messageLoggerSplit =
'process.MessageLogger = cms.Service' 3735 childProcess =
Process(
'Child')
3736 del childProcess.MessageLogger
3737 combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
3738 self.assertEqual(
_lineDiff(d, combinedDump), equalD)
3740 process.fillProcessDesc(p)
3741 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
3742 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
3743 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
3753 proc.fillProcessDesc(p)
3754 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
3755 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
3756 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
3757 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
3758 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
3759 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
3768 self.assertEqual(proc.sp.label_(),
"sp")
3769 self.assertEqual(proc.sp.test1.label_(),
"sp@test1")
3770 self.assertEqual(proc.sp.test2.label_(),
"sp@test2")
3773 proc.s =
Sequence(proc.a + proc.sp)
3774 proc.t =
Task(proc.a, proc.sp)
3776 proc.p.associate(proc.t)
3778 proc.fillProcessDesc(p)
3779 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3780 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3781 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3782 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3784 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3785 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3786 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
3787 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3788 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
3789 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3790 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3791 dump = proc.dumpPython()
3792 self.assertEqual(dump.find(
'@'), -1)
3793 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
3794 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
3803 proc.s =
Sequence(proc.a + proc.sp)
3804 proc.t =
Task(proc.a, proc.sp)
3806 proc.p.associate(proc.t)
3808 proc.fillProcessDesc(p)
3809 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3810 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3811 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3812 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3814 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3815 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3816 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
3817 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
3818 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3819 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3820 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3821 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
3830 proc.s =
Sequence(proc.a + proc.sp)
3831 proc.t =
Task(proc.a, proc.sp)
3833 proc.p.associate(proc.t)
3835 proc.fillProcessDesc(p)
3836 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3837 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3838 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3839 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
3840 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3841 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
3842 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
3843 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3844 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
3845 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3846 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
3857 proc.spp = proc.spct.clone()
3860 proc.p =
Path(proc.a, proc.ct)
3861 proc.pp =
Path(proc.a + proc.spp)
3863 proc.fillProcessDesc(p)
3864 self.assertEqual([
"a",
"spct",
"spct@test1",
"spct@test2",
"spp",
"spp@test1",
"spp@test2"], p.values[
"@all_modules"][1])
3865 self.assertEqual([
"a",
"#",
"spct",
"spct@test1",
"spct@test2",
"@"], p.values[
"p"][1])
3866 self.assertEqual([
"a",
"spp",
"#",
"spp@test1",
"spp@test2",
"@"], p.values[
"pp"][1])
3881 p.t3 =
Task(p.g, p.t1)
3885 p.path1 =
Path(p.a, p.t3, p.ct3)
3887 self.assertTrue(p.schedule
is None)
3890 self.assertEqual(pths[keys[0]],p.path1)
3891 self.assertEqual(pths[keys[1]],p.path2)
3893 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
3895 p.vpset2 = untracked.VPSet()
3897 self.assertTrue(hasattr(p,
'a'))
3898 self.assertTrue(hasattr(p,
'b'))
3899 self.assertTrue(
not hasattr(p,
'c'))
3900 self.assertTrue(
not hasattr(p,
'd'))
3901 self.assertTrue(hasattr(p,
'e'))
3902 self.assertTrue(
not hasattr(p,
'f'))
3903 self.assertTrue(hasattr(p,
'g'))
3904 self.assertTrue(hasattr(p,
'h'))
3905 self.assertTrue(
not hasattr(p,
's'))
3906 self.assertTrue(hasattr(p,
't1'))
3907 self.assertTrue(
not hasattr(p,
't2'))
3908 self.assertTrue(hasattr(p,
't3'))
3909 self.assertTrue(hasattr(p,
'path1'))
3910 self.assertTrue(hasattr(p,
'path2'))
3940 p.path1 =
Path(p.a, p.t3, p.ct3)
3942 p.path3 =
Path(p.b+p.s2)
3943 p.path4 =
Path(p.b+p.s3)
3944 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3945 p.schedule.associate(p.t4)
3948 self.assertEqual(pths[keys[0]],p.path1)
3949 self.assertEqual(pths[keys[1]],p.path2)
3951 self.assertTrue(hasattr(p,
'a'))
3952 self.assertTrue(hasattr(p,
'b'))
3953 self.assertTrue(
not hasattr(p,
'c'))
3954 self.assertTrue(
not hasattr(p,
'd'))
3955 self.assertTrue(
not hasattr(p,
'e'))
3956 self.assertTrue(
not hasattr(p,
'f'))
3957 self.assertTrue(hasattr(p,
'g'))
3958 self.assertTrue(hasattr(p,
'h'))
3959 self.assertTrue(hasattr(p,
'i'))
3960 self.assertTrue(hasattr(p,
'j'))
3961 self.assertTrue(hasattr(p,
'k'))
3962 self.assertTrue(
not hasattr(p,
'l'))
3963 self.assertTrue(
not hasattr(p,
't1'))
3964 self.assertTrue(hasattr(p,
't2'))
3965 self.assertTrue(hasattr(p,
't3'))
3966 self.assertTrue(hasattr(p,
't4'))
3967 self.assertTrue(
not hasattr(p,
'ct1'))
3968 self.assertTrue(hasattr(p,
'ct2'))
3969 self.assertTrue(hasattr(p,
'ct3'))
3970 self.assertTrue(
not hasattr(p,
'ct4'))
3971 self.assertTrue(
not hasattr(p,
's'))
3972 self.assertTrue(hasattr(p,
's2'))
3973 self.assertTrue(
not hasattr(p,
's3'))
3974 self.assertTrue(hasattr(p,
'path1'))
3975 self.assertTrue(hasattr(p,
'path2'))
3976 self.assertTrue(hasattr(p,
'path3'))
3977 self.assertTrue(
not hasattr(p,
'path4'))
3985 self.assertTrue(hasattr(p,
'a'))
3986 self.assertTrue(hasattr(p,
'b'))
3987 self.assertTrue(hasattr(p,
's'))
3988 self.assertTrue(hasattr(p,
'pth'))
3994 p.prune(keepUnresolvedSequencePlaceholders=
True)
3995 self.assertTrue(hasattr(p,
'b'))
3996 self.assertTrue(hasattr(p,
's'))
3997 self.assertTrue(hasattr(p,
'pth'))
3998 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
4006 self.assertTrue(hasattr(p,
'a'))
4007 self.assertTrue(hasattr(p,
'b'))
4008 self.assertTrue(hasattr(p,
's'))
4009 self.assertTrue(hasattr(p,
'pth'))
4017 self.assertTrue(hasattr(p,
'a'))
4018 self.assertTrue(hasattr(p,
'b'))
4019 self.assertTrue(hasattr(p,
's'))
4020 self.assertTrue(hasattr(p,
'pth'))
4026 p.prune(keepUnresolvedSequencePlaceholders=
True)
4027 self.assertTrue(hasattr(p,
'b'))
4028 self.assertTrue(hasattr(p,
's'))
4029 self.assertTrue(hasattr(p,
'pth'))
4030 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
4038 p.path1 =
Path(p.b, p.t2, p.t3)
4041 p.endpath1 =
EndPath(p.b, p.t5)
4045 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
4055 """process.a = cms.EDProducer("ma") 4056 process.c = cms.EDProducer("mc") 4057 process.d = cms.EDProducer("md") 4058 process.e = cms.EDProducer("me") 4059 process.f = cms.EDProducer("mf") 4060 process.g = cms.EDProducer("mg") 4061 process.h = cms.EDProducer("mh") 4062 process.i = cms.EDProducer("mi") 4063 process.j = cms.EDProducer("mj") 4064 process.b = cms.EDAnalyzer("mb") 4065 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 4066 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 4067 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 4068 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 4069 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 4070 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 4071 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 4072 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 4073 process.path1 = cms.Path(process.b, process.t2, process.t3) 4074 process.endpath1 = cms.EndPath(process.b, process.t5) 4075 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4078 """process.a = cms.EDProducer("ma") 4079 process.c = cms.EDProducer("mc") 4080 process.d = cms.EDProducer("md") 4081 process.e = cms.EDProducer("me") 4082 process.f = cms.EDProducer("mf") 4083 process.g = cms.EDProducer("mg") 4084 process.h = cms.EDProducer("mh") 4085 process.i = cms.EDProducer("mi") 4086 process.j = cms.EDProducer("mj") 4087 process.b = cms.EDAnalyzer("mb") 4088 process.t1 = cms.Task(process.c) 4089 process.t2 = cms.Task(process.a, process.d, process.t1) 4090 process.t3 = cms.Task(process.e) 4091 process.t4 = cms.Task(process.f) 4092 process.t6 = cms.Task(process.h) 4093 process.t7 = cms.Task(process.a, process.i, process.t6) 4094 process.t8 = cms.Task(process.j) 4095 process.t5 = cms.Task(process.a, process.g, process.t4) 4096 process.path1 = cms.Path(process.b, process.t2, process.t3) 4097 process.endpath1 = cms.EndPath(process.b, process.t5) 4098 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4106 p.path1 =
Path(p.b, p.t2, p.t3)
4109 p.path2 =
Path(p.b, p.t5)
4110 p.schedule =
Schedule(p.path1, p.path2)
4120 """process.a = cms.EDProducer("ma") 4121 process.c = cms.EDProducer("mc") 4122 process.d = cms.EDProducer("md") 4123 process.e = cms.EDProducer("me") 4124 process.f = cms.EDProducer("mf") 4125 process.g = cms.EDProducer("mg") 4126 process.h = cms.EDProducer("mh") 4127 process.i = cms.EDProducer("mi") 4128 process.j = cms.EDProducer("mj") 4129 process.b = cms.EDAnalyzer("mb") 4130 process.t1 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("c")) 4131 process.t2 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("d"), process.a, process.t1) 4132 process.t3 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("e")) 4133 process.t5 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("g"), cms.ConditionalTaskPlaceholder("t4"), process.a) 4134 process.t4 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("f")) 4135 process.path1 = cms.Path(process.b, process.t2, process.t3) 4136 process.path2 = cms.Path(process.b, process.t5) 4137 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4140 """process.a = cms.EDProducer("ma") 4141 process.c = cms.EDProducer("mc") 4142 process.d = cms.EDProducer("md") 4143 process.e = cms.EDProducer("me") 4144 process.f = cms.EDProducer("mf") 4145 process.g = cms.EDProducer("mg") 4146 process.h = cms.EDProducer("mh") 4147 process.i = cms.EDProducer("mi") 4148 process.j = cms.EDProducer("mj") 4149 process.b = cms.EDAnalyzer("mb") 4150 process.t1 = cms.ConditionalTask(process.c) 4151 process.t2 = cms.ConditionalTask(process.a, process.d, process.t1) 4152 process.t3 = cms.ConditionalTask(process.e) 4153 process.t4 = cms.ConditionalTask(process.f) 4154 process.t5 = cms.ConditionalTask(process.a, process.g, process.t4) 4155 process.path1 = cms.Path(process.b, process.t2, process.t3) 4156 process.path2 = cms.Path(process.b, process.t5) 4157 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4173 p.t1 =
Task(p.g, p.h, p.i)
4174 t2 =
Task(p.g, p.h, p.i)
4182 p.path1 =
Path(p.a+p.f+p.s,t2,ct2)
4184 p.path3 =
Path(ct3, p.ct4)
4187 p.schedule =
Schedule(p.path2, p.path3, p.endpath2, tasks=[t3, p.t4])
4188 self.assertTrue(hasattr(p,
'f'))
4189 self.assertTrue(hasattr(p,
'g'))
4190 self.assertTrue(hasattr(p,
'i'))
4195 self.assertFalse(hasattr(p,
'f'))
4196 self.assertFalse(hasattr(p,
'g'))
4197 self.assertEqual(p.t1.dumpPython(),
'cms.Task(process.h)\n')
4198 self.assertEqual(p.ct1.dumpPython(),
'cms.ConditionalTask(process.h)\n')
4199 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(process.d)\n')
4200 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+process.s, cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4201 self.assertEqual(p.endpath1.dumpPython(),
'cms.EndPath(process.b)\n')
4202 self.assertEqual(p.path3.dumpPython(),
'cms.Path(cms.ConditionalTask(process.h), process.ct4)\n')
4204 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+(process.d), cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4205 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path2, process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4207 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4209 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4211 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h), process.t4])\n')
4213 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
4216 Process._firstProcess =
True 4218 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4220 Process._firstProcess =
True 4225 m1.toModify(p.a,_mod_fred)
4226 self.assertEqual(p.a.fred.value(),2)
4228 m1.toModify(p.b, wilma = 2)
4229 self.assertEqual(p.b.wilma.value(),2)
4230 self.assertTrue(p.isUsingModifier(m1))
4233 Process._firstProcess =
True 4236 m1.toModify(p.a,_mod_fred)
4238 m1.toModify(p.b, wilma = 2)
4239 self.assertEqual(p.a.fred.value(),1)
4240 self.assertEqual(p.b.wilma.value(),1)
4241 self.assertEqual(p.isUsingModifier(m1),
False)
4244 Process._firstProcess =
True 4247 m1.toModify(p.a, fred =
int32(2))
4248 p.b = p.a.clone(wilma =
int32(3))
4249 self.assertEqual(p.a.fred.value(),2)
4250 self.assertEqual(p.a.wilma.value(),1)
4251 self.assertEqual(p.b.fred.value(),2)
4252 self.assertEqual(p.b.wilma.value(),3)
4255 Process._firstProcess =
True 4258 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4259 self.assertEqual(hasattr(p.a,
"fred"),
False)
4260 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4261 self.assertEqual(p.a.wilma.value(),1)
4264 Process._firstProcess =
True 4267 m1.toModify(p.a, wilma =
int32(2))
4268 self.assertEqual(p.a.fred.value(), 1)
4269 self.assertEqual(p.a.wilma.value(),2)
4272 Process._firstProcess =
True 4275 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
4276 self.assertEqual(p.a.flintstones.fred.value(),2)
4277 self.assertEqual(p.a.flintstones.wilma.value(),1)
4280 Process._firstProcess =
True 4283 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4284 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4287 Process._firstProcess =
True 4290 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
4291 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4292 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4295 Process._firstProcess =
True 4298 m1.toModify(p.a, fred = {1:7})
4299 self.assertEqual(p.a.fred[0],1)
4300 self.assertEqual(p.a.fred[1],7)
4301 self.assertEqual(p.a.fred[2],3)
4304 Process._firstProcess =
True 4308 try: m1.toModify(p.a, fred = {5:7})
4309 except IndexError
as e: raised =
True 4310 self.assertEqual(raised,
True)
4313 Process._firstProcess =
True 4317 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
4318 except TypeError
as e: raised =
True 4319 self.assertEqual(raised,
True)
4323 class ProcModifierMod(
object):
4329 testMod = DummyMod()
4331 self.assertTrue(hasattr(p,
"a"))
4333 Process._firstProcess =
True 4335 testProcMod = ProcModifierMod(m1,_rem_a)
4337 p.extend(testProcMod)
4338 self.assertTrue(
not hasattr(p,
"a"))
4342 Process._firstProcess =
True 4344 self.assertTrue(p.isUsingModifier(m1))
4345 self.assertTrue(p.isUsingModifier(mc))
4346 testMod = DummyMod()
4348 m1.toModify(p.b, fred =
int32(3))
4350 testProcMod = ProcModifierMod(m1,_rem_a)
4351 p.extend(testProcMod)
4352 self.assertTrue(
not hasattr(p,
"a"))
4353 self.assertEqual(p.b.fred.value(),3)
4358 mclone = mc.copyAndExclude([m2])
4359 self.assertTrue(
not mclone._isOrContains(m2))
4360 self.assertTrue(mclone._isOrContains(m1))
4363 mclone = mc2.copyAndExclude([m2])
4364 self.assertTrue(
not mclone._isOrContains(m2))
4365 self.assertTrue(mclone._isOrContains(m1))
4366 self.assertTrue(mclone._isOrContains(m3))
4370 Process._firstProcess =
True 4373 (m1 & m2).toModify(p.a, fred =
int32(2))
4374 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4375 self.assertEqual(p.a.fred, 1)
4378 Process._firstProcess =
True 4381 (m1 & m2).toModify(p.a, fred =
int32(2))
4382 self.assertEqual(p.a.fred, 2)
4386 Process._firstProcess =
True 4389 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
4390 self.assertEqual(p.a.fred, 2)
4391 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
4392 self.assertEqual(p.a.fred, 3)
4393 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
4394 self.assertEqual(p.a.fred, 4)
4398 Process._firstProcess =
True 4401 (~m1).toModify(p.a, fred=2)
4402 self.assertEqual(p.a.fred, 1)
4403 (~m2).toModify(p.a, wilma=2)
4404 self.assertEqual(p.a.wilma, 2)
4405 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4406 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4411 Process._firstProcess =
True 4414 (m1 | m2).toModify(p.a, fred=2)
4415 self.assertEqual(p.a.fred, 2)
4416 (m1 | m2 | m3).toModify(p.a, fred=3)
4417 self.assertEqual(p.a.fred, 3)
4418 (m3 | m2 | m1).toModify(p.a, fred=4)
4419 self.assertEqual(p.a.fred, 4)
4420 ((m1 | m2) | m3).toModify(p.a, fred=5)
4421 self.assertEqual(p.a.fred, 5)
4422 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4423 self.assertEqual(p.a.fred, 6)
4424 (m2 | m3).toModify(p.a, fred=7)
4425 self.assertEqual(p.a.fred, 6)
4426 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4427 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4433 Process._firstProcess =
True 4436 (m1 & ~m2).toModify(p.a, fred=2)
4437 self.assertEqual(p.a.fred, 1)
4438 (m1 & ~m3).toModify(p.a, fred=2)
4439 self.assertEqual(p.a.fred, 2)
4440 (m1 | ~m2).toModify(p.a, fred=3)
4441 self.assertEqual(p.a.fred, 3)
4442 (~m1 | ~m2).toModify(p.a, fred=4)
4443 self.assertEqual(p.a.fred, 3)
4444 (~m3 & ~m4).toModify(p.a, fred=4)
4445 self.assertEqual(p.a.fred, 4)
4446 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4447 self.assertEqual(p.a.fred, 5)
4450 Process._firstProcess =
True 4454 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4462 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4463 self.assertEqual(p.a.wilma.value(),3)
4464 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4465 self.assertEqual(hasattr(p,
"fred"),
False)
4466 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4468 m1.toReplaceWith(p.td,
Task(p.e))
4469 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4479 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4480 self.assertEqual(p.a.wilma.value(),3)
4481 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4482 self.assertEqual(hasattr(p,
"fred"),
False)
4483 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4486 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4489 Process._firstProcess =
True 4493 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4499 Process._firstProcess =
True 4502 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4503 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4504 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4505 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4506 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4507 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4508 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
4509 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4510 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4511 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4512 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4513 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4514 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4515 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4516 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
4517 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4518 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
4519 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4524 Process._firstProcess =
True 4528 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4529 self.assertEqual(p.a.fred, 2)
4530 self.assertEqual(p.a.wilma, 1)
4531 self.assertEqual(p.b.barney, 1)
4532 self.assertEqual(p.b.betty, 3)
4533 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4534 self.assertEqual(p.a.fred, 2)
4535 self.assertEqual(p.a.wilma, 4)
4536 self.assertEqual(p.b.barney, 5)
4537 self.assertEqual(p.b.betty, 3)
4538 (m2 & ~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4539 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4540 self.assertEqual(p.b.barney, 6)
4541 self.assertEqual(p.b.betty, 3)
4542 (m1 & ~m3).toModify(p.a, param=
int32(42)).toReplaceWith(p.b,
EDProducer(
"YourProducer"))
4543 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4544 self.assertEqual(p.a.param, 42)
4545 self.assertEqual(p.b.type_(),
"YourProducer")
4552 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4553 self.assertEqual(a.foo2[0].type,
"Foo3")
4556 self.assertEqual(a.foo2[0].type,
"Foo3")
4557 self.assertEqual(a.foo4[0].type,
"Foo4")
4559 m.toModify(a, foo2 =
None)
4560 self.assertFalse(hasattr(a,
"foo2"))
4561 self.assertEqual(a.foo4[0].type,
"Foo4")
4564 self.assertFalse(hasattr(a,
"foo2"))
4565 self.assertFalse(hasattr(a,
"foo4"))
4566 self.assertTrue(hasattr(a,
"bar"))
4567 self.assertEqual(a.bar[0].type,
"Bar")
4580 test1 = dict(a = 4, b = dict(c =
None)),
4581 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4582 self.assertEqual(sp.test1.a.value(), 4)
4583 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4584 self.assertEqual(sp.test2.aa.value(), 15)
4585 self.assertEqual(sp.test2.bb.cc.value(), 45)
4586 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4589 self.assertEqual(sp.test1.type_(),
"Fred")
4590 self.assertEqual(sp.test1.x.value(), 42)
4591 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
4594 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4595 self.assertEqual(sp.test2.x.value(), 24)
4596 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
4599 self.assertEqual(sp.test3.type_(),
"Wilma")
4600 self.assertEqual(sp.test3.y.value(), 24)
4601 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
4603 m.toModify(sp, test2 =
None)
4604 self.assertEqual(hasattr(sp,
"test2"),
False)
4607 self.assertTrue(hasattr(sp.test2,
"foo"))
4610 self.assertTrue(hasattr(sp.test2,
"bar"))
4613 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4615 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
4621 p.maxEvents.input = 10
4622 p.options.numberOfThreads = 4
4623 p.maxLuminosityBlocks.input = 2
4625 self.assertEqual(p.maxEvents.input.value(),10)
4626 self.assertEqual(p.options.numberOfThreads.value(), 4)
4627 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
4633 self.assertTrue(hasattr(p,
'fltr'))
4637 p.TestService =
Service(
"TestService")
4638 self.assertTrue(hasattr(proc,
"TestService"))
4639 self.assertEqual(proc.TestService.type_(),
"TestService")
4640 self.assertRaises(TypeError, setattr, p,
"a",
EDProducer(
"Foo"))
4641 p.add_(
Service(
"TestServiceTwo"))
4642 self.assertTrue(hasattr(proc,
"TestServiceTwo"))
4643 self.assertEqual(proc.TestServiceTwo.type_(),
"TestServiceTwo")
4644 p.TestService.foo = untracked.uint32(42)
4645 self.assertEqual(proc.TestService.foo.value(), 42)
4647 self.assertRaises(TypeError, getattr, p,
"mod")
4651 proc.fillProcessDesc(p)
4652 self.assertTrue([
"cpu"], p.values[
"@available_accelerators"][1])
4653 self.assertFalse(p.values[
"@selected_accelerators"][0])
4654 self.assertTrue([
"cpu"], p.values[
"@selected_accelerators"][1])
4655 self.assertFalse(p.values[
"@module_type_resolver"][0])
4656 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4661 del proc.MessageLogger
4663 self.assertEqual(proc.dumpPython(),
4664 """import FWCore.ParameterSet.Config as cms 4665 from test import ProcessAcceleratorTest 4667 process = cms.Process("TEST") 4669 process.maxEvents = cms.untracked.PSet( 4670 input = cms.optional.untracked.int32, 4671 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 4674 process.maxLuminosityBlocks = cms.untracked.PSet( 4675 input = cms.untracked.int32(-1) 4678 process.options = cms.untracked.PSet( 4679 IgnoreCompletely = cms.untracked.vstring(), 4680 Rethrow = cms.untracked.vstring(), 4681 TryToContinue = cms.untracked.vstring(), 4682 accelerators = cms.untracked.vstring('*'), 4683 allowUnscheduled = cms.obsolete.untracked.bool, 4684 canDeleteEarly = cms.untracked.vstring(), 4685 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 4686 dumpOptions = cms.untracked.bool(False), 4687 emptyRunLumiMode = cms.obsolete.untracked.string, 4688 eventSetup = cms.untracked.PSet( 4689 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 4690 allowAnyLabel_=cms.required.untracked.uint32 4692 numberOfConcurrentIOVs = cms.untracked.uint32(0) 4694 fileMode = cms.untracked.string('FULLMERGE'), 4695 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 4696 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 4697 makeTriggerResults = cms.obsolete.untracked.bool, 4698 modulesToCallForTryToContinue = cms.untracked.vstring(), 4699 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 4700 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 4701 numberOfConcurrentRuns = cms.untracked.uint32(1), 4702 numberOfStreams = cms.untracked.uint32(0), 4703 numberOfThreads = cms.untracked.uint32(1), 4704 printDependencies = cms.untracked.bool(False), 4705 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 4706 throwIfIllegalParameter = cms.untracked.bool(True), 4707 wantSummary = cms.untracked.bool(False) 4710 process.ProcessAcceleratorTest = ProcessAcceleratorTest( 4711 enabled = ['test1', 'test2', 'anothertest3'] 4717 proc.fillProcessDesc(p)
4718 self.assertEqual([
"*"], p.values[
"options"][1].values[
"accelerators"][1])
4719 self.assertFalse(p.values[
"options"][1].values[
"accelerators"][0])
4720 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4721 self.assertEqual(
"AcceleratorTestService", p.values[
"services"][1][0].values[
"@service_type"][1])
4722 self.assertFalse(p.values[
"@available_accelerators"][0])
4723 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4724 self.assertFalse(p.values[
"@module_type_resolver"][0])
4725 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4729 proc.add_(
Service(
"AcceleratorTestServiceRemove"))
4731 proc.fillProcessDesc(p)
4732 services = [x.values[
"@service_type"][1]
for x
in p.values[
"services"][1]]
4733 self.assertTrue(
"AcceleratorTestService" in services)
4734 self.assertFalse(
"AcceleratorTestServiceRemove" in services)
4739 proc.fillProcessDesc(p)
4740 self.assertEqual([
"cpu",
"test1"], p.values[
"@selected_accelerators"][1])
4741 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4745 proc.options.accelerators = [
"test2"]
4747 proc.fillProcessDesc(p)
4748 self.assertEqual([
"test2"], p.values[
"@selected_accelerators"][1])
4749 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4753 proc.options.accelerators = [
"test*"]
4754 proc.fillProcessDesc(p)
4755 self.assertEqual([
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4756 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4760 proc.options.accelerators = [
"test2"]
4762 proc.fillProcessDesc(p)
4763 self.assertEqual([], p.values[
"@selected_accelerators"][1])
4764 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4768 proc.options.accelerators = [
"cpu*"]
4770 proc.fillProcessDesc(p)
4771 self.assertEqual([
"cpu"], p.values[
"@selected_accelerators"][1])
4772 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4776 proc.options.accelerators = [
"test3"]
4778 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4782 proc.options.accelerators = [
"*",
"test1"]
4784 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4790 proc.fillProcessDesc(p)
4791 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4792 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4797 proc.options.accelerators = [
"*test3",
"c*"]
4799 proc.fillProcessDesc(p)
4800 self.assertEqual([
"anothertest3",
"cpu"], p.values[
"@selected_accelerators"][1])
4801 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4811 proc.p =
Path(proc.sp)
4813 proc.fillProcessDesc(p)
4814 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4824 proc.p =
Path(proc.sp)
4826 proc.fillProcessDesc(p)
4827 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4831 proc.options.accelerators = [
"test1"]
4838 proc.p =
Path(proc.sp)
4840 proc.fillProcessDesc(p)
4841 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4845 proc.options.accelerators = [
"test*"]
4852 proc.p =
Path(proc.sp)
4854 proc.fillProcessDesc(p)
4855 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4859 proc.options.accelerators = [
"anothertest3"]
4866 proc.p =
Path(proc.sp)
4868 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4874 proc.normalProducer =
EDProducer(
"FooProducer")
4875 proc.testProducer =
EDProducer(
"BarProducer@test")
4876 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4877 proc.testAnalyzer =
EDAnalyzer(
"Analyzer@test")
4879 proc.testESProducer =
ESProducer(
"ESProducer@test")
4880 proc.testESSource =
ESSource(
"ESSource@test")
4881 proc.p =
Path(proc.normalProducer+proc.testProducer+proc.test2Producer+proc.testAnalyzer+proc.testFilter)
4883 proc.fillProcessDesc(p)
4884 self.assertEqual(
"TestModuleTypeResolver", p.values[
"@module_type_resolver"][1])
4885 self.assertEqual(
"FooProducer", p.values[
"normalProducer"][1].values[
"@module_type"][1])
4886 self.assertEqual(len(list(
filter(
lambda x:
not "@" in x, p.values[
"normalProducer"][1].values.keys()))), 0)
4887 self.assertEqual(
"BarProducer@test", p.values[
"testProducer"][1].values[
"@module_type"][1])
4888 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][0])
4889 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][0])
4890 self.assertEqual(
"test1_backend", p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][1])
4891 self.assertEqual(
"BarProducer@test", p.values[
"test2Producer"][1].values[
"@module_type"][1])
4892 self.assertEqual(
"test2_backend", p.values[
"test2Producer"][1].values[
"test"][1].values[
"backend"][1])
4893 self.assertEqual(
"Analyzer@test", p.values[
"testAnalyzer"][1].values[
"@module_type"][1])
4894 self.assertEqual(
"test1_backend", p.values[
"testAnalyzer"][1].values[
"test"][1].values[
"backend"][1])
4895 self.assertEqual(
"Filter@test", p.values[
"testFilter"][1].values[
"@module_type"][1])
4896 self.assertEqual(
"test1_backend", p.values[
"testFilter"][1].values[
"test"][1].values[
"backend"][1])
4897 self.assertEqual(
"ESProducer@test", p.values[
"ESProducer@test@testESProducer"][1].values[
"@module_type"][1])
4898 self.assertEqual(
"test1_backend", p.values[
"ESProducer@test@testESProducer"][1].values[
"test"][1].values[
"backend"][1])
4899 self.assertEqual(
"ESSource@test", p.values[
"ESSource@test@testESSource"][1].values[
"@module_type"][1])
4900 self.assertEqual(
"test1_backend", p.values[
"ESSource@test@testESSource"][1].values[
"test"][1].values[
"backend"][1])
4906 proc.options.accelerators = []
4907 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4912 proc.options.accelerators = [
"test1"]
4913 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4914 proc.p =
Path(proc.test2Producer)
4915 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4924 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4935 proc.p =
Path(proc.sp)
4936 pkl = pickle.dumps(proc)
4937 unpkl = pickle.loads(pkl)
4939 unpkl.fillProcessDesc(p)
4940 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4941 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4942 unpkl = pickle.loads(pkl)
4943 unpkl.ProcessAcceleratorTest.setEnabled([
"test1"])
4945 unpkl.fillProcessDesc(p)
4946 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4947 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 testConditionalTaskPlaceholder(self)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def __init__(self, enabled=["anothertest3", anothertest4, moduleTypeResolverMaker=None)
def _place(self, label, process)
def testServiceInProcess(self)
def addString(self, tracked, label, value)
def __findFirstUsingModule(self, seqsOrTasks, mod)
def _pruneModules(self, d, scheduledNames)
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
def __init__(self, process)
def _dumpConfigUnnamedList
def _insertPaths(self, processPSet, nodeVisitor)
def apply(self, process, accelerators)
bool any(const std::vector< T > &v, const T &what)
def addVESInputTag(self, tracked, label, value)
def _dumpConfigOptionallyNamedList
def _switchproducer_test2_case2(accelerators)
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 addDouble(self, tracked, label, value)
def dumpPythonImpl(self, options)
def moduleTypeResolver(self, accelerators)
def _placeConditionalTask
def apply(self, process, accelerators)
def __init__(self, kargs)
def apply(self, process, accelerators)
def _dumpPythonSubProcesses
def __updateOptions(self, opt)
def _replaceInConditionalTasks
def addVUInt64(self, tracked, label, value)
def _validateConditionalTask
def testProcessForProcessAccelerator(self)
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 _insertSubProcessesInto
def __init__(self, accelerators)
def _lineDiff(newString, oldString)
def dumpPythonImpl(self, options)
def format_outerframe(number)
def __init__(self, args, kw)
def _raiseUnknownKey(key)
def addUInt32(self, tracked, label, value)
def setLooper_(self, lpr)
def setSource_(self, src)
def extend(self, other, items=())
def __getattr__(self, label)
def addVInt32(self, tracked, label, value)
def handleProcessAccelerators(self, parameterSet)
def addVInputTag(self, tracked, label, value)
def _applyNewProcessModifiers(self, process)
def addLuminosityBlockID(self, tracked, label, value)
def addESInputTag(self, tracked, label, value)
def __new__(cls, args, kw)
def toModify(self, obj, func=None, kw)
def setEnabled(self, enabled)
def 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 addFileInPath(self, tracked, label, value)
def _replaceInScheduleDirectly
def __init__(self, lhs, rhs=None)
def _insertSwitchProducersInto
def moduleTypeResolver(self, accelerators)
def _toModify(obj, func, kw)
def __init__(self, modifier, func)
def _toReplaceWith(toObj, fromObj)
def _toModifyCheck(obj, func, kw)
def isUsingModifier(self, mod)
def __copyIfExclude(self, toExclude)
def split(sequence, size)
def testParameterizable(self)
def __init__(self, enabled=["test1", test2, anothertest3, moduleTypeResolverMaker=None)
def addPSet(self, tracked, label, value)
def testProcessDumpPython(self)
def _switchproducer_test2_case1(accelerators)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def dumpPython(process, name)
def testConditionalTask(self)
def dumpPython(self, options=PrintOptions())
def _toReplaceWithCheck(toObj, fromObj)
def switchProducerNames(self)
def toReplaceWith(self, toObj, fromObj)
def prefer(self, esmodule, args, kargs)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def checkImportPermission
def addInputTag(self, tracked, label, value)
def testCloneSequence(self)
def makeProcessModifier(self, func)
def addSubProcess(self, mod)
def switchProducers_(self)
def _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def addService(process, multirun=False)
def testProcessExtend(self)
def __insertValue(self, tracked, label, value)
def __init__(self, kargs)
def setModuleVariant(self, module)
def __getValue(self, tracked, label)
def _place(self, name, proc)
def processAccelerators_(self)
def addBool(self, tracked, label, value)
def addEventID(self, tracked, label, value)
def testImplicitSchedule(self)
def addVDouble(self, tracked, label, value)
def _insertInto(self, parameterSet, itemDict)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def dumpPythonImpl(self, options)
def addInt32(self, tracked, label, value)
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)