4 from Options
import Options
10 from Mixins
import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase
14 from Modules
import _Module
15 from SequenceTypes
import *
16 from SequenceTypes
import _ModuleSequenceType, _Sequenceable
17 from SequenceVisitors
import PathValidator, EndPathValidator
18 from Utilities
import *
21 from ExceptionHandling
import *
24 if sys.getrecursionlimit()<5000:
25 sys.setrecursionlimit(5000)
29 Raise an exception if called by special config files. This checks
30 the call or import stack for the importing file. An exception is raised if
31 the importing module is not in allowedPatterns and if it is called too deeply:
32 minLevel = 2: inclusion by top lvel cfg only
33 minLevel = 1: No inclusion allowed
34 allowedPatterns = ['Module1','Module2/SubModule1'] allows import
35 by any module in Module1 or Submodule1
41 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>']
42 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
46 for item
in inspect.stack():
50 for pattern
in CMSSWPath:
51 if item[1].
find(pattern) != -1:
54 if item[1].
find(
'/') == -1:
57 for pattern
in ignorePatterns:
58 if item[1].
find(pattern) != -1:
62 if inPath
and not ignore:
63 trueStack.append(item[1])
65 importedFile = trueStack[0]
67 if len(trueStack) > 1:
68 importedBy = trueStack[1]
70 for pattern
in allowedPatterns:
71 if importedBy.find(pattern) > -1:
74 if len(trueStack) <= minLevel:
77 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files."
81 """Look inside the module and find the Processes it contains"""
85 if isinstance(module,dict):
86 if 'process' in module:
90 if hasattr(module,
'process'):
91 if isinstance(module.process,Process):
92 process = module.process
94 raise RuntimeError(
"The attribute named 'process' does not inherit from the Process class")
96 raise RuntimeError(
"no 'process' attribute found in the module, please add one")
101 """Root class for a CMS configuration process"""
103 """The argument 'name' will be the name applied to this Process"""
104 self.__dict__[
'_Process__name'] = name
105 if not name.isalnum():
106 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
107 self.__dict__[
'_Process__filters'] = {}
108 self.__dict__[
'_Process__producers'] = {}
109 self.__dict__[
'_Process__source'] =
None
110 self.__dict__[
'_Process__looper'] =
None
111 self.__dict__[
'_Process__subProcess'] =
None
112 self.__dict__[
'_Process__schedule'] =
None
113 self.__dict__[
'_Process__analyzers'] = {}
114 self.__dict__[
'_Process__outputmodules'] = {}
117 self.__dict__[
'_Process__sequences'] = {}
118 self.__dict__[
'_Process__services'] = {}
119 self.__dict__[
'_Process__essources'] = {}
120 self.__dict__[
'_Process__esproducers'] = {}
121 self.__dict__[
'_Process__esprefers'] = {}
122 self.__dict__[
'_Process__psets']={}
123 self.__dict__[
'_Process__vpsets']={}
124 self.__dict__[
'_cloneToObjectDict'] = {}
126 self.__dict__[
'_Process__InExtendCall'] =
False
127 self.__dict__[
'_Process__partialschedules'] = {}
132 _Module.__isStrict__ =
True
136 """Returns a string containing all the EDProducer labels separated by a blank"""
139 """Returns a string containing all the EDAnalyzer labels separated by a blank"""
142 """Returns a string containing all the EDFilter labels separated by a blank"""
145 """Returns a string containing all the Path names separated by a blank"""
152 Since cloneToObjectDict stores a hash of objects by their
153 id() it needs to be updated when unpickling to use the
154 new object id values instantiated during the unpickle.
157 self.__dict__.update(pkldict)
159 for value
in self._cloneToObjectDict.values():
160 tmpDict[
id(value)] = value
161 self.__dict__[
'_cloneToObjectDict'] = tmpDict
166 """returns a dict of the filters which have been added to the Process"""
168 filters = property(filters_, doc=
"dictionary containing the filters for the process")
172 if not name.isalnum():
173 raise RuntimeError(
"Error: The process name is an empty string or contains non-alphanumeric characters")
174 self.__dict__[
'_Process__name'] = name
175 process = property(name_,setName_, doc=
"name of the process")
177 """returns a dict of the producers which have been added to the Process"""
179 producers = property(producers_,doc=
"dictionary containing the producers for the process")
181 """returns the source which has been added to the Process or None if none have been added"""
185 source = property(source_,setSource_,doc=
'the main source or None if not set')
187 """returns the looper which has been added to the Process or None if none have been added"""
191 looper = property(looper_,setLooper_,doc=
'the main looper or None if not set')
193 """returns the sub-process which has been added to the Process or None if none have been added"""
194 return self.__subProcess
197 subProcess = property(subProcess_,setSubProcess_,doc=
'the SubProcess or None if not set')
199 """returns a dict of the analyzers which have been added to the Process"""
201 analyzers = property(analyzers_,doc=
"dictionary containing the analyzers for the process")
203 """returns a dict of the output modules which have been added to the Process"""
205 outputModules = property(outputModules_,doc=
"dictionary containing the output_modules for the process")
207 """returns a dict of the paths which have been added to the Process"""
209 paths = property(paths_,doc=
"dictionary containing the paths for the process")
211 """returns a dict of the endpaths which have been added to the Process"""
213 endpaths = property(endpaths_,doc=
"dictionary containing the endpaths for the process")
215 """returns a dict of the sequences which have been added to the Process"""
217 sequences = property(sequences_,doc=
"dictionary containing the sequences for the process")
219 """returns the schedule which has been added to the Process or None if none have been added"""
220 return self.__schedule
222 if label ==
"schedule":
225 self.
_place(label, sch, self.__partialschedules)
234 raise RuntimeError(
"The path at index "+str(index)+
" in the Schedule was not attached to the process.")
236 self.__dict__[
'_Process__schedule'] = sch
237 schedule = property(schedule_,setSchedule_,doc=
'the schedule or None if not set')
239 """returns a dict of the services which have been added to the Process"""
241 services = property(services_,doc=
"dictionary containing the services for the process")
243 """returns a dict of the esproducers which have been added to the Process"""
245 es_producers = property(es_producers_,doc=
"dictionary containing the es_producers for the process")
247 """returns a the es_sources which have been added to the Process"""
249 es_sources = property(es_sources_,doc=
"dictionary containing the es_sources for the process")
251 """returns a dict of the es_prefers which have been added to the Process"""
253 es_prefers = property(es_prefers_,doc=
"dictionary containing the es_prefers for the process")
255 """returns a dict of the PSets which have been added to the Process"""
257 psets = property(psets_,doc=
"dictionary containing the PSets for the process")
259 """returns a dict of the VPSets which have been added to the Process"""
261 vpsets = property(vpsets_,doc=
"dictionary containing the PSets for the process")
264 if not name.replace(
'_',
'').isalnum():
265 raise ValueError(
'The label '+name+
' contains forbiden characters')
268 if name.startswith(
'_Process__'):
269 self.__dict__[name]=value
271 if not isinstance(value,_ConfigureComponent):
272 raise TypeError(
"can only assign labels to an object which inherits from '_ConfigureComponent'\n"
273 +
"an instance of "+str(type(value))+
" will not work")
274 if not isinstance(value,_Labelable)
and not isinstance(value,Source)
and not isinstance(value,Looper)
and not isinstance(value,Schedule):
275 if name == value.type_():
279 raise TypeError(
"an instance of "+str(type(value))+
" can not be assigned the label '"+name+
"'.\n"+
280 "Please either use the label '"+value.type_()+
" or use the 'add_' method instead.")
283 newValue =value.copy()
285 newValue._filename = value._filename
291 if not self.
_okToPlace(name, value, self.__dict__):
292 msg =
"Trying to override definition of process."+name
293 msg +=
"\n new object defined in: "+value._filename
294 msg +=
"\n existing object defined in: "+getattr(self,name)._filename
295 raise ValueError(msg)
297 if hasattr(self,name)
and not (getattr(self,name)==newValue):
301 if not self.__InExtendCall
and isinstance(newValue, _Sequenceable):
304 self.__dict__[name]=newValue
305 if isinstance(newValue,_Labelable):
306 newValue.setLabel(name)
307 self._cloneToObjectDict[
id(value)] = newValue
308 self._cloneToObjectDict[
id(newValue)] = newValue
310 newValue._place(name,self)
313 if not hasattr(self,name):
314 raise KeyError(
'process does not know about '+name)
315 elif name.startswith(
'_Process__'):
316 raise ValueError(
'this attribute cannot be deleted')
321 if reg.has_key(name): del reg[name]
323 obj = getattr(self,name)
324 if isinstance(obj,_Labelable):
325 getattr(self,name).setLabel(
None)
328 del self.__dict__[name]
333 """Allows addition of components which do not have to have a label, e.g. Services"""
334 if not isinstance(value,_ConfigureComponent):
336 if not isinstance(value,_Unlabelable):
341 newValue =value.copy()
345 newValue._place(
'',self)
348 if not self.__InExtendCall:
359 if d[name]._isModified:
370 if self.
__isStrict and isinstance(mod, _ModuleSequenceType):
371 d[name] = mod._postProcessFixup(self._cloneToObjectDict)
374 if isinstance(mod,_Labelable):
377 self.
_place(name, mod, self.__outputmodules)
379 self.
_place(name, mod, self.__producers)
381 self.
_place(name, mod, self.__filters)
383 self.
_place(name, mod, self.__analyzers)
387 self.
_place(name, mod, self.__paths)
388 except ModuleCloneError, msg:
390 raise Exception(
"%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
394 self.
_place(name, mod, self.__endpaths)
395 except ModuleCloneError, msg:
397 raise Exception(
"%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
400 self.
_place(name, mod, self.__sequences)
402 self.
_place(name, mod, self.__esproducers)
404 self.
_place(name, mod, self.__esprefers)
406 self.
_place(name, mod, self.__essources)
408 self.
_place(name, mod, self.__psets)
410 self.
_place(name, mod, self.__vpsets)
412 """Allow the source to be referenced by 'source' or by type name"""
414 raise ValueError(
"The label '"+name+
"' can not be used for a Source. Only 'source' is allowed.")
415 if self.__dict__[
'_Process__source']
is not None :
416 del self.__dict__[self.__dict__[
'_Process__source'].type_()]
417 self.__dict__[
'_Process__source'] = mod
418 self.__dict__[mod.type_()] = mod
421 raise ValueError(
"The label '"+name+
"' can not be used for a Looper. Only 'looper' is allowed.")
422 self.__dict__[
'_Process__looper'] = mod
423 self.__dict__[mod.type_()] = mod
425 if name !=
'subProcess':
426 raise ValueError(
"The label '"+name+
"' can not be used for a SubProcess. Only 'subProcess' is allowed.")
427 self.__dict__[
'_Process__subProcess'] = mod
428 self.__dict__[mod.type_()] = mod
430 self.
_place(typeName, mod, self.__services)
431 self.__dict__[typeName]=mod
433 moduleName = moduleName.replace(
"/",
".")
434 module = __import__(moduleName)
437 """Look in other and find types which we can use"""
439 self.__dict__[
'_Process__InExtendCall'] =
True
443 for name
in dir(other):
445 if name.startswith(
'_'):
447 item = getattr(other,name)
448 if name ==
"source" or name ==
"looper" or name ==
"subProcess":
450 elif isinstance(item,_ModuleSequenceType):
452 elif isinstance(item,_Labelable):
460 elif isinstance(item,Schedule):
462 elif isinstance(item,_Unlabelable):
466 for name
in seqs.iterkeys():
470 if id(seq)
not in self._cloneToObjectDict:
473 newSeq = self._cloneToObjectDict[
id(seq)]
474 self.__dict__[name]=newSeq
475 newSeq.setLabel(name)
477 newSeq._place(name,self)
478 self.__dict__[
'_Process__InExtendCall'] =
False
481 for name,item
in items:
482 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
486 for name,item
in items:
487 returnValue +=options.indentation()+typeName+
' = '+item.dumpConfig(options)
491 for name,item
in items:
492 if name == item.type_():
494 returnValue +=options.indentation()+typeName+
' '+name+
' = '+item.dumpConfig(options)
497 """return a string containing the equivalent process defined using the old configuration language"""
498 config =
"process "+self.__name+
" = {\n"
540 for name,item
in self.psets.iteritems():
541 config +=options.indentation()+item.configTypeName()+
' '+name+
' = '+item.configValue(options)
542 for name,item
in self.vpsets.iteritems():
543 config +=options.indentation()+
'VPSet '+name+
' = '+item.configValue(options)
545 pathNames = [p.label_()
for p
in self.
schedule]
546 config +=options.indentation()+
'schedule = {'+
','.
join(pathNames)+
'}\n'
557 result +=options.indentation()+
'es_prefer '+item.targetLabel_()+
' = '+item.dumpConfig(options)
562 for name,item
in d.items():
563 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n'
565 for name,item
in sorted(d.items()):
566 returnValue +=
'process.'+name+
' = '+item.dumpPython(options)+
'\n\n'
573 sequence.visit(nameVisitor)
575 raise RuntimeError(
"An entry in sequence "+label +
' has no label')
580 for label,seq
in self.sequences.iteritems():
584 dependencies[label]=[dep.label_()
for dep
in d
if dep.hasLabel_()]
585 resolvedDependencies=
True
589 while resolvedDependencies:
591 resolvedDependencies = (0 != len(dependencies))
592 oldDeps =
dict(dependencies)
593 for label,deps
in oldDeps.iteritems():
595 if len(deps)==0
or iterCount > 100:
597 resolvedDependencies=
True
600 del dependencies[label]
601 for lb2,deps2
in dependencies.iteritems():
602 while deps2.count(label):
604 if len(dependencies):
605 raise RuntimeError(
"circular sequence dependency discovered \n"+
606 ",".
join([label
for label,junk
in dependencies.iteritems()]))
610 for name, value
in d.iteritems():
611 result += value.dumpPythonAs(name,options)+
'\n'
614 """return a string containing the equivalent process defined using python"""
615 result =
"import FWCore.ParameterSet.Config as cms\n\n"
616 result +=
"process = cms.Process(\""+self.__name+
"\")\n\n"
637 pathNames = [
'process.'+p.label_()
for p
in self.
schedule]
638 result +=
'process.schedule = cms.Schedule(*[ ' +
', '.
join(pathNames) +
' ])\n'
642 old = getattr(self,label)
644 for sequenceable
in self.sequences.itervalues():
645 sequenceable.replace(old,new)
646 for sequenceable
in self.paths.itervalues():
647 sequenceable.replace(old,new)
648 for sequenceable
in self.endpaths.itervalues():
649 sequenceable.replace(old,new)
651 """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths"""
652 if not hasattr(self,label):
653 raise LookupError(
"process has no item of label "+label)
655 setattr(self,label,new)
657 for name,value
in itemDict.iteritems():
658 value.insertInto(parameterSet, name)
662 newlabel = item.nameInProcessDesc_(label)
664 item.insertInto(parameterSet, newlabel)
665 parameterSet.addVString(tracked, label, vitems)
668 for name,value
in itemDict.iteritems():
669 newLabel = value.nameInProcessDesc_(name)
671 value.insertInto(parameterSet, name)
674 parameterSet.addVString(tracked, label, l)
681 for name,value
in self.
paths_().iteritems():
682 scheduledPaths.append(name)
683 triggerPaths.append(name)
684 for name,value
in self.
endpaths_().iteritems():
685 scheduledPaths.append(name)
686 endpaths.append(name)
689 pathname = path.label_()
690 scheduledPaths.append(pathname)
692 endpaths.append(pathname)
694 triggerPaths.append(pathname)
695 processPSet.addVString(
True,
"@end_paths", endpaths)
696 processPSet.addVString(
True,
"@paths", scheduledPaths)
698 p = processPSet.newPSet()
699 p.addVString(
True,
"@trigger_paths", triggerPaths)
700 processPSet.addPSet(
True,
"@trigger_paths", p)
704 for triggername
in triggerPaths:
706 pathValidator.setLabel(triggername)
708 self.
paths_()[triggername].insertInto(processPSet, triggername, self.__dict__)
709 for endpathname
in endpaths:
711 endpathValidator.setLabel(endpathname)
713 self.
endpaths_()[endpathname].insertInto(processPSet, endpathname, self.__dict__)
714 processPSet.addVString(
False,
"@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
717 """ Remove clutter from the process which we think is unnecessary:
718 tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths
719 not in the schedule will also be removed, along with an modules and sequences used only by
720 those removed Paths and EndPaths."""
721 for name
in self.
psets_():
722 if getattr(self,name).isTracked():
727 for x
in self.paths.itervalues():
728 x.resolve(self.__dict__)
729 for x
in self.endpaths.itervalues():
730 x.resolve(self.__dict__)
735 schedNames =
set(( x.label_()
for x
in self.
schedule_()))
738 junk = names - schedNames
742 pths =
list(self.paths.itervalues())
743 pths.extend(self.endpaths.itervalues())
745 usedModules=
set(temp.moduleNames())
752 for p
in self.paths.itervalues():
754 for p
in self.endpaths.itervalues():
756 keepSeqSet =
set(( s
for s
in seqs
if s.hasLabel_()))
757 availableSeqs =
set(self.sequences.itervalues())
758 for s
in availableSeqs-keepSeqSet:
759 delattr(self,s.label_())
762 moduleNames =
set(d.keys())
763 junk = moduleNames - scheduledNames
768 """Used by the framework to convert python to C++ objects"""
769 class ServiceInjectorAdaptor(
object):
773 def addService(self,pset):
774 self.__thelist.append(pset)
776 return self.__processPSet.newPSet()
778 processPSet.addString(
True,
"@process_name", self.
name_())
796 getattr(self,n).insertInto(ServiceInjectorAdaptor(processPSet,services))
797 processPSet.addVPSet(
False,
"services",services)
807 def prefer(self, esmodule,*args,**kargs):
808 """Prefer this ES source or producer. The argument can
809 either be an object label, e.g.,
810 process.prefer(process.juicerProducer) (not supported yet)
811 or a name of an ESSource or ESProducer
812 process.prefer("juicer")
813 or a type of unnamed ESSource or ESProducer
814 process.prefer("JuicerProducer")
815 In addition, you can pass as a labelled arguments the name of the Record you wish to
816 prefer where the type passed is a cms.vstring and that vstring can contain the
817 name of the C++ types in the Record which are being preferred, e.g.,
818 #prefer all data in record 'OrangeRecord' from 'juicer'
819 process.prefer("juicer", OrangeRecord=cms.vstring())
821 #prefer only "Orange" data in "OrangeRecord" from "juicer"
822 process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
824 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
825 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))
828 if isinstance(esmodule, ESSource)
or isinstance(esmodule, ESProducer):
829 raise RuntimeError(
"Syntax of process.prefer(process.esmodule) not supported yet")
830 elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs)
or \
831 self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
834 raise RuntimeError(
"Cannot resolve prefer for "+repr(esmodule))
839 typ = d[esname].type_()
848 for name, value
in d.iteritems():
849 if value.type_() == esname:
851 raise RuntimeError(
"More than one ES module for "+esname)
857 """a dictionary with fixed keys"""
859 raise AttributeError,
"An FilteredStream defintion cannot be modified after creation."
860 _blocked_attribute = property(_blocked_attribute)
861 __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
862 pop = popitem = setdefault = update = _blocked_attribute
864 new = dict.__new__(cls)
865 dict.__init__(new, *args, **kw)
868 if keys != [
'content',
'dataTier',
'name',
'paths',
'responsible',
'selectEvents']:
869 raise ValueError(
"The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
870 if not isinstance(kw[
'name'],str):
871 raise ValueError(
"name must be of type string")
872 if not isinstance(kw[
'content'], vstring)
and not isinstance(kw[
'content'],str):
873 raise ValueError(
"content must be of type vstring or string")
874 if not isinstance(kw[
'dataTier'], string):
875 raise ValueError(
"dataTier must be of type string")
876 if not isinstance(kw[
'selectEvents'], PSet):
877 raise ValueError(
"selectEvents must be of type PSet")
878 if not isinstance(kw[
'paths'],(tuple, Path)):
879 raise ValueError(
"'paths' must be a tuple of paths")
884 return "FilteredStream object: %s" %self[
"name"]
889 """Allows embedding another process within a parent process. This allows one to
890 chain processes together directly in one cmsRun job rather than having to run
891 separate jobs which are connected via a temporary file.
893 def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
896 if not isinstance(process, Process):
897 raise ValueError(
"the 'process' argument must be of type cms.Process")
898 if not isinstance(SelectEvents,PSet):
899 raise ValueError(
"the 'SelectEvents' argument must be of type cms.untracked.PSet")
900 if not isinstance(outputCommands,vstring):
901 raise ValueError(
"the 'outputCommands' argument must be of type cms.untracked.vstring")
906 out =
"parentProcess"+str(
hash(self))+
" = process\n"
907 out += self.__process.dumpPython()
908 out +=
"childProcess = process\n"
909 out +=
"process = parentProcess"+str(
hash(self))+
"\n"
910 out +=
"process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = "+self.__SelectEvents.dumpPython(options) +
", outputCommands = "+self.__outputCommands.dumpPython(options) +
")\n"
915 return '@sub_process'
917 process._placeSubProcess(
'subProcess',self)
919 topPSet = parameterSet.newPSet()
920 self.__process.fillProcessDesc(topPSet)
921 subProcessPSet = parameterSet.newPSet()
922 self.__SelectEvents.insertInto(subProcessPSet,
"SelectEvents")
923 self.__outputCommands.insertInto(subProcessPSet,
"outputCommands")
924 subProcessPSet.addPSet(
False,
"process",topPSet)
927 if __name__==
"__main__":
930 """Has same interface as the C++ object which creates PSets
935 self.
values[label]=(tracked,value)
997 self.assertEqual(len(p.parameterNames_()),0)
999 self.assert_(
'a' in p.parameterNames_())
1000 self.assertEqual(p.a.value(), 1)
1002 self.assertEqual(p.a.value(), 10)
1004 self.assertEqual(p.a.value(), 1)
1005 self.failIf(p.a.isTracked())
1006 p.a = untracked.int32(1)
1007 self.assertEqual(p.a.value(), 1)
1008 self.failIf(p.a.isTracked())
1010 self.assertEqual(p.foo.value(), 10)
1011 self.assertEqual(p.bar.value(),1.0)
1012 self.failIf(p.bar.isTracked())
1013 self.assertRaises(TypeError,setattr,(p,
'c',1))
1015 self.assertEqual(p.a.foo.value(),10)
1016 self.assertEqual(p.a.bar.value(),1.0)
1018 self.assertEqual(p.b.fii.value(),1)
1019 self.failIf(p.b.isTracked())
1024 self.assertEqual(p.a.value(),11)
1026 self.assertEqual(p.a.value(),12)
1027 self.assertEqual(v.value(),12)
1033 self.assertNotEqual(p.b,other.b)
1038 self.assert_(
'a' in p.analyzers_() )
1039 self.assert_(
'a' in p.analyzers)
1040 p.add_(
Service(
"MessageLogger"))
1041 self.assert_(
'MessageLogger' in p.services_())
1042 self.assertEqual(p.MessageLogger.type_(),
"MessageLogger")
1044 self.assert_(
'Tracer' in p.services_())
1045 self.assertRaises(TypeError, setattr, *(p,
'b',
"this should fail"))
1046 self.assertRaises(TypeError, setattr, *(p,
'bad',
Service(
"MessageLogger")))
1047 self.assertRaises(ValueError, setattr, *(p,
'bad',
Source(
"PoolSource")))
1049 self.assertEqual(p.out.type_(),
'Outer')
1050 self.assert_(
'out' in p.outputModules_() )
1053 self.assert_(
'geom' in p.es_sources_())
1055 self.assert_(
'ConfigDB' in p.es_sources_())
1060 for name
in args.iterkeys():
1061 self.__dict__[name]=args[name]
1078 self.assertEqual(p.a.type_(),
"MyAnalyzer")
1079 self.assertRaises(AttributeError,getattr,p,
'b')
1080 self.assertEqual(p.Full.type_(),
"Full")
1081 self.assertEqual(str(p.c),
'a')
1082 self.assertEqual(str(p.d),
'a')
1094 """import FWCore.ParameterSet.Config as cms
1096 process = cms.Process("test")
1098 process.a = cms.EDAnalyzer("MyAnalyzer")
1101 process.s = cms.Sequence(process.a)
1104 process.r = cms.Sequence(process.s)
1107 process.p = cms.Path(process.a)
1110 process.p2 = cms.Path(process.s)
1113 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1126 """import FWCore.ParameterSet.Config as cms
1128 process = cms.Process("test")
1130 process.a = cms.EDAnalyzer("MyAnalyzer")
1133 process.b = cms.EDAnalyzer("YourAnalyzer")
1136 process.r = cms.Sequence(process.a)
1139 process.s = cms.Sequence(process.r)
1142 process.p = cms.Path(process.a)
1145 process.p2 = cms.Path(process.r)
1148 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1160 """import FWCore.ParameterSet.Config as cms
1162 process = cms.Process("test")
1164 process.a = cms.EDAnalyzer("MyAnalyzer")
1167 process.r = cms.Sequence((process.a))
1170 process.p = cms.Path(process.a)
1173 process.p2 = cms.Path(process.r)
1176 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1182 self.assertEqual(p.dumpPython().
replace(
'\n',
''),
'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
1190 p.p =
Path(p.c+p.s+p.a)
1192 p.globalReplace(
"a",new)
1200 self.assertEqual(str(p.s),
'a+b')
1201 self.assertEqual(p.s.label_(),
's')
1202 path =
Path(p.c+p.s)
1203 self.assertEqual(str(path),
'c+a+b')
1204 p._validateSequence(path,
'p1')
1206 p2 =
Path(p.c+p.s*notInProcess)
1207 self.assertRaises(RuntimeError, p._validateSequence, p2,
'p2')
1217 self.assertEqual(str(path),
'a+b+c')
1218 path =
Path(p.a*p.b+p.c)
1219 self.assertEqual(str(path),
'a+b+c')
1222 path =
Path(p.a+ p.b*p.c)
1223 self.assertEqual(str(path),
'a+b+c')
1224 path =
Path(p.a*(p.b+p.c))
1225 self.assertEqual(str(path),
'a+b+c')
1226 path =
Path(p.a*(p.b+~p.c))
1227 self.assertEqual(str(path),
'a+b+~c')
1229 self.assertRaises(TypeError,Path,p.es)
1240 p.path =
Path(p.a*p.b)
1241 lookuptable = {
id(a): p.a,
id(b): p.b}
1245 self.assertEqual(str(path),str(p.path))
1258 self.assertEqual(s[0],p.path1)
1259 self.assertEqual(s[1],p.path2)
1261 self.assert_(
'b' in p.schedule.moduleNames())
1262 self.assert_(hasattr(p,
'b'))
1263 self.assert_(hasattr(p,
'c'))
1264 self.assert_(hasattr(p,
'd'))
1265 self.assert_(hasattr(p,
'path1'))
1266 self.assert_(hasattr(p,
'path2'))
1267 self.assert_(hasattr(p,
'path3'))
1269 self.assert_(
'b' in p.schedule.moduleNames())
1270 self.assert_(hasattr(p,
'b'))
1271 self.assert_(
not hasattr(p,
'c'))
1272 self.assert_(
not hasattr(p,
'd'))
1273 self.assert_(hasattr(p,
'path1'))
1274 self.assert_(hasattr(p,
'path2'))
1275 self.assert_(
not hasattr(p,
'path3'))
1282 self.assertRaises(RuntimeError,
lambda : p.setSchedule_(s) )
1291 self.assert_(
'a' in s.moduleNames())
1292 self.assert_(
'b' in s.moduleNames())
1293 self.assert_(
'c' in s.moduleNames())
1297 self.assert_(
'a' in s.moduleNames())
1298 self.assert_(
'b' in s.moduleNames())
1299 self.assert_(
'c' in s.moduleNames())
1308 self.assert_(p.schedule
is None)
1311 self.assertEqual(pths[keys[0]],p.path1)
1312 self.assertEqual(pths[keys[1]],p.path2)
1314 self.assert_(hasattr(p,
'a'))
1315 self.assert_(hasattr(p,
'b'))
1316 self.assert_(
not hasattr(p,
'c'))
1317 self.assert_(hasattr(p,
'path1'))
1318 self.assert_(hasattr(p,
'path2'))
1327 self.assert_(p.schedule
is None)
1330 self.assertEqual(pths[keys[1]],p.path1)
1331 self.assertEqual(pths[keys[0]],p.path2)
1338 self.assertEqual(p.modu.a.value(),1)
1339 self.assertEqual(p.modu.b.value(),2)
1344 self.assert_(
not a.isModified())
1346 self.assert_(a.isModified())
1348 self.assertEqual(p.a.a1.value(), 1)
1352 self.assertEqual(p.a.a1.value(), 2)
1361 self.assertRaises(ValueError, EDProducer,
'C', ps1, ps2)
1362 self.assertRaises(ValueError, EDProducer,
'C', ps1, a=
int32(3))
1370 p.bars.foos =
'Foosball'
1371 self.assertEqual(p.bars.foos,
InputTag(
'Foosball'))
1372 p.p =
Path(p.foos*p.bars)
1374 p.add_(
Service(
"MessageLogger"))
1380 p.prefer(
"ForceSource")
1382 self.assertEqual(p.dumpConfig(),
1384 es_module juicer = JuicerProducer {
1386 es_source = ForceSource {
1388 es_prefer = ForceSource {
1390 es_prefer juicer = JuicerProducer {
1394 p.prefer(
"juicer",fooRcd=
vstring(
"Foo"))
1395 self.assertEqual(p.dumpConfig(),
1397 es_module juicer = JuicerProducer {
1399 es_source = ForceSource {
1401 es_prefer = ForceSource {
1403 es_prefer juicer = JuicerProducer {
1411 self.assertEqual(p.dumpPython(),
1412 """import FWCore.ParameterSet.Config as cms
1414 process = cms.Process("Test")
1416 process.juicer = cms.ESProducer("JuicerProducer")
1419 process.ForceSource = cms.ESSource("ForceSource")
1422 process.prefer("ForceSource")
1424 process.prefer("juicer",
1425 fooRcd = cms.vstring('Foo')
1442 self.assertEqual(process.m.p.i.value(), 4)
1452 subProcess.p =
Path(subProcess.a)
1453 subProcess.add_(
Service(
"Foo"))
1455 d = process.dumpPython()
1456 equalD =
"""import FWCore.ParameterSet.Config as cms
1458 process = cms.Process("Parent")
1460 parentProcess = process
1461 import FWCore.ParameterSet.Config as cms
1463 process = cms.Process("Child")
1465 process.a = cms.EDProducer("A")
1468 process.p = cms.Path(process.a)
1471 process.Foo = cms.Service("Foo")
1474 childProcess = process
1475 process = parentProcess
1476 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet(
1478 ), outputCommands = cms.untracked.vstring())
1480 equalD = equalD.replace(
"parentProcess",
"parentProcess"+str(
hash(process.subProcess)))
1481 self.assertEqual(d,equalD)
1483 process.subProcess.insertInto(p,
"dummy")
1484 self.assertEqual((
True,[
'a']),p.values[
"@sub_process"][1].values[
"process"][1].values[
'@all_modules'])
1485 self.assertEqual((
True,[
'p']),p.values[
"@sub_process"][1].values[
"process"][1].values[
'@paths'])
1486 self.assertEqual({
'@service_type':(
True,
'Foo')}, p.values[
"@sub_process"][1].values[
"process"][1].values[
"services"][1][0].values)
1496 self.assert_(p.schedule
is None)
1499 self.assertEqual(pths[keys[0]],p.path1)
1500 self.assertEqual(pths[keys[1]],p.path2)
1502 self.assert_(hasattr(p,
'a'))
1503 self.assert_(hasattr(p,
'b'))
1504 self.assert_(
not hasattr(p,
'c'))
1505 self.assert_(
not hasattr(p,
'd'))
1506 self.assert_(
not hasattr(p,
's'))
1507 self.assert_(hasattr(p,
'path1'))
1508 self.assert_(hasattr(p,
'path2'))
1521 p.path3 =
Path(p.b+p.s2)
1522 p.path4 =
Path(p.b+p.s3)
1523 p.schedule =
Schedule(p.path1,p.path2,p.path3)
1526 self.assertEqual(pths[keys[0]],p.path1)
1527 self.assertEqual(pths[keys[1]],p.path2)
1529 self.assert_(hasattr(p,
'a'))
1530 self.assert_(hasattr(p,
'b'))
1531 self.assert_(
not hasattr(p,
'c'))
1532 self.assert_(
not hasattr(p,
'd'))
1533 self.assert_(
not hasattr(p,
'e'))
1534 self.assert_(
not hasattr(p,
's'))
1535 self.assert_(hasattr(p,
's2'))
1536 self.assert_(
not hasattr(p,
's3'))
1537 self.assert_(hasattr(p,
'path1'))
1538 self.assert_(hasattr(p,
'path2'))
1539 self.assert_(hasattr(p,
'path3'))
1540 self.assert_(
not hasattr(p,
'path4'))
1548 self.assert_(hasattr(p,
'a'))
1549 self.assert_(hasattr(p,
'b'))
1550 self.assert_(hasattr(p,
's'))
1551 self.assert_(hasattr(p,
'pth'))
def _dumpConfigUnnamedList
def testProcessDumpPython
def _dumpConfigOptionallyNamedList
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def _sequencesInDependencyOrder
static std::string join(char **cmd)
def checkImportPermission
def testTypedParameterizable
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
void set(const std::string &name, int value)
set the flag, with a run-time name