4 from __future__
import print_function
5 from __future__
import absolute_import
7 from .Options
import Options
13 from .Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
16 from .Modules
import *
17 from .Modules
import _Module
18 from .SequenceTypes
import *
19 from .SequenceTypes
import _ModuleSequenceType, _Sequenceable
20 from .SequenceVisitors
import PathValidator, EndPathValidator, FinalPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
21 from .MessageLogger
import MessageLogger
22 from .
import DictTypes
24 from .ExceptionHandling
import *
27 if sys.getrecursionlimit()<5000:
28 sys.setrecursionlimit(5000)
33 Configuration =
"{Configuration}" 34 UnavailableAccelerator =
"{UnavailableAccelerator}" 43 Raise an exception if called by special config files. This checks 44 the call or import stack for the importing file. An exception is raised if 45 the importing module is not in allowedPatterns and if it is called too deeply: 46 minLevel = 2: inclusion by top lvel cfg only 47 minLevel = 1: No inclusion allowed 48 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 49 by any module in Module1 or Submodule1 55 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'FWCore/ParameterSet/python/Config.py',
'<string>',
'<frozen ']
56 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
60 for item
in inspect.stack():
64 for pattern
in CMSSWPath:
65 if item[1].
find(pattern) != -1:
68 if item[1].
find(
'/') == -1:
71 for pattern
in ignorePatterns:
72 if item[1].
find(pattern) != -1:
76 if inPath
and not ignore:
77 trueStack.append(item[1])
79 importedFile = trueStack[0]
81 if len(trueStack) > 1:
82 importedBy = trueStack[1]
84 for pattern
in allowedPatterns:
85 if importedBy.find(pattern) > -1:
88 if len(trueStack) <= minLevel:
91 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files." 95 """Look inside the module and find the Processes it contains""" 99 if isinstance(module,dict):
100 if 'process' in module:
101 p = module[
'process']
104 if hasattr(module,
'process'):
105 if isinstance(module.process,Process):
106 process = module.process
108 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
110 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
114 """Root class for a CMS configuration process""" 117 """The argument 'name' will be the name applied to this Process 118 Can optionally pass as additional arguments cms.Modifier instances 119 that will be used to modify the Process as it is built 121 self.__dict__[
'_Process__name'] = name
122 if not name.isalnum():
123 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
124 self.__dict__[
'_Process__filters'] = {}
125 self.__dict__[
'_Process__producers'] = {}
126 self.__dict__[
'_Process__switchproducers'] = {}
127 self.__dict__[
'_Process__source'] =
None 128 self.__dict__[
'_Process__looper'] =
None 129 self.__dict__[
'_Process__subProcesses'] = []
130 self.__dict__[
'_Process__schedule'] =
None 131 self.__dict__[
'_Process__analyzers'] = {}
132 self.__dict__[
'_Process__outputmodules'] = {}
136 self.__dict__[
'_Process__sequences'] = {}
137 self.__dict__[
'_Process__tasks'] = {}
138 self.__dict__[
'_Process__conditionaltasks'] = {}
139 self.__dict__[
'_Process__services'] = {}
140 self.__dict__[
'_Process__essources'] = {}
141 self.__dict__[
'_Process__esproducers'] = {}
142 self.__dict__[
'_Process__esprefers'] = {}
143 self.__dict__[
'_Process__aliases'] = {}
144 self.__dict__[
'_Process__psets']={}
145 self.__dict__[
'_Process__vpsets']={}
146 self.__dict__[
'_cloneToObjectDict'] = {}
148 self.__dict__[
'_Process__InExtendCall'] =
False 149 self.__dict__[
'_Process__partialschedules'] = {}
151 self.__dict__[
'_Process__modifiers'] = Mods
152 self.__dict__[
'_Process__accelerators'] = {}
161 if Process._firstProcess:
162 Process._firstProcess =
False 165 for m
in self.__modifiers:
166 if not m._isChosen():
167 raise RuntimeError(
"The Process {} tried to redefine which Modifiers to use after another Process was already started".
format(name))
168 for m
in self.__modifiers:
173 _Module.__isStrict__ =
True 177 """Returns a string containing all the EDProducer labels separated by a blank""" 180 """Returns a string containing all the SwitchProducer labels separated by a blank""" 183 """Returns a string containing all the EDAnalyzer labels separated by a blank""" 186 """Returns a string containing all the EDFilter labels separated by a blank""" 189 """Returns a string containing all the Path names separated by a blank""" 196 Since cloneToObjectDict stores a hash of objects by their 197 id() it needs to be updated when unpickling to use the 198 new object id values instantiated during the unpickle. 201 self.__dict__.
update(pkldict)
203 for value
in self._cloneToObjectDict.
values():
204 tmpDict[
id(value)] = value
205 self.__dict__[
'_cloneToObjectDict'] = tmpDict
210 """returns a dict of the filters that have been added to the Process""" 212 filters = property(filters_, doc=
"dictionary containing the filters for the process")
216 if not name.isalnum():
217 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
218 self.__dict__[
'_Process__name'] = name
219 process = property(name_,setName_, doc=
"name of the process")
221 """returns a dict of the producers that have been added to the Process""" 223 producers = property(producers_,doc=
"dictionary containing the producers for the process")
225 """returns a dict of the SwitchProducers that have been added to the Process""" 227 switchProducers = property(switchProducers_,doc=
"dictionary containing the SwitchProducers for the process")
229 """returns the source that has been added to the Process or None if none have been added""" 233 source = property(source_,setSource_,doc=
'the main source or None if not set')
235 """returns the looper that has been added to the Process or None if none have been added""" 239 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
242 return untracked.PSet(numberOfThreads = untracked.uint32(1),
243 numberOfStreams = untracked.uint32(0),
244 numberOfConcurrentRuns = untracked.uint32(1),
245 numberOfConcurrentLuminosityBlocks = untracked.uint32(0),
246 eventSetup = untracked.PSet(
247 numberOfConcurrentIOVs = untracked.uint32(0),
248 forceNumberOfConcurrentIOVs = untracked.PSet(
249 allowAnyLabel_ = required.untracked.uint32
252 accelerators = untracked.vstring(
'*'),
253 wantSummary = untracked.bool(
False),
254 fileMode = untracked.string(
'FULLMERGE'),
255 forceEventSetupCacheClearOnNewRun = untracked.bool(
False),
256 throwIfIllegalParameter = untracked.bool(
True),
257 printDependencies = untracked.bool(
False),
258 deleteNonConsumedUnscheduledModules = untracked.bool(
True),
259 sizeOfStackForThreadsInKB = optional.untracked.uint32,
260 Rethrow = untracked.vstring(),
261 TryToContinue = untracked.vstring(),
262 IgnoreCompletely = untracked.vstring(),
263 modulesToCallForTryToContinue = untracked.vstring(),
264 canDeleteEarly = untracked.vstring(),
265 holdsReferencesToDeleteEarly = untracked.VPSet(),
266 modulesToIgnoreForDeleteEarly = untracked.vstring(),
267 dumpOptions = untracked.bool(
False),
268 allowUnscheduled = obsolete.untracked.bool,
269 emptyRunLumiMode = obsolete.untracked.string,
270 makeTriggerResults = obsolete.untracked.bool,
274 if isinstance(opt,dict):
275 for k,v
in opt.items():
278 for p
in opt.parameters_():
279 setattr(newOpts, p, getattr(opt,p))
283 return untracked.PSet(input=optional.untracked.int32,
284 output=optional.untracked.allowed(int32,PSet))
287 if isinstance(ps,dict):
288 for k,v
in ps.items():
291 for p
in ps.parameters_():
292 setattr(newMax, p, getattr(ps,p))
296 return untracked.PSet(input=untracked.int32(-1))
298 """returns a list of the subProcesses that have been added to the Process""" 299 return self.__subProcesses
300 subProcesses = property(subProcesses_,doc=
'the SubProcesses that have been added to the Process')
302 """returns a dict of the analyzers that have been added to the Process""" 304 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
306 """returns a dict of the output modules that have been added to the Process""" 308 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
310 """returns a dict of the paths that have been added to the Process""" 312 paths = property(paths_,doc=
"dictionary containing the paths for the process")
314 """returns a dict of the endpaths that have been added to the Process""" 316 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
318 """returns a dict of the finalpaths that have been added to the Process""" 320 finalpaths = property(finalpaths_,doc=
"dictionary containing the finalpaths for the process")
322 """returns a dict of the sequences that have been added to the Process""" 324 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
326 """returns a dict of the tasks that have been added to the Process""" 328 tasks = property(tasks_,doc=
"dictionary containing the tasks for the process")
330 """returns a dict of the conditionaltasks that have been added to the Process""" 332 conditionaltasks = property(conditionaltasks_,doc=
"dictionary containing the conditionatasks for the process")
334 """returns the schedule that has been added to the Process or None if none have been added""" 335 return self.__schedule
337 if label ==
"schedule":
340 self.
_place(label, sch, self.__partialschedules)
349 raise RuntimeError(
"The path at index "+
str(index)+
" in the Schedule was not attached to the process.")
350 self.__dict__[
'_Process__schedule'] = sch
351 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
353 """returns a dict of the services that have been added to the Process""" 355 services = property(services_,doc=
"dictionary containing the services for the process")
357 """returns a dict of the ProcessAccelerators that have been added to the Process""" 359 processAccelerators = property(processAccelerators_,doc=
"dictionary containing the ProcessAccelerators for the process")
361 """returns a dict of the esproducers that have been added to the Process""" 363 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
365 """returns a the es_sources that have been added to the Process""" 367 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
369 """returns a dict of the es_prefers that have been added to the Process""" 371 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
373 """returns a dict of the aliases that have been added to the Process""" 375 aliases = property(aliases_,doc=
"dictionary containing the aliases for the process")
377 """returns a dict of the PSets that have been added to the Process""" 379 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
381 """returns a dict of the VPSets that have been added to the Process""" 383 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
386 """returns True if the Modifier is in used by this Process""" 388 for m
in self.__modifiers:
389 if m._isOrContains(mod):
394 if not object.hasLabel_() :
395 object.setLabel(newLabel)
397 if newLabel == object.label_() :
399 if newLabel
is None :
400 object.setLabel(
None)
402 if (hasattr(self, object.label_())
and id(getattr(self, object.label_())) ==
id(object)) :
403 msg100 =
"Attempting to change the label of an attribute of the Process\n" 404 msg101 =
"Old label = "+object.label_()+
" New label = "+newLabel+
"\n" 405 msg102 =
"Type = "+
str(type(object))+
"\n" 406 msg103 =
"Some possible solutions:\n" 407 msg104 =
" 1. Clone modules instead of using simple assignment. Cloning is\n" 408 msg105 =
" also preferred for other types when possible.\n" 409 msg106 =
" 2. Declare new names starting with an underscore if they are\n" 410 msg107 =
" for temporaries you do not want propagated into the Process. The\n" 411 msg108 =
" underscore tells \"from x import *\" and process.load not to import\n" 412 msg109 =
" the name.\n" 413 msg110 =
" 3. Reorganize so the assigment is not necessary. Giving a second\n" 414 msg111 =
" name to the same object usually causes confusion and problems.\n" 415 msg112 =
" 4. Compose Sequences: newName = cms.Sequence(oldName)\n" 416 raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
417 object.setLabel(
None)
418 object.setLabel(newLabel)
422 if not name.replace(
'_',
'').isalnum():
423 raise ValueError(
'The label '+name+
' contains forbiden characters')
425 if name ==
'options':
427 if name ==
'maxEvents':
431 if name.startswith(
'_Process__'):
432 self.__dict__[name]=value
434 if not isinstance(value,_ConfigureComponent):
435 raise TypeError(
"can only assign labels to an object that inherits from '_ConfigureComponent'\n" 436 +
"an instance of "+
str(type(value))+
" will not work - requested label is "+name)
437 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
438 if name == value.type_():
439 if hasattr(self,name)
and (getattr(self,name)!=value):
446 raise TypeError(
"an instance of "+
str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
447 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
450 newValue =value.copy()
452 newValue._filename = value._filename
458 if not self.
_okToPlace(name, value, self.__dict__):
459 newFile=
'top level config' 460 if hasattr(value,
'_filename'):
461 newFile = value._filename
462 oldFile=
'top level config' 463 oldValue = getattr(self,name)
464 if hasattr(oldValue,
'_filename'):
465 oldFile = oldValue._filename
466 msg =
"Trying to override definition of process."+name
467 msg +=
"\n new object defined in: "+newFile
468 msg +=
"\n existing object defined in: "+oldFile
469 raise ValueError(msg)
471 if hasattr(self,name)
and not (getattr(self,name)==newValue):
475 if newValue._isTaskComponent():
476 if not self.__InExtendCall:
481 if not isinstance(newValue, Task):
483 newFile=
'top level config' 484 if hasattr(value,
'_filename'):
485 newFile = value._filename
486 oldFile=
'top level config' 487 oldValue = getattr(self,name)
488 if hasattr(oldValue,
'_filename'):
489 oldFile = oldValue._filename
490 msg1 =
"Trying to override definition of "+name+
" while it is used by the task " 491 msg2 =
"\n new object defined in: "+newFile
492 msg2 +=
"\n existing object defined in: "+oldFile
495 raise ValueError(msg1+s.label_()+msg2)
497 if isinstance(newValue, _Sequenceable)
or newValue._isTaskComponent()
or isinstance(newValue, ConditionalTask):
498 if not self.__InExtendCall:
499 if isinstance(newValue, ConditionalTask):
504 newFile=
'top level config' 505 if hasattr(value,
'_filename'):
506 newFile = value._filename
507 oldFile=
'top level config' 508 oldValue = getattr(self,name)
509 if hasattr(oldValue,
'_filename'):
510 oldFile = oldValue._filename
511 msg1 =
"Trying to override definition of "+name+
" while it is used by the " 512 msg2 =
"\n new object defined in: "+newFile
513 msg2 +=
"\n existing object defined in: "+oldFile
516 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
519 raise ValueError(msg1+
"path "+s.label_()+msg2)
522 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
525 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
528 if isinstance(newValue, EDAlias):
529 oldValue = getattr(self, name)
531 newFile=
'top level config' 532 if hasattr(value,
'_filename'):
533 newFile = value._filename
534 oldFile=
'top level config' 535 if hasattr(oldValue,
'_filename'):
536 oldFile = oldValue._filename
537 msg1 =
"Trying to override definition of "+name+
" with an EDAlias while it is used by the " 538 msg2 =
"\n new object defined in: "+newFile
539 msg2 +=
"\n existing object defined in: "+oldFile
542 raise ValueError(msg1+
"task "+s.label_()+msg2)
545 raise ValueError(msg1+
"sequence "+s.label_()+msg2)
548 raise ValueError(msg1+
"path "+s.label_()+msg2)
551 raise ValueError(msg1+
"endpath "+s.label_()+msg2)
554 raise ValueError(msg1+
"finalpath "+s.label_()+msg2)
556 if not self.__InExtendCall
and (Schedule._itemIsValid(newValue)
or isinstance(newValue, Task)):
564 self.__dict__[name]=newValue
565 if isinstance(newValue,_Labelable):
567 self._cloneToObjectDict[
id(value)] = newValue
568 self._cloneToObjectDict[
id(newValue)] = newValue
570 newValue._place(name,self)
572 """Given a container of sequences or tasks, find the first sequence or task 573 containing mod and return it. If none is found, return None""" 576 for seqOrTask
in seqsOrTasks.values():
585 if not hasattr(self,name):
586 raise KeyError(
'process does not know about '+name)
587 elif name.startswith(
'_Process__'):
588 raise ValueError(
'this attribute cannot be deleted')
593 if name
in reg: del reg[name]
595 obj = getattr(self,name)
596 if isinstance(obj,_Labelable):
598 if isinstance(obj,Service):
599 obj._inProcess =
False 603 obj = getattr(self,name)
605 if not isinstance(obj, Sequence)
and not isinstance(obj, Task)
and not isinstance(obj,ConditionalTask):
615 if obj._isTaskComponent():
619 if isinstance(obj, _Sequenceable)
or obj._isTaskComponent():
621 if Schedule._itemIsValid(obj)
or isinstance(obj, Task):
625 del self.__dict__[name]
630 """Similar to __delattr__ but we need different behavior when called from __setattr__""" 634 del self.__dict__[name]
639 """Allows addition of components that do not have to have a label, e.g. Services""" 640 if not isinstance(value,_ConfigureComponent):
642 if not isinstance(value,_Unlabelable):
646 newValue =value.copy()
650 newValue._place(
'',self)
653 if not self.__InExtendCall:
664 if d[name]._isModified:
675 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
676 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
679 if isinstance(mod,_Labelable):
682 self.
_place(name, mod, self.__outputmodules)
684 self.
_place(name, mod, self.__producers)
686 self.
_place(name, mod, self.__switchproducers)
688 self.
_place(name, mod, self.__filters)
690 self.
_place(name, mod, self.__analyzers)
694 self.
_place(name, mod, self.__paths)
695 except ModuleCloneError
as msg:
697 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
701 self.
_place(name, mod, self.__endpaths)
702 except ModuleCloneError
as msg:
704 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
708 self.
_place(name, mod, self.__finalpaths)
709 except ModuleCloneError
as msg:
711 raise Exception(
"%sThe module %s in finalpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
714 self.
_place(name, mod, self.__sequences)
716 self.
_place(name, mod, self.__esproducers)
718 self.
_place(name, mod, self.__esprefers)
720 self.
_place(name, mod, self.__essources)
723 self.
_place(name, task, self.__tasks)
726 self.
_place(name, task, self.__conditionaltasks)
728 self.
_place(name, mod, self.__aliases)
730 self.
_place(name, mod, self.__psets)
732 self.
_place(name, mod, self.__vpsets)
734 """Allow the source to be referenced by 'source' or by type name""" 736 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
737 if self.__dict__[
'_Process__source']
is not None :
738 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
739 self.__dict__[
'_Process__source'] = mod
740 self.__dict__[mod.type_()] = mod
743 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
744 self.__dict__[
'_Process__looper'] = mod
745 self.__dict__[mod.type_()] = mod
747 self.__dict__[
'_Process__subProcess'] = mod
748 self.__dict__[mod.type_()] = mod
750 self.__subProcesses.
append(mod)
752 self.
_place(typeName, mod, self.__services)
753 if typeName
in self.__dict__:
754 self.__dict__[typeName]._inProcess =
False 755 self.__dict__[typeName]=mod
757 self.
_place(typeName, mod, self.__accelerators)
758 self.__dict__[typeName]=mod
760 moduleName = moduleName.replace(
"/",
".")
761 module = __import__(moduleName)
762 self.
extend(sys.modules[moduleName])
764 """Look in other and find types that we can use""" 766 self.__dict__[
'_Process__InExtendCall'] =
True 769 tasksToAttach = dict()
771 for name
in dir(other):
773 if name.startswith(
'_'):
775 item = getattr(other,name)
776 if name ==
"source" or name ==
"looper":
780 elif isinstance(item,_ModuleSequenceType):
782 elif isinstance(item,Task)
or isinstance(item, ConditionalTask):
783 tasksToAttach[name] = item
784 elif isinstance(item,_Labelable):
786 if not item.hasLabel_() :
788 elif isinstance(item,Schedule):
790 elif isinstance(item,_Unlabelable):
792 elif isinstance(item,ProcessModifier):
794 elif isinstance(item,ProcessFragment):
798 for name,seq
in seqs.items():
799 if id(seq)
not in self._cloneToObjectDict:
802 newSeq = self._cloneToObjectDict[
id(seq)]
803 self.__dict__[name]=newSeq
806 newSeq._place(name,self)
808 for name, task
in tasksToAttach.items():
815 self.__dict__[
'_Process__InExtendCall'] =
False 819 for name,item
in items:
820 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
825 for name,item
in items:
826 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
831 for name,item
in items:
832 if name == item.type_():
834 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
838 """return a string containing the equivalent process defined using the old configuration language""" 839 config =
"process "+self.__name+
" = {\n" 892 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
894 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
896 pathNames = [p.label_()
for p
in self.
schedule]
897 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n' 909 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
915 returnValue += item.dumpPython(options)+
'\n\n' 921 for name,item
in d.items():
922 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 924 for name,item
in sorted(d.items()):
925 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n' 932 dependencies = item.directDependencies()
933 for module_subfolder, module
in dependencies:
934 module = module +
'_cfi' 935 if options.useSubdirectories
and module_subfolder:
936 module = module_subfolder +
'.' + module
937 if options.targetDirectory
is not None:
938 if options.useSubdirectories
and subfolder:
939 module =
'..' + module
941 module =
'.' + module
942 code +=
'from ' + module +
' import *\n' 945 code += name +
' = ' + item.dumpPython(options)
946 parts[name] = subfolder, code
954 sequence.visit(visitor)
955 except Exception
as e:
956 raise RuntimeError(
"An entry in sequence {} has no label\n Seen entries: {}\n Error: {}".
format(label, l, e))
965 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
973 raise RuntimeError(
"An entry in task " + label +
' has not been attached to the process')
985 for label,item
in processDictionaryOfItems.items():
987 if isinstance(item, Task):
989 elif isinstance(item, ConditionalTask):
996 if isinstance(item, Task):
997 raise RuntimeError(
"Failed in a Task visitor. Probably " \
998 "a circular dependency discovered in Task with label " + label)
999 elif isinstance(item, ConditionalTask):
1000 raise RuntimeError(
"Failed in a ConditionalTask visitor. Probably " \
1001 "a circular dependency discovered in ConditionalTask with label " + label)
1003 raise RuntimeError(
"Failed in a Sequence visitor. Probably a " \
1004 "circular dependency discovered in Sequence with label " + label)
1005 for containedItem
in containedItems:
1011 if containedItem.hasLabel_():
1012 testItem = processDictionaryOfItems.get(containedItem.label_())
1013 if testItem
is None or containedItem != testItem:
1014 if isinstance(item, Task):
1015 raise RuntimeError(
"Task has a label, but using its label to get an attribute" \
1016 " from the process yields a different object or None\n"+
1017 "label = " + containedItem.label_())
1018 if isinstance(item, ConditionalTask):
1019 raise RuntimeError(
"ConditionalTask has a label, but using its label to get an attribute" \
1020 " from the process yields a different object or None\n"+
1021 "label = " + containedItem.label_())
1023 raise RuntimeError(
"Sequence has a label, but using its label to get an attribute" \
1024 " from the process yields a different object or None\n"+
1025 "label = " + containedItem.label_())
1026 dependencies[label]=[dep.label_()
for dep
in containedItems
if dep.hasLabel_()]
1030 oldDeps = dict(dependencies)
1031 for label,deps
in oldDeps.items():
1033 returnValue[label]=processDictionaryOfItems[label]
1035 del dependencies[label]
1036 for lb2,deps2
in dependencies.items():
1037 while deps2.count(label):
1043 for name, value
in sorted(d.items()):
1044 result += value.dumpPythonAs(name,options)+
'\n' 1049 for name, value
in sorted(d.items()):
1050 result[name] = subfolder, value.dumpPythonAs(name, options) +
'\n' 1054 """return a string containing the equivalent process defined using python""" 1055 specialImportRegistry._reset()
1056 header =
"import FWCore.ParameterSet.Config as cms" 1057 result =
"process = cms.Process(\""+self.__name+
"\")\n\n" 1084 imports = specialImportRegistry.getSpecialImports()
1085 if len(imports) > 0:
1086 header +=
"\n" +
"\n".
join(imports)
1088 return header+result
1091 """return a map of file names to python configuration fragments""" 1092 specialImportRegistry._reset()
1094 options.isCfg =
False 1095 header =
"import FWCore.ParameterSet.Config as cms" 1100 result =
'process = cms.Process("' + self.__name +
'")\n\n' 1113 sys.stderr.write(
"error: subprocesses are not supported yet\n\n")
1130 if options.targetDirectory
is not None:
1131 files[options.targetDirectory +
'/__init__.py'] =
'' 1133 if options.useSubdirectories:
1134 for sub
in 'psets',
'modules',
'services',
'eventsetup',
'tasks',
'sequences',
'paths':
1135 if options.targetDirectory
is not None:
1136 sub = options.targetDirectory +
'/' + sub
1137 files[sub +
'/__init__.py'] =
'' 1140 parts = sorted(parts.items(), key =
lambda nsc: (nsc[1][0].lower()
if nsc[1][0]
else '', nsc[0].lower()))
1142 for (name, (subfolder, code))
in parts:
1143 filename = name +
'_cfi' 1144 if options.useSubdirectories
and subfolder:
1145 filename = subfolder +
'/' + filename
1146 if options.targetDirectory
is not None:
1147 filename = options.targetDirectory +
'/' + filename
1148 result +=
'process.load("%s")\n' % filename
1149 files[filename +
'.py'] = header +
'\n\n' + code
1152 options.isCfg =
True 1155 imports = specialImportRegistry.getSpecialImports()
1156 if len(imports) > 0:
1157 header +=
'\n' +
'\n'.
join(imports)
1158 files[
'-'] = header +
'\n\n' + result
1162 old = getattr(self,label)
1169 sequenceable._replaceIfHeldDirectly(old,new)
1171 sequenceable.replace(old,new)
1173 sequenceable.replace(old,new)
1175 sequenceable.replace(old,new)
1177 sequenceable.replace(old,new)
1179 old = getattr(self,label)
1181 task.replace(old, new)
1183 old = getattr(self,label)
1185 task.replace(old, new)
1189 old = getattr(self,label)
1191 task.replace(old, new)
1195 old = getattr(self,label)
1196 self.
schedule_()._replaceIfHeldDirectly(old, new)
1198 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks""" 1199 if not hasattr(self,label):
1200 raise LookupError(
"process has no item of label "+label)
1201 setattr(self,label,new)
1203 for name,value
in itemDict.items():
1204 value.insertInto(parameterSet, name)
1207 if not item ==
None:
1208 newlabel = item.nameInProcessDesc_(label)
1210 item.insertInto(parameterSet, newlabel)
1211 parameterSet.addVString(tracked, label, vitems)
1214 for name,value
in itemDict.items():
1215 value.appendToProcessDescList_(l, name)
1216 value.insertInto(parameterSet, name)
1219 parameterSet.addVString(tracked, label, l)
1221 modules = parameterSet.getVString(tracked, labelModules)
1222 aliases = parameterSet.getVString(tracked, labelAliases)
1223 accelerators = parameterSet.getVString(
False,
"@selected_accelerators")
1224 for name,value
in itemDict.items():
1225 value.appendToProcessDescLists_(modules, aliases, name)
1226 value.insertInto(parameterSet, name, accelerators)
1229 parameterSet.addVString(tracked, labelModules, modules)
1230 parameterSet.addVString(tracked, labelAliases, aliases)
1234 for value
in itemList:
1235 name = value.getProcessName()
1236 newLabel = value.nameInProcessDesc_(name)
1238 pset = value.getSubProcessPSet(parameterSet)
1239 subprocs.append(pset)
1242 parameterSet.addVString(tracked, label, l)
1243 parameterSet.addVPSet(
False,
"subProcesses",subprocs)
1251 for name
in self.
paths_():
1252 scheduledPaths.append(name)
1253 triggerPaths.append(name)
1255 scheduledPaths.append(name)
1256 endpaths.append(name)
1258 finalpaths.append(name)
1261 pathname = path.label_()
1263 endpaths.append(pathname)
1264 scheduledPaths.append(pathname)
1266 finalpaths.append(pathname)
1268 scheduledPaths.append(pathname)
1269 triggerPaths.append(pathname)
1271 task.resolve(self.__dict__)
1273 task.visit(scheduleTaskValidator)
1274 task.visit(nodeVisitor)
1276 endPathWithFinalPathModulesName =
"@finalPath" 1279 endpaths.append(endPathWithFinalPathModulesName)
1280 scheduledPaths.append(endPathWithFinalPathModulesName)
1282 modulesOnFinalPath = []
1283 for finalpathname
in finalpaths:
1285 iFinalPath.resolve(self.__dict__)
1286 finalpathValidator.setLabel(finalpathname)
1287 iFinalPath.visit(finalpathValidator)
1288 invalidModules = finalpathValidator.invalidModulesOnFinalpaths
1290 raise RuntimeError(
"FinalPath %s has non OutputModules %s" % (finalpathname,
",".
join(invalidModules)))
1291 modulesOnFinalPath.extend(iFinalPath.moduleNames())
1292 for m
in modulesOnFinalPath:
1293 mod = getattr(self, m)
1294 setattr(mod,
"@onFinalPath", untracked.bool(
True))
1295 finalPathEndPath += mod
1297 processPSet.addVString(
True,
"@end_paths", endpaths)
1298 processPSet.addVString(
True,
"@paths", scheduledPaths)
1300 p = processPSet.newPSet()
1301 p.addVString(
True,
"@trigger_paths", triggerPaths)
1302 processPSet.addPSet(
True,
"@trigger_paths", p)
1308 condTaskModules = []
1310 pathCompositeVisitor =
CompositeVisitor(pathValidator, nodeVisitor, lister, condTaskVistor)
1311 endpathCompositeVisitor =
CompositeVisitor(endpathValidator, nodeVisitor, lister)
1312 for triggername
in triggerPaths:
1313 iPath = self.
paths_()[triggername]
1314 iPath.resolve(self.__dict__)
1315 pathValidator.setLabel(triggername)
1317 condTaskModules[:] = []
1318 iPath.visit(pathCompositeVisitor)
1320 decoratedList.append(
"#")
1321 l = list({x.label_()
for x
in condTaskModules})
1323 decoratedList.extend(l)
1324 decoratedList.append(
"@")
1325 iPath.insertInto(processPSet, triggername, decoratedList[:])
1326 for endpathname
in endpaths:
1327 if endpathname
is not endPathWithFinalPathModulesName:
1328 iEndPath = self.
endpaths_()[endpathname]
1330 iEndPath = finalPathEndPath
1331 iEndPath.resolve(self.__dict__)
1332 endpathValidator.setLabel(endpathname)
1334 iEndPath.visit(endpathCompositeVisitor)
1335 iEndPath.insertInto(processPSet, endpathname, decoratedList[:])
1336 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1339 def resolve(self,keepUnresolvedSequencePlaceholders=False):
1341 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1343 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1345 x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1348 task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1350 def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1351 """ Remove clutter from the process that we think is unnecessary: 1352 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths 1353 not in the schedule will also be removed, along with an modules and sequences used only by 1354 those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders.""" 1363 self.
resolve(keepUnresolvedSequencePlaceholders)
1365 unneededPaths = set()
1369 usedModules=set(self.
schedule_().moduleNames())
1371 schedNames = set(( x.label_()
for x
in self.
schedule_()))
1372 names = set(self.
paths)
1375 unneededPaths = names - schedNames
1376 for n
in unneededPaths:
1387 usedModules=set(temp.moduleNames())
1404 def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1405 _keepSet = set(( s
for s
in seqOrTasks
if s.hasLabel_()))
1406 _availableSet = set(allSequencesOrTasks.values())
1407 _unneededSet = _availableSet-_keepSet
1408 _unneededLabels = []
1409 for s
in _unneededSet:
1410 _unneededLabels.append(s.label_())
1411 delattr(self,s.label_())
1412 return _unneededLabels
1413 unneededSeqLabels = removeUnneeded(seqs, self.
sequences)
1414 unneededTaskLabels = removeUnneeded(tasks, self.
tasks)
1416 print(
"prune removed the following:")
1417 print(
" modules:"+
",".
join(unneededModules))
1418 print(
" tasks:"+
",".
join(unneededTaskLabels))
1419 print(
" sequences:"+
",".
join(unneededSeqLabels))
1420 print(
" paths/endpaths/finalpaths:"+
",".
join(unneededPaths))
1422 moduleNames = set(d.keys())
1423 junk = moduleNames - scheduledNames
1429 """Used by the framework to convert python to C++ objects""" 1430 class ServiceInjectorAdaptor(
object):
1441 class TopLevelPSetAcessorAdaptor(
object):
1445 def __getattr__(self,attr):
1446 return getattr(self.
__ppset,attr)
1447 def getTopPSet_(self,label):
1451 def addPSet(self,tracked,name,ppset):
1452 return self.
__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1453 def addVPSet(self,tracked,name,vpset):
1454 return self.
__ppset.addVPSet(tracked,name,[self.__extractPSet(x)
for x
in vpset])
1455 def __extractPSet(self,pset):
1456 if isinstance(pset,TopLevelPSetAcessorAdaptor):
1461 processPSet.addString(
True,
"@process_name", self.
name_())
1464 all_modules.update(self.
filters_())
1467 if hasattr(self.options,
"modulesToCallForTryToContinue") :
1468 shouldTryToContinue = set(self.options.modulesToCallForTryToContinue)
1469 for m
in all_modules:
1470 if m
in shouldTryToContinue:
1471 setattr(getattr(self,m),
"@shouldTryToContinue",untracked.bool(
True))
1472 missing = shouldTryToContinue.difference(all_modules)
1474 print(
"Warning: The following modules appear in options.modulesToCallForTryToContinue but are not in the Process: {} ".
format(
",".
join(missing)))
1475 adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1488 all_modules_onTasksOrScheduled = { key:value
for key, value
in all_modules.items()
if value
in nodeVisitor.modules }
1489 self.
_insertManyInto(adaptor,
"@all_modules", all_modules_onTasksOrScheduled,
True)
1491 all_switches_onTasksOrScheduled = {key:value
for key, value
in all_switches.items()
if value
in nodeVisitor.modules }
1497 pTask.visit(processNodeVisitor)
1498 esProducersToEnable = {}
1500 if esProducer
in nodeVisitor.esProducers
or not (esProducer
in processNodeVisitor.esProducers):
1501 esProducersToEnable[esProducerName] = esProducer
1502 self.
_insertManyInto(adaptor,
"@all_esmodules", esProducersToEnable,
True)
1503 esSourcesToEnable = {}
1505 if esSource
in nodeVisitor.esSources
or not (esSource
in processNodeVisitor.esSources):
1506 esSourcesToEnable[esSourceName] = esSource
1507 self.
_insertManyInto(adaptor,
"@all_essources", esSourcesToEnable,
True)
1511 if serviceObject
in nodeVisitor.services
or not (serviceObject
in processNodeVisitor.services):
1512 serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1513 adaptor.addVPSet(
False,
"services",services)
1525 allAccelerators = set([
"cpu"])
1526 availableAccelerators = set([
"cpu"])
1527 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1528 allAccelerators.update(acc.labels())
1529 availableAccelerators.update(acc.enabledLabels())
1530 availableAccelerators = sorted(list(availableAccelerators))
1531 parameterSet.addVString(
False,
"@available_accelerators", availableAccelerators)
1534 selectedAccelerators = []
1535 if "*" in self.options.accelerators:
1536 if len(self.options.accelerators) >= 2:
1537 raise ValueError(
"process.options.accelerators may contain '*' only as the only element, now it has {} elements".
format(len(self.options.accelerators)))
1538 selectedAccelerators = availableAccelerators
1543 for pattern
in self.options.accelerators:
1544 acc = [a
for a
in availableAccelerators
if fnmatch.fnmatchcase(a, pattern)]
1546 if not any(fnmatch.fnmatchcase(a, pattern)
for a
in allAccelerators):
1547 invalid.append(pattern)
1549 resolved.update(acc)
1551 if len(invalid) != 0:
1552 raise ValueError(
"Invalid pattern{} of '{}' in process.options.accelerators, valid values are '{}' or a pattern matching some of them.".
format(
1553 "s" if len(invalid) > 2
else "",
1554 "', '".
join(invalid),
1555 "', '".
join(sorted(list(allAccelerators)))))
1556 selectedAccelerators = sorted(list(resolved))
1557 parameterSet.addVString(
False,
"@selected_accelerators", selectedAccelerators)
1560 moduleTypeResolver =
None 1561 moduleTypeResolverPlugin =
"" 1562 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1563 resolver = acc.moduleTypeResolver(selectedAccelerators)
1564 if resolver
is not None:
1565 if moduleTypeResolver
is not None:
1566 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(
1567 moduleTypeResolver.__class__.__name__,
1568 acc.__class__.__name__,
1569 resolver.__class__.__name__))
1570 moduleTypeResolver = resolver
1571 if moduleTypeResolver
is not None:
1573 moduleTypeResolverPlugin = moduleTypeResolver.plugin()
1576 for modlist
in [self.producers_, self.filters_, self.analyzers_,
1577 self.es_producers_, self.es_sources_]:
1578 for module
in modlist().
values():
1579 moduleTypeResolver.setModuleVariant(module)
1581 parameterSet.addString(
False,
"@module_type_resolver", moduleTypeResolverPlugin)
1584 wrapped = ProcessForProcessAccelerator(self)
1585 for acc
in self.__dict__[
'_Process__accelerators'].
values():
1586 acc.apply(wrapped, selectedAccelerators)
1589 """Prefer this ES source or producer. The argument can 1590 either be an object label, e.g., 1591 process.prefer(process.juicerProducer) (not supported yet) 1592 or a name of an ESSource or ESProducer 1593 process.prefer("juicer") 1594 or a type of unnamed ESSource or ESProducer 1595 process.prefer("JuicerProducer") 1596 In addition, you can pass as a labelled arguments the name of the Record you wish to 1597 prefer where the type passed is a cms.vstring and that vstring can contain the 1598 name of the C++ types in the Record that are being preferred, e.g., 1599 #prefer all data in record 'OrangeRecord' from 'juicer' 1600 process.prefer("juicer", OrangeRecord=cms.vstring()) 1602 #prefer only "Orange" data in "OrangeRecord" from "juicer" 1603 process.prefer("juicer", OrangeRecord=cms.vstring("Orange")) 1605 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 1606 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 1609 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
1610 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
1615 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
1620 typ = d[esname].type_()
1629 for name, value
in d.items():
1630 if value.type_() == esname:
1632 raise RuntimeError(
"More than one ES module for "+esname)
1640 if isinstance(process, Process):
1642 elif isinstance(process, str):
1649 raise TypeError(
'a ProcessFragment can only be constructed from an existig Process or from process name')
1651 return [ x
for x
in dir(self.
__process)
if isinstance(getattr(self.
__process, x), _ConfigureComponent) ]
1653 if name ==
'_ProcessFragment__process':
1654 return object.__getattribute__(self,
'_ProcessFragment__process')
1658 if name ==
'_ProcessFragment__process':
1659 object.__setattr__(self, name, value)
1663 if name ==
'_ProcessFragment__process':
1670 """a dictionary with fixed keys""" 1672 raise AttributeError(
"An FilteredStream defintion cannot be modified after creation.")
1673 _blocked_attribute = property(_blocked_attribute)
1674 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1675 pop = popitem = setdefault = update = _blocked_attribute
1677 new = dict.__new__(cls)
1678 dict.__init__(new, *args, **kw)
1679 keys = sorted(kw.keys())
1680 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
1681 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1682 if not isinstance(kw[
'name'],str):
1683 raise ValueError(
"name must be of type string")
1684 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
1685 raise ValueError(
"content must be of type vstring or string")
1686 if not isinstance(kw[
'dataTier'], string):
1687 raise ValueError(
"dataTier must be of type string")
1688 if not isinstance(kw[
'selectEvents'], PSet):
1689 raise ValueError(
"selectEvents must be of type PSet")
1690 if not isinstance(kw[
'paths'],(tuple, Path)):
1691 raise ValueError(
"'paths' must be a tuple of paths")
1696 return "FilteredStream object: %s" %self[
"name"]
1701 """Allows embedding another process within a parent process. This allows one to 1702 chain processes together directly in one cmsRun job rather than having to run 1703 separate jobs that are connected via a temporary file. 1705 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1708 if not isinstance(process, Process):
1709 raise ValueError(
"the 'process' argument must be of type cms.Process")
1710 if not isinstance(SelectEvents,PSet):
1711 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
1712 if not isinstance(outputCommands,vstring):
1713 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
1718 if self.
__process.MessageLogger
is not MessageLogger:
1719 print(
"""Warning: You have reconfigured service 1720 'edm::MessageLogger' in a subprocess. 1721 This service has already been configured. 1722 This particular service may not be reconfigured in a subprocess. 1723 The reconfiguration will be ignored.""")
1726 out =
"parentProcess"+
str(
hash(self))+
" = process\n" 1728 out +=
"childProcess = process\n" 1729 out +=
"process = parentProcess"+
str(
hash(self))+
"\n" 1745 process._placeSubProcess(
'subProcess',self)
1747 topPSet = parameterSet.newPSet()
1749 subProcessPSet = parameterSet.newPSet()
1752 subProcessPSet.addPSet(
False,
"process",topPSet)
1753 return subProcessPSet
1756 """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object""" 1763 params[k] = getattr(obj,k)
1767 setattr(obj,k,params[k])
1773 raise KeyError(
"Unknown parameter name "+key+
" specified while calling Modifier")
1776 """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code""" 1782 Modifier._toModifyCheck(obj,func,**kw)
1783 if self._isChosen():
1784 Modifier._toModify(obj,func,**kw)
1787 Modifier._toReplaceWithCheck(toObj,fromObj)
1788 if self._isChosen():
1789 Modifier._toReplaceWith(toObj,fromObj)
1792 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1793 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1794 In order to work, the value returned from this function must be assigned to a uniquely named variable.""" 1804 """A modifier which only applies if multiple Modifiers are chosen""" 1806 super(_AndModifier,self).
__init__(lhs, rhs)
1811 """A modifier which only applies if a Modifier is not chosen""" 1813 super(_InvertModifier,self).
__init__(lhs)
1818 """A modifier which only applies if at least one of multiple Modifiers is chosen""" 1820 super(_OrModifier,self).
__init__(lhs, rhs)
1826 """This class is used to define standard modifications to a Process. 1827 An instance of this class is declared to denote a specific modification,e.g. era2017 could 1828 reconfigure items in a process to match our expectation of running in 2017. Once declared, 1829 these Modifier instances are imported into a configuration and items that need to be modified 1830 are then associated with the Modifier and with the action to do the modification. 1831 The registered modifications will only occur if the Modifier was passed to 1832 the cms.Process' constructor. 1838 """This is used to create a ProcessModifer that can perform actions on the process as a whole. 1839 This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process. 1840 In order to work, the value returned from this function must be assigned to a uniquely named variable. 1845 if func
is not None and len(kw) != 0:
1846 raise TypeError(
"toModify takes either two arguments or one argument and key/value pairs")
1848 """This is used to register an action to be performed on the specific object. Two different forms are allowed 1849 Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument 1850 that will be the object passed in as the first argument. 1851 Form 2: A list of parameter name, value pairs can be passed 1852 mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14)) 1853 This form can also be used to remove a parameter by passing the value of None 1854 #remove the parameter foo.fred 1855 mod.toModify(foo, fred = None) 1856 Additionally, parameters embedded within PSets can also be modified using a dictionary 1857 #change foo.fred.pebbles to 3 and foo.fred.friend to "barney" 1858 mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) 1860 Modifier._toModifyCheck(obj,func,**kw)
1862 Modifier._toModify(obj,func,**kw)
1866 if func
is not None:
1873 if not isinstance(fromObj, type(toObj)):
1874 raise TypeError(
"toReplaceWith requires both arguments to be the same class type")
1876 """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj 1878 Modifier._toReplaceWithCheck(toObj,fromObj)
1880 Modifier._toReplaceWith(toObj,fromObj)
1884 if isinstance(fromObj,_ModuleSequenceType):
1885 toObj._seq = fromObj._seq
1886 toObj._tasks = fromObj._tasks
1887 elif isinstance(fromObj,Task):
1888 toObj._collection = fromObj._collection
1889 elif isinstance(fromObj,ConditionalTask):
1890 toObj._collection = fromObj._collection
1891 elif isinstance(fromObj,_Parameterizable):
1893 for p
in toObj.parameterNames_():
1895 for p
in fromObj.parameterNames_():
1896 setattr(toObj,p,getattr(fromObj,p))
1897 if isinstance(fromObj,_TypedParameterizable):
1898 toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1901 raise TypeError(
"toReplaceWith does not work with type "+
str(type(toObj)))
1904 """Should only be called by cms.Process instances""" 1915 return self == other
1919 """A Modifier made up of a list of Modifiers 1925 """Should only be called by cms.Process instances 1926 applies list of accumulated changes to the process""" 1928 m._applyNewProcessModifiers(process)
1930 """Should only be called by cms.Process instances""" 1937 """Creates a new ModifierChain which is a copy of 1938 this ModifierChain but excludes any Modifier or 1939 ModifierChain in the list toExclude. 1940 The exclusion is done recursively down the chain. 1944 if m
not in toExclude:
1946 if isinstance(m,ModifierChain):
1947 s = m.__copyIfExclude(toExclude)
1963 if m._isOrContains(other):
1968 """A class used by a Modifier to affect an entire Process instance. 1969 When a Process 'loads' a module containing a ProcessModifier, that 1970 ProcessModifier will be applied to the Process if and only if the 1971 Modifier passed to the constructor has been chosen. 1984 """A class used to specify possible compute accelerators in a Process 1985 instance. It is intended to be derived for any 1986 accelerator/portability technology, and provides hooks such that a 1987 specific customization can be applied to the Process on a worker 1988 node at the point where the python configuration is serialized for C++. 1990 The customization must not change the configuration hash. To 1991 enforce this reuirement, the customization gets a 1992 ProcessForProcessAccelerator wrapper that gives access to only 1993 those parts of the configuration that can be changed. Nevertheless 1994 it would be good to have specific unit test for each deriving 1995 class to ensure that all combinations of the enabled accelerators 1996 give the same configuration hash. 1998 The deriving class must do its checks for hardware availability 1999 only in enabledLabels(), and possibly in apply() if any further 2000 fine-tuning is needed, because those two are the only functions 2001 that are guaranteed to be called at the worker node. 2006 proc._placeAccelerator(self.type_(), self)
2008 return type(self).__name__
2010 specialImportRegistry.registerUse(self)
2011 result = self.__class__.__name__+
"(" 2016 result +=
"\n"+res+
"\n" 2022 """Override if need to add any 'body' content to dumpPython(). Returns a string.""" 2025 """Override to return a list of strings for the accelerator labels.""" 2028 """Override to return a list of strings for the accelerator labels 2029 that are enabled in the system the job is being run on.""" 2032 """Override to return an object that implements "module type resolver" 2033 in python. The object should have the following methods 2034 - __init__(self, accelerators) 2035 * accelerators = list of selected accelerators 2037 * should return a string for the type resolver plugin name 2038 - setModuleVariant(self, module): 2039 * Called for each ED and ES module. Should act only if 2040 module.type_() contains the magic identifier 2042 At most one of the ProcessAccelerators in a job can return a 2047 """Override if need to customize the Process at worker node. The 2048 selected available accelerator labels are given in the 2049 'accelerators' argument (the patterns, e.g. '*' have been 2050 expanded to concrete labels). 2052 This function may touch only untracked parameters. 2057 """This class is inteded to wrap the Process object to constrain the 2058 available functionality for ProcessAccelerator.apply()""" 2063 if not isinstance(value, Service):
2064 raise TypeError(
"ProcessAccelerator.apply() can get only Services. Tried to get {} with label {}".
format(
str(type(value)), label))
2067 if label ==
"_ProcessForProcessAccelerator__process":
2070 if not isinstance(value, Service):
2071 raise TypeError(
"ProcessAccelerator.apply() can only set Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2075 if not isinstance(value, Service):
2076 raise TypeError(
"ProcessAccelerator.apply() can delete only Services. Tried to del {} with label {}".
format(
str(type(value)), label))
2079 if not isinstance(value, Service):
2080 raise TypeError(
"ProcessAccelerator.apply() can only add Services. Tried to set {} with label {}".
format(
str(type(value)), label))
2086 return (
"test1" in accelerators, -10)
2088 return (
"test2" in accelerators, -9)
2090 if __name__==
"__main__":
2095 newString = ( x
for x
in newString.split(
'\n')
if len(x) > 0)
2096 oldString = [ x
for x
in oldString.split(
'\n')
if len(x) > 0]
2100 if oldStringLine >= len(oldString):
2103 if l == oldString[oldStringLine]:
2107 return "\n".
join( diff )
2110 """Has same interface as the C++ object that creates PSets 2115 self.
values[label]=(tracked,value)
2117 pair = self.
values[label]
2118 if pair[0] != tracked:
2119 raise Exception(
"Asked for %s parameter '%s', but it is %s" % (
"tracked" if tracked
else "untracked",
2121 "tracked" if pair[0]
else "untracked"))
2182 super(SwitchProducerTest,self).
__init__(
2184 test1 =
lambda accelerators: (
True, -10),
2185 test2 =
lambda accelerators: (
True, -9),
2186 test3 =
lambda accelerators: (
True, -8),
2187 test4 =
lambda accelerators: (
True, -7)
2189 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest,
"from test import SwitchProducerTest")
2193 super(SwitchProducerTest2,self).
__init__(
2195 test1 = _switchproducer_test2_case1,
2196 test2 = _switchproducer_test2_case2,
2198 specialImportRegistry.registerSpecialImportForType(SwitchProducerTest2,
"from test import SwitchProducerTest2")
2204 if "test1" in accelerators:
2206 if "test2" in accelerators:
2209 raise EDMException(edm.errors.UnavailableAccelerator,
"Machine has no accelerators that Test supports (has {})".
format(
", ".
join(accelerators)))
2212 return "TestModuleTypeResolver" 2215 if "@test" in module.type_():
2217 if hasattr(module,
"test"):
2218 if hasattr(module.test,
"backend"):
2220 raise EDMException(edm.errors.UnavailableAccelerator,
"Module {} has the Test backend set explicitly, but its accelerator is not available for the job".
format(module.label_()))
2222 module.test.backend = untracked.string(defaultBackend)
2224 module.test = untracked.PSet(
2225 backend = untracked.string(defaultBackend)
2229 def __init__(self, enabled=["test1", "test2", "anothertest3"], moduleTypeResolverMaker=None):
2235 invalid = set(enabled).difference(set(self.
_labels))
2236 if len(invalid) > 0:
2237 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2240 result =
"{}enabled = [{}]".
format(options.indentation(),
2252 process.AcceleratorTestService =
Service(
"AcceleratorTestService")
2253 if hasattr(process,
"AcceleratorTestServiceRemove"):
2254 del process.AcceleratorTestServiceRemove
2255 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest,
"from test import ProcessAcceleratorTest")
2258 def __init__(self, enabled=["anothertest3", "anothertest4"], moduleTypeResolverMaker=None):
2264 invalid = set(enabled).difference(set(self.
_labels))
2265 if len(invalid) > 0:
2266 raise Exception(
"Tried to enabled nonexistent test accelerators {}".
format(
",".
join(invalid)))
2269 result =
"{}enabled = [{}]".
format(options.indentation(),
2282 specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest2,
"from test import ProcessAcceleratorTest2")
2286 """Nothing to do """ 2290 self.assertEqual(len(p.parameterNames_()),0)
2292 self.assertTrue(
'a' in p.parameterNames_())
2293 self.assertEqual(p.a.value(), 1)
2295 self.assertEqual(p.a.value(), 10)
2297 self.assertEqual(p.a.value(), 1)
2298 self.assertFalse(p.a.isTracked())
2299 p.a = untracked.int32(1)
2300 self.assertEqual(p.a.value(), 1)
2301 self.assertFalse(p.a.isTracked())
2303 self.assertEqual(p.foo.value(), 10)
2304 self.assertEqual(p.bar.value(),1.0)
2305 self.assertFalse(p.bar.isTracked())
2306 self.assertRaises(TypeError,setattr,(p,
'c',1))
2308 self.assertEqual(p.a.foo.value(),10)
2309 self.assertEqual(p.a.bar.value(),1.0)
2311 self.assertEqual(p.b.fii.value(),1)
2312 self.assertFalse(p.b.isTracked())
2317 self.assertEqual(p.a.value(),11)
2319 self.assertEqual(p.a.value(),12)
2320 self.assertEqual(v.value(),12)
2326 self.assertNotEqual(p.b,other.b)
2331 self.assertTrue(
'a' in p.analyzers_() )
2332 self.assertTrue(
'a' in p.analyzers)
2333 p.add_(
Service(
"SomeService"))
2334 self.assertTrue(
'SomeService' in p.services_())
2335 self.assertEqual(p.SomeService.type_(),
"SomeService")
2337 self.assertTrue(
'Tracer' in p.services_())
2338 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
2339 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
2340 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
2342 self.assertEqual(p.out.type_(),
'Outer')
2343 self.assertTrue(
'out' in p.outputModules_() )
2346 self.assertTrue(
'geom' in p.es_sources_())
2348 self.assertTrue(
'ConfigDB' in p.es_sources_())
2351 self.assertTrue(
'aliasfoo1' in p.aliases_())
2356 for name
in args.keys():
2357 self.__dict__[name]=args[name]
2376 self.assertEqual(p.a.type_(),
"MyAnalyzer")
2377 self.assertEqual(p.a.label_(),
"a")
2378 self.assertRaises(AttributeError,getattr,p,
'b')
2379 self.assertEqual(p.Full.type_(),
"Full")
2380 self.assertEqual(
str(p.c),
'a')
2381 self.assertEqual(
str(p.d),
'a')
2396 self.assertRaises(ValueError, p1.extend, z1)
2405 aaa=copy.deepcopy(a),
2406 s4=copy.deepcopy(s3),
2413 self.assertEqual(p2.s4.label_(),
"s4")
2415 self.assertRaises(ValueError, p2.s4.setLabel,
"foo")
2416 p2.s4.setLabel(
"s4")
2417 p2.s4.setLabel(
None)
2418 p2.s4.setLabel(
"foo")
2419 p2._Process__setObjectLabel(p2.s4,
"foo")
2420 p2._Process__setObjectLabel(p2.s4,
None)
2421 p2._Process__setObjectLabel(p2.s4,
"bar")
2428 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2429 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2430 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2436 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2437 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2438 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2444 self.assertRaises(ValueError, p.extend, FromArg(a =
EDProducer(
"YourProducer")))
2445 self.assertRaises(ValueError, p.extend, FromArg(a =
EDAlias()))
2446 self.assertRaises(ValueError, p.__setattr__,
"a",
EDAlias())
2450 """import FWCore.ParameterSet.Config as cms 2452 process = cms.Process("test") 2454 process.maxEvents = cms.untracked.PSet( 2455 input = cms.optional.untracked.int32, 2456 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 2459 process.maxLuminosityBlocks = cms.untracked.PSet( 2460 input = cms.untracked.int32(-1) 2463 process.options = cms.untracked.PSet( 2464 IgnoreCompletely = cms.untracked.vstring(), 2465 Rethrow = cms.untracked.vstring(), 2466 TryToContinue = cms.untracked.vstring(), 2467 accelerators = cms.untracked.vstring('*'), 2468 allowUnscheduled = cms.obsolete.untracked.bool, 2469 canDeleteEarly = cms.untracked.vstring(), 2470 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 2471 dumpOptions = cms.untracked.bool(False), 2472 emptyRunLumiMode = cms.obsolete.untracked.string, 2473 eventSetup = cms.untracked.PSet( 2474 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 2475 allowAnyLabel_=cms.required.untracked.uint32 2477 numberOfConcurrentIOVs = cms.untracked.uint32(0) 2479 fileMode = cms.untracked.string('FULLMERGE'), 2480 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 2481 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 2482 makeTriggerResults = cms.obsolete.untracked.bool, 2483 modulesToCallForTryToContinue = cms.untracked.vstring(), 2484 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 2485 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 2486 numberOfConcurrentRuns = cms.untracked.uint32(1), 2487 numberOfStreams = cms.untracked.uint32(0), 2488 numberOfThreads = cms.untracked.uint32(1), 2489 printDependencies = cms.untracked.bool(False), 2490 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 2491 throwIfIllegalParameter = cms.untracked.bool(True), 2492 wantSummary = cms.untracked.bool(False) 2495 process.MessageLogger = cms.Service("MessageLogger", 2496 cerr = cms.untracked.PSet( 2497 FwkReport = cms.untracked.PSet( 2498 limit = cms.untracked.int32(10000000), 2499 reportEvery = cms.untracked.int32(1) 2501 FwkSummary = cms.untracked.PSet( 2502 limit = cms.untracked.int32(10000000), 2503 reportEvery = cms.untracked.int32(1) 2505 INFO = cms.untracked.PSet( 2506 limit = cms.untracked.int32(0) 2508 Root_NoDictionary = cms.untracked.PSet( 2509 limit = cms.untracked.int32(0) 2511 default = cms.untracked.PSet( 2512 limit = cms.untracked.int32(10000000) 2514 enable = cms.untracked.bool(True), 2515 enableStatistics = cms.untracked.bool(False), 2516 lineLength = cms.optional.untracked.int32, 2517 noLineBreaks = cms.optional.untracked.bool, 2518 noTimeStamps = cms.untracked.bool(False), 2519 resetStatistics = cms.untracked.bool(False), 2520 statisticsThreshold = cms.untracked.string('WARNING'), 2521 threshold = cms.untracked.string('INFO'), 2522 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2523 limit = cms.optional.untracked.int32, 2524 reportEvery = cms.untracked.int32(1), 2525 timespan = cms.optional.untracked.int32 2528 cout = cms.untracked.PSet( 2529 enable = cms.untracked.bool(False), 2530 enableStatistics = cms.untracked.bool(False), 2531 lineLength = cms.optional.untracked.int32, 2532 noLineBreaks = cms.optional.untracked.bool, 2533 noTimeStamps = cms.optional.untracked.bool, 2534 resetStatistics = cms.untracked.bool(False), 2535 statisticsThreshold = cms.optional.untracked.string, 2536 threshold = cms.optional.untracked.string, 2537 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2538 limit = cms.optional.untracked.int32, 2539 reportEvery = cms.untracked.int32(1), 2540 timespan = cms.optional.untracked.int32 2543 debugModules = cms.untracked.vstring(), 2544 default = cms.untracked.PSet( 2545 limit = cms.optional.untracked.int32, 2546 lineLength = cms.untracked.int32(80), 2547 noLineBreaks = cms.untracked.bool(False), 2548 noTimeStamps = cms.untracked.bool(False), 2549 reportEvery = cms.untracked.int32(1), 2550 statisticsThreshold = cms.untracked.string('INFO'), 2551 threshold = cms.untracked.string('INFO'), 2552 timespan = cms.optional.untracked.int32, 2553 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2554 limit = cms.optional.untracked.int32, 2555 reportEvery = cms.untracked.int32(1), 2556 timespan = cms.optional.untracked.int32 2559 files = cms.untracked.PSet( 2560 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2561 enableStatistics = cms.untracked.bool(False), 2562 extension = cms.optional.untracked.string, 2563 filename = cms.optional.untracked.string, 2564 lineLength = cms.optional.untracked.int32, 2565 noLineBreaks = cms.optional.untracked.bool, 2566 noTimeStamps = cms.optional.untracked.bool, 2567 output = cms.optional.untracked.string, 2568 resetStatistics = cms.untracked.bool(False), 2569 statisticsThreshold = cms.optional.untracked.string, 2570 threshold = cms.optional.untracked.string, 2571 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2572 limit = cms.optional.untracked.int32, 2573 reportEvery = cms.untracked.int32(1), 2574 timespan = cms.optional.untracked.int32 2578 suppressDebug = cms.untracked.vstring(), 2579 suppressFwkInfo = cms.untracked.vstring(), 2580 suppressInfo = cms.untracked.vstring(), 2581 suppressWarning = cms.untracked.vstring(), 2582 allowAnyLabel_=cms.optional.untracked.PSetTemplate( 2583 limit = cms.optional.untracked.int32, 2584 reportEvery = cms.untracked.int32(1), 2585 timespan = cms.optional.untracked.int32 2600 """process.a = cms.EDAnalyzer("MyAnalyzer") 2601 process.s = cms.Sequence(process.a) 2602 process.r = cms.Sequence(process.s) 2603 process.p = cms.Path(process.a) 2604 process.p2 = cms.Path(process.s) 2605 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2617 """process.a = cms.EDAnalyzer("MyAnalyzer") 2618 process.b = cms.EDAnalyzer("YourAnalyzer") 2619 process.r = cms.Sequence(process.a) 2620 process.s = cms.Sequence(process.r) 2621 process.p = cms.Path(process.a) 2622 process.p2 = cms.Path(process.r) 2623 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2634 """process.a = cms.EDAnalyzer("MyAnalyzer") 2635 process.r = cms.Sequence((process.a)) 2636 process.p = cms.Path(process.a) 2637 process.p2 = cms.Path(process.r) 2638 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2654 p.task3.add(p.task1)
2658 p.p2 =
Path(p.r, p.task1, p.task2)
2659 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2662 """process.b = cms.EDProducer("bProducer") 2663 process.c = cms.EDProducer("cProducer") 2664 process.d = cms.EDProducer("dProducer") 2665 process.e = cms.EDProducer("eProducer") 2666 process.f = cms.EDProducer("fProducer") 2667 process.g = cms.EDProducer("gProducer") 2668 process.a = cms.EDAnalyzer("MyAnalyzer") 2669 process.task5 = cms.Task() 2670 process.task1 = cms.Task(process.task5) 2671 process.task3 = cms.Task(process.task1) 2672 process.task2 = cms.Task(process.c, process.task3) 2673 process.task4 = cms.Task(process.f, process.task2) 2674 process.r = cms.Sequence((process.a)) 2675 process.p = cms.Path(process.a) 2676 process.p2 = cms.Path(process.r, process.task1, process.task2) 2677 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2694 p.p2 =
Path(p.r, p.task1, p.task2)
2695 p.schedule =
Schedule(p.p2,p.p,tasks=[p.task5])
2698 """process.b = cms.EDProducer("bProducer") 2699 process.c = cms.EDProducer("cProducer") 2700 process.d = cms.EDProducer("dProducer") 2701 process.e = cms.EDProducer("eProducer") 2702 process.f = cms.EDProducer("fProducer") 2703 process.g = cms.EDProducer("gProducer") 2704 process.a = cms.EDAnalyzer("MyAnalyzer") 2705 process.task5 = cms.Task() 2706 process.task3 = cms.Task() 2707 process.task2 = cms.ConditionalTask(process.c, process.task3) 2708 process.task1 = cms.ConditionalTask(process.task5) 2709 process.r = cms.Sequence((process.a)) 2710 process.p = cms.Path(process.a) 2711 process.p2 = cms.Path(process.r, process.task1, process.task2) 2712 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task5])""")
2719 p.task1 =
Task(p.d, p.e)
2720 task2 =
Task(p.f, p.g)
2721 p.schedule =
Schedule(tasks=[p.task1,task2])
2724 """process.d = cms.EDProducer("dProducer") 2725 process.e = cms.EDProducer("eProducer") 2726 process.f = cms.EDProducer("fProducer") 2727 process.g = cms.EDProducer("gProducer") 2728 process.task1 = cms.Task(process.d, process.e) 2729 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2735 """process.schedule = cms.Schedule()""")
2744 d=process.dumpPython()
2746 """process.a = cms.EDProducer("A") 2747 process.s2 = cms.Sequence(process.a)""")
2757 d=process.dumpPython()
2759 """process.a = cms.EDProducer("A") 2760 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2786 p.p =
Path(p.c+s+p.a)
2787 p.p2 =
Path(p.c+p.s4+p.a, p.ct1)
2793 self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2795 p.globalReplace(
"a",new)
2796 p.globalReplace(
"d",new2)
2799 self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2800 self.assertEqual(p.p.dumpPython()[:-1],
"cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2802 p.p2.visit(visitor_p2)
2803 self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2804 self.assertEqual(p.p2.dumpPython()[:-1],
"cms.Path(process.c+process.s4+process.a, process.ct1)")
2806 p.e3.visit(visitor3)
2807 self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2809 p.s4.visit(visitor4)
2810 self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2811 self.assertEqual(p.s4.dumpPython()[:-1],
"cms.Sequence(process.a+process.b, cms.Task(process.d), process.ct1)")
2813 p.t1.visit(visitor5)
2814 self.assertTrue(visitor5.modules == set([new2]))
2816 listOfTasks = list(p.schedule._tasks)
2817 listOfTasks[0].visit(visitor6)
2818 self.assertTrue(visitor6.modules == set([new2]))
2820 p.ct1.visit(visitor7)
2821 self.assertTrue(visitor7.modules == set([new2]))
2823 listOfConditionalTasks = list(p.conditionaltasks.values())
2824 listOfConditionalTasks[0].visit(visitor8)
2825 self.assertTrue(visitor8.modules == set([new2]))
2829 p.schedule =
Schedule(p.p, p.p2, p.e3, tasks=[p.t1])
2830 self.assertEqual(p.schedule.dumpPython()[:-1],
"cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.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])")
2844 self.assertEqual(
str(p.s),
'a+b')
2845 self.assertEqual(p.s.label_(),
's')
2846 path =
Path(p.c+p.s)
2847 self.assertEqual(
str(path),
'c+a+b')
2848 p._validateSequence(path,
'p1')
2850 p2 =
Path(p.c+p.s*notInProcess)
2851 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
2861 self.assertRaises(ValueError, p.__setattr__,
"y", testseq)
2865 self.assertFalse(service._inProcess)
2868 self.assertTrue(service._inProcess)
2870 process.d = service2
2871 self.assertFalse(service._inProcess)
2872 self.assertTrue(service2._inProcess)
2874 self.assertFalse(service2._inProcess)
2888 service3 =
Service(
"d", v = untracked.uint32(3))
2894 testTask1 =
Task(edproducer, edfilter)
2895 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2896 testTask1.add(essource, service)
2897 testTask1.add(essource, esproducer)
2898 testTask1.add(testTask2)
2899 coll = testTask1._collection
2900 self.assertTrue(edproducer
in coll)
2901 self.assertTrue(edfilter
in coll)
2902 self.assertTrue(service
in coll)
2903 self.assertTrue(essource
in coll)
2904 self.assertTrue(esproducer
in coll)
2905 self.assertTrue(testTask2
in coll)
2906 self.assertTrue(len(coll) == 6)
2907 self.assertTrue(len(testTask2._collection) == 0)
2911 taskContents.append(i)
2912 self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2917 process.mproducer = edproducer
2918 process.mproducer2 = edproducer2
2919 process.mfilter = edfilter
2920 process.messource = essource
2921 process.mesproducer = esproducer
2924 testTask3 =
Task(edproducer, edproducer2)
2925 testTask1.add(testTask3)
2926 process.myTask1 = testTask1
2933 testTask1.visit(visitor)
2934 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2935 l2 = testTask1.moduleNames
2936 self.assertTrue(l == set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
2938 testTask4 =
Task(edproducer3)
2940 self.assertRaises(RuntimeError, testTask4.visit, visitor)
2942 process.myTask4 = testTask4
2943 self.assertTrue(
False)
2944 except RuntimeError:
2947 testTask5 =
Task(service3)
2949 self.assertRaises(RuntimeError, testTask5.visit, visitor)
2951 process.myTask5 = testTask5
2952 self.assertTrue(
False)
2953 except RuntimeError:
2956 process.d = service3
2957 process.myTask5 = testTask5
2960 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
2962 self.assertTrue(process.tasks == expectedFixedDict)
2963 self.assertTrue(process.tasks[
'myTask1'] == testTask1)
2964 self.assertTrue(process.myTask1 == testTask1)
2968 process.mproducer2 = edproducer4
2972 testTask1.visit(visitor1)
2973 l.sort(key=
lambda mod: mod.__str__())
2974 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
2975 self.assertTrue(expectedList == l)
2976 process.myTask6 =
Task()
2977 process.myTask7 =
Task()
2978 process.mproducer8 = edproducer8
2979 process.myTask8 =
Task(process.mproducer8)
2980 process.myTask6.add(process.myTask7)
2981 process.myTask7.add(process.myTask8)
2982 process.myTask1.add(process.myTask6)
2983 process.myTask8.add(process.myTask5)
2985 testDict = process._itemsInDependencyOrder(process.tasks)
2986 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
2987 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2989 for testLabel, testTask
in testDict.items():
2990 self.assertTrue(testLabel == expectedLabels[index])
2991 self.assertTrue(testTask == expectedTasks[index])
2997 expectedPythonDump =
'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 2998 self.assertTrue(pythonDump == expectedPythonDump)
3000 process.myTask5 =
Task()
3001 process.myTask100 =
Task()
3002 process.mproducer9 = edproducer9
3003 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3004 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3005 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3007 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3008 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3009 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3010 process.path2 =
Path(process.mproducer)
3011 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3013 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')
3015 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')
3020 process.path1.visit(nameVisitor)
3021 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3022 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3026 process.path21 = process.path11.copy()
3027 process.path21.replace(process.mproducer, process.mproducer10)
3029 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')
3038 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')
3040 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3041 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')
3043 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3044 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')
3053 process.path24 =
Path(process.a+process.b+process.c+process.d)
3054 process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
3055 self.assertTrue(process.path25.dumpPython() ==
'cms.Path(process.d)\n')
3060 process.path200.replace(process.c,process.b)
3061 process.path200.replace(process.e,process.f)
3062 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.b, cms.Task(process.f))\n")
3063 process.path200.replace(process.b,process.c)
3064 process.path200.replace(process.f,process.e)
3065 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3066 process.path200.replace(process.c,process.a)
3067 process.path200.replace(process.e,process.g)
3068 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.a, cms.Task(process.g))\n")
3069 process.path200.replace(process.a,process.c)
3070 process.path200.replace(process.g,process.e)
3071 self.assertEqual(process.path200.dumpPython(),
"cms.EndPath(process.c, cms.Task(process.e))\n")
3085 service3 =
Service(
"d", v = untracked.uint32(3))
3093 self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
3094 testTask1.add(essource, service)
3095 testTask1.add(essource, esproducer)
3096 testTask1.add(testTask2)
3097 testTask1.add(testCTask2)
3098 coll = testTask1._collection
3099 self.assertTrue(edproducer
in coll)
3100 self.assertTrue(edfilter
in coll)
3101 self.assertTrue(service
in coll)
3102 self.assertTrue(essource
in coll)
3103 self.assertTrue(esproducer
in coll)
3104 self.assertTrue(testTask2
in coll)
3105 self.assertTrue(testCTask2
in coll)
3106 self.assertTrue(len(coll) == 7)
3107 self.assertTrue(len(testTask2._collection) == 0)
3111 taskContents.append(i)
3112 self.assertEqual(taskContents, [edproducer, edfilter, essource, service, esproducer, testTask2, testCTask2])
3117 process.mproducer = edproducer
3118 process.mproducer2 = edproducer2
3119 process.mfilter = edfilter
3120 process.messource = essource
3121 process.mesproducer = esproducer
3125 testTask1.add(testTask3)
3126 process.myTask1 = testTask1
3133 testTask1.visit(visitor)
3134 self.assertEqual(l, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3135 l2 = testTask1.moduleNames()
3136 self.assertEqual(l2, set([
'mesproducer',
'mproducer',
'mproducer2',
'mfilter',
'd',
'messource']))
3140 self.assertRaises(RuntimeError, testTask4.visit, visitor)
3142 process.myTask4 = testTask4
3143 self.assertTrue(
False)
3144 except RuntimeError:
3149 self.assertRaises(RuntimeError, testTask5.visit, visitor)
3151 process.myTask5 = testTask5
3152 self.assertTrue(
False)
3153 except RuntimeError:
3156 process.d = service3
3157 process.myTask5 = testTask5
3160 expectedDict = {
'myTask1' : testTask1,
'myTask5' : testTask5 }
3162 self.assertEqual(process.conditionaltasks, expectedFixedDict)
3163 self.assertEqual(process.conditionaltasks[
'myTask1'], testTask1)
3164 self.assertEqual(process.myTask1, testTask1)
3168 process.mproducer2 = edproducer4
3172 testTask1.visit(visitor1)
3173 l.sort(key=
lambda mod: mod.__str__())
3174 expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=
lambda mod: mod.__str__())
3175 self.assertEqual(expectedList, l)
3178 process.mproducer8 = edproducer8
3180 process.myTask6.add(process.myTask7)
3181 process.myTask7.add(process.myTask8)
3182 process.myTask1.add(process.myTask6)
3183 process.myTask8.add(process.myTask5)
3184 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3186 testDict = process._itemsInDependencyOrder(process.conditionaltasks)
3187 expectedLabels = [
"myTask5",
"myTask8",
"myTask7",
"myTask6",
"myTask1"]
3188 expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
3190 for testLabel, testTask
in testDict.items():
3191 self.assertEqual(testLabel, expectedLabels[index])
3192 self.assertEqual(testTask, expectedTasks[index])
3198 expectedPythonDump =
'cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n' 3199 self.assertEqual(pythonDump, expectedPythonDump)
3202 self.assertEqual(process.myTask8.dumpPython(),
"cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3204 process.mproducer9 = edproducer9
3205 sequence1 =
Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3206 sequence2 =
Sequence(process.mproducer8 + process.mproducer9)
3207 process.sequence3 =
Sequence((process.mproducer8 + process.mfilter))
3209 process.path1 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3210 process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3211 process.path11 =
Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3212 process.path2 =
Path(process.mproducer)
3213 process.path3 =
Path(process.mproducer9+process.mproducer8,testTask2)
3215 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')
3217 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')
3222 process.path1.visit(nameVisitor)
3223 self.assertTrue(l == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3224 self.assertTrue(process.path1.moduleNames() == set([
'mproducer',
'd',
'mesproducer',
None,
'mproducer9',
'mproducer8',
'messource',
'mproducer2',
'mfilter']))
3228 process.path21 = process.path11.copy()
3229 process.path21.replace(process.mproducer, process.mproducer10)
3231 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')
3240 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')
3242 process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3243 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')
3245 process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3246 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')
3255 process.fillProcessDesc(p)
3256 self.assertEqual(p.values[
"@all_modules"], (
True, [
'b',
'b2',
'b3']))
3257 self.assertEqual(p.values[
"@paths"], (
True, [
'p']))
3258 self.assertEqual(p.values[
"p"], (
True, [
'b',
'#',
'b2',
'b3',
'@']))
3269 self.assertEqual(
str(path),
'a+b+c')
3270 path =
Path(p.a*p.b+p.c)
3271 self.assertEqual(
str(path),
'a+b+c')
3274 path =
Path(p.a+ p.b*p.c)
3275 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))
3280 self.assertEqual(
str(path),
'a+b+~c')
3282 self.assertRaises(TypeError,Path,p.es)
3285 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path()\n')
3288 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a)\n')
3291 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.Task())\n')
3294 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task())\n')
3299 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3302 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(cms.ConditionalTask())\n')
3305 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.ConditionalTask())\n')
3310 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.Path(process.a, cms.Task(), process.t1)\n')
3320 self.assertEqual(
str(path),
'a+b+c')
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.assertRaises(TypeError,FinalPath, p.es)
3331 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath()\n')
3334 self.assertEqual(t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3336 self.assertRaises(TypeError, FinalPath,
Task())
3337 self.assertRaises(TypeError, FinalPath, p.a,
Task())
3341 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
Task(), p.t1)
3345 self.assertRaises(TypeError, FinalPath, p.a, p.t1,
ConditionalTask(), p.t1)
3349 self.assertEqual(p.t.dumpPython(
PrintOptions()),
'cms.FinalPath(process.a)\n')
3354 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3359 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3364 self.assertRaises(RuntimeError, p.fillProcessDesc, pset)
3369 p.fillProcessDesc(pset)
3380 p.path =
Path(p.a*p.b)
3381 lookuptable = {
id(a): p.a,
id(b): p.b}
3385 self.assertEqual(
str(path),
str(p.path))
3407 path =
Path(a * c * seq1, task1, ctask1)
3409 self.assertTrue(path.contains(a))
3410 self.assertFalse(path.contains(b))
3411 self.assertTrue(path.contains(c))
3412 self.assertFalse(path.contains(d))
3413 self.assertTrue(path.contains(e))
3414 self.assertFalse(path.contains(f))
3415 self.assertTrue(path.contains(g))
3416 self.assertTrue(path.contains(h))
3419 self.assertFalse(endpath.contains(b))
3420 self.assertTrue(endpath.contains(i))
3423 self.assertFalse(seq.contains(b))
3424 self.assertTrue(seq.contains(c))
3427 task =
Task(j, k, task2)
3428 self.assertFalse(task.contains(b))
3429 self.assertTrue(task.contains(j))
3430 self.assertTrue(task.contains(k))
3431 self.assertTrue(task.contains(l))
3435 sch =
Schedule(path, path2, tasks=[task,task3])
3436 self.assertFalse(sch.contains(b))
3437 self.assertTrue(sch.contains(a))
3438 self.assertTrue(sch.contains(c))
3439 self.assertTrue(sch.contains(e))
3440 self.assertTrue(sch.contains(g))
3441 self.assertTrue(sch.contains(n))
3442 self.assertTrue(sch.contains(j))
3443 self.assertTrue(sch.contains(k))
3444 self.assertTrue(sch.contains(l))
3445 self.assertTrue(sch.contains(m))
3449 self.assertFalse(ctask.contains(b))
3450 self.assertTrue(ctask.contains(j))
3451 self.assertTrue(ctask.contains(k))
3452 self.assertTrue(ctask.contains(l))
3453 self.assertTrue(ctask.contains(g))
3466 self.assertEqual(s[0],p.path1)
3467 self.assertEqual(s[1],p.path2)
3469 self.assertTrue(
'b' in p.schedule.moduleNames())
3470 self.assertTrue(hasattr(p,
'b'))
3471 self.assertTrue(hasattr(p,
'c'))
3472 self.assertTrue(hasattr(p,
'd'))
3473 self.assertTrue(hasattr(p,
'path1'))
3474 self.assertTrue(hasattr(p,
'path2'))
3475 self.assertTrue(hasattr(p,
'path3'))
3477 self.assertTrue(
'b' in p.schedule.moduleNames())
3478 self.assertTrue(hasattr(p,
'b'))
3479 self.assertTrue(
not hasattr(p,
'c'))
3480 self.assertTrue(
not hasattr(p,
'd'))
3481 self.assertTrue(hasattr(p,
'path1'))
3482 self.assertTrue(hasattr(p,
'path2'))
3483 self.assertTrue(
not hasattr(p,
'path3'))
3485 self.assertTrue(len(p.schedule._tasks) == 0)
3499 p.task2 =
Task(p.f, p.Tracer)
3500 s =
Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
3501 self.assertEqual(s[0],p.path1)
3502 self.assertEqual(s[1],p.path2)
3503 self.assertTrue(len(s._tasks) == 2)
3504 self.assertTrue(p.task1
in s._tasks)
3505 self.assertTrue(p.task2
in s._tasks)
3506 listOfTasks = list(s._tasks)
3507 self.assertTrue(len(listOfTasks) == 2)
3508 self.assertTrue(p.task1 == listOfTasks[0])
3509 self.assertTrue(p.task2 == listOfTasks[1])
3511 self.assertTrue(
'b' in p.schedule.moduleNames())
3516 process2.path1 =
Path(process2.a)
3517 process2.task1 =
Task(process2.e)
3518 process2.schedule =
Schedule(process2.path1,tasks=process2.task1)
3519 listOfTasks = list(process2.schedule._tasks)
3520 self.assertTrue(listOfTasks[0] == process2.task1)
3524 self.assertEqual(s2[0],p.path1)
3525 self.assertEqual(s2[1],p.path2)
3526 self.assertTrue(len(s2._tasks) == 2)
3527 self.assertTrue(p.task1
in s2._tasks)
3528 self.assertTrue(p.task2
in s2._tasks)
3529 listOfTasks = list(s2._tasks)
3530 self.assertTrue(len(listOfTasks) == 2)
3531 self.assertTrue(p.task1 == listOfTasks[0])
3532 self.assertTrue(p.task2 == listOfTasks[1])
3534 names = s.moduleNames()
3535 self.assertTrue(names == set([
'a',
'b',
'e',
'Tracer',
'f']))
3541 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
3550 self.assertTrue(
'a' in s.moduleNames())
3551 self.assertTrue(
'b' in s.moduleNames())
3552 self.assertTrue(
'c' in s.moduleNames())
3556 self.assertTrue(
'a' in s.moduleNames())
3557 self.assertTrue(
'b' in s.moduleNames())
3558 self.assertTrue(
'c' in s.moduleNames())
3567 self.assertTrue(p.schedule
is None)
3570 self.assertEqual(pths[keys[0]],p.path1)
3571 self.assertEqual(pths[keys[1]],p.path2)
3573 self.assertTrue(hasattr(p,
'a'))
3574 self.assertTrue(hasattr(p,
'b'))
3575 self.assertTrue(
not hasattr(p,
'c'))
3576 self.assertTrue(hasattr(p,
'path1'))
3577 self.assertTrue(hasattr(p,
'path2'))
3586 self.assertTrue(p.schedule
is None)
3589 self.assertEqual(pths[keys[1]],p.path1)
3590 self.assertEqual(pths[keys[0]],p.path2)
3597 self.assertEqual(p.modu.a.value(),1)
3598 self.assertEqual(p.modu.b.value(),2)
3603 self.assertTrue(
not a.isModified())
3605 self.assertTrue(a.isModified())
3607 self.assertEqual(p.a.a1.value(), 1)
3611 self.assertEqual(p.a.a1.value(), 2)
3620 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
3621 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
3625 self.assertEqual(p.options.numberOfThreads.value(),1)
3626 p.options.numberOfThreads = 8
3627 self.assertEqual(p.options.numberOfThreads.value(),8)
3629 self.assertEqual(p.options.numberOfThreads.value(),1)
3630 p.options = dict(numberOfStreams =2,
3632 self.assertEqual(p.options.numberOfThreads.value(),2)
3633 self.assertEqual(p.options.numberOfStreams.value(),2)
3635 self.assertRaises(TypeError, setattr, p,
'options', untracked.PSet(numberOfThreads =
int32(-1)))
3636 p.options = untracked.PSet(numberOfThreads = untracked.uint32(4))
3637 self.assertEqual(p.options.numberOfThreads.value(), 4)
3641 p.maxEvents.input = 10
3642 self.assertEqual(p.maxEvents.input.value(),10)
3644 p.maxEvents.output = 10
3645 self.assertEqual(p.maxEvents.output.value(),10)
3647 p.maxEvents.output =
PSet(out=untracked.int32(10))
3648 self.assertEqual(p.maxEvents.output.out.value(), 10)
3650 p.maxEvents = untracked.PSet(input = untracked.int32(5))
3651 self.assertEqual(p.maxEvents.input.value(), 5)
3653 self.assertRaises(TypeError, setattr, p,
'maxEvents', untracked.PSet(input = untracked.uint32(1)))
3654 p.maxEvents = untracked.PSet(input = untracked.int32(1))
3655 self.assertEqual(p.maxEvents.input.value(), 1)
3663 p.bars.foos =
'Foosball' 3664 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
3665 p.p =
Path(p.foos*p.bars)
3667 p.add_(
Service(
"MessageLogger"))
3673 p.prefer(
"ForceSource")
3676 """process.juicer = cms.ESProducer("JuicerProducer") 3677 process.ForceSource = cms.ESSource("ForceSource") 3678 process.prefer("ForceSource") 3679 process.prefer("juicer")""")
3680 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
3682 """process.juicer = cms.ESProducer("JuicerProducer") 3683 process.ForceSource = cms.ESSource("ForceSource") 3684 process.prefer("ForceSource") 3685 process.prefer("juicer", 3686 fooRcd = cms.vstring('Foo') 3701 self.assertEqual(process.m.p.i.value(), 4)
3711 subProcess.p =
Path(subProcess.a)
3712 subProcess.add_(
Service(
"Foo"))
3713 process.addSubProcess(
SubProcess(subProcess))
3714 d = process.dumpPython()
3715 equalD =
"""parentProcess = process 3716 process.a = cms.EDProducer("A") 3717 process.Foo = cms.Service("Foo") 3718 process.p = cms.Path(process.a) 3719 childProcess = process 3720 process = parentProcess 3721 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( 3722 ), outputCommands = cms.untracked.vstring()))""" 3723 equalD = equalD.replace(
"parentProcess",
"parentProcess"+
str(
hash(process.subProcesses_()[0])))
3731 messageLoggerSplit =
'process.MessageLogger = cms.Service' 3733 childProcess =
Process(
'Child')
3734 del childProcess.MessageLogger
3735 combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
3736 self.assertEqual(
_lineDiff(d, combinedDump), equalD)
3738 process.fillProcessDesc(p)
3739 self.assertEqual((
True,[
'a']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@all_modules'])
3740 self.assertEqual((
True,[
'p']),p.values[
"subProcesses"][1][0].values[
"process"][1].values[
'@paths'])
3741 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"subProcesses"][1][0].values[
"process"][1].values[
"services"][1][0].values)
3751 proc.fillProcessDesc(p)
3752 self.assertEqual((
True,1),p.values[
"ref"][1].values[
"a"])
3753 self.assertEqual((
True,1),p.values[
"ref3"][1].values[
"a"])
3754 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"a"])
3755 self.assertEqual((
True,1),p.values[
"ref2"][1].values[
"b"][1].values[
"a"])
3756 self.assertEqual((
True,1),p.values[
"ref4"][1][0].values[
"a"])
3757 self.assertEqual((
True,1),p.values[
"ref4"][1][1].values[
"a"])
3766 self.assertEqual(proc.sp.label_(),
"sp")
3767 self.assertEqual(proc.sp.test1.label_(),
"sp@test1")
3768 self.assertEqual(proc.sp.test2.label_(),
"sp@test2")
3771 proc.s =
Sequence(proc.a + proc.sp)
3772 proc.t =
Task(proc.a, proc.sp)
3774 proc.p.associate(proc.t)
3776 proc.fillProcessDesc(p)
3777 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3778 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3779 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3780 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3782 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3783 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3784 self.assertEqual([
"a",
"sp",
"sp@test1",
"sp@test2"], p.values[
"@all_modules"][1])
3785 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3786 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"@module_type"])
3787 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3788 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3789 dump = proc.dumpPython()
3790 self.assertEqual(dump.find(
'@'), -1)
3791 self.assertEqual(specialImportRegistry.getSpecialImports(), [
"from test import SwitchProducerTest"])
3792 self.assertTrue(dump.find(
"\nfrom test import SwitchProducerTest\n") != -1)
3801 proc.s =
Sequence(proc.a + proc.sp)
3802 proc.t =
Task(proc.a, proc.sp)
3804 proc.p.associate(proc.t)
3806 proc.fillProcessDesc(p)
3807 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3808 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3809 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3810 all_cases = copy.deepcopy(p.values[
"sp"][1].values[
"@all_cases"])
3812 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), all_cases)
3813 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3814 self.assertEqual([
"a",
"sp",
"sp@test2"], p.values[
"@all_modules"][1])
3815 self.assertEqual([
"sp@test1"], p.values[
"@all_aliases"][1])
3816 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3817 self.assertEqual((
True,
"Foo"), p.values[
"sp@test2"][1].values[
"@module_type"])
3818 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3819 self.assertEqual((
True,
"Bar"), p.values[
"sp@test1"][1].values[
"a"][1][0].values[
"type"])
3828 proc.s =
Sequence(proc.a + proc.sp)
3829 proc.t =
Task(proc.a, proc.sp)
3831 proc.p.associate(proc.t)
3833 proc.fillProcessDesc(p)
3834 self.assertEqual((
True,
"EDProducer"), p.values[
"sp"][1].values[
"@module_edm_type"])
3835 self.assertEqual((
True,
"SwitchProducer"), p.values[
"sp"][1].values[
"@module_type"])
3836 self.assertEqual((
True,
"sp"), p.values[
"sp"][1].values[
"@module_label"])
3837 self.assertEqual((
True, [
"sp@test1",
"sp@test2"]), p.values[
"sp"][1].values[
"@all_cases"])
3838 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
3839 self.assertEqual([
"a",
"sp",
"sp@test1"], p.values[
"@all_modules"][1])
3840 self.assertEqual([
"sp@test2"], p.values[
"@all_aliases"][1])
3841 self.assertEqual((
True,
"EDProducer"), p.values[
"sp@test1"][1].values[
"@module_edm_type"])
3842 self.assertEqual((
True,
"Foo"), p.values[
"sp@test1"][1].values[
"@module_type"])
3843 self.assertEqual((
True,
"EDAlias"), p.values[
"sp@test2"][1].values[
"@module_edm_type"])
3844 self.assertEqual((
True,
"Bar"), p.values[
"sp@test2"][1].values[
"a"][1][0].values[
"type"])
3855 proc.spp = proc.spct.clone()
3858 proc.p =
Path(proc.a, proc.ct)
3859 proc.pp =
Path(proc.a + proc.spp)
3861 proc.fillProcessDesc(p)
3862 self.assertEqual([
"a",
"spct",
"spct@test1",
"spct@test2",
"spp",
"spp@test1",
"spp@test2"], p.values[
"@all_modules"][1])
3863 self.assertEqual([
"a",
"#",
"spct",
"spct@test1",
"spct@test2",
"@"], p.values[
"p"][1])
3864 self.assertEqual([
"a",
"spp",
"#",
"spp@test1",
"spp@test2",
"@"], p.values[
"pp"][1])
3879 p.t3 =
Task(p.g, p.t1)
3883 p.path1 =
Path(p.a, p.t3, p.ct3)
3885 self.assertTrue(p.schedule
is None)
3888 self.assertEqual(pths[keys[0]],p.path1)
3889 self.assertEqual(pths[keys[1]],p.path2)
3891 p.pset2 = untracked.PSet(parA =
string(
"pset2"))
3893 p.vpset2 = untracked.VPSet()
3895 self.assertTrue(hasattr(p,
'a'))
3896 self.assertTrue(hasattr(p,
'b'))
3897 self.assertTrue(
not hasattr(p,
'c'))
3898 self.assertTrue(
not hasattr(p,
'd'))
3899 self.assertTrue(hasattr(p,
'e'))
3900 self.assertTrue(
not hasattr(p,
'f'))
3901 self.assertTrue(hasattr(p,
'g'))
3902 self.assertTrue(hasattr(p,
'h'))
3903 self.assertTrue(
not hasattr(p,
's'))
3904 self.assertTrue(hasattr(p,
't1'))
3905 self.assertTrue(
not hasattr(p,
't2'))
3906 self.assertTrue(hasattr(p,
't3'))
3907 self.assertTrue(hasattr(p,
'path1'))
3908 self.assertTrue(hasattr(p,
'path2'))
3938 p.path1 =
Path(p.a, p.t3, p.ct3)
3940 p.path3 =
Path(p.b+p.s2)
3941 p.path4 =
Path(p.b+p.s3)
3942 p.schedule =
Schedule(p.path1,p.path2,p.path3)
3943 p.schedule.associate(p.t4)
3946 self.assertEqual(pths[keys[0]],p.path1)
3947 self.assertEqual(pths[keys[1]],p.path2)
3949 self.assertTrue(hasattr(p,
'a'))
3950 self.assertTrue(hasattr(p,
'b'))
3951 self.assertTrue(
not hasattr(p,
'c'))
3952 self.assertTrue(
not hasattr(p,
'd'))
3953 self.assertTrue(
not hasattr(p,
'e'))
3954 self.assertTrue(
not hasattr(p,
'f'))
3955 self.assertTrue(hasattr(p,
'g'))
3956 self.assertTrue(hasattr(p,
'h'))
3957 self.assertTrue(hasattr(p,
'i'))
3958 self.assertTrue(hasattr(p,
'j'))
3959 self.assertTrue(hasattr(p,
'k'))
3960 self.assertTrue(
not hasattr(p,
'l'))
3961 self.assertTrue(
not hasattr(p,
't1'))
3962 self.assertTrue(hasattr(p,
't2'))
3963 self.assertTrue(hasattr(p,
't3'))
3964 self.assertTrue(hasattr(p,
't4'))
3965 self.assertTrue(
not hasattr(p,
'ct1'))
3966 self.assertTrue(hasattr(p,
'ct2'))
3967 self.assertTrue(hasattr(p,
'ct3'))
3968 self.assertTrue(
not hasattr(p,
'ct4'))
3969 self.assertTrue(
not hasattr(p,
's'))
3970 self.assertTrue(hasattr(p,
's2'))
3971 self.assertTrue(
not hasattr(p,
's3'))
3972 self.assertTrue(hasattr(p,
'path1'))
3973 self.assertTrue(hasattr(p,
'path2'))
3974 self.assertTrue(hasattr(p,
'path3'))
3975 self.assertTrue(
not hasattr(p,
'path4'))
3983 self.assertTrue(hasattr(p,
'a'))
3984 self.assertTrue(hasattr(p,
'b'))
3985 self.assertTrue(hasattr(p,
's'))
3986 self.assertTrue(hasattr(p,
'pth'))
3992 p.prune(keepUnresolvedSequencePlaceholders=
True)
3993 self.assertTrue(hasattr(p,
'b'))
3994 self.assertTrue(hasattr(p,
's'))
3995 self.assertTrue(hasattr(p,
'pth'))
3996 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
4004 self.assertTrue(hasattr(p,
'a'))
4005 self.assertTrue(hasattr(p,
'b'))
4006 self.assertTrue(hasattr(p,
's'))
4007 self.assertTrue(hasattr(p,
'pth'))
4015 self.assertTrue(hasattr(p,
'a'))
4016 self.assertTrue(hasattr(p,
'b'))
4017 self.assertTrue(hasattr(p,
's'))
4018 self.assertTrue(hasattr(p,
'pth'))
4024 p.prune(keepUnresolvedSequencePlaceholders=
True)
4025 self.assertTrue(hasattr(p,
'b'))
4026 self.assertTrue(hasattr(p,
's'))
4027 self.assertTrue(hasattr(p,
'pth'))
4028 self.assertEqual(p.s.dumpPython(),
'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
4036 p.path1 =
Path(p.b, p.t2, p.t3)
4039 p.endpath1 =
EndPath(p.b, p.t5)
4043 p.schedule =
Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
4053 """process.a = cms.EDProducer("ma") 4054 process.c = cms.EDProducer("mc") 4055 process.d = cms.EDProducer("md") 4056 process.e = cms.EDProducer("me") 4057 process.f = cms.EDProducer("mf") 4058 process.g = cms.EDProducer("mg") 4059 process.h = cms.EDProducer("mh") 4060 process.i = cms.EDProducer("mi") 4061 process.j = cms.EDProducer("mj") 4062 process.b = cms.EDAnalyzer("mb") 4063 process.t1 = cms.Task(cms.TaskPlaceholder("c")) 4064 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1) 4065 process.t3 = cms.Task(cms.TaskPlaceholder("e")) 4066 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a) 4067 process.t4 = cms.Task(cms.TaskPlaceholder("f")) 4068 process.t6 = cms.Task(cms.TaskPlaceholder("h")) 4069 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6) 4070 process.t8 = cms.Task(cms.TaskPlaceholder("j")) 4071 process.path1 = cms.Path(process.b, process.t2, process.t3) 4072 process.endpath1 = cms.EndPath(process.b, process.t5) 4073 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4076 """process.a = cms.EDProducer("ma") 4077 process.c = cms.EDProducer("mc") 4078 process.d = cms.EDProducer("md") 4079 process.e = cms.EDProducer("me") 4080 process.f = cms.EDProducer("mf") 4081 process.g = cms.EDProducer("mg") 4082 process.h = cms.EDProducer("mh") 4083 process.i = cms.EDProducer("mi") 4084 process.j = cms.EDProducer("mj") 4085 process.b = cms.EDAnalyzer("mb") 4086 process.t1 = cms.Task(process.c) 4087 process.t2 = cms.Task(process.a, process.d, process.t1) 4088 process.t3 = cms.Task(process.e) 4089 process.t4 = cms.Task(process.f) 4090 process.t6 = cms.Task(process.h) 4091 process.t7 = cms.Task(process.a, process.i, process.t6) 4092 process.t8 = cms.Task(process.j) 4093 process.t5 = cms.Task(process.a, process.g, process.t4) 4094 process.path1 = cms.Path(process.b, process.t2, process.t3) 4095 process.endpath1 = cms.EndPath(process.b, process.t5) 4096 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
4104 p.path1 =
Path(p.b, p.t2, p.t3)
4107 p.path2 =
Path(p.b, p.t5)
4108 p.schedule =
Schedule(p.path1, p.path2)
4118 """process.a = cms.EDProducer("ma") 4119 process.c = cms.EDProducer("mc") 4120 process.d = cms.EDProducer("md") 4121 process.e = cms.EDProducer("me") 4122 process.f = cms.EDProducer("mf") 4123 process.g = cms.EDProducer("mg") 4124 process.h = cms.EDProducer("mh") 4125 process.i = cms.EDProducer("mi") 4126 process.j = cms.EDProducer("mj") 4127 process.b = cms.EDAnalyzer("mb") 4128 process.t1 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("c")) 4129 process.t2 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("d"), process.a, process.t1) 4130 process.t3 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("e")) 4131 process.t5 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("g"), cms.ConditionalTaskPlaceholder("t4"), process.a) 4132 process.t4 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("f")) 4133 process.path1 = cms.Path(process.b, process.t2, process.t3) 4134 process.path2 = cms.Path(process.b, process.t5) 4135 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4138 """process.a = cms.EDProducer("ma") 4139 process.c = cms.EDProducer("mc") 4140 process.d = cms.EDProducer("md") 4141 process.e = cms.EDProducer("me") 4142 process.f = cms.EDProducer("mf") 4143 process.g = cms.EDProducer("mg") 4144 process.h = cms.EDProducer("mh") 4145 process.i = cms.EDProducer("mi") 4146 process.j = cms.EDProducer("mj") 4147 process.b = cms.EDAnalyzer("mb") 4148 process.t1 = cms.ConditionalTask(process.c) 4149 process.t2 = cms.ConditionalTask(process.a, process.d, process.t1) 4150 process.t3 = cms.ConditionalTask(process.e) 4151 process.t4 = cms.ConditionalTask(process.f) 4152 process.t5 = cms.ConditionalTask(process.a, process.g, process.t4) 4153 process.path1 = cms.Path(process.b, process.t2, process.t3) 4154 process.path2 = cms.Path(process.b, process.t5) 4155 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4171 p.t1 =
Task(p.g, p.h, p.i)
4172 t2 =
Task(p.g, p.h, p.i)
4180 p.path1 =
Path(p.a+p.f+p.s,t2,ct2)
4182 p.path3 =
Path(ct3, p.ct4)
4185 p.schedule =
Schedule(p.path2, p.path3, p.endpath2, tasks=[t3, p.t4])
4186 self.assertTrue(hasattr(p,
'f'))
4187 self.assertTrue(hasattr(p,
'g'))
4188 self.assertTrue(hasattr(p,
'i'))
4193 self.assertFalse(hasattr(p,
'f'))
4194 self.assertFalse(hasattr(p,
'g'))
4195 self.assertEqual(p.t1.dumpPython(),
'cms.Task(process.h)\n')
4196 self.assertEqual(p.ct1.dumpPython(),
'cms.ConditionalTask(process.h)\n')
4197 self.assertEqual(p.s.dumpPython(),
'cms.Sequence(process.d)\n')
4198 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+process.s, cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4199 self.assertEqual(p.endpath1.dumpPython(),
'cms.EndPath(process.b)\n')
4200 self.assertEqual(p.path3.dumpPython(),
'cms.Path(cms.ConditionalTask(process.h), process.ct4)\n')
4202 self.assertEqual(p.path1.dumpPython(),
'cms.Path(process.a+(process.d), cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4203 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path2, process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4205 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4207 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(*[ process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4209 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h), process.t4])\n')
4211 self.assertEqual(p.schedule_().
dumpPython(),
'cms.Schedule(tasks=[cms.Task(process.h)])\n')
4214 Process._firstProcess =
True 4216 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4218 Process._firstProcess =
True 4223 m1.toModify(p.a,_mod_fred)
4224 self.assertEqual(p.a.fred.value(),2)
4226 m1.toModify(p.b, wilma = 2)
4227 self.assertEqual(p.b.wilma.value(),2)
4228 self.assertTrue(p.isUsingModifier(m1))
4231 Process._firstProcess =
True 4234 m1.toModify(p.a,_mod_fred)
4236 m1.toModify(p.b, wilma = 2)
4237 self.assertEqual(p.a.fred.value(),1)
4238 self.assertEqual(p.b.wilma.value(),1)
4239 self.assertEqual(p.isUsingModifier(m1),
False)
4242 Process._firstProcess =
True 4245 m1.toModify(p.a, fred =
int32(2))
4246 p.b = p.a.clone(wilma =
int32(3))
4247 self.assertEqual(p.a.fred.value(),2)
4248 self.assertEqual(p.a.wilma.value(),1)
4249 self.assertEqual(p.b.fred.value(),2)
4250 self.assertEqual(p.b.wilma.value(),3)
4253 Process._firstProcess =
True 4256 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4257 self.assertEqual(hasattr(p.a,
"fred"),
False)
4258 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4259 self.assertEqual(p.a.wilma.value(),1)
4262 Process._firstProcess =
True 4265 m1.toModify(p.a, wilma =
int32(2))
4266 self.assertEqual(p.a.fred.value(), 1)
4267 self.assertEqual(p.a.wilma.value(),2)
4270 Process._firstProcess =
True 4273 m1.toModify(p.a, flintstones = dict(fred =
int32(2)))
4274 self.assertEqual(p.a.flintstones.fred.value(),2)
4275 self.assertEqual(p.a.flintstones.wilma.value(),1)
4278 Process._firstProcess =
True 4281 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4282 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4285 Process._firstProcess =
True 4288 m1.toModify(p.a, flintstones = {1:dict(wilma =
int32(2))})
4289 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4290 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4293 Process._firstProcess =
True 4296 m1.toModify(p.a, fred = {1:7})
4297 self.assertEqual(p.a.fred[0],1)
4298 self.assertEqual(p.a.fred[1],7)
4299 self.assertEqual(p.a.fred[2],3)
4302 Process._firstProcess =
True 4306 try: m1.toModify(p.a, fred = {5:7})
4307 except IndexError
as e: raised =
True 4308 self.assertEqual(raised,
True)
4311 Process._firstProcess =
True 4315 try: m1.toModify(p.a, flintstones = dict(bogus =
int32(37)))
4316 except TypeError
as e: raised =
True 4317 self.assertEqual(raised,
True)
4321 class ProcModifierMod(
object):
4327 testMod = DummyMod()
4329 self.assertTrue(hasattr(p,
"a"))
4331 Process._firstProcess =
True 4333 testProcMod = ProcModifierMod(m1,_rem_a)
4335 p.extend(testProcMod)
4336 self.assertTrue(
not hasattr(p,
"a"))
4340 Process._firstProcess =
True 4342 self.assertTrue(p.isUsingModifier(m1))
4343 self.assertTrue(p.isUsingModifier(mc))
4344 testMod = DummyMod()
4346 m1.toModify(p.b, fred =
int32(3))
4348 testProcMod = ProcModifierMod(m1,_rem_a)
4349 p.extend(testProcMod)
4350 self.assertTrue(
not hasattr(p,
"a"))
4351 self.assertEqual(p.b.fred.value(),3)
4356 mclone = mc.copyAndExclude([m2])
4357 self.assertTrue(
not mclone._isOrContains(m2))
4358 self.assertTrue(mclone._isOrContains(m1))
4361 mclone = mc2.copyAndExclude([m2])
4362 self.assertTrue(
not mclone._isOrContains(m2))
4363 self.assertTrue(mclone._isOrContains(m1))
4364 self.assertTrue(mclone._isOrContains(m3))
4368 Process._firstProcess =
True 4371 (m1 & m2).toModify(p.a, fred =
int32(2))
4372 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4373 self.assertEqual(p.a.fred, 1)
4376 Process._firstProcess =
True 4379 (m1 & m2).toModify(p.a, fred =
int32(2))
4380 self.assertEqual(p.a.fred, 2)
4384 Process._firstProcess =
True 4387 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
4388 self.assertEqual(p.a.fred, 2)
4389 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
4390 self.assertEqual(p.a.fred, 3)
4391 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
4392 self.assertEqual(p.a.fred, 4)
4396 Process._firstProcess =
True 4399 (~m1).toModify(p.a, fred=2)
4400 self.assertEqual(p.a.fred, 1)
4401 (~m2).toModify(p.a, wilma=2)
4402 self.assertEqual(p.a.wilma, 2)
4403 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4404 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4409 Process._firstProcess =
True 4412 (m1 | m2).toModify(p.a, fred=2)
4413 self.assertEqual(p.a.fred, 2)
4414 (m1 | m2 | m3).toModify(p.a, fred=3)
4415 self.assertEqual(p.a.fred, 3)
4416 (m3 | m2 | m1).toModify(p.a, fred=4)
4417 self.assertEqual(p.a.fred, 4)
4418 ((m1 | m2) | m3).toModify(p.a, fred=5)
4419 self.assertEqual(p.a.fred, 5)
4420 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4421 self.assertEqual(p.a.fred, 6)
4422 (m2 | m3).toModify(p.a, fred=7)
4423 self.assertEqual(p.a.fred, 6)
4424 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4425 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4431 Process._firstProcess =
True 4434 (m1 & ~m2).toModify(p.a, fred=2)
4435 self.assertEqual(p.a.fred, 1)
4436 (m1 & ~m3).toModify(p.a, fred=2)
4437 self.assertEqual(p.a.fred, 2)
4438 (m1 | ~m2).toModify(p.a, fred=3)
4439 self.assertEqual(p.a.fred, 3)
4440 (~m1 | ~m2).toModify(p.a, fred=4)
4441 self.assertEqual(p.a.fred, 3)
4442 (~m3 & ~m4).toModify(p.a, fred=4)
4443 self.assertEqual(p.a.fred, 4)
4444 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4445 self.assertEqual(p.a.fred, 5)
4448 Process._firstProcess =
True 4452 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4460 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4461 self.assertEqual(p.a.wilma.value(),3)
4462 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4463 self.assertEqual(hasattr(p,
"fred"),
False)
4464 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4466 m1.toReplaceWith(p.td,
Task(p.e))
4467 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4477 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4478 self.assertEqual(p.a.wilma.value(),3)
4479 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4480 self.assertEqual(hasattr(p,
"fred"),
False)
4481 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4484 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4487 Process._firstProcess =
True 4491 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4497 Process._firstProcess =
True 4500 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4501 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4502 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4503 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4504 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4505 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
4506 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
4507 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4508 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4509 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4510 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4511 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4512 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
4513 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4514 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
4515 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4516 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
4517 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4522 Process._firstProcess =
True 4526 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4527 self.assertEqual(p.a.fred, 2)
4528 self.assertEqual(p.a.wilma, 1)
4529 self.assertEqual(p.b.barney, 1)
4530 self.assertEqual(p.b.betty, 3)
4531 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4532 self.assertEqual(p.a.fred, 2)
4533 self.assertEqual(p.a.wilma, 4)
4534 self.assertEqual(p.b.barney, 5)
4535 self.assertEqual(p.b.betty, 3)
4536 (m2 & ~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4537 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4538 self.assertEqual(p.b.barney, 6)
4539 self.assertEqual(p.b.betty, 3)
4540 (m1 & ~m3).toModify(p.a, param=
int32(42)).toReplaceWith(p.b,
EDProducer(
"YourProducer"))
4541 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4542 self.assertEqual(p.a.param, 42)
4543 self.assertEqual(p.b.type_(),
"YourProducer")
4550 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4551 self.assertEqual(a.foo2[0].type,
"Foo3")
4554 self.assertEqual(a.foo2[0].type,
"Foo3")
4555 self.assertEqual(a.foo4[0].type,
"Foo4")
4557 m.toModify(a, foo2 =
None)
4558 self.assertFalse(hasattr(a,
"foo2"))
4559 self.assertEqual(a.foo4[0].type,
"Foo4")
4562 self.assertFalse(hasattr(a,
"foo2"))
4563 self.assertFalse(hasattr(a,
"foo4"))
4564 self.assertTrue(hasattr(a,
"bar"))
4565 self.assertEqual(a.bar[0].type,
"Bar")
4578 test1 = dict(a = 4, b = dict(c =
None)),
4579 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4580 self.assertEqual(sp.test1.a.value(), 4)
4581 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4582 self.assertEqual(sp.test2.aa.value(), 15)
4583 self.assertEqual(sp.test2.bb.cc.value(), 45)
4584 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4587 self.assertEqual(sp.test1.type_(),
"Fred")
4588 self.assertEqual(sp.test1.x.value(), 42)
4589 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
4592 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4593 self.assertEqual(sp.test2.x.value(), 24)
4594 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
4597 self.assertEqual(sp.test3.type_(),
"Wilma")
4598 self.assertEqual(sp.test3.y.value(), 24)
4599 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
4601 m.toModify(sp, test2 =
None)
4602 self.assertEqual(hasattr(sp,
"test2"),
False)
4605 self.assertTrue(hasattr(sp.test2,
"foo"))
4608 self.assertTrue(hasattr(sp.test2,
"bar"))
4611 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4613 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))
4619 p.maxEvents.input = 10
4620 p.options.numberOfThreads = 4
4621 p.maxLuminosityBlocks.input = 2
4623 self.assertEqual(p.maxEvents.input.value(),10)
4624 self.assertEqual(p.options.numberOfThreads.value(), 4)
4625 self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
4631 self.assertTrue(hasattr(p,
'fltr'))
4635 p.TestService =
Service(
"TestService")
4636 self.assertTrue(hasattr(proc,
"TestService"))
4637 self.assertEqual(proc.TestService.type_(),
"TestService")
4638 self.assertRaises(TypeError, setattr, p,
"a",
EDProducer(
"Foo"))
4639 p.add_(
Service(
"TestServiceTwo"))
4640 self.assertTrue(hasattr(proc,
"TestServiceTwo"))
4641 self.assertEqual(proc.TestServiceTwo.type_(),
"TestServiceTwo")
4642 p.TestService.foo = untracked.uint32(42)
4643 self.assertEqual(proc.TestService.foo.value(), 42)
4645 self.assertRaises(TypeError, getattr, p,
"mod")
4649 proc.fillProcessDesc(p)
4650 self.assertTrue([
"cpu"], p.values[
"@available_accelerators"][1])
4651 self.assertFalse(p.values[
"@selected_accelerators"][0])
4652 self.assertTrue([
"cpu"], p.values[
"@selected_accelerators"][1])
4653 self.assertFalse(p.values[
"@module_type_resolver"][0])
4654 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4659 del proc.MessageLogger
4661 self.assertEqual(proc.dumpPython(),
4662 """import FWCore.ParameterSet.Config as cms 4663 from test import ProcessAcceleratorTest 4665 process = cms.Process("TEST") 4667 process.maxEvents = cms.untracked.PSet( 4668 input = cms.optional.untracked.int32, 4669 output = cms.optional.untracked.allowed(cms.int32,cms.PSet) 4672 process.maxLuminosityBlocks = cms.untracked.PSet( 4673 input = cms.untracked.int32(-1) 4676 process.options = cms.untracked.PSet( 4677 IgnoreCompletely = cms.untracked.vstring(), 4678 Rethrow = cms.untracked.vstring(), 4679 TryToContinue = cms.untracked.vstring(), 4680 accelerators = cms.untracked.vstring('*'), 4681 allowUnscheduled = cms.obsolete.untracked.bool, 4682 canDeleteEarly = cms.untracked.vstring(), 4683 deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), 4684 dumpOptions = cms.untracked.bool(False), 4685 emptyRunLumiMode = cms.obsolete.untracked.string, 4686 eventSetup = cms.untracked.PSet( 4687 forceNumberOfConcurrentIOVs = cms.untracked.PSet( 4688 allowAnyLabel_=cms.required.untracked.uint32 4690 numberOfConcurrentIOVs = cms.untracked.uint32(0) 4692 fileMode = cms.untracked.string('FULLMERGE'), 4693 forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), 4694 holdsReferencesToDeleteEarly = cms.untracked.VPSet(), 4695 makeTriggerResults = cms.obsolete.untracked.bool, 4696 modulesToCallForTryToContinue = cms.untracked.vstring(), 4697 modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), 4698 numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), 4699 numberOfConcurrentRuns = cms.untracked.uint32(1), 4700 numberOfStreams = cms.untracked.uint32(0), 4701 numberOfThreads = cms.untracked.uint32(1), 4702 printDependencies = cms.untracked.bool(False), 4703 sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, 4704 throwIfIllegalParameter = cms.untracked.bool(True), 4705 wantSummary = cms.untracked.bool(False) 4708 process.ProcessAcceleratorTest = ProcessAcceleratorTest( 4709 enabled = ['test1', 'test2', 'anothertest3'] 4715 proc.fillProcessDesc(p)
4716 self.assertEqual([
"*"], p.values[
"options"][1].values[
"accelerators"][1])
4717 self.assertFalse(p.values[
"options"][1].values[
"accelerators"][0])
4718 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4719 self.assertEqual(
"AcceleratorTestService", p.values[
"services"][1][0].values[
"@service_type"][1])
4720 self.assertFalse(p.values[
"@available_accelerators"][0])
4721 self.assertTrue([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4722 self.assertFalse(p.values[
"@module_type_resolver"][0])
4723 self.assertEqual(
"", p.values[
"@module_type_resolver"][1])
4727 proc.add_(
Service(
"AcceleratorTestServiceRemove"))
4729 proc.fillProcessDesc(p)
4730 services = [x.values[
"@service_type"][1]
for x
in p.values[
"services"][1]]
4731 self.assertTrue(
"AcceleratorTestService" in services)
4732 self.assertFalse(
"AcceleratorTestServiceRemove" in services)
4737 proc.fillProcessDesc(p)
4738 self.assertEqual([
"cpu",
"test1"], p.values[
"@selected_accelerators"][1])
4739 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4743 proc.options.accelerators = [
"test2"]
4745 proc.fillProcessDesc(p)
4746 self.assertEqual([
"test2"], p.values[
"@selected_accelerators"][1])
4747 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4751 proc.options.accelerators = [
"test*"]
4752 proc.fillProcessDesc(p)
4753 self.assertEqual([
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4754 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4758 proc.options.accelerators = [
"test2"]
4760 proc.fillProcessDesc(p)
4761 self.assertEqual([], p.values[
"@selected_accelerators"][1])
4762 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
4766 proc.options.accelerators = [
"cpu*"]
4768 proc.fillProcessDesc(p)
4769 self.assertEqual([
"cpu"], p.values[
"@selected_accelerators"][1])
4770 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4774 proc.options.accelerators = [
"test3"]
4776 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4780 proc.options.accelerators = [
"*",
"test1"]
4782 self.assertRaises(ValueError, proc.fillProcessDesc, p)
4788 proc.fillProcessDesc(p)
4789 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@selected_accelerators"][1])
4790 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4795 proc.options.accelerators = [
"*test3",
"c*"]
4797 proc.fillProcessDesc(p)
4798 self.assertEqual([
"anothertest3",
"cpu"], p.values[
"@selected_accelerators"][1])
4799 self.assertEqual([
"anothertest3",
"anothertest4",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4809 proc.p =
Path(proc.sp)
4811 proc.fillProcessDesc(p)
4812 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4822 proc.p =
Path(proc.sp)
4824 proc.fillProcessDesc(p)
4825 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4829 proc.options.accelerators = [
"test1"]
4836 proc.p =
Path(proc.sp)
4838 proc.fillProcessDesc(p)
4839 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4843 proc.options.accelerators = [
"test*"]
4850 proc.p =
Path(proc.sp)
4852 proc.fillProcessDesc(p)
4853 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4857 proc.options.accelerators = [
"anothertest3"]
4864 proc.p =
Path(proc.sp)
4866 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4872 proc.normalProducer =
EDProducer(
"FooProducer")
4873 proc.testProducer =
EDProducer(
"BarProducer@test")
4874 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4875 proc.testAnalyzer =
EDAnalyzer(
"Analyzer@test")
4877 proc.testESProducer =
ESProducer(
"ESProducer@test")
4878 proc.testESSource =
ESSource(
"ESSource@test")
4879 proc.p =
Path(proc.normalProducer+proc.testProducer+proc.test2Producer+proc.testAnalyzer+proc.testFilter)
4881 proc.fillProcessDesc(p)
4882 self.assertEqual(
"TestModuleTypeResolver", p.values[
"@module_type_resolver"][1])
4883 self.assertEqual(
"FooProducer", p.values[
"normalProducer"][1].values[
"@module_type"][1])
4884 self.assertEqual(len(list(
filter(
lambda x:
not "@" in x, p.values[
"normalProducer"][1].values.keys()))), 0)
4885 self.assertEqual(
"BarProducer@test", p.values[
"testProducer"][1].values[
"@module_type"][1])
4886 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][0])
4887 self.assertEqual(
False, p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][0])
4888 self.assertEqual(
"test1_backend", p.values[
"testProducer"][1].values[
"test"][1].values[
"backend"][1])
4889 self.assertEqual(
"BarProducer@test", p.values[
"test2Producer"][1].values[
"@module_type"][1])
4890 self.assertEqual(
"test2_backend", p.values[
"test2Producer"][1].values[
"test"][1].values[
"backend"][1])
4891 self.assertEqual(
"Analyzer@test", p.values[
"testAnalyzer"][1].values[
"@module_type"][1])
4892 self.assertEqual(
"test1_backend", p.values[
"testAnalyzer"][1].values[
"test"][1].values[
"backend"][1])
4893 self.assertEqual(
"Filter@test", p.values[
"testFilter"][1].values[
"@module_type"][1])
4894 self.assertEqual(
"test1_backend", p.values[
"testFilter"][1].values[
"test"][1].values[
"backend"][1])
4895 self.assertEqual(
"ESProducer@test", p.values[
"ESProducer@test@testESProducer"][1].values[
"@module_type"][1])
4896 self.assertEqual(
"test1_backend", p.values[
"ESProducer@test@testESProducer"][1].values[
"test"][1].values[
"backend"][1])
4897 self.assertEqual(
"ESSource@test", p.values[
"ESSource@test@testESSource"][1].values[
"@module_type"][1])
4898 self.assertEqual(
"test1_backend", p.values[
"ESSource@test@testESSource"][1].values[
"test"][1].values[
"backend"][1])
4904 proc.options.accelerators = []
4905 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4910 proc.options.accelerators = [
"test1"]
4911 proc.test2Producer =
EDProducer(
"BarProducer@test", test=untracked.PSet(backend=untracked.string(
"test2_backend")))
4912 proc.p =
Path(proc.test2Producer)
4913 self.assertRaises(EDMException, proc.fillProcessDesc, p)
4922 self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4933 proc.p =
Path(proc.sp)
4934 pkl = pickle.dumps(proc)
4935 unpkl = pickle.loads(pkl)
4937 unpkl.fillProcessDesc(p)
4938 self.assertEqual((
False,
"sp@test2"), p.values[
"sp"][1].values[
"@chosen_case"])
4939 self.assertEqual([
"anothertest3",
"cpu",
"test1",
"test2"], p.values[
"@available_accelerators"][1])
4940 unpkl = pickle.loads(pkl)
4941 unpkl.ProcessAcceleratorTest.setEnabled([
"test1"])
4943 unpkl.fillProcessDesc(p)
4944 self.assertEqual((
False,
"sp@test1"), p.values[
"sp"][1].values[
"@chosen_case"])
4945 self.assertEqual([
"cpu",
"test1"], p.values[
"@available_accelerators"][1])
def __setstate__(self, pkldict)
def conditionaltasks_(self)
def addVString(self, tracked, label, value)
def testProcessAccelerator(self)
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
def testConditionalTaskPlaceholder(self)
def addEventRange(self, tracked, label, value)
def __init__(self, lhs, rhs)
def __init__(self, enabled=["anothertest3", anothertest4, moduleTypeResolverMaker=None)
def __getattribute__(self, name)
def _place(self, label, process)
def testServiceInProcess(self)
def _dumpConfigUnnamedList(self, items, typeName, options)
def _placeAnalyzer(self, name, mod)
def addString(self, tracked, label, value)
def __findFirstUsingModule(self, seqsOrTasks, mod)
def _pruneModules(self, d, scheduledNames)
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
def _placeESPrefer(self, name, mod)
def __init__(self, process)
def __updateMaxEvents(self, ps)
def _placeSwitchProducer(self, name, mod)
def _insertPaths(self, processPSet, nodeVisitor)
def apply(self, process, accelerators)
def _placeESProducer(self, name, mod)
def _splitPythonList(self, subfolder, d, options)
bool any(const std::vector< T > &v, const T &what)
def addVESInputTag(self, tracked, label, value)
def _switchproducer_test2_case2(accelerators)
def _placeSequence(self, name, mod)
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def _validateSequence(self, sequence, label)
def __getattr__(self, attr)
def setStrict(self, value)
def addDouble(self, tracked, label, value)
def dumpPythonImpl(self, options)
def moduleTypeResolver(self, accelerators)
def _findPreferred(self, esname, d, args, kargs)
def apply(self, process, accelerators)
def __init__(self, kargs)
def apply(self, process, accelerators)
def _insertOneInto(self, parameterSet, label, item, tracked)
def __setattr__(self, label, value)
def __updateOptions(self, opt)
def __delattr__(self, name)
def _placePath(self, name, mod)
def addVUInt64(self, tracked, label, value)
def _placeEndPath(self, name, mod)
def testProcessForProcessAccelerator(self)
def __init__(self, name, Mods)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def testTypedParameterizable(self)
def addUInt64(self, tracked, label, value)
def _itemsInDependencyOrder(self, processDictionaryOfItems)
def addVPSet(self, tracked, label, value)
def nameInProcessDesc_(self, label)
def __init__(self, accelerators)
def _lineDiff(newString, oldString)
def dumpPythonImpl(self, options)
def format_outerframe(number)
def __init__(self, args, kw)
def load(self, moduleName)
def _raiseUnknownKey(key)
def _insertSubProcessesInto(self, parameterSet, label, itemList, tracked)
def addUInt32(self, tracked, label, value)
def __init__(self, error, message)
def _dumpConfigESPrefers(self, options)
def __setattr__(self, name, value)
def setLooper_(self, lpr)
def setSource_(self, src)
def __init__(self, process)
def extend(self, other, items=())
def _okToPlace(self, name, mod, d)
def __injectValidValue(self, name, value, newValue=None)
def __getattr__(self, label)
def _replaceInTasks(self, label, new)
def addVInt32(self, tracked, label, value)
def _placeFilter(self, name, mod)
def handleProcessAccelerators(self, parameterSet)
def addVInputTag(self, tracked, label, value)
def _applyNewProcessModifiers(self, process)
def addLuminosityBlockID(self, tracked, label, value)
def addESInputTag(self, tracked, label, value)
def __delattr__(self, label)
def __new__(cls, args, kw)
def toModify(self, obj, func=None, kw)
def setEnabled(self, enabled)
def __setattr__(self, name, value)
def _placeESSource(self, name, mod)
def addVInt64(self, tracked, label, value)
def addVEventID(self, tracked, label, value)
def setEnabled(self, enabled)
def toModify(self, obj, func=None, kw)
def testGlobalReplace(self)
def testSwitchProducer(self)
def getVString(self, tracked, label)
def moduleTypeResolver(self, accelerators)
def defaultMaxLuminosityBlocks_()
def testProcessFragment(self)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def toReplaceWith(self, toObj, fromObj)
def _placeOutputModule(self, name, mod)
def addFileInPath(self, tracked, label, value)
def _placeSource(self, name, mod)
def __init__(self, lhs, rhs=None)
def _dumpPythonSubProcesses(self, l, options)
def _insertSwitchProducersInto(self, parameterSet, labelModules, labelAliases, itemDict, tracked)
def moduleTypeResolver(self, accelerators)
def checkImportPermission(minLevel=2, allowedPatterns=[])
def _toModify(obj, func, kw)
def __init__(self, modifier, func)
def _toReplaceWith(toObj, fromObj)
def _toModifyCheck(obj, func, kw)
def isUsingModifier(self, mod)
def dumpPython(self, options=PrintOptions())
def __copyIfExclude(self, toExclude)
def split(sequence, size)
def _validateTask(self, task, label)
def testParameterizable(self)
def _placeSubProcess(self, name, mod)
def __init__(self, enabled=["test1", test2, anothertest3, moduleTypeResolverMaker=None)
def setPartialSchedule_(self, sch, label)
def addPSet(self, tracked, label, value)
def testProcessDumpPython(self)
def _placeService(self, typeName, mod)
def resolve(self, keepUnresolvedSequencePlaceholders=False)
def _switchproducer_test2_case1(accelerators)
static std::string join(char **cmd)
def _isOrContains(self, other)
def getSubProcessPSet(self, parameterSet)
def _validateConditionalTask(self, task, label)
def copyAndExclude(self, toExclude)
def addVUInt32(self, tracked, label, value)
def addVEventRange(self, tracked, label, value)
def _splitPython(self, subfolder, d, options)
def __init__(self, lhs, rhs)
def _placeAccelerator(self, typeName, mod)
def dumpPython(process, name)
def __setObjectLabel(self, object, newLabel)
def testConditionalTask(self)
def _delHelper(self, name)
def _placeAlias(self, name, mod)
def dumpPython(self, options=PrintOptions())
def _replaceInSequences(self, label, new)
def setSchedule_(self, sch)
def dumpPython(self, options=PrintOptions())
def _toReplaceWithCheck(toObj, fromObj)
def switchProducerNames(self)
def toReplaceWith(self, toObj, fromObj)
def _placeProducer(self, name, mod)
def prefer(self, esmodule, args, kargs)
def __delattr__(self, name)
def _dumpConfigNamedList(self, items, typeName, options)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def addInputTag(self, tracked, label, value)
def _insertManyInto(self, parameterSet, label, itemDict, tracked)
def dumpConfig(self, options=PrintOptions())
def testCloneSequence(self)
def _placeTask(self, name, task)
def makeProcessModifier(self, func)
def addSubProcess(self, mod)
def switchProducers_(self)
def _placePSet(self, name, mod)
def _placeFinalPath(self, name, mod)
def _isOrContains(self, other)
def addInt64(self, tracked, label, value)
def addService(process, multirun=False)
def _place(self, name, mod, d)
def testProcessExtend(self)
def _dumpPythonList(self, d, options)
def __insertValue(self, tracked, label, value)
def splitPython(self, options=PrintOptions())
def __init__(self, kargs)
def setModuleVariant(self, module)
def __getValue(self, tracked, label)
def _place(self, name, proc)
def _placeVPSet(self, name, mod)
def processAccelerators_(self)
def globalReplace(self, label, new)
def addBool(self, tracked, label, value)
def addEventID(self, tracked, label, value)
def _placeLooper(self, name, mod)
def testImplicitSchedule(self)
def prune(self, verbose=False, keepUnresolvedSequencePlaceholders=False)
def addVDouble(self, tracked, label, value)
def _insertInto(self, parameterSet, itemDict)
def _delattrFromSetattr(self, name)
def _replaceInConditionalTasks(self, label, new)
def makeProcessModifier(self, func)
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
def _placeConditionalTask(self, name, task)
def _replaceInScheduleDirectly(self, label, new)
def __init__(self, chainedModifiers)
def testTaskPlaceholder(self)
def _replaceInSchedule(self, label, new)
def dumpPythonImpl(self, options)
def _dumpPython(self, d, options)
def addInt32(self, tracked, label, value)
def fillProcessDesc(self, processPSet)
def testProcessInsertion(self)