CMS 3D CMS Logo

Config.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
4 from __future__ import print_function
5 from __future__ import absolute_import
6 import six
7 import os
8 from .Options import Options
9 options = Options()
10 
11 
12 
13 import sys
14 from .Mixins import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase, _modifyParametersFromDict
15 from .Mixins import *
16 from .Types import *
17 from .Modules import *
18 from .Modules import _Module
19 from .SequenceTypes import *
20 from .SequenceTypes import _ModuleSequenceType, _Sequenceable #extend needs it
21 from .SequenceVisitors import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
22 from . import DictTypes
23 
24 from .ExceptionHandling import *
25 
26 #when building RECO paths we have hit the default recursion limit
27 if sys.getrecursionlimit()<5000:
28  sys.setrecursionlimit(5000)
29 
30 def checkImportPermission(minLevel = 2, allowedPatterns = []):
31  """
32  Raise an exception if called by special config files. This checks
33  the call or import stack for the importing file. An exception is raised if
34  the importing module is not in allowedPatterns and if it is called too deeply:
35  minLevel = 2: inclusion by top lvel cfg only
36  minLevel = 1: No inclusion allowed
37  allowedPatterns = ['Module1','Module2/SubModule1'] allows import
38  by any module in Module1 or Submodule1
39  """
40 
41  import inspect
42  import os
43 
44  ignorePatterns = ['FWCore/ParameterSet/Config.py','<string>','<frozen ']
45  CMSSWPath = [os.environ['CMSSW_BASE'],os.environ['CMSSW_RELEASE_BASE']]
46 
47  # Filter the stack to things in CMSSWPath and not in ignorePatterns
48  trueStack = []
49  for item in inspect.stack():
50  inPath = False
51  ignore = False
52 
53  for pattern in CMSSWPath:
54  if item[1].find(pattern) != -1:
55  inPath = True
56  break
57  if item[1].find('/') == -1: # The base file, no path
58  inPath = True
59 
60  for pattern in ignorePatterns:
61  if item[1].find(pattern) != -1:
62  ignore = True
63  break
64 
65  if inPath and not ignore:
66  trueStack.append(item[1])
67 
68  importedFile = trueStack[0]
69  importedBy = ''
70  if len(trueStack) > 1:
71  importedBy = trueStack[1]
72 
73  for pattern in allowedPatterns:
74  if importedBy.find(pattern) > -1:
75  return True
76 
77  if len(trueStack) <= minLevel: # Imported directly
78  return True
79 
80  raise ImportError("Inclusion of %s is allowed only by cfg or specified cfi files."
81  % importedFile)
82 
83 def findProcess(module):
84  """Look inside the module and find the Processes it contains"""
85  class Temp(object):
86  pass
87  process = None
88  if isinstance(module,dict):
89  if 'process' in module:
90  p = module['process']
91  module = Temp()
92  module.process = p
93  if hasattr(module,'process'):
94  if isinstance(module.process,Process):
95  process = module.process
96  else:
97  raise RuntimeError("The attribute named 'process' does not inherit from the Process class")
98  else:
99  raise RuntimeError("no 'process' attribute found in the module, please add one")
100  return process
101 
103  """Root class for a CMS configuration process"""
104  def __init__(self,name,*Mods):
105  """The argument 'name' will be the name applied to this Process
106  Can optionally pass as additional arguments cms.Modifier instances
107  that will be used to modify the Process as it is built
108  """
109  self.__dict__['_Process__name'] = name
110  if not name.isalnum():
111  raise RuntimeError("Error: The process name is an empty string or contains non-alphanumeric characters")
112  self.__dict__['_Process__filters'] = {}
113  self.__dict__['_Process__producers'] = {}
114  self.__dict__['_Process__switchproducers'] = {}
115  self.__dict__['_Process__source'] = None
116  self.__dict__['_Process__looper'] = None
117  self.__dict__['_Process__subProcesses'] = []
118  self.__dict__['_Process__schedule'] = None
119  self.__dict__['_Process__analyzers'] = {}
120  self.__dict__['_Process__outputmodules'] = {}
121  self.__dict__['_Process__paths'] = DictTypes.SortedKeysDict() # have to keep the order
122  self.__dict__['_Process__endpaths'] = DictTypes.SortedKeysDict() # of definition
123  self.__dict__['_Process__sequences'] = {}
124  self.__dict__['_Process__tasks'] = {}
125  self.__dict__['_Process__services'] = {}
126  self.__dict__['_Process__essources'] = {}
127  self.__dict__['_Process__esproducers'] = {}
128  self.__dict__['_Process__esprefers'] = {}
129  self.__dict__['_Process__aliases'] = {}
130  self.__dict__['_Process__psets']={}
131  self.__dict__['_Process__vpsets']={}
132  self.__dict__['_cloneToObjectDict'] = {}
133  # policy switch to avoid object overwriting during extend/load
134  self.__dict__['_Process__InExtendCall'] = False
135  self.__dict__['_Process__partialschedules'] = {}
136  self.__isStrict = False
137  self.__dict__['_Process__modifiers'] = Mods
138  self.options = Process.defaultOptions_()
139  self.maxEvents = Process.defaultMaxEvents_()
140  self.maxLuminosityBlocks = Process.defaultMaxLuminosityBlocks_()
141  for m in self.__modifiers:
142  m._setChosen()
143 
144  def setStrict(self, value):
145  self.__isStrict = value
146  _Module.__isStrict__ = True
147 
148  # some user-friendly methods for command-line browsing
149  def producerNames(self):
150  """Returns a string containing all the EDProducer labels separated by a blank"""
151  return ' '.join(self.producers_().keys())
153  """Returns a string containing all the SwitchProducer labels separated by a blank"""
154  return ' '.join(self.switchProducers_().keys())
155  def analyzerNames(self):
156  """Returns a string containing all the EDAnalyzer labels separated by a blank"""
157  return ' '.join(self.analyzers_().keys())
158  def filterNames(self):
159  """Returns a string containing all the EDFilter labels separated by a blank"""
160  return ' '.join(self.filters_().keys())
161  def pathNames(self):
162  """Returns a string containing all the Path names separated by a blank"""
163  return ' '.join(self.paths_().keys())
164 
165  def __setstate__(self, pkldict):
166  """
167  Unpickling hook.
168 
169  Since cloneToObjectDict stores a hash of objects by their
170  id() it needs to be updated when unpickling to use the
171  new object id values instantiated during the unpickle.
172 
173  """
174  self.__dict__.update(pkldict)
175  tmpDict = {}
176  for value in self._cloneToObjectDict.values():
177  tmpDict[id(value)] = value
178  self.__dict__['_cloneToObjectDict'] = tmpDict
179 
180 
181 
182  def filters_(self):
183  """returns a dict of the filters that have been added to the Process"""
184  return DictTypes.FixedKeysDict(self.__filters)
185  filters = property(filters_, doc="dictionary containing the filters for the process")
186  def name_(self):
187  return self.__name
188  def setName_(self,name):
189  if not name.isalnum():
190  raise RuntimeError("Error: The process name is an empty string or contains non-alphanumeric characters")
191  self.__dict__['_Process__name'] = name
192  process = property(name_,setName_, doc="name of the process")
193  def producers_(self):
194  """returns a dict of the producers that have been added to the Process"""
195  return DictTypes.FixedKeysDict(self.__producers)
196  producers = property(producers_,doc="dictionary containing the producers for the process")
197  def switchProducers_(self):
198  """returns a dict of the SwitchProducers that have been added to the Process"""
199  return DictTypes.FixedKeysDict(self.__switchproducers)
200  switchProducers = property(switchProducers_,doc="dictionary containing the SwitchProducers for the process")
201  def source_(self):
202  """returns the source that has been added to the Process or None if none have been added"""
203  return self.__source
204  def setSource_(self,src):
205  self._placeSource('source',src)
206  source = property(source_,setSource_,doc='the main source or None if not set')
207  def looper_(self):
208  """returns the looper that has been added to the Process or None if none have been added"""
209  return self.__looper
210  def setLooper_(self,lpr):
211  self._placeLooper('looper',lpr)
212  looper = property(looper_,setLooper_,doc='the main looper or None if not set')
213  @staticmethod
215  return untracked.PSet(numberOfThreads = untracked.uint32(1),
216  numberOfStreams = untracked.uint32(0),
217  numberOfConcurrentRuns = untracked.uint32(1),
218  numberOfConcurrentLuminosityBlocks = untracked.uint32(1),
219  eventSetup = untracked.PSet(
220  numberOfConcurrentIOVs = untracked.uint32(1),
221  forceNumberOfConcurrentIOVs = untracked.PSet(
222  allowAnyLabel_ = required.untracked.uint32
223  )
224  ),
225  wantSummary = untracked.bool(False),
226  fileMode = untracked.string('FULLMERGE'),
227  forceEventSetupCacheClearOnNewRun = untracked.bool(False),
228  throwIfIllegalParameter = untracked.bool(True),
229  printDependencies = untracked.bool(False),
230  sizeOfStackForThreadsInKB = optional.untracked.uint32,
231  Rethrow = untracked.vstring(),
232  SkipEvent = untracked.vstring(),
233  FailPath = untracked.vstring(),
234  IgnoreCompletely = untracked.vstring(),
235  canDeleteEarly = untracked.vstring(),
236  allowUnscheduled = obsolete.untracked.bool,
237  emptyRunLumiMode = obsolete.untracked.string,
238  makeTriggerResults = obsolete.untracked.bool
239  )
240  def __updateOptions(self,opt):
241  newOpts = self.defaultOptions_()
242  if isinstance(opt,dict):
243  for k,v in six.iteritems(opt):
244  setattr(newOpts,k,v)
245  else:
246  for p in opt.parameters_():
247  setattr(newOpts, p, getattr(opt,p))
248  return newOpts
249  @staticmethod
251  return untracked.PSet(input=optional.untracked.int32,
252  output=optional.untracked.allowed(int32,PSet))
253  def __updateMaxEvents(self,ps):
254  newMax = self.defaultMaxEvents_()
255  if isinstance(ps,dict):
256  for k,v in six.iteritems(ps):
257  setattr(newMax,k,v)
258  else:
259  for p in ps.parameters_():
260  setattr(newMax, p, getattr(ps,p))
261  return newMax
262  @staticmethod
264  return untracked.PSet(input=untracked.int32(-1))
265  def subProcesses_(self):
266  """returns a list of the subProcesses that have been added to the Process"""
267  return self.__subProcesses
268  subProcesses = property(subProcesses_,doc='the SubProcesses that have been added to the Process')
269  def analyzers_(self):
270  """returns a dict of the analyzers that have been added to the Process"""
271  return DictTypes.FixedKeysDict(self.__analyzers)
272  analyzers = property(analyzers_,doc="dictionary containing the analyzers for the process")
273  def outputModules_(self):
274  """returns a dict of the output modules that have been added to the Process"""
275  return DictTypes.FixedKeysDict(self.__outputmodules)
276  outputModules = property(outputModules_,doc="dictionary containing the output_modules for the process")
277  def paths_(self):
278  """returns a dict of the paths that have been added to the Process"""
279  return DictTypes.SortedAndFixedKeysDict(self.__paths)
280  paths = property(paths_,doc="dictionary containing the paths for the process")
281  def endpaths_(self):
282  """returns a dict of the endpaths that have been added to the Process"""
283  return DictTypes.SortedAndFixedKeysDict(self.__endpaths)
284  endpaths = property(endpaths_,doc="dictionary containing the endpaths for the process")
285  def sequences_(self):
286  """returns a dict of the sequences that have been added to the Process"""
287  return DictTypes.FixedKeysDict(self.__sequences)
288  sequences = property(sequences_,doc="dictionary containing the sequences for the process")
289  def tasks_(self):
290  """returns a dict of the tasks that have been added to the Process"""
291  return DictTypes.FixedKeysDict(self.__tasks)
292  tasks = property(tasks_,doc="dictionary containing the tasks for the process")
293  def schedule_(self):
294  """returns the schedule that has been added to the Process or None if none have been added"""
295  return self.__schedule
296  def setPartialSchedule_(self,sch,label):
297  if label == "schedule":
298  self.setSchedule_(sch)
299  else:
300  self._place(label, sch, self.__partialschedules)
301  def setSchedule_(self,sch):
302  # See if every path and endpath has been inserted into the process
303  index = 0
304  try:
305  for p in sch:
306  p.label_()
307  index +=1
308  except:
309  raise RuntimeError("The path at index "+str(index)+" in the Schedule was not attached to the process.")
310  self.__dict__['_Process__schedule'] = sch
311  schedule = property(schedule_,setSchedule_,doc='the schedule or None if not set')
312  def services_(self):
313  """returns a dict of the services that have been added to the Process"""
314  return DictTypes.FixedKeysDict(self.__services)
315  services = property(services_,doc="dictionary containing the services for the process")
316  def es_producers_(self):
317  """returns a dict of the esproducers that have been added to the Process"""
318  return DictTypes.FixedKeysDict(self.__esproducers)
319  es_producers = property(es_producers_,doc="dictionary containing the es_producers for the process")
320  def es_sources_(self):
321  """returns a the es_sources that have been added to the Process"""
322  return DictTypes.FixedKeysDict(self.__essources)
323  es_sources = property(es_sources_,doc="dictionary containing the es_sources for the process")
324  def es_prefers_(self):
325  """returns a dict of the es_prefers that have been added to the Process"""
326  return DictTypes.FixedKeysDict(self.__esprefers)
327  es_prefers = property(es_prefers_,doc="dictionary containing the es_prefers for the process")
328  def aliases_(self):
329  """returns a dict of the aliases that have been added to the Process"""
330  return DictTypes.FixedKeysDict(self.__aliases)
331  aliases = property(aliases_,doc="dictionary containing the aliases for the process")
332  def psets_(self):
333  """returns a dict of the PSets that have been added to the Process"""
334  return DictTypes.FixedKeysDict(self.__psets)
335  psets = property(psets_,doc="dictionary containing the PSets for the process")
336  def vpsets_(self):
337  """returns a dict of the VPSets that have been added to the Process"""
338  return DictTypes.FixedKeysDict(self.__vpsets)
339  vpsets = property(vpsets_,doc="dictionary containing the PSets for the process")
340 
341  def isUsingModifier(self,mod):
342  """returns True if the Modifier is in used by this Process"""
343  if mod._isChosen():
344  for m in self.__modifiers:
345  if m._isOrContains(mod):
346  return True
347  return False
348 
349  def __setObjectLabel(self, object, newLabel) :
350  if not object.hasLabel_() :
351  object.setLabel(newLabel)
352  return
353  if newLabel == object.label_() :
354  return
355  if newLabel is None :
356  object.setLabel(None)
357  return
358  if (hasattr(self, object.label_()) and id(getattr(self, object.label_())) == id(object)) :
359  msg100 = "Attempting to change the label of an attribute of the Process\n"
360  msg101 = "Old label = "+object.label_()+" New label = "+newLabel+"\n"
361  msg102 = "Type = "+str(type(object))+"\n"
362  msg103 = "Some possible solutions:\n"
363  msg104 = " 1. Clone modules instead of using simple assignment. Cloning is\n"
364  msg105 = " also preferred for other types when possible.\n"
365  msg106 = " 2. Declare new names starting with an underscore if they are\n"
366  msg107 = " for temporaries you do not want propagated into the Process. The\n"
367  msg108 = " underscore tells \"from x import *\" and process.load not to import\n"
368  msg109 = " the name.\n"
369  msg110 = " 3. Reorganize so the assigment is not necessary. Giving a second\n"
370  msg111 = " name to the same object usually causes confusion and problems.\n"
371  msg112 = " 4. Compose Sequences: newName = cms.Sequence(oldName)\n"
372  raise ValueError(msg100+msg101+msg102+msg103+msg104+msg105+msg106+msg107+msg108+msg109+msg110+msg111+msg112)
373  object.setLabel(None)
374  object.setLabel(newLabel)
375 
376  def __setattr__(self,name,value):
377  # check if the name is well-formed (only _ and alphanumerics are allowed)
378  if not name.replace('_','').isalnum():
379  raise ValueError('The label '+name+' contains forbiden characters')
380 
381  if name == 'options':
382  value = self.__updateOptions(value)
383  if name == 'maxEvents':
384  value = self.__updateMaxEvents(value)
385 
386  # private variable exempt from all this
387  if name.startswith('_Process__'):
388  self.__dict__[name]=value
389  return
390  if not isinstance(value,_ConfigureComponent):
391  raise TypeError("can only assign labels to an object that inherits from '_ConfigureComponent'\n"
392  +"an instance of "+str(type(value))+" will not work - requested label is "+name)
393  if not isinstance(value,_Labelable) and not isinstance(value,Source) and not isinstance(value,Looper) and not isinstance(value,Schedule):
394  if name == value.type_():
395  # Only Services get handled here
396  self.add_(value)
397  return
398  else:
399  raise TypeError("an instance of "+str(type(value))+" can not be assigned the label '"+name+"'.\n"+
400  "Please either use the label '"+value.type_()+" or use the 'add_' method instead.")
401  #clone the item
402  if self.__isStrict:
403  newValue =value.copy()
404  try:
405  newValue._filename = value._filename
406  except:
407  pass
408  value.setIsFrozen()
409  else:
410  newValue =value
411  if not self._okToPlace(name, value, self.__dict__):
412  newFile='top level config'
413  if hasattr(value,'_filename'):
414  newFile = value._filename
415  oldFile='top level config'
416  oldValue = getattr(self,name)
417  if hasattr(oldValue,'_filename'):
418  oldFile = oldValue._filename
419  msg = "Trying to override definition of process."+name
420  msg += "\n new object defined in: "+newFile
421  msg += "\n existing object defined in: "+oldFile
422  raise ValueError(msg)
423  # remove the old object of the name (if there is one)
424  if hasattr(self,name) and not (getattr(self,name)==newValue):
425  # Complain if items in sequences or tasks from load() statements have
426  # degenerate names, but if the user overwrites a name in the
427  # main config, replace it everywhere
428  if newValue._isTaskComponent():
429  if not self.__InExtendCall:
430  self._replaceInTasks(name, newValue)
431  self._replaceInSchedule(name, newValue)
432  else:
433  if not isinstance(newValue, Task):
434  #should check to see if used in task before complaining
435  newFile='top level config'
436  if hasattr(value,'_filename'):
437  newFile = value._filename
438  oldFile='top level config'
439  oldValue = getattr(self,name)
440  if hasattr(oldValue,'_filename'):
441  oldFile = oldValue._filename
442  msg1 = "Trying to override definition of "+name+" while it is used by the task "
443  msg2 = "\n new object defined in: "+newFile
444  msg2 += "\n existing object defined in: "+oldFile
445  s = self.__findFirstUsingModule(self.tasks,oldValue)
446  if s is not None:
447  raise ValueError(msg1+s.label_()+msg2)
448 
449  if isinstance(newValue, _Sequenceable) or newValue._isTaskComponent():
450  if not self.__InExtendCall:
451  self._replaceInSequences(name, newValue)
452  else:
453  #should check to see if used in sequence before complaining
454  newFile='top level config'
455  if hasattr(value,'_filename'):
456  newFile = value._filename
457  oldFile='top level config'
458  oldValue = getattr(self,name)
459  if hasattr(oldValue,'_filename'):
460  oldFile = oldValue._filename
461  msg1 = "Trying to override definition of "+name+" while it is used by the "
462  msg2 = "\n new object defined in: "+newFile
463  msg2 += "\n existing object defined in: "+oldFile
464  s = self.__findFirstUsingModule(self.sequences,oldValue)
465  if s is not None:
466  raise ValueError(msg1+"sequence "+s.label_()+msg2)
467  s = self.__findFirstUsingModule(self.paths,oldValue)
468  if s is not None:
469  raise ValueError(msg1+"path "+s.label_()+msg2)
470  s = self.__findFirstUsingModule(self.endpaths,oldValue)
471  if s is not None:
472  raise ValueError(msg1+"endpath "+s.label_()+msg2)
473 
474  # In case of EDAlias, raise Exception always to avoid surprises
475  if isinstance(newValue, EDAlias):
476  oldValue = getattr(self, name)
477  #should check to see if used in task/sequence before complaining
478  newFile='top level config'
479  if hasattr(value,'_filename'):
480  newFile = value._filename
481  oldFile='top level config'
482  if hasattr(oldValue,'_filename'):
483  oldFile = oldValue._filename
484  msg1 = "Trying to override definition of "+name+" with an EDAlias while it is used by the "
485  msg2 = "\n new object defined in: "+newFile
486  msg2 += "\n existing object defined in: "+oldFile
487  s = self.__findFirstUsingModule(self.tasks,oldValue)
488  if s is not None:
489  raise ValueError(msg1+"task "+s.label_()+msg2)
490  s = self.__findFirstUsingModule(self.sequences,oldValue)
491  if s is not None:
492  raise ValueError(msg1+"sequence "+s.label_()+msg2)
493  s = self.__findFirstUsingModule(self.paths,oldValue)
494  if s is not None:
495  raise ValueError(msg1+"path "+s.label_()+msg2)
496  s = self.__findFirstUsingModule(self.endpaths,oldValue)
497  if s is not None:
498  raise ValueError(msg1+"endpath "+s.label_()+msg2)
499 
500  self._delattrFromSetattr(name)
501  self.__dict__[name]=newValue
502  if isinstance(newValue,_Labelable):
503  self.__setObjectLabel(newValue, name)
504  self._cloneToObjectDict[id(value)] = newValue
505  self._cloneToObjectDict[id(newValue)] = newValue
506  #now put in proper bucket
507  newValue._place(name,self)
508  def __findFirstUsingModule(self, seqsOrTasks, mod):
509  """Given a container of sequences or tasks, find the first sequence or task
510  containing mod and return it. If none is found, return None"""
511  from FWCore.ParameterSet.SequenceTypes import ModuleNodeVisitor
512  l = list()
513  for seqOrTask in six.itervalues(seqsOrTasks):
514  l[:] = []
515  v = ModuleNodeVisitor(l)
516  seqOrTask.visit(v)
517  if mod in l:
518  return seqOrTask
519  return None
520 
521  def _delHelper(self,name):
522  if not hasattr(self,name):
523  raise KeyError('process does not know about '+name)
524  elif name.startswith('_Process__'):
525  raise ValueError('this attribute cannot be deleted')
526 
527  # we have to remove it from all dictionaries/registries
528  dicts = [item for item in self.__dict__.values() if (isinstance(item, dict) or isinstance(item, DictTypes.SortedKeysDict))]
529  for reg in dicts:
530  if name in reg: del reg[name]
531  # if it was a labelable object, the label needs to be removed
532  obj = getattr(self,name)
533  if isinstance(obj,_Labelable):
534  obj.setLabel(None)
535  if isinstance(obj,Service):
536  obj._inProcess = False
537 
538  def __delattr__(self,name):
539  self._delHelper(name)
540  obj = getattr(self,name)
541  if not obj is None:
542  if not isinstance(obj, Sequence) and not isinstance(obj, Task):
543  # For modules, ES modules and services we can also remove
544  # the deleted object from Sequences, Paths, EndPaths, and
545  # Tasks. Note that for Sequences and Tasks that cannot be done
546  # reliably as the places where the Sequence or Task was used
547  # might have been expanded so we do not even try. We considered
548  # raising an exception if a Sequences or Task was explicitly
549  # deleted, but did not because when done carefully deletion
550  # is sometimes OK (for example in the prune function where it
551  # has been checked that the deleted Sequence is not used).
552  if obj._isTaskComponent():
553  self._replaceInTasks(name, None)
554  self._replaceInSchedule(name, None)
555  if isinstance(obj, _Sequenceable) or obj._isTaskComponent():
556  self._replaceInSequences(name, None)
557  # now remove it from the process itself
558  try:
559  del self.__dict__[name]
560  except:
561  pass
562 
563  def _delattrFromSetattr(self,name):
564  """Similar to __delattr__ but we need different behavior when called from __setattr__"""
565  self._delHelper(name)
566  # now remove it from the process itself
567  try:
568  del self.__dict__[name]
569  except:
570  pass
571 
572  def add_(self,value):
573  """Allows addition of components that do not have to have a label, e.g. Services"""
574  if not isinstance(value,_ConfigureComponent):
575  raise TypeError
576  if not isinstance(value,_Unlabelable):
577  raise TypeError
578  #clone the item
579  #clone the item
580  if self.__isStrict:
581  newValue =value.copy()
582  value.setIsFrozen()
583  else:
584  newValue =value
585  newValue._place('',self)
586 
587  def _okToPlace(self, name, mod, d):
588  if not self.__InExtendCall:
589  # if going
590  return True
591  elif not self.__isStrict:
592  return True
593  elif name in d:
594  # if there's an old copy, and the new one
595  # hasn't been modified, we're done. Still
596  # not quite safe if something has been defined twice.
597  # Need to add checks
598  if mod._isModified:
599  if d[name]._isModified:
600  return False
601  else:
602  return True
603  else:
604  return True
605  else:
606  return True
607 
608  def _place(self, name, mod, d):
609  if self._okToPlace(name, mod, d):
610  if self.__isStrict and isinstance(mod, _ModuleSequenceType):
611  d[name] = mod._postProcessFixup(self._cloneToObjectDict)
612  else:
613  d[name] = mod
614  if isinstance(mod,_Labelable):
615  self.__setObjectLabel(mod, name)
616  def _placeOutputModule(self,name,mod):
617  self._place(name, mod, self.__outputmodules)
618  def _placeProducer(self,name,mod):
619  self._place(name, mod, self.__producers)
620  def _placeSwitchProducer(self,name,mod):
621  self._place(name, mod, self.__switchproducers)
622  def _placeFilter(self,name,mod):
623  self._place(name, mod, self.__filters)
624  def _placeAnalyzer(self,name,mod):
625  self._place(name, mod, self.__analyzers)
626  def _placePath(self,name,mod):
627  self._validateSequence(mod, name)
628  try:
629  self._place(name, mod, self.__paths)
630  except ModuleCloneError as msg:
631  context = format_outerframe(4)
632  raise Exception("%sThe module %s in path %s is unknown to the process %s." %(context, msg, name, self._Process__name))
633  def _placeEndPath(self,name,mod):
634  self._validateSequence(mod, name)
635  try:
636  self._place(name, mod, self.__endpaths)
637  except ModuleCloneError as msg:
638  context = format_outerframe(4)
639  raise Exception("%sThe module %s in endpath %s is unknown to the process %s." %(context, msg, name, self._Process__name))
640  def _placeSequence(self,name,mod):
641  self._validateSequence(mod, name)
642  self._place(name, mod, self.__sequences)
643  def _placeESProducer(self,name,mod):
644  self._place(name, mod, self.__esproducers)
645  def _placeESPrefer(self,name,mod):
646  self._place(name, mod, self.__esprefers)
647  def _placeESSource(self,name,mod):
648  self._place(name, mod, self.__essources)
649  def _placeTask(self,name,task):
650  self._validateTask(task, name)
651  self._place(name, task, self.__tasks)
652  def _placeAlias(self,name,mod):
653  self._place(name, mod, self.__aliases)
654  def _placePSet(self,name,mod):
655  self._place(name, mod, self.__psets)
656  def _placeVPSet(self,name,mod):
657  self._place(name, mod, self.__vpsets)
658  def _placeSource(self,name,mod):
659  """Allow the source to be referenced by 'source' or by type name"""
660  if name != 'source':
661  raise ValueError("The label '"+name+"' can not be used for a Source. Only 'source' is allowed.")
662  if self.__dict__['_Process__source'] is not None :
663  del self.__dict__[self.__dict__['_Process__source'].type_()]
664  self.__dict__['_Process__source'] = mod
665  self.__dict__[mod.type_()] = mod
666  def _placeLooper(self,name,mod):
667  if name != 'looper':
668  raise ValueError("The label '"+name+"' can not be used for a Looper. Only 'looper' is allowed.")
669  self.__dict__['_Process__looper'] = mod
670  self.__dict__[mod.type_()] = mod
671  def _placeSubProcess(self,name,mod):
672  self.__dict__['_Process__subProcess'] = mod
673  self.__dict__[mod.type_()] = mod
674  def addSubProcess(self,mod):
675  self.__subProcesses.append(mod)
676  def _placeService(self,typeName,mod):
677  self._place(typeName, mod, self.__services)
678  if typeName in self.__dict__:
679  self.__dict__[typeName]._inProcess = False
680  self.__dict__[typeName]=mod
681  def load(self, moduleName):
682  moduleName = moduleName.replace("/",".")
683  module = __import__(moduleName)
684  self.extend(sys.modules[moduleName])
685  def extend(self,other,items=()):
686  """Look in other and find types that we can use"""
687  # enable explicit check to avoid overwriting of existing objects
688  self.__dict__['_Process__InExtendCall'] = True
689 
690  seqs = dict()
691  tasksToAttach = dict()
692  mods = []
693  for name in dir(other):
694  #'from XX import *' ignores these, and so should we.
695  if name.startswith('_'):
696  continue
697  item = getattr(other,name)
698  if name == "source" or name == "looper":
699  # In these cases 'item' could be None if the specific object was not defined
700  if item is not None:
701  self.__setattr__(name,item)
702  elif isinstance(item,_ModuleSequenceType):
703  seqs[name]=item
704  elif isinstance(item,Task):
705  tasksToAttach[name] = item
706  elif isinstance(item,_Labelable):
707  self.__setattr__(name,item)
708  if not item.hasLabel_() :
709  item.setLabel(name)
710  elif isinstance(item,Schedule):
711  self.__setattr__(name,item)
712  elif isinstance(item,_Unlabelable):
713  self.add_(item)
714  elif isinstance(item,ProcessModifier):
715  mods.append(item)
716  elif isinstance(item,ProcessFragment):
717  self.extend(item)
718 
719  #now create a sequence that uses the newly made items
720  for name,seq in six.iteritems(seqs):
721  if id(seq) not in self._cloneToObjectDict:
722  self.__setattr__(name,seq)
723  else:
724  newSeq = self._cloneToObjectDict[id(seq)]
725  self.__dict__[name]=newSeq
726  self.__setObjectLabel(newSeq, name)
727  #now put in proper bucket
728  newSeq._place(name,self)
729 
730  for name, task in six.iteritems(tasksToAttach):
731  self.__setattr__(name, task)
732 
733  #apply modifiers now that all names have been added
734  for item in mods:
735  item.apply(self)
736 
737  self.__dict__['_Process__InExtendCall'] = False
738 
739  def _dumpConfigNamedList(self,items,typeName,options):
740  returnValue = ''
741  for name,item in items:
742  returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
743  return returnValue
744 
745  def _dumpConfigUnnamedList(self,items,typeName,options):
746  returnValue = ''
747  for name,item in items:
748  returnValue +=options.indentation()+typeName+' = '+item.dumpConfig(options)
749  return returnValue
750 
751  def _dumpConfigOptionallyNamedList(self,items,typeName,options):
752  returnValue = ''
753  for name,item in items:
754  if name == item.type_():
755  name = ''
756  returnValue +=options.indentation()+typeName+' '+name+' = '+item.dumpConfig(options)
757  return returnValue
758 
759  def dumpConfig(self, options=PrintOptions()):
760  """return a string containing the equivalent process defined using the old configuration language"""
761  config = "process "+self.__name+" = {\n"
762  options.indent()
763  if self.source_():
764  config += options.indentation()+"source = "+self.source_().dumpConfig(options)
765  if self.looper_():
766  config += options.indentation()+"looper = "+self.looper_().dumpConfig(options)
767 
768  config+=self._dumpConfigNamedList(self.subProcesses_(),
769  'subProcess',
770  options)
771  config+=self._dumpConfigNamedList(six.iteritems(self.producers_()),
772  'module',
773  options)
774  config+=self._dumpConfigNamedList(six.iteritems(self.switchProducers_()),
775  'module',
776  options)
777  config+=self._dumpConfigNamedList(six.iteritems(self.filters_()),
778  'module',
779  options)
780  config+=self._dumpConfigNamedList(six.iteritems(self.analyzers_()),
781  'module',
782  options)
783  config+=self._dumpConfigNamedList(six.iteritems(self.outputModules_()),
784  'module',
785  options)
786  config+=self._dumpConfigNamedList(six.iteritems(self.sequences_()),
787  'sequence',
788  options)
789  config+=self._dumpConfigNamedList(six.iteritems(self.paths_()),
790  'path',
791  options)
792  config+=self._dumpConfigNamedList(six.iteritems(self.endpaths_()),
793  'endpath',
794  options)
795  config+=self._dumpConfigUnnamedList(six.iteritems(self.services_()),
796  'service',
797  options)
798  config+=self._dumpConfigNamedList(six.iteritems(self.aliases_()),
799  'alias',
800  options)
801  config+=self._dumpConfigOptionallyNamedList(
802  six.iteritems(self.es_producers_()),
803  'es_module',
804  options)
805  config+=self._dumpConfigOptionallyNamedList(
806  six.iteritems(self.es_sources_()),
807  'es_source',
808  options)
809  config += self._dumpConfigESPrefers(options)
810  for name,item in six.iteritems(self.psets):
811  config +=options.indentation()+item.configTypeName()+' '+name+' = '+item.configValue(options)
812  for name,item in six.iteritems(self.vpsets):
813  config +=options.indentation()+'VPSet '+name+' = '+item.configValue(options)
814  if self.schedule:
815  pathNames = [p.label_() for p in self.schedule]
816  config +=options.indentation()+'schedule = {'+','.join(pathNames)+'}\n'
817 
818 # config+=self._dumpConfigNamedList(six.iteritems(self.vpsets),
819 # 'VPSet',
820 # options)
821  config += "}\n"
822  options.unindent()
823  return config
824 
825  def _dumpConfigESPrefers(self, options):
826  result = ''
827  for item in six.itervalues(self.es_prefers_()):
828  result +=options.indentation()+'es_prefer '+item.targetLabel_()+' = '+item.dumpConfig(options)
829  return result
830 
831  def _dumpPythonSubProcesses(self, l, options):
832  returnValue = ''
833  for item in l:
834  returnValue += item.dumpPython(options)+'\n\n'
835  return returnValue
836 
837  def _dumpPythonList(self, d, options):
838  returnValue = ''
839  if isinstance(d, DictTypes.SortedKeysDict):
840  for name,item in d.items():
841  returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n'
842  else:
843  for name,item in sorted(d.items()):
844  returnValue +='process.'+name+' = '+item.dumpPython(options)+'\n\n'
845  return returnValue
846 
847  def _splitPythonList(self, subfolder, d, options):
848  parts = DictTypes.SortedKeysDict()
849  for name, item in d.items() if isinstance(d, DictTypes.SortedKeysDict) else sorted(d.items()):
850  code = ''
851  dependencies = item.directDependencies()
852  for module_subfolder, module in dependencies:
853  module = module + '_cfi'
854  if options.useSubdirectories and module_subfolder:
855  module = module_subfolder + '.' + module
856  if options.targetDirectory is not None:
857  if options.useSubdirectories and subfolder:
858  module = '..' + module
859  else:
860  module = '.' + module
861  code += 'from ' + module + ' import *\n'
862  if dependencies:
863  code += '\n'
864  code += name + ' = ' + item.dumpPython(options)
865  parts[name] = subfolder, code
866  return parts
867 
868  def _validateSequence(self, sequence, label):
869  # See if every module has been inserted into the process
870  try:
871  l = set()
872  visitor = NodeNameVisitor(l)
873  sequence.visit(visitor)
874  except:
875  raise RuntimeError("An entry in sequence "+label + ' has no label')
876 
877  def _validateTask(self, task, label):
878  # See if every module and service has been inserted into the process
879  try:
880  l = set()
881  visitor = NodeNameVisitor(l)
882  task.visit(visitor)
883  except:
884  raise RuntimeError("An entry in task " + label + ' has not been attached to the process')
885 
886  def _itemsInDependencyOrder(self, processDictionaryOfItems):
887  # The items can be Sequences or Tasks and the input
888  # argument should either be the dictionary of sequences
889  # or the dictionary of tasks from the process.
890 
891  returnValue=DictTypes.SortedKeysDict()
892 
893  # For each item, see what other items it depends upon
894  # For our purpose here, an item depends on the items it contains.
895  dependencies = {}
896  for label,item in six.iteritems(processDictionaryOfItems):
897  containedItems = []
898  if isinstance(item, Task):
899  v = TaskVisitor(containedItems)
900  else:
901  v = SequenceVisitor(containedItems)
902  try:
903  item.visit(v)
904  except RuntimeError:
905  if isinstance(item, Task):
906  raise RuntimeError("Failed in a Task visitor. Probably " \
907  "a circular dependency discovered in Task with label " + label)
908  else:
909  raise RuntimeError("Failed in a Sequence visitor. Probably a " \
910  "circular dependency discovered in Sequence with label " + label)
911  for containedItem in containedItems:
912  # Check for items that both have labels and are not in the process.
913  # This should not normally occur unless someone explicitly assigns a
914  # label without putting the item in the process (which should not ever
915  # be done). We check here because this problem could cause the code
916  # in the 'while' loop below to go into an infinite loop.
917  if containedItem.hasLabel_():
918  testItem = processDictionaryOfItems.get(containedItem.label_())
919  if testItem is None or containedItem != testItem:
920  if isinstance(item, Task):
921  raise RuntimeError("Task has a label, but using its label to get an attribute" \
922  " from the process yields a different object or None\n"+
923  "label = " + containedItem.label_())
924  else:
925  raise RuntimeError("Sequence has a label, but using its label to get an attribute" \
926  " from the process yields a different object or None\n"+
927  "label = " + containedItem.label_())
928  dependencies[label]=[dep.label_() for dep in containedItems if dep.hasLabel_()]
929 
930  # keep looping until we get rid of all dependencies
931  while dependencies:
932  oldDeps = dict(dependencies)
933  for label,deps in six.iteritems(oldDeps):
934  if len(deps)==0:
935  returnValue[label]=processDictionaryOfItems[label]
936  #remove this as a dependency for all other tasks
937  del dependencies[label]
938  for lb2,deps2 in six.iteritems(dependencies):
939  while deps2.count(label):
940  deps2.remove(label)
941  return returnValue
942 
943  def _dumpPython(self, d, options):
944  result = ''
945  for name, value in sorted(six.iteritems(d)):
946  result += value.dumpPythonAs(name,options)+'\n'
947  return result
948 
949  def _splitPython(self, subfolder, d, options):
950  result = {}
951  for name, value in sorted(six.iteritems(d)):
952  result[name] = subfolder, value.dumpPythonAs(name, options) + '\n'
953  return result
954 
955  def dumpPython(self, options=PrintOptions()):
956  """return a string containing the equivalent process defined using python"""
957  specialImportRegistry._reset()
958  header = "import FWCore.ParameterSet.Config as cms"
959  result = "process = cms.Process(\""+self.__name+"\")\n\n"
960  if self.source_():
961  result += "process.source = "+self.source_().dumpPython(options)
962  if self.looper_():
963  result += "process.looper = "+self.looper_().dumpPython()
964  result+=self._dumpPythonList(self.psets, options)
965  result+=self._dumpPythonList(self.vpsets, options)
966  result+=self._dumpPythonSubProcesses(self.subProcesses_(), options)
967  result+=self._dumpPythonList(self.producers_(), options)
968  result+=self._dumpPythonList(self.switchProducers_(), options)
969  result+=self._dumpPythonList(self.filters_() , options)
970  result+=self._dumpPythonList(self.analyzers_(), options)
971  result+=self._dumpPythonList(self.outputModules_(), options)
972  result+=self._dumpPythonList(self.services_(), options)
973  result+=self._dumpPythonList(self.es_producers_(), options)
974  result+=self._dumpPythonList(self.es_sources_(), options)
975  result+=self._dumpPython(self.es_prefers_(), options)
976  result+=self._dumpPythonList(self._itemsInDependencyOrder(self.tasks), options)
977  result+=self._dumpPythonList(self._itemsInDependencyOrder(self.sequences), options)
978  result+=self._dumpPythonList(self.paths_(), options)
979  result+=self._dumpPythonList(self.endpaths_(), options)
980  result+=self._dumpPythonList(self.aliases_(), options)
981  if not self.schedule_() == None:
982  result += 'process.schedule = ' + self.schedule.dumpPython(options)
983  imports = specialImportRegistry.getSpecialImports()
984  if len(imports) > 0:
985  header += "\n" + "\n".join(imports)
986  header += "\n\n"
987  return header+result
988 
989  def splitPython(self, options = PrintOptions()):
990  """return a map of file names to python configuration fragments"""
991  specialImportRegistry._reset()
992  # extract individual fragments
993  options.isCfg = False
994  header = "import FWCore.ParameterSet.Config as cms"
995  result = ''
996  parts = {}
997  files = {}
998 
999  result = 'process = cms.Process("' + self.__name + '")\n\n'
1000 
1001  if self.source_():
1002  parts['source'] = (None, 'source = ' + self.source_().dumpPython(options))
1003 
1004  if self.looper_():
1005  parts['looper'] = (None, 'looper = ' + self.looper_().dumpPython())
1006 
1007  parts.update(self._splitPythonList('psets', self.psets, options))
1008  parts.update(self._splitPythonList('psets', self.vpsets, options))
1009  # FIXME
1010  #parts.update(self._splitPythonSubProcesses(self.subProcesses_(), options))
1011  if len(self.subProcesses_()):
1012  sys.stderr.write("error: subprocesses are not supported yet\n\n")
1013  parts.update(self._splitPythonList('modules', self.producers_(), options))
1014  parts.update(self._splitPythonList('modules', self.switchProducers_(), options))
1015  parts.update(self._splitPythonList('modules', self.filters_() , options))
1016  parts.update(self._splitPythonList('modules', self.analyzers_(), options))
1017  parts.update(self._splitPythonList('modules', self.outputModules_(), options))
1018  parts.update(self._splitPythonList('services', self.services_(), options))
1019  parts.update(self._splitPythonList('eventsetup', self.es_producers_(), options))
1020  parts.update(self._splitPythonList('eventsetup', self.es_sources_(), options))
1021  parts.update(self._splitPython('eventsetup', self.es_prefers_(), options))
1022  parts.update(self._splitPythonList('tasks', self._itemsInDependencyOrder(self.tasks), options))
1023  parts.update(self._splitPythonList('sequences', self._itemsInDependencyOrder(self.sequences), options))
1024  parts.update(self._splitPythonList('paths', self.paths_(), options))
1025  parts.update(self._splitPythonList('paths', self.endpaths_(), options))
1026  parts.update(self._splitPythonList('modules', self.aliases_(), options))
1027 
1028  if options.targetDirectory is not None:
1029  files[options.targetDirectory + '/__init__.py'] = ''
1030 
1031  if options.useSubdirectories:
1032  for sub in 'psets', 'modules', 'services', 'eventsetup', 'tasks', 'sequences', 'paths':
1033  if options.targetDirectory is not None:
1034  sub = options.targetDirectory + '/' + sub
1035  files[sub + '/__init__.py'] = ''
1036 
1037  # case insensitive sort by subfolder and module name
1038  parts = sorted(parts.items(), key = lambda nsc: (nsc[1][0].lower() if nsc[1][0] else '', nsc[0].lower()))
1039 
1040  for (name, (subfolder, code)) in parts:
1041  filename = name + '_cfi'
1042  if options.useSubdirectories and subfolder:
1043  filename = subfolder + '/' + filename
1044  if options.targetDirectory is not None:
1045  filename = options.targetDirectory + '/' + filename
1046  result += 'process.load("%s")\n' % filename
1047  files[filename + '.py'] = header + '\n\n' + code
1048 
1049  if self.schedule_() is not None:
1050  options.isCfg = True
1051  result += '\nprocess.schedule = ' + self.schedule.dumpPython(options)
1052 
1053  imports = specialImportRegistry.getSpecialImports()
1054  if len(imports) > 0:
1055  header += '\n' + '\n'.join(imports)
1056  files['-'] = header + '\n\n' + result
1057  return files
1058 
1059  def _replaceInSequences(self, label, new):
1060  old = getattr(self,label)
1061  #TODO - replace by iterator concatenation
1062  #to ovoid dependency problems between sequences, first modify
1063  # process known sequences to do a non-recursive change. Then do
1064  # a recursive change to get cases where a sub-sequence unknown to
1065  # the process has the item to be replaced
1066  for sequenceable in six.itervalues(self.sequences):
1067  sequenceable._replaceIfHeldDirectly(old,new)
1068  for sequenceable in six.itervalues(self.sequences):
1069  sequenceable.replace(old,new)
1070  for sequenceable in six.itervalues(self.paths):
1071  sequenceable.replace(old,new)
1072  for sequenceable in six.itervalues(self.endpaths):
1073  sequenceable.replace(old,new)
1074  def _replaceInTasks(self, label, new):
1075  old = getattr(self,label)
1076  for task in six.itervalues(self.tasks):
1077  task.replace(old, new)
1078  def _replaceInSchedule(self, label, new):
1079  if self.schedule_() == None:
1080  return
1081  old = getattr(self,label)
1082  for task in self.schedule_()._tasks:
1083  task.replace(old, new)
1084  def globalReplace(self,label,new):
1085  """ Replace the item with label 'label' by object 'new' in the process and all sequences/paths/tasks"""
1086  if not hasattr(self,label):
1087  raise LookupError("process has no item of label "+label)
1088  setattr(self,label,new)
1089  def _insertInto(self, parameterSet, itemDict):
1090  for name,value in six.iteritems(itemDict):
1091  value.insertInto(parameterSet, name)
1092  def _insertOneInto(self, parameterSet, label, item, tracked):
1093  vitems = []
1094  if not item == None:
1095  newlabel = item.nameInProcessDesc_(label)
1096  vitems = [newlabel]
1097  item.insertInto(parameterSet, newlabel)
1098  parameterSet.addVString(tracked, label, vitems)
1099  def _insertManyInto(self, parameterSet, label, itemDict, tracked):
1100  l = []
1101  for name,value in six.iteritems(itemDict):
1102  value.appendToProcessDescList_(l, name)
1103  value.insertInto(parameterSet, name)
1104  # alphabetical order is easier to compare with old language
1105  l.sort()
1106  parameterSet.addVString(tracked, label, l)
1107  def _insertSwitchProducersInto(self, parameterSet, labelModules, labelAliases, itemDict, tracked):
1108  modules = parameterSet.getVString(tracked, labelModules)
1109  aliases = parameterSet.getVString(tracked, labelAliases)
1110  for name,value in six.iteritems(itemDict):
1111  value.appendToProcessDescLists_(modules, aliases, name)
1112  value.insertInto(parameterSet, name)
1113  modules.sort()
1114  aliases.sort()
1115  parameterSet.addVString(tracked, labelModules, modules)
1116  parameterSet.addVString(tracked, labelAliases, aliases)
1117  def _insertSubProcessesInto(self, parameterSet, label, itemList, tracked):
1118  l = []
1119  subprocs = []
1120  for value in itemList:
1121  name = value.getProcessName()
1122  newLabel = value.nameInProcessDesc_(name)
1123  l.append(newLabel)
1124  pset = value.getSubProcessPSet(parameterSet)
1125  subprocs.append(pset)
1126  # alphabetical order is easier to compare with old language
1127  l.sort()
1128  parameterSet.addVString(tracked, label, l)
1129  parameterSet.addVPSet(False,"subProcesses",subprocs)
1130  def _insertPaths(self, processPSet, nodeVisitor):
1131  scheduledPaths = []
1132  triggerPaths = []
1133  endpaths = []
1134  if self.schedule_() == None:
1135  # make one from triggerpaths & endpaths
1136  for name in self.paths_():
1137  scheduledPaths.append(name)
1138  triggerPaths.append(name)
1139  for name in self.endpaths_():
1140  scheduledPaths.append(name)
1141  endpaths.append(name)
1142  else:
1143  for path in self.schedule_():
1144  pathname = path.label_()
1145  scheduledPaths.append(pathname)
1146  if pathname in self.endpaths_():
1147  endpaths.append(pathname)
1148  else:
1149  triggerPaths.append(pathname)
1150  for task in self.schedule_()._tasks:
1151  task.resolve(self.__dict__)
1152  scheduleTaskValidator = ScheduleTaskValidator()
1153  task.visit(scheduleTaskValidator)
1154  task.visit(nodeVisitor)
1155  processPSet.addVString(True, "@end_paths", endpaths)
1156  processPSet.addVString(True, "@paths", scheduledPaths)
1157  # trigger_paths are a little different
1158  p = processPSet.newPSet()
1159  p.addVString(True, "@trigger_paths", triggerPaths)
1160  processPSet.addPSet(True, "@trigger_paths", p)
1161  # add all these paths
1162  pathValidator = PathValidator()
1163  endpathValidator = EndPathValidator()
1164  decoratedList = []
1165  lister = DecoratedNodeNameVisitor(decoratedList)
1166  pathCompositeVisitor = CompositeVisitor(pathValidator, nodeVisitor, lister)
1167  endpathCompositeVisitor = CompositeVisitor(endpathValidator, nodeVisitor, lister)
1168  for triggername in triggerPaths:
1169  iPath = self.paths_()[triggername]
1170  iPath.resolve(self.__dict__)
1171  pathValidator.setLabel(triggername)
1172  lister.initialize()
1173  iPath.visit(pathCompositeVisitor)
1174  iPath.insertInto(processPSet, triggername, decoratedList)
1175  for endpathname in endpaths:
1176  iEndPath = self.endpaths_()[endpathname]
1177  iEndPath.resolve(self.__dict__)
1178  endpathValidator.setLabel(endpathname)
1179  lister.initialize()
1180  iEndPath.visit(endpathCompositeVisitor)
1181  iEndPath.insertInto(processPSet, endpathname, decoratedList)
1182  processPSet.addVString(False, "@filters_on_endpaths", endpathValidator.filtersOnEndpaths)
1183 
1184  def resolve(self,keepUnresolvedSequencePlaceholders=False):
1185  for x in six.itervalues(self.paths):
1186  x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1187  for x in six.itervalues(self.endpaths):
1188  x.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1189  if not self.schedule_() == None:
1190  for task in self.schedule_()._tasks:
1191  task.resolve(self.__dict__,keepUnresolvedSequencePlaceholders)
1192 
1193  def prune(self,verbose=False,keepUnresolvedSequencePlaceholders=False):
1194  """ Remove clutter from the process that we think is unnecessary:
1195  tracked PSets, VPSets and unused modules and sequences. If a Schedule has been set, then Paths and EndPaths
1196  not in the schedule will also be removed, along with an modules and sequences used only by
1197  those removed Paths and EndPaths. The keepUnresolvedSequencePlaceholders keeps also unresolved TaskPlaceholders."""
1198 # need to update this to only prune psets not on refToPSets
1199 # but for now, remove the delattr
1200 # for name in self.psets_():
1201 # if getattr(self,name).isTracked():
1202 # delattr(self, name)
1203  for name in self.vpsets_():
1204  delattr(self, name)
1205  #first we need to resolve any SequencePlaceholders being used
1206  self.resolve(keepUnresolvedSequencePlaceholders)
1207  usedModules = set()
1208  unneededPaths = set()
1209  tasks = list()
1210  tv = TaskVisitor(tasks)
1211  if self.schedule_():
1212  usedModules=set(self.schedule_().moduleNames())
1213  #get rid of unused paths
1214  schedNames = set(( x.label_() for x in self.schedule_()))
1215  names = set(self.paths)
1216  names.update(set(self.endpaths))
1217  unneededPaths = names - schedNames
1218  for n in unneededPaths:
1219  delattr(self,n)
1220  for t in self.schedule_().tasks():
1221  tv.enter(t)
1222  t.visit(tv)
1223  tv.leave(t)
1224  else:
1225  pths = list(six.itervalues(self.paths))
1226  pths.extend(six.itervalues(self.endpaths))
1227  temp = Schedule(*pths)
1228  usedModules=set(temp.moduleNames())
1229  unneededModules = self._pruneModules(self.producers_(), usedModules)
1230  unneededModules.update(self._pruneModules(self.switchProducers_(), usedModules))
1231  unneededModules.update(self._pruneModules(self.filters_(), usedModules))
1232  unneededModules.update(self._pruneModules(self.analyzers_(), usedModules))
1233  #remove sequences and tasks that do not appear in remaining paths and endpaths
1234  seqs = list()
1235  sv = SequenceVisitor(seqs)
1236  for p in six.itervalues(self.paths):
1237  p.visit(sv)
1238  p.visit(tv)
1239  for p in six.itervalues(self.endpaths):
1240  p.visit(sv)
1241  p.visit(tv)
1242  def removeUnneeded(seqOrTasks, allSequencesOrTasks):
1243  _keepSet = set(( s for s in seqOrTasks if s.hasLabel_()))
1244  _availableSet = set(six.itervalues(allSequencesOrTasks))
1245  _unneededSet = _availableSet-_keepSet
1246  _unneededLabels = []
1247  for s in _unneededSet:
1248  _unneededLabels.append(s.label_())
1249  delattr(self,s.label_())
1250  return _unneededLabels
1251  unneededSeqLabels = removeUnneeded(seqs, self.sequences)
1252  unneededTaskLabels = removeUnneeded(tasks, self.tasks)
1253  if verbose:
1254  print("prune removed the following:")
1255  print(" modules:"+",".join(unneededModules))
1256  print(" tasks:"+",".join(unneededTaskLabels))
1257  print(" sequences:"+",".join(unneededSeqLabels))
1258  print(" paths/endpaths:"+",".join(unneededPaths))
1259  def _pruneModules(self, d, scheduledNames):
1260  moduleNames = set(d.keys())
1261  junk = moduleNames - scheduledNames
1262  for name in junk:
1263  delattr(self, name)
1264  return junk
1265 
1266  def fillProcessDesc(self, processPSet):
1267  """Used by the framework to convert python to C++ objects"""
1268  class ServiceInjectorAdaptor(object):
1269  def __init__(self,ppset,thelist):
1270  self.__thelist = thelist
1271  self.__processPSet = ppset
1272  def addService(self,pset):
1273  self.__thelist.append(pset)
1274  def newPSet(self):
1275  return self.__processPSet.newPSet()
1276  #This adaptor is used to 'add' the method 'getTopPSet_'
1277  # to the ProcessDesc and PythonParameterSet C++ classes.
1278  # This method is needed for the PSet refToPSet_ functionality.
1279  class TopLevelPSetAcessorAdaptor(object):
1280  def __init__(self,ppset,process):
1281  self.__ppset = ppset
1282  self.__process = process
1283  def __getattr__(self,attr):
1284  return getattr(self.__ppset,attr)
1285  def getTopPSet_(self,label):
1286  return getattr(self.__process,label)
1287  def newPSet(self):
1288  return TopLevelPSetAcessorAdaptor(self.__ppset.newPSet(),self.__process)
1289  def addPSet(self,tracked,name,ppset):
1290  return self.__ppset.addPSet(tracked,name,self.__extractPSet(ppset))
1291  def addVPSet(self,tracked,name,vpset):
1292  return self.__ppset.addVPSet(tracked,name,[self.__extractPSet(x) for x in vpset])
1293  def __extractPSet(self,pset):
1294  if isinstance(pset,TopLevelPSetAcessorAdaptor):
1295  return pset.__ppset
1296  return pset
1297 
1298  self.validate()
1299  processPSet.addString(True, "@process_name", self.name_())
1300  all_modules = self.producers_().copy()
1301  all_modules.update(self.filters_())
1302  all_modules.update(self.analyzers_())
1303  all_modules.update(self.outputModules_())
1304  adaptor = TopLevelPSetAcessorAdaptor(processPSet,self)
1305  self._insertInto(adaptor, self.psets_())
1306  self._insertInto(adaptor, self.vpsets_())
1307  self._insertOneInto(adaptor, "@all_sources", self.source_(), True)
1308  self._insertOneInto(adaptor, "@all_loopers", self.looper_(), True)
1309  self._insertSubProcessesInto(adaptor, "@all_subprocesses", self.subProcesses_(), False)
1310  self._insertManyInto(adaptor, "@all_esprefers", self.es_prefers_(), True)
1311  self._insertManyInto(adaptor, "@all_aliases", self.aliases_(), True)
1312  # This will visit all the paths and endpaths that are scheduled to run,
1313  # as well as the Tasks associated to them and the schedule. It remembers
1314  # the modules, ESSources, ESProducers, and services it visits.
1315  nodeVisitor = NodeVisitor()
1316  self._insertPaths(adaptor, nodeVisitor)
1317  all_modules_onTasksOrScheduled = { key:value for key, value in six.iteritems(all_modules) if value in nodeVisitor.modules }
1318  self._insertManyInto(adaptor, "@all_modules", all_modules_onTasksOrScheduled, True)
1319  all_switches = self.switchProducers_().copy()
1320  all_switches_onTasksOrScheduled = {key:value for key, value in six.iteritems(all_switches) if value in nodeVisitor.modules }
1321  self._insertSwitchProducersInto(adaptor, "@all_modules", "@all_aliases", all_switches_onTasksOrScheduled, True)
1322  # Same as nodeVisitor except this one visits all the Tasks attached
1323  # to the process.
1324  processNodeVisitor = NodeVisitor()
1325  for pTask in six.itervalues(self.tasks):
1326  pTask.visit(processNodeVisitor)
1327  esProducersToEnable = {}
1328  for esProducerName, esProducer in six.iteritems(self.es_producers_()):
1329  if esProducer in nodeVisitor.esProducers or not (esProducer in processNodeVisitor.esProducers):
1330  esProducersToEnable[esProducerName] = esProducer
1331  self._insertManyInto(adaptor, "@all_esmodules", esProducersToEnable, True)
1332  esSourcesToEnable = {}
1333  for esSourceName, esSource in six.iteritems(self.es_sources_()):
1334  if esSource in nodeVisitor.esSources or not (esSource in processNodeVisitor.esSources):
1335  esSourcesToEnable[esSourceName] = esSource
1336  self._insertManyInto(adaptor, "@all_essources", esSourcesToEnable, True)
1337  #handle services differently
1338  services = []
1339  for serviceName, serviceObject in six.iteritems(self.services_()):
1340  if serviceObject in nodeVisitor.services or not (serviceObject in processNodeVisitor.services):
1341  serviceObject.insertInto(ServiceInjectorAdaptor(adaptor,services))
1342  adaptor.addVPSet(False,"services",services)
1343  return processPSet
1344 
1345  def validate(self):
1346  # check if there's some input
1347  # Breaks too many unit tests for now
1348  #if self.source_() == None and self.looper_() == None:
1349  # raise RuntimeError("No input source was found for this process")
1350  pass
1351 
1352  def prefer(self, esmodule,*args,**kargs):
1353  """Prefer this ES source or producer. The argument can
1354  either be an object label, e.g.,
1355  process.prefer(process.juicerProducer) (not supported yet)
1356  or a name of an ESSource or ESProducer
1357  process.prefer("juicer")
1358  or a type of unnamed ESSource or ESProducer
1359  process.prefer("JuicerProducer")
1360  In addition, you can pass as a labelled arguments the name of the Record you wish to
1361  prefer where the type passed is a cms.vstring and that vstring can contain the
1362  name of the C++ types in the Record that are being preferred, e.g.,
1363  #prefer all data in record 'OrangeRecord' from 'juicer'
1364  process.prefer("juicer", OrangeRecord=cms.vstring())
1365  or
1366  #prefer only "Orange" data in "OrangeRecord" from "juicer"
1367  process.prefer("juicer", OrangeRecord=cms.vstring("Orange"))
1368  or
1369  #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer"
1370  ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp"))
1371  """
1372  # see if this refers to a named ESProducer
1373  if isinstance(esmodule, ESSource) or isinstance(esmodule, ESProducer):
1374  raise RuntimeError("Syntax of process.prefer(process.esmodule) not supported yet")
1375  elif self._findPreferred(esmodule, self.es_producers_(),*args,**kargs) or \
1376  self._findPreferred(esmodule, self.es_sources_(),*args,**kargs):
1377  pass
1378  else:
1379  raise RuntimeError("Cannot resolve prefer for "+repr(esmodule))
1380 
1381  def _findPreferred(self, esname, d,*args,**kargs):
1382  # is esname a name in the dictionary?
1383  if esname in d:
1384  typ = d[esname].type_()
1385  if typ == esname:
1386  self.__setattr__( esname+"_prefer", ESPrefer(typ,*args,**kargs) )
1387  else:
1388  self.__setattr__( esname+"_prefer", ESPrefer(typ, esname,*args,**kargs) )
1389  return True
1390  else:
1391  # maybe it's an unnamed ESModule?
1392  found = False
1393  for name, value in six.iteritems(d):
1394  if value.type_() == esname:
1395  if found:
1396  raise RuntimeError("More than one ES module for "+esname)
1397  found = True
1398  self.__setattr__(esname+"_prefer", ESPrefer(d[esname].type_()) )
1399  return found
1400 
1401 
1403  def __init__(self, process):
1404  if isinstance(process, Process):
1405  self.__process = process
1406  elif isinstance(process, str):
1407  self.__process = Process(process)
1408  #make sure we do not override the defaults
1409  del self.__process.options
1410  del self.__process.maxEvents
1411  del self.__process.maxLuminosityBlocks
1412  else:
1413  raise TypeError('a ProcessFragment can only be constructed from an existig Process or from process name')
1414  def __dir__(self):
1415  return [ x for x in dir(self.__process) if isinstance(getattr(self.__process, x), _ConfigureComponent) ]
1416  def __getattribute__(self, name):
1417  if name == '_ProcessFragment__process':
1418  return object.__getattribute__(self, '_ProcessFragment__process')
1419  else:
1420  return getattr(self.__process, name)
1421  def __setattr__(self, name, value):
1422  if name == '_ProcessFragment__process':
1423  object.__setattr__(self, name, value)
1424  else:
1425  setattr(self.__process, name, value)
1426  def __delattr__(self, name):
1427  if name == '_ProcessFragment__process':
1428  pass
1429  else:
1430  return delattr(self.__process, name)
1431 
1432 
1433 class FilteredStream(dict):
1434  """a dictionary with fixed keys"""
1436  raise AttributeError("An FilteredStream defintion cannot be modified after creation.")
1437  _blocked_attribute = property(_blocked_attribute)
1438  __setattr__ = __delitem__ = __setitem__ = clear = _blocked_attribute
1439  pop = popitem = setdefault = update = _blocked_attribute
1440  def __new__(cls, *args, **kw):
1441  new = dict.__new__(cls)
1442  dict.__init__(new, *args, **kw)
1443  keys = sorted(kw.keys())
1444  if keys != ['content', 'dataTier', 'name', 'paths', 'responsible', 'selectEvents']:
1445  raise ValueError("The needed parameters are: content, dataTier, name, paths, responsible, selectEvents")
1446  if not isinstance(kw['name'],str):
1447  raise ValueError("name must be of type string")
1448  if not isinstance(kw['content'], vstring) and not isinstance(kw['content'],str):
1449  raise ValueError("content must be of type vstring or string")
1450  if not isinstance(kw['dataTier'], string):
1451  raise ValueError("dataTier must be of type string")
1452  if not isinstance(kw['selectEvents'], PSet):
1453  raise ValueError("selectEvents must be of type PSet")
1454  if not isinstance(kw['paths'],(tuple, Path)):
1455  raise ValueError("'paths' must be a tuple of paths")
1456  return new
1457  def __init__(self, *args, **kw):
1458  pass
1459  def __repr__(self):
1460  return "FilteredStream object: %s" %self["name"]
1461  def __getattr__(self,attr):
1462  return self[attr]
1463 
1465  """Allows embedding another process within a parent process. This allows one to
1466  chain processes together directly in one cmsRun job rather than having to run
1467  separate jobs that are connected via a temporary file.
1468  """
1469  def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = untracked.vstring()):
1470  """
1471  """
1472  if not isinstance(process, Process):
1473  raise ValueError("the 'process' argument must be of type cms.Process")
1474  if not isinstance(SelectEvents,PSet):
1475  raise ValueError("the 'SelectEvents' argument must be of type cms.untracked.PSet")
1476  if not isinstance(outputCommands,vstring):
1477  raise ValueError("the 'outputCommands' argument must be of type cms.untracked.vstring")
1478  self.__process = process
1479  self.__SelectEvents = SelectEvents
1480  self.__outputCommands = outputCommands
1481  def dumpPython(self, options=PrintOptions()):
1482  out = "parentProcess"+str(hash(self))+" = process\n"
1483  out += self.__process.dumpPython()
1484  out += "childProcess = process\n"
1485  out += "process = parentProcess"+str(hash(self))+"\n"
1486  out += "process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = "+self.__SelectEvents.dumpPython(options) +", outputCommands = "+self.__outputCommands.dumpPython(options) +"))"
1487  return out
1488  def getProcessName(self):
1489  return self.__process.name_()
1490  def process(self):
1491  return self.__process
1492  def SelectEvents(self):
1493  return self.__SelectEvents
1494  def outputCommands(self):
1495  return self.__outputCommands
1496  def type_(self):
1497  return 'subProcess'
1498  def nameInProcessDesc_(self,label):
1499  return label
1500  def _place(self,label,process):
1501  process._placeSubProcess('subProcess',self)
1502  def getSubProcessPSet(self,parameterSet):
1503  topPSet = parameterSet.newPSet()
1504  self.__process.fillProcessDesc(topPSet)
1505  subProcessPSet = parameterSet.newPSet()
1506  self.__SelectEvents.insertInto(subProcessPSet,"SelectEvents")
1507  self.__outputCommands.insertInto(subProcessPSet,"outputCommands")
1508  subProcessPSet.addPSet(False,"process",topPSet)
1509  return subProcessPSet
1510 
1512  """Helper class for Modifier that takes key/value pairs and uses them to reset parameters of the object"""
1513  def __init__(self,args):
1514  self.__args = args
1515  def __call__(self,obj):
1516  params = {}
1517  for k in six.iterkeys(self.__args):
1518  if hasattr(obj,k):
1519  params[k] = getattr(obj,k)
1521  for k in six.iterkeys(self.__args):
1522  if k in params:
1523  setattr(obj,k,params[k])
1524  else:
1525  #the parameter must have been removed
1526  delattr(obj,k)
1527  @staticmethod
1529  raise KeyError("Unknown parameter name "+key+" specified while calling Modifier")
1530 
1532  """A helper base class for _AndModifier, _InvertModifier, and _OrModifier to contain the common code"""
1533  def __init__(self, lhs, rhs=None):
1534  self._lhs = lhs
1535  if rhs is not None:
1536  self._rhs = rhs
1537  def toModify(self,obj, func=None,**kw):
1538  Modifier._toModifyCheck(obj,func,**kw)
1539  if not self._isChosen():
1540  return
1541  Modifier._toModify(obj,func,**kw)
1542  def toReplaceWith(self,toObj,fromObj):
1543  Modifier._toReplaceWithCheck(toObj,fromObj)
1544  if not self._isChosen():
1545  return
1546  Modifier._toReplaceWith(toObj,fromObj)
1547  def makeProcessModifier(self,func):
1548  """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1549  This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1550  In order to work, the value returned from this function must be assigned to a uniquely named variable."""
1551  return ProcessModifier(self,func)
1552  def __and__(self, other):
1553  return _AndModifier(self,other)
1554  def __invert__(self):
1555  return _InvertModifier(self)
1556  def __or__(self, other):
1557  return _OrModifier(self,other)
1558 
1560  """A modifier which only applies if multiple Modifiers are chosen"""
1561  def __init__(self, lhs, rhs):
1562  super(_AndModifier,self).__init__(lhs, rhs)
1563  def _isChosen(self):
1564  return self._lhs._isChosen() and self._rhs._isChosen()
1565 
1567  """A modifier which only applies if a Modifier is not chosen"""
1568  def __init__(self, lhs):
1569  super(_InvertModifier,self).__init__(lhs)
1570  def _isChosen(self):
1571  return not self._lhs._isChosen()
1572 
1574  """A modifier which only applies if at least one of multiple Modifiers is chosen"""
1575  def __init__(self, lhs, rhs):
1576  super(_OrModifier,self).__init__(lhs, rhs)
1577  def _isChosen(self):
1578  return self._lhs._isChosen() or self._rhs._isChosen()
1579 
1580 
1582  """This class is used to define standard modifications to a Process.
1583  An instance of this class is declared to denote a specific modification,e.g. era2017 could
1584  reconfigure items in a process to match our expectation of running in 2017. Once declared,
1585  these Modifier instances are imported into a configuration and items that need to be modified
1586  are then associated with the Modifier and with the action to do the modification.
1587  The registered modifications will only occur if the Modifier was passed to
1588  the cms.Process' constructor.
1589  """
1590  def __init__(self):
1592  self.__chosen = False
1593  def makeProcessModifier(self,func):
1594  """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1595  This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1596  In order to work, the value returned from this function must be assigned to a uniquely named variable.
1597  """
1598  return ProcessModifier(self,func)
1599  @staticmethod
1600  def _toModifyCheck(obj,func,**kw):
1601  if func is not None and len(kw) != 0:
1602  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1603  def toModify(self,obj, func=None,**kw):
1604  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1605  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1606  that will be the object passed in as the first argument.
1607  Form 2: A list of parameter name, value pairs can be passed
1608  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1609  This form can also be used to remove a parameter by passing the value of None
1610  #remove the parameter foo.fred
1611  mod.toModify(foo, fred = None)
1612  Additionally, parameters embedded within PSets can also be modified using a dictionary
1613  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1614  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1615  """
1616  Modifier._toModifyCheck(obj,func,**kw)
1617  if not self._isChosen():
1618  return
1619  Modifier._toModify(obj,func,**kw)
1620  @staticmethod
1621  def _toModify(obj,func,**kw):
1622  if func is not None:
1623  func(obj)
1624  else:
1625  temp =_ParameterModifier(kw)
1626  temp(obj)
1627  @staticmethod
1628  def _toReplaceWithCheck(toObj,fromObj):
1629  if not isinstance(fromObj, type(toObj)):
1630  raise TypeError("toReplaceWith requires both arguments to be the same class type")
1631  def toReplaceWith(self,toObj,fromObj):
1632  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1633  """
1634  Modifier._toReplaceWithCheck(toObj,fromObj)
1635  if not self._isChosen():
1636  return
1637  Modifier._toReplaceWith(toObj,fromObj)
1638  @staticmethod
1639  def _toReplaceWith(toObj,fromObj):
1640  if isinstance(fromObj,_ModuleSequenceType):
1641  toObj._seq = fromObj._seq
1642  toObj._tasks = fromObj._tasks
1643  elif isinstance(fromObj,Task):
1644  toObj._collection = fromObj._collection
1645  elif isinstance(fromObj,_Parameterizable):
1646  #clear old items just incase fromObj is not a complete superset of toObj
1647  for p in toObj.parameterNames_():
1648  delattr(toObj,p)
1649  for p in fromObj.parameterNames_():
1650  setattr(toObj,p,getattr(fromObj,p))
1651  if isinstance(fromObj,_TypedParameterizable):
1652  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1653 
1654  else:
1655  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
1656 
1657  def _setChosen(self):
1658  """Should only be called by cms.Process instances"""
1659  self.__chosen = True
1660  def _isChosen(self):
1661  return self.__chosen
1662  def __and__(self, other):
1663  return _AndModifier(self,other)
1664  def __invert__(self):
1665  return _InvertModifier(self)
1666  def __or__(self, other):
1667  return _OrModifier(self,other)
1668  def _isOrContains(self, other):
1669  return self == other
1670 
1671 
1673  """A Modifier made up of a list of Modifiers
1674  """
1675  def __init__(self, *chainedModifiers):
1676  self.__chosen = False
1677  self.__chain = chainedModifiers
1678  def _applyNewProcessModifiers(self,process):
1679  """Should only be called by cms.Process instances
1680  applies list of accumulated changes to the process"""
1681  for m in self.__chain:
1682  m._applyNewProcessModifiers(process)
1683  def _setChosen(self):
1684  """Should only be called by cms.Process instances"""
1685  self.__chosen = True
1686  for m in self.__chain:
1687  m._setChosen()
1688  def _isChosen(self):
1689  return self.__chosen
1690  def copyAndExclude(self, toExclude):
1691  """Creates a new ModifierChain which is a copy of
1692  this ModifierChain but excludes any Modifier or
1693  ModifierChain in the list toExclude.
1694  The exclusion is done recursively down the chain.
1695  """
1696  newMods = []
1697  for m in self.__chain:
1698  if m not in toExclude:
1699  s = m
1700  if isinstance(m,ModifierChain):
1701  s = m.__copyIfExclude(toExclude)
1702  newMods.append(s)
1703  return ModifierChain(*newMods)
1704  def __copyIfExclude(self,toExclude):
1705  shouldCopy = False
1706  for m in toExclude:
1707  if self._isOrContains(m):
1708  shouldCopy = True
1709  break
1710  if shouldCopy:
1711  return self.copyAndExclude(toExclude)
1712  return self
1713  def _isOrContains(self, other):
1714  if self is other:
1715  return True
1716  for m in self.__chain:
1717  if m._isOrContains(other):
1718  return True
1719  return False
1720 
1722  """A class used by a Modifier to affect an entire Process instance.
1723  When a Process 'loads' a module containing a ProcessModifier, that
1724  ProcessModifier will be applied to the Process if and only if the
1725  Modifier passed to the constructor has been chosen.
1726  """
1727  def __init__(self, modifier, func):
1728  self.__modifier = modifier
1729  self.__func = func
1730  self.__seenProcesses = set()
1731  def apply(self,process):
1732  if self.__modifier._isChosen():
1733  if process not in self.__seenProcesses:
1734  self.__func(process)
1735  self.__seenProcesses.add(process)
1736 
1737 if __name__=="__main__":
1738  import unittest
1739  import copy
1740 
1741  def _lineDiff(newString, oldString):
1742  newString = ( x for x in newString.split('\n') if len(x) > 0)
1743  oldString = [ x for x in oldString.split('\n') if len(x) > 0]
1744  diff = []
1745  oldStringLine = 0
1746  for l in newString:
1747  if oldStringLine >= len(oldString):
1748  diff.append(l)
1749  continue
1750  if l == oldString[oldStringLine]:
1751  oldStringLine +=1
1752  continue
1753  diff.append(l)
1754  return "\n".join( diff )
1755 
1757  """Has same interface as the C++ object that creates PSets
1758  """
1759  def __init__(self):
1760  self.values = dict()
1761  def __insertValue(self,tracked,label,value):
1762  self.values[label]=(tracked,value)
1763  def __getValue(self,tracked,label):
1764  pair = self.values[label]
1765  if pair[0] != tracked:
1766  raise Exception("Asked for %s parameter '%s', but it is %s" % ("tracked" if tracked else "untracked",
1767  label,
1768  "tracked" if pair[0] else "untracked"))
1769  return pair[1]
1770  def addInt32(self,tracked,label,value):
1771  self.__insertValue(tracked,label,value)
1772  def addVInt32(self,tracked,label,value):
1773  self.__insertValue(tracked,label,value)
1774  def addUInt32(self,tracked,label,value):
1775  self.__insertValue(tracked,label,value)
1776  def addVUInt32(self,tracked,label,value):
1777  self.__insertValue(tracked,label,value)
1778  def addInt64(self,tracked,label,value):
1779  self.__insertValue(tracked,label,value)
1780  def addVInt64(self,tracked,label,value):
1781  self.__insertValue(tracked,label,value)
1782  def addUInt64(self,tracked,label,value):
1783  self.__insertValue(tracked,label,value)
1784  def addVUInt64(self,tracked,label,value):
1785  self.__insertValue(tracked,label,value)
1786  def addDouble(self,tracked,label,value):
1787  self.__insertValue(tracked,label,value)
1788  def addVDouble(self,tracked,label,value):
1789  self.__insertValue(tracked,label,value)
1790  def addBool(self,tracked,label,value):
1791  self.__insertValue(tracked,label,value)
1792  def addString(self,tracked,label,value):
1793  self.__insertValue(tracked,label,value)
1794  def addVString(self,tracked,label,value):
1795  self.__insertValue(tracked,label,value)
1796  def getVString(self,tracked,label):
1797  return self.__getValue(tracked, label)
1798  def addInputTag(self,tracked,label,value):
1799  self.__insertValue(tracked,label,value)
1800  def addVInputTag(self,tracked,label,value):
1801  self.__insertValue(tracked,label,value)
1802  def addESInputTag(self,tracked,label,value):
1803  self.__insertValue(tracked,label,value)
1804  def addVESInputTag(self,tracked,label,value):
1805  self.__insertValue(tracked,label,value)
1806  def addEventID(self,tracked,label,value):
1807  self.__insertValue(tracked,label,value)
1808  def addVEventID(self,tracked,label,value):
1809  self.__insertValue(tracked,label,value)
1810  def addLuminosityBlockID(self,tracked,label,value):
1811  self.__insertValue(tracked,label,value)
1812  def addLuminosityBlockID(self,tracked,label,value):
1813  self.__insertValue(tracked,label,value)
1814  def addEventRange(self,tracked,label,value):
1815  self.__insertValue(tracked,label,value)
1816  def addVEventRange(self,tracked,label,value):
1817  self.__insertValue(tracked,label,value)
1818  def addPSet(self,tracked,label,value):
1819  self.__insertValue(tracked,label,value)
1820  def addVPSet(self,tracked,label,value):
1821  self.__insertValue(tracked,label,value)
1822  def addFileInPath(self,tracked,label,value):
1823  self.__insertValue(tracked,label,value)
1824  def newPSet(self):
1825  return TestMakePSet()
1826 
1828  def __init__(self, **kargs):
1829  super(SwitchProducerTest,self).__init__(
1830  dict(
1831  test1 = lambda: (True, -10),
1832  test2 = lambda: (True, -9),
1833  test3 = lambda: (True, -8),
1834  test4 = lambda: (True, -7)
1835  ), **kargs)
1836  specialImportRegistry.registerSpecialImportForType(SwitchProducerTest, "from test import SwitchProducerTest")
1837 
1838  class TestModuleCommand(unittest.TestCase):
1839  def setUp(self):
1840  """Nothing to do """
1841  None
1843  p = _Parameterizable()
1844  self.assertEqual(len(p.parameterNames_()),0)
1845  p.a = int32(1)
1846  self.assertTrue('a' in p.parameterNames_())
1847  self.assertEqual(p.a.value(), 1)
1848  p.a = 10
1849  self.assertEqual(p.a.value(), 10)
1850  p.a = untracked(int32(1))
1851  self.assertEqual(p.a.value(), 1)
1852  self.assertFalse(p.a.isTracked())
1853  p.a = untracked.int32(1)
1854  self.assertEqual(p.a.value(), 1)
1855  self.assertFalse(p.a.isTracked())
1856  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1857  self.assertEqual(p.foo.value(), 10)
1858  self.assertEqual(p.bar.value(),1.0)
1859  self.assertFalse(p.bar.isTracked())
1860  self.assertRaises(TypeError,setattr,(p,'c',1))
1861  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1862  self.assertEqual(p.a.foo.value(),10)
1863  self.assertEqual(p.a.bar.value(),1.0)
1864  p.b = untracked(PSet(fii = int32(1)))
1865  self.assertEqual(p.b.fii.value(),1)
1866  self.assertFalse(p.b.isTracked())
1867  #test the fact that values can be shared
1868  v = int32(10)
1869  p=_Parameterizable(a=v)
1870  v.setValue(11)
1871  self.assertEqual(p.a.value(),11)
1872  p.a = 12
1873  self.assertEqual(p.a.value(),12)
1874  self.assertEqual(v.value(),12)
1876  p = _TypedParameterizable("blah", b=int32(1))
1877  #see if copy works deeply
1878  other = p.copy()
1879  other.b = 2
1880  self.assertNotEqual(p.b,other.b)
1881 
1883  p = Process("test")
1884  p.a = EDAnalyzer("MyAnalyzer")
1885  self.assertTrue( 'a' in p.analyzers_() )
1886  self.assertTrue( 'a' in p.analyzers)
1887  p.add_(Service("MessageLogger"))
1888  self.assertTrue('MessageLogger' in p.services_())
1889  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1890  p.Tracer = Service("Tracer")
1891  self.assertTrue('Tracer' in p.services_())
1892  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1893  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1894  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1895  p.out = OutputModule("Outer")
1896  self.assertEqual(p.out.type_(), 'Outer')
1897  self.assertTrue( 'out' in p.outputModules_() )
1898 
1899  p.geom = ESSource("GeomProd")
1900  self.assertTrue('geom' in p.es_sources_())
1901  p.add_(ESSource("ConfigDB"))
1902  self.assertTrue('ConfigDB' in p.es_sources_())
1903 
1904  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1905  self.assertTrue('aliasfoo1' in p.aliases_())
1906 
1908  class FromArg(object):
1909  def __init__(self,*arg,**args):
1910  for name in six.iterkeys(args):
1911  self.__dict__[name]=args[name]
1912 
1913  a=EDAnalyzer("MyAnalyzer")
1914  t=EDAnalyzer("MyAnalyzer")
1915  t.setLabel("foo")
1916  s1 = Sequence(a)
1917  s2 = Sequence(s1)
1918  s3 = Sequence(s2)
1919  d = FromArg(
1920  a=a,
1921  b=Service("Full"),
1922  c=Path(a),
1923  d=s2,
1924  e=s1,
1925  f=s3,
1926  g=Sequence(s1+s2+s3)
1927  )
1928  p = Process("Test")
1929  p.extend(d)
1930  self.assertEqual(p.a.type_(),"MyAnalyzer")
1931  self.assertEqual(p.a.label_(),"a")
1932  self.assertRaises(AttributeError,getattr,p,'b')
1933  self.assertEqual(p.Full.type_(),"Full")
1934  self.assertEqual(str(p.c),'a')
1935  self.assertEqual(str(p.d),'a')
1936 
1937  z1 = FromArg(
1938  a=a,
1939  b=Service("Full"),
1940  c=Path(a),
1941  d=s2,
1942  e=s1,
1943  f=s3,
1944  s4=s3,
1945  g=Sequence(s1+s2+s3)
1946  )
1947 
1948  p1 = Process("Test")
1949  #p1.extend(z1)
1950  self.assertRaises(ValueError, p1.extend, z1)
1951 
1952  z2 = FromArg(
1953  a=a,
1954  b=Service("Full"),
1955  c=Path(a),
1956  d=s2,
1957  e=s1,
1958  f=s3,
1959  aaa=copy.deepcopy(a),
1960  s4=copy.deepcopy(s3),
1961  g=Sequence(s1+s2+s3),
1962  t=t
1963  )
1964  p2 = Process("Test")
1965  p2.extend(z2)
1966  #self.assertRaises(ValueError, p2.extend, z2)
1967  self.assertEqual(p2.s4.label_(),"s4")
1968  #p2.s4.setLabel("foo")
1969  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1970  p2.s4.setLabel("s4")
1971  p2.s4.setLabel(None)
1972  p2.s4.setLabel("foo")
1973  p2._Process__setObjectLabel(p2.s4, "foo")
1974  p2._Process__setObjectLabel(p2.s4, None)
1975  p2._Process__setObjectLabel(p2.s4, "bar")
1976 
1977 
1978  p = Process('test')
1979  p.a = EDProducer("MyProducer")
1980  p.t = Task(p.a)
1981  p.p = Path(p.t)
1982  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
1983  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
1984  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
1985 
1986  p = Process('test')
1987  p.a = EDProducer("MyProducer")
1988  p.s = Sequence(p.a)
1989  p.p = Path(p.s)
1990  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
1991  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
1992  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
1993 
1995  self.assertEqual(Process("test").dumpPython(),
1996 """import FWCore.ParameterSet.Config as cms\n\nprocess = cms.Process("test")
1997 
1998 process.maxEvents = cms.untracked.PSet(
1999  input = cms.optional.untracked.int32,
2000  output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
2001 )
2002 
2003 process.maxLuminosityBlocks = cms.untracked.PSet(
2004  input = cms.untracked.int32(-1)
2005 )
2006 
2007 process.options = cms.untracked.PSet(
2008  FailPath = cms.untracked.vstring(),
2009  IgnoreCompletely = cms.untracked.vstring(),
2010  Rethrow = cms.untracked.vstring(),
2011  SkipEvent = cms.untracked.vstring(),
2012  allowUnscheduled = cms.obsolete.untracked.bool,
2013  canDeleteEarly = cms.untracked.vstring(),
2014  emptyRunLumiMode = cms.obsolete.untracked.string,
2015  eventSetup = cms.untracked.PSet(
2016  forceNumberOfConcurrentIOVs = cms.untracked.PSet(
2017 
2018  ),
2019  numberOfConcurrentIOVs = cms.untracked.uint32(1)
2020  ),
2021  fileMode = cms.untracked.string('FULLMERGE'),
2022  forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
2023  makeTriggerResults = cms.obsolete.untracked.bool,
2024  numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(1),
2025  numberOfConcurrentRuns = cms.untracked.uint32(1),
2026  numberOfStreams = cms.untracked.uint32(0),
2027  numberOfThreads = cms.untracked.uint32(1),
2028  printDependencies = cms.untracked.bool(False),
2029  sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
2030  throwIfIllegalParameter = cms.untracked.bool(True),
2031  wantSummary = cms.untracked.bool(False)
2032 )
2033 
2034 """)
2035  p = Process("test")
2036  p.a = EDAnalyzer("MyAnalyzer")
2037  p.p = Path(p.a)
2038  p.s = Sequence(p.a)
2039  p.r = Sequence(p.s)
2040  p.p2 = Path(p.s)
2041  p.schedule = Schedule(p.p2,p.p)
2042  d=p.dumpPython()
2043  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2044 """process.a = cms.EDAnalyzer("MyAnalyzer")
2045 process.s = cms.Sequence(process.a)
2046 process.r = cms.Sequence(process.s)
2047 process.p = cms.Path(process.a)
2048 process.p2 = cms.Path(process.s)
2049 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2050  #Reverse order of 'r' and 's'
2051  p = Process("test")
2052  p.a = EDAnalyzer("MyAnalyzer")
2053  p.p = Path(p.a)
2054  p.r = Sequence(p.a)
2055  p.s = Sequence(p.r)
2056  p.p2 = Path(p.r)
2057  p.schedule = Schedule(p.p2,p.p)
2058  p.b = EDAnalyzer("YourAnalyzer")
2059  d=p.dumpPython()
2060  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2061 """process.a = cms.EDAnalyzer("MyAnalyzer")
2062 process.b = cms.EDAnalyzer("YourAnalyzer")
2063 process.r = cms.Sequence(process.a)
2064 process.s = cms.Sequence(process.r)
2065 process.p = cms.Path(process.a)
2066 process.p2 = cms.Path(process.r)
2067 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2068  #use an anonymous sequence
2069  p = Process("test")
2070  p.a = EDAnalyzer("MyAnalyzer")
2071  p.p = Path(p.a)
2072  s = Sequence(p.a)
2073  p.r = Sequence(s)
2074  p.p2 = Path(p.r)
2075  p.schedule = Schedule(p.p2,p.p)
2076  d=p.dumpPython()
2077  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2078 """process.a = cms.EDAnalyzer("MyAnalyzer")
2079 process.r = cms.Sequence((process.a))
2080 process.p = cms.Path(process.a)
2081 process.p2 = cms.Path(process.r)
2082 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2083 
2084  # include some tasks
2085  p = Process("test")
2086  p.a = EDAnalyzer("MyAnalyzer")
2087  p.b = EDProducer("bProducer")
2088  p.c = EDProducer("cProducer")
2089  p.d = EDProducer("dProducer")
2090  p.e = EDProducer("eProducer")
2091  p.f = EDProducer("fProducer")
2092  p.g = EDProducer("gProducer")
2093  p.task5 = Task()
2094  p.task3 = Task()
2095  p.task2 = Task(p.c, p.task3)
2096  p.task4 = Task(p.f, p.task2)
2097  p.task1 = Task(p.task5)
2098  p.task3.add(p.task1)
2099  p.p = Path(p.a)
2100  s = Sequence(p.a)
2101  p.r = Sequence(s)
2102  p.p2 = Path(p.r, p.task1, p.task2)
2103  p.schedule = Schedule(p.p2,p.p,tasks=[p.task3,p.task4, p.task5])
2104  d=p.dumpPython()
2105  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2106 """process.b = cms.EDProducer("bProducer")
2107 process.c = cms.EDProducer("cProducer")
2108 process.d = cms.EDProducer("dProducer")
2109 process.e = cms.EDProducer("eProducer")
2110 process.f = cms.EDProducer("fProducer")
2111 process.g = cms.EDProducer("gProducer")
2112 process.a = cms.EDAnalyzer("MyAnalyzer")
2113 process.task5 = cms.Task()
2114 process.task1 = cms.Task(process.task5)
2115 process.task3 = cms.Task(process.task1)
2116 process.task2 = cms.Task(process.c, process.task3)
2117 process.task4 = cms.Task(process.f, process.task2)
2118 process.r = cms.Sequence((process.a))
2119 process.p = cms.Path(process.a)
2120 process.p2 = cms.Path(process.r, process.task1, process.task2)
2121 process.schedule = cms.Schedule(*[ process.p2, process.p ], tasks=[process.task3, process.task4, process.task5])""")
2122  # only tasks
2123  p = Process("test")
2124  p.d = EDProducer("dProducer")
2125  p.e = EDProducer("eProducer")
2126  p.f = EDProducer("fProducer")
2127  p.g = EDProducer("gProducer")
2128  p.task1 = Task(p.d, p.e)
2129  task2 = Task(p.f, p.g)
2130  p.schedule = Schedule(tasks=[p.task1,task2])
2131  d=p.dumpPython()
2132  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2133 """process.d = cms.EDProducer("dProducer")
2134 process.e = cms.EDProducer("eProducer")
2135 process.f = cms.EDProducer("fProducer")
2136 process.g = cms.EDProducer("gProducer")
2137 process.task1 = cms.Task(process.d, process.e)
2138 process.schedule = cms.Schedule(tasks=[cms.Task(process.f, process.g), process.task1])""")
2139  # empty schedule
2140  p = Process("test")
2141  p.schedule = Schedule()
2142  d=p.dumpPython()
2143  self.assertEqual(_lineDiff(d,Process('test').dumpPython()),
2144 """process.schedule = cms.Schedule()""")
2145 
2146  s = Sequence()
2147  a = EDProducer("A")
2148  s2 = Sequence(a)
2149  s2 += s
2150  process = Process("DUMP")
2151  process.a = a
2152  process.s2 = s2
2153  d=process.dumpPython()
2154  self.assertEqual(_lineDiff(d,Process('DUMP').dumpPython()),
2155 """process.a = cms.EDProducer("A")
2156 process.s2 = cms.Sequence(process.a)""")
2157  s = Sequence()
2158  s1 = Sequence(s)
2159  a = EDProducer("A")
2160  s3 = Sequence(a+a)
2161  s2 = Sequence(a+s3)
2162  s2 += s1
2163  process = Process("DUMP")
2164  process.a = a
2165  process.s2 = s2
2166  d=process.dumpPython()
2167  self.assertEqual(_lineDiff(d,Process('DUMP').dumpPython()),
2168 """process.a = cms.EDProducer("A")
2169 process.s2 = cms.Sequence(process.a+(process.a+process.a))""")
2170 
2171  def testSecSource(self):
2172  p = Process('test')
2173  p.a = SecSource("MySecSource")
2174  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),'process.a = cms.SecSource("MySecSource")')
2175 
2177  p = Process('test')
2178  p.a = EDAnalyzer("MyAnalyzer")
2179  old = p.a
2180  p.b = EDAnalyzer("YourAnalyzer")
2181  p.c = EDAnalyzer("OurAnalyzer")
2182  p.d = EDProducer("MyProducer")
2183  old2 = p.d
2184  p.t1 = Task(p.d)
2185  t2 = Task(p.d)
2186  t3 = Task(p.d)
2187  t4 = Task(p.d)
2188  t5 = Task(p.d)
2189  t6 = Task(p.d)
2190  s = Sequence(p.a*p.b)
2191  p.s4 = Sequence(p.a*p.b)
2192  s.associate(t2)
2193  p.s4.associate(t2)
2194  p.p = Path(p.c+s+p.a)
2195  p.p2 = Path(p.c+p.s4+p.a)
2196  p.e3 = EndPath(p.c+s+p.a)
2197  new = EDAnalyzer("NewAnalyzer")
2198  new2 = EDProducer("NewProducer")
2199  visitor1 = NodeVisitor()
2200  p.p.visit(visitor1)
2201  self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2202  p.schedule = Schedule(tasks=[t6])
2203  p.globalReplace("a",new)
2204  p.globalReplace("d",new2)
2205  visitor2 = NodeVisitor()
2206  p.p.visit(visitor2)
2207  self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2208  self.assertEqual(p.p.dumpPython()[:-1], "cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2209  visitor_p2 = NodeVisitor()
2210  p.p2.visit(visitor_p2)
2211  self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2212  self.assertEqual(p.p2.dumpPython()[:-1], "cms.Path(process.c+process.s4+process.a)")
2213  visitor3 = NodeVisitor()
2214  p.e3.visit(visitor3)
2215  self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2216  visitor4 = NodeVisitor()
2217  p.s4.visit(visitor4)
2218  self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2219  self.assertEqual(p.s4.dumpPython()[:-1],"cms.Sequence(process.a+process.b, cms.Task(process.d))")
2220  visitor5 = NodeVisitor()
2221  p.t1.visit(visitor5)
2222  self.assertTrue(visitor5.modules == set([new2]))
2223  visitor6 = NodeVisitor()
2224  listOfTasks = list(p.schedule._tasks)
2225  listOfTasks[0].visit(visitor6)
2226  self.assertTrue(visitor6.modules == set([new2]))
2227 
2228  def testSequence(self):
2229  p = Process('test')
2230  p.a = EDAnalyzer("MyAnalyzer")
2231  p.b = EDAnalyzer("YourAnalyzer")
2232  p.c = EDAnalyzer("OurAnalyzer")
2233  p.s = Sequence(p.a*p.b)
2234  self.assertEqual(str(p.s),'a+b')
2235  self.assertEqual(p.s.label_(),'s')
2236  path = Path(p.c+p.s)
2237  self.assertEqual(str(path),'c+a+b')
2238  p._validateSequence(path, 'p1')
2239  notInProcess = EDAnalyzer('NotInProcess')
2240  p2 = Path(p.c+p.s*notInProcess)
2241  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
2242 
2243  def testSequence2(self):
2244  p = Process('test')
2245  p.a = EDAnalyzer("MyAnalyzer")
2246  p.b = EDAnalyzer("YourAnalyzer")
2247  p.c = EDAnalyzer("OurAnalyzer")
2248  testseq = Sequence(p.a*p.b)
2249  p.s = testseq
2250  #p.y = testseq
2251  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
2252 
2254  service = Service("d")
2255  self.assertFalse(service._inProcess)
2256  process = Process("test")
2257  process.d = service
2258  self.assertTrue(service._inProcess)
2259  service2 = Service("d")
2260  process.d = service2
2261  self.assertFalse(service._inProcess)
2262  self.assertTrue(service2._inProcess)
2263  del process.d
2264  self.assertFalse(service2._inProcess)
2265 
2266  def testTask(self):
2267 
2268  # create some objects to use in tests
2269  edanalyzer = EDAnalyzer("a")
2270  edproducer = EDProducer("b")
2271  edproducer2 = EDProducer("b2")
2272  edproducer3 = EDProducer("b3")
2273  edproducer4 = EDProducer("b4")
2274  edproducer8 = EDProducer("b8")
2275  edproducer9 = EDProducer("b9")
2276  edfilter = EDFilter("c")
2277  service = Service("d")
2278  service3 = Service("d")
2279  essource = ESSource("e")
2280  esproducer = ESProducer("f")
2281  testTask2 = Task()
2282 
2283  # test adding things to Tasks
2284  testTask1 = Task(edproducer, edfilter)
2285  self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2286  testTask1.add(essource, service)
2287  testTask1.add(essource, esproducer)
2288  testTask1.add(testTask2)
2289  coll = testTask1._collection
2290  self.assertTrue(edproducer in coll)
2291  self.assertTrue(edfilter in coll)
2292  self.assertTrue(service in coll)
2293  self.assertTrue(essource in coll)
2294  self.assertTrue(esproducer in coll)
2295  self.assertTrue(testTask2 in coll)
2296  self.assertTrue(len(coll) == 6)
2297  self.assertTrue(len(testTask2._collection) == 0)
2298 
2299  taskContents = []
2300  for i in testTask1:
2301  taskContents.append(i)
2302  self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2303 
2304  # test attaching Task to Process
2305  process = Process("test")
2306 
2307  process.mproducer = edproducer
2308  process.mproducer2 = edproducer2
2309  process.mfilter = edfilter
2310  process.messource = essource
2311  process.mesproducer = esproducer
2312  process.d = service
2313 
2314  testTask3 = Task(edproducer, edproducer2)
2315  testTask1.add(testTask3)
2316  process.myTask1 = testTask1
2317 
2318  # test the validation that occurs when attaching a Task to a Process
2319  # first a case that passes, then one the fails on an EDProducer
2320  # then one that fails on a service
2321  l = set()
2322  visitor = NodeNameVisitor(l)
2323  testTask1.visit(visitor)
2324  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2325  l2 = testTask1.moduleNames
2326  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2327 
2328  testTask4 = Task(edproducer3)
2329  l.clear()
2330  self.assertRaises(RuntimeError, testTask4.visit, visitor)
2331  try:
2332  process.myTask4 = testTask4
2333  self.assertTrue(False)
2334  except RuntimeError:
2335  pass
2336 
2337  testTask5 = Task(service3)
2338  l.clear()
2339  self.assertRaises(RuntimeError, testTask5.visit, visitor)
2340  try:
2341  process.myTask5 = testTask5
2342  self.assertTrue(False)
2343  except RuntimeError:
2344  pass
2345 
2346  process.d = service3
2347  process.myTask5 = testTask5
2348 
2349  # test placement into the Process and the tasks property
2350  expectedDict = { 'myTask1' : testTask1, 'myTask5' : testTask5 }
2351  expectedFixedDict = DictTypes.FixedKeysDict(expectedDict);
2352  self.assertTrue(process.tasks == expectedFixedDict)
2353  self.assertTrue(process.tasks['myTask1'] == testTask1)
2354  self.assertTrue(process.myTask1 == testTask1)
2355 
2356  # test replacing an EDProducer in a Task when calling __settattr__
2357  # for the EDProducer on the Process.
2358  process.mproducer2 = edproducer4
2359  process.d = service
2360  l = list()
2361  visitor1 = ModuleNodeVisitor(l)
2362  testTask1.visit(visitor1)
2363  l.sort(key=lambda mod: mod.__str__())
2364  expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=lambda mod: mod.__str__())
2365  self.assertTrue(expectedList == l)
2366  process.myTask6 = Task()
2367  process.myTask7 = Task()
2368  process.mproducer8 = edproducer8
2369  process.myTask8 = Task(process.mproducer8)
2370  process.myTask6.add(process.myTask7)
2371  process.myTask7.add(process.myTask8)
2372  process.myTask1.add(process.myTask6)
2373  process.myTask8.add(process.myTask5)
2374 
2375  testDict = process._itemsInDependencyOrder(process.tasks)
2376  expectedLabels = ["myTask5", "myTask8", "myTask7", "myTask6", "myTask1"]
2377  expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2378  index = 0
2379  for testLabel, testTask in testDict.items():
2380  self.assertTrue(testLabel == expectedLabels[index])
2381  self.assertTrue(testTask == expectedTasks[index])
2382  index += 1
2383 
2384  pythonDump = testTask1.dumpPython(PrintOptions())
2385 
2386 
2387  expectedPythonDump = 'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n'
2388  self.assertTrue(pythonDump == expectedPythonDump)
2389 
2390  process.myTask5 = Task()
2391  process.myTask100 = Task()
2392  process.mproducer9 = edproducer9
2393  sequence1 = Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2394  sequence2 = Sequence(process.mproducer8 + process.mproducer9)
2395  process.sequence3 = Sequence((process.mproducer8 + process.mfilter))
2396  sequence4 = Sequence()
2397  process.path1 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2398  process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2399  process.path11 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2400  process.path2 = Path(process.mproducer)
2401  process.path3 = Path(process.mproducer9+process.mproducer8,testTask2)
2402 
2403  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')
2404 
2405  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')
2406 
2407  # test NodeNameVisitor and moduleNames
2408  l = set()
2409  nameVisitor = NodeNameVisitor(l)
2410  process.path1.visit(nameVisitor)
2411  self.assertTrue(l == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2412  self.assertTrue(process.path1.moduleNames() == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2413 
2414  # test copy
2415  process.mproducer10 = EDProducer("b10")
2416  process.path21 = process.path11.copy()
2417  process.path21.replace(process.mproducer, process.mproducer10)
2418 
2419  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')
2420 
2421  # Some peculiarities of the way things work show up here. dumpPython sorts tasks and
2422  # removes duplication at the level of strings. The Task and Sequence objects themselves
2423  # remove duplicate tasks in their contents if the instances are the same (exact same python
2424  # object id which is not the same as the string representation being the same).
2425  # Also note that the mutating visitor replaces sequences and tasks that have
2426  # modified contents with their modified contents, it does not modify the sequence
2427  # or task itself.
2428  self.assertTrue(process.path21.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2429 
2430  process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2431  self.assertTrue(process.path22.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2432 
2433  process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2434  self.assertTrue(process.path23.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
2435 
2436  process.a = EDAnalyzer("MyAnalyzer")
2437  process.b = OutputModule("MyOutputModule")
2438  process.c = EDFilter("MyFilter")
2439  process.d = EDProducer("MyProducer")
2440  process.e = ESProducer("MyESProducer")
2441  process.f = ESSource("MyESSource")
2442  process.g = ESProducer("g")
2443  process.path24 = Path(process.a+process.b+process.c+process.d)
2444  process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2445  self.assertTrue(process.path25.dumpPython() == 'cms.Path(process.d)\n')
2446  #print process.path3
2447  #print process.dumpPython()
2448 
2449  process.path200 = EndPath(Sequence(process.c,Task(process.e)))
2450  process.path200.replace(process.c,process.b)
2451  process.path200.replace(process.e,process.f)
2452  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.b, cms.Task(process.f))\n")
2453  process.path200.replace(process.b,process.c)
2454  process.path200.replace(process.f,process.e)
2455  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2456  process.path200.replace(process.c,process.a)
2457  process.path200.replace(process.e,process.g)
2458  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.a, cms.Task(process.g))\n")
2459  process.path200.replace(process.a,process.c)
2460  process.path200.replace(process.g,process.e)
2461  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2462 
2463 
2464  def testPath(self):
2465  p = Process("test")
2466  p.a = EDAnalyzer("MyAnalyzer")
2467  p.b = EDAnalyzer("YourAnalyzer")
2468  p.c = EDAnalyzer("OurAnalyzer")
2469  path = Path(p.a)
2470  path *= p.b
2471  path += p.c
2472  self.assertEqual(str(path),'a+b+c')
2473  path = Path(p.a*p.b+p.c)
2474  self.assertEqual(str(path),'a+b+c')
2475 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
2476 # self.assertEqual(str(path),'((a*b)+c)')
2477  path = Path(p.a+ p.b*p.c)
2478  self.assertEqual(str(path),'a+b+c')
2479  path = Path(p.a*(p.b+p.c))
2480  self.assertEqual(str(path),'a+b+c')
2481  path = Path(p.a*(p.b+~p.c))
2482  pathx = Path(p.a*(p.b+ignore(p.c)))
2483  self.assertEqual(str(path),'a+b+~c')
2484  p.es = ESProducer("AnESProducer")
2485  self.assertRaises(TypeError,Path,p.es)
2486 
2487  t = Path()
2488  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path()\n')
2489 
2490  t = Path(p.a)
2491  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a)\n')
2492 
2493  t = Path(Task())
2494  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(cms.Task())\n')
2495 
2496  t = Path(p.a, Task())
2497  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task())\n')
2498 
2499  p.prod = EDProducer("prodName")
2500  p.t1 = Task(p.prod)
2501  t = Path(p.a, p.t1, Task(), p.t1)
2502  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task(), process.t1)\n')
2503 
2505  p = Process("test")
2506  a = EDAnalyzer("MyAnalyzer")
2507  p.a = a
2508  a.setLabel("a")
2509  b = EDAnalyzer("YOurAnalyzer")
2510  p.b = b
2511  b.setLabel("b")
2512  path = Path(a * b)
2513  p.path = Path(p.a*p.b)
2514  lookuptable = {id(a): p.a, id(b): p.b}
2515  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2516  #lookuptable = p._cloneToObjectDict
2517  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2518  self.assertEqual(str(path),str(p.path))
2519 
2520  def testContains(self):
2521 
2522  a = EDProducer("a")
2523  b = EDProducer("b")
2524  c = EDProducer("c")
2525  d = EDProducer("d")
2526  e = EDProducer("e")
2527  f = EDProducer("f")
2528  g = EDProducer("g")
2529  h = EDProducer("h")
2530  i = EDProducer("i")
2531  j = EDProducer("j")
2532  k = EDProducer("k")
2533  l = EDProducer("l")
2534  m = EDProducer("m")
2535  n = EDProducer("n")
2536 
2537  seq1 = Sequence(e)
2538  task1 = Task(g)
2539  path = Path(a * c * seq1, task1)
2540 
2541  self.assertTrue(path.contains(a))
2542  self.assertFalse(path.contains(b))
2543  self.assertTrue(path.contains(c))
2544  self.assertFalse(path.contains(d))
2545  self.assertTrue(path.contains(e))
2546  self.assertFalse(path.contains(f))
2547  self.assertTrue(path.contains(g))
2548 
2549  endpath = EndPath(h * i)
2550  self.assertFalse(endpath.contains(b))
2551  self.assertTrue(endpath.contains(i))
2552 
2553  seq = Sequence(a * c)
2554  self.assertFalse(seq.contains(b))
2555  self.assertTrue(seq.contains(c))
2556 
2557  task2 = Task(l)
2558  task = Task(j, k, task2)
2559  self.assertFalse(task.contains(b))
2560  self.assertTrue(task.contains(j))
2561  self.assertTrue(task.contains(k))
2562  self.assertTrue(task.contains(l))
2563 
2564  task3 = Task(m)
2565  path2 = Path(n)
2566  sch = Schedule(path, path2, tasks=[task,task3])
2567  self.assertFalse(sch.contains(b))
2568  self.assertTrue(sch.contains(a))
2569  self.assertTrue(sch.contains(c))
2570  self.assertTrue(sch.contains(e))
2571  self.assertTrue(sch.contains(g))
2572  self.assertTrue(sch.contains(n))
2573  self.assertTrue(sch.contains(j))
2574  self.assertTrue(sch.contains(k))
2575  self.assertTrue(sch.contains(l))
2576  self.assertTrue(sch.contains(m))
2577 
2578  def testSchedule(self):
2579  p = Process("test")
2580  p.a = EDAnalyzer("MyAnalyzer")
2581  p.b = EDAnalyzer("YourAnalyzer")
2582  p.c = EDAnalyzer("OurAnalyzer")
2583  p.d = EDAnalyzer("OurAnalyzer")
2584  p.path1 = Path(p.a)
2585  p.path2 = Path(p.b)
2586  p.path3 = Path(p.d)
2587 
2588  s = Schedule(p.path1,p.path2)
2589  self.assertEqual(s[0],p.path1)
2590  self.assertEqual(s[1],p.path2)
2591  p.schedule = s
2592  self.assertTrue('b' in p.schedule.moduleNames())
2593  self.assertTrue(hasattr(p, 'b'))
2594  self.assertTrue(hasattr(p, 'c'))
2595  self.assertTrue(hasattr(p, 'd'))
2596  self.assertTrue(hasattr(p, 'path1'))
2597  self.assertTrue(hasattr(p, 'path2'))
2598  self.assertTrue(hasattr(p, 'path3'))
2599  p.prune()
2600  self.assertTrue('b' in p.schedule.moduleNames())
2601  self.assertTrue(hasattr(p, 'b'))
2602  self.assertTrue(not hasattr(p, 'c'))
2603  self.assertTrue(not hasattr(p, 'd'))
2604  self.assertTrue(hasattr(p, 'path1'))
2605  self.assertTrue(hasattr(p, 'path2'))
2606  self.assertTrue(not hasattr(p, 'path3'))
2607 
2608  self.assertTrue(len(p.schedule._tasks) == 0)
2609 
2610  p = Process("test")
2611  p.a = EDAnalyzer("MyAnalyzer")
2612  p.b = EDAnalyzer("YourAnalyzer")
2613  p.c = EDAnalyzer("OurAnalyzer")
2614  p.d = EDAnalyzer("dAnalyzer")
2615  p.e = EDProducer("eProducer")
2616  p.f = EDProducer("fProducer")
2617  p.Tracer = Service("Tracer")
2618  p.path1 = Path(p.a)
2619  p.path2 = Path(p.b)
2620  p.path3 = Path(p.d)
2621  p.task1 = Task(p.e)
2622  p.task2 = Task(p.f, p.Tracer)
2623  s = Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2624  self.assertEqual(s[0],p.path1)
2625  self.assertEqual(s[1],p.path2)
2626  self.assertTrue(len(s._tasks) == 2)
2627  self.assertTrue(p.task1 in s._tasks)
2628  self.assertTrue(p.task2 in s._tasks)
2629  listOfTasks = list(s._tasks)
2630  self.assertTrue(len(listOfTasks) == 2)
2631  self.assertTrue(p.task1 == listOfTasks[0])
2632  self.assertTrue(p.task2 == listOfTasks[1])
2633  p.schedule = s
2634  self.assertTrue('b' in p.schedule.moduleNames())
2635 
2636  process2 = Process("test")
2637  process2.a = EDAnalyzer("MyAnalyzer")
2638  process2.e = EDProducer("eProducer")
2639  process2.path1 = Path(process2.a)
2640  process2.task1 = Task(process2.e)
2641  process2.schedule = Schedule(process2.path1,tasks=process2.task1)
2642  listOfTasks = list(process2.schedule._tasks)
2643  self.assertTrue(listOfTasks[0] == process2.task1)
2644 
2645  # test Schedule copy
2646  s2 = s.copy()
2647  self.assertEqual(s2[0],p.path1)
2648  self.assertEqual(s2[1],p.path2)
2649  self.assertTrue(len(s2._tasks) == 2)
2650  self.assertTrue(p.task1 in s2._tasks)
2651  self.assertTrue(p.task2 in s2._tasks)
2652  listOfTasks = list(s2._tasks)
2653  self.assertTrue(len(listOfTasks) == 2)
2654  self.assertTrue(p.task1 == listOfTasks[0])
2655  self.assertTrue(p.task2 == listOfTasks[1])
2656 
2657  names = s.moduleNames()
2658  self.assertTrue(names == set(['a', 'b', 'e', 'Tracer', 'f']))
2659  #adding a path not attached to the Process should cause an exception
2660  p = Process("test")
2661  p.a = EDAnalyzer("MyAnalyzer")
2662  path1 = Path(p.a)
2663  s = Schedule(path1)
2664  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
2665 
2666  #make sure anonymous sequences work
2667  p = Process("test")
2668  p.a = EDAnalyzer("MyAnalyzer")
2669  p.b = EDAnalyzer("MyOtherAnalyzer")
2670  p.c = EDProducer("MyProd")
2671  path1 = Path(p.c*Sequence(p.a+p.b))
2672  s = Schedule(path1)
2673  self.assertTrue('a' in s.moduleNames())
2674  self.assertTrue('b' in s.moduleNames())
2675  self.assertTrue('c' in s.moduleNames())
2676  p.path1 = path1
2677  p.schedule = s
2678  p.prune()
2679  self.assertTrue('a' in s.moduleNames())
2680  self.assertTrue('b' in s.moduleNames())
2681  self.assertTrue('c' in s.moduleNames())
2682 
2684  p = Process("test")
2685  p.a = EDAnalyzer("MyAnalyzer")
2686  p.b = EDAnalyzer("YourAnalyzer")
2687  p.c = EDAnalyzer("OurAnalyzer")
2688  p.path1 = Path(p.a)
2689  p.path2 = Path(p.b)
2690  self.assertTrue(p.schedule is None)
2691  pths = p.paths
2692  keys = pths.keys()
2693  self.assertEqual(pths[keys[0]],p.path1)
2694  self.assertEqual(pths[keys[1]],p.path2)
2695  p.prune()
2696  self.assertTrue(hasattr(p, 'a'))
2697  self.assertTrue(hasattr(p, 'b'))
2698  self.assertTrue(not hasattr(p, 'c'))
2699  self.assertTrue(hasattr(p, 'path1'))
2700  self.assertTrue(hasattr(p, 'path2'))
2701 
2702 
2703  p = Process("test")
2704  p.a = EDAnalyzer("MyAnalyzer")
2705  p.b = EDAnalyzer("YourAnalyzer")
2706  p.c = EDAnalyzer("OurAnalyzer")
2707  p.path2 = Path(p.b)
2708  p.path1 = Path(p.a)
2709  self.assertTrue(p.schedule is None)
2710  pths = p.paths
2711  keys = pths.keys()
2712  self.assertEqual(pths[keys[1]],p.path1)
2713  self.assertEqual(pths[keys[0]],p.path2)
2714 
2715 
2716  def testUsing(self):
2717  p = Process('test')
2718  p.block = PSet(a = int32(1))
2719  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
2720  self.assertEqual(p.modu.a.value(),1)
2721  self.assertEqual(p.modu.b.value(),2)
2722 
2723  def testOverride(self):
2724  p = Process('test')
2725  a = EDProducer("A", a1=int32(0))
2726  self.assertTrue(not a.isModified())
2727  a.a1 = 1
2728  self.assertTrue(a.isModified())
2729  p.a = a
2730  self.assertEqual(p.a.a1.value(), 1)
2731  # try adding an unmodified module.
2732  # should accept it
2733  p.a = EDProducer("A", a1=int32(2))
2734  self.assertEqual(p.a.a1.value(), 2)
2735  # try adding a modified module. Should throw
2736  # no longer, since the same (modified) say, geometry
2737  # could come from more than one cff
2738  b = EDProducer("A", a1=int32(3))
2739  b.a1 = 4
2740  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
2741  ps1 = PSet(a = int32(1))
2742  ps2 = PSet(a = int32(2))
2743  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
2744  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
2745 
2746  def testOptions(self):
2747  p = Process('test')
2748  self.assertEqual(p.options.numberOfThreads.value(),1)
2749  p.options.numberOfThreads = 8
2750  self.assertEqual(p.options.numberOfThreads.value(),8)
2751  p.options = PSet()
2752  self.assertEqual(p.options.numberOfThreads.value(),1)
2753  p.options = dict(numberOfStreams =2,
2754  numberOfThreads =2)
2755  self.assertEqual(p.options.numberOfThreads.value(),2)
2756  self.assertEqual(p.options.numberOfStreams.value(),2)
2757 
2758  def testMaxEvents(self):
2759  p = Process("Test")
2760  p.maxEvents.input = 10
2761  self.assertEqual(p.maxEvents.input.value(),10)
2762  p = Process("Test")
2763  p.maxEvents.output = 10
2764  self.assertEqual(p.maxEvents.output.value(),10)
2765  p = Process("Test")
2766  p.maxEvents.output = PSet(out=untracked.int32(10))
2767  self.assertEqual(p.maxEvents.output.out.value(), 10)
2768  p = Process("Test")
2769  p.maxEvents = untracked.PSet(input = untracked.int32(5))
2770  self.assertEqual(p.maxEvents.input.value(), 5)
2771 
2772 
2773  def testExamples(self):
2774  p = Process("Test")
2775  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
2776  p.foos = EDProducer("FooProducer")
2777  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
2778  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
2779  p.bars.foos = 'Foosball'
2780  self.assertEqual(p.bars.foos, InputTag('Foosball'))
2781  p.p = Path(p.foos*p.bars)
2782  p.e = EndPath(p.out)
2783  p.add_(Service("MessageLogger"))
2784 
2785  def testPrefers(self):
2786  p = Process("Test")
2787  p.add_(ESSource("ForceSource"))
2788  p.juicer = ESProducer("JuicerProducer")
2789  p.prefer("ForceSource")
2790  p.prefer("juicer")
2791  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
2792 """process.juicer = cms.ESProducer("JuicerProducer")
2793 process.ForceSource = cms.ESSource("ForceSource")
2794 process.prefer("ForceSource")
2795 process.prefer("juicer")""")
2796  p.prefer("juicer",fooRcd=vstring("Foo"))
2797  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
2798 """process.juicer = cms.ESProducer("JuicerProducer")
2799 process.ForceSource = cms.ESSource("ForceSource")
2800 process.prefer("ForceSource")
2801 process.prefer("juicer",
2802  fooRcd = cms.vstring('Foo')
2803 )""")
2804 
2805  def testFreeze(self):
2806  process = Process("Freeze")
2807  m = EDProducer("M", p=PSet(i = int32(1)))
2808  m.p.i = 2
2809  process.m = m
2810  # should be frozen
2811  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
2812  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
2813  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
2814  #self.assertRaises(ValueError, setattr, m, 'j', 1)
2815  # But OK to change through the process
2816  process.m.p.i = 4
2817  self.assertEqual(process.m.p.i.value(), 4)
2818  process.m.p = PSet(j=int32(1))
2819  # should work to clone it, though
2820  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
2821  m2.p.i = 6
2822  m2.j = 8
2823  def testSubProcess(self):
2824  process = Process("Parent")
2825  subProcess = Process("Child")
2826  subProcess.a = EDProducer("A")
2827  subProcess.p = Path(subProcess.a)
2828  subProcess.add_(Service("Foo"))
2829  process.addSubProcess(SubProcess(subProcess))
2830  d = process.dumpPython()
2831  equalD ="""parentProcess = process
2832 process.a = cms.EDProducer("A")
2833 process.Foo = cms.Service("Foo")
2834 process.p = cms.Path(process.a)
2835 childProcess = process
2836 process = parentProcess
2837 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
2838 ), outputCommands = cms.untracked.vstring()))"""
2839  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
2840  self.assertEqual(_lineDiff(d,Process('Parent').dumpPython()+Process('Child').dumpPython()),equalD)
2841  p = TestMakePSet()
2842  process.fillProcessDesc(p)
2843  self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
2844  self.assertEqual((True,['p']),p.values["subProcesses"][1][0].values["process"][1].values['@paths'])
2845  self.assertEqual({'@service_type':(True,'Foo')}, p.values["subProcesses"][1][0].values["process"][1].values["services"][1][0].values)
2846  def testRefToPSet(self):
2847  proc = Process("test")
2848  proc.top = PSet(a = int32(1))
2849  proc.ref = PSet(refToPSet_ = string("top"))
2850  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
2851  proc.ref3 = PSet(refToPSet_ = string("ref"))
2852  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
2853  PSet(refToPSet_ = string("ref2")))
2854  p = TestMakePSet()
2855  proc.fillProcessDesc(p)
2856  self.assertEqual((True,1),p.values["ref"][1].values["a"])
2857  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
2858  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
2859  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
2860  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
2861  self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])
2863  proc = Process("test")
2864  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
2865  a = int32(1),
2866  b = PSet(c = int32(2))),
2867  test1 = EDProducer("Bar",
2868  aa = int32(11),
2869  bb = PSet(cc = int32(12))))
2870  proc.a = EDProducer("A")
2871  proc.s = Sequence(proc.a + proc.sp)
2872  proc.t = Task(proc.a, proc.sp)
2873  proc.p = Path()
2874  proc.p.associate(proc.t)
2875  p = TestMakePSet()
2876  proc.fillProcessDesc(p)
2877  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2878  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2879  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2880  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
2881  all_cases[1].sort() # names of all cases come via dict, i.e. their order is undefined
2882  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
2883  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2884  self.assertEqual(["a", "sp", "sp@test1", "sp@test2"], p.values["@all_modules"][1])
2885  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
2886  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["@module_type"])
2887  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
2888  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
2889  dump = proc.dumpPython()
2890  self.assertEqual(dump.find('@'), -1)
2891  self.assertEqual(specialImportRegistry.getSpecialImports(), ["from test import SwitchProducerTest"])
2892  self.assertTrue(dump.find("\nfrom test import SwitchProducerTest\n") != -1)
2893 
2894  # EDAlias as non-chosen case
2895  proc = Process("test")
2896  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
2897  a = int32(1),
2898  b = PSet(c = int32(2))),
2899  test1 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
2900  proc.a = EDProducer("A")
2901  proc.s = Sequence(proc.a + proc.sp)
2902  proc.t = Task(proc.a, proc.sp)
2903  proc.p = Path()
2904  proc.p.associate(proc.t)
2905  p = TestMakePSet()
2906  proc.fillProcessDesc(p)
2907  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2908  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2909  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2910  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
2911  all_cases[1].sort()
2912  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
2913  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2914  self.assertEqual(["a", "sp", "sp@test2"], p.values["@all_modules"][1])
2915  self.assertEqual(["sp@test1"], p.values["@all_aliases"][1])
2916  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
2917  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
2918  self.assertEqual((True,"EDAlias"), p.values["sp@test1"][1].values["@module_edm_type"])
2919  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["a"][1][0].values["type"])
2920 
2921  # EDAlias as chosen case
2922  proc = Process("test")
2923  proc.sp = SwitchProducerTest(test1 = EDProducer("Foo",
2924  a = int32(1),
2925  b = PSet(c = int32(2))),
2926  test2 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
2927  proc.a = EDProducer("A")
2928  proc.s = Sequence(proc.a + proc.sp)
2929  proc.t = Task(proc.a, proc.sp)
2930  proc.p = Path()
2931  proc.p.associate(proc.t)
2932  p = TestMakePSet()
2933  proc.fillProcessDesc(p)
2934  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2935  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2936  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2937  self.assertEqual((True, ["sp@test1", "sp@test2"]), p.values["sp"][1].values["@all_cases"])
2938  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2939  self.assertEqual(["a", "sp", "sp@test1"], p.values["@all_modules"][1])
2940  self.assertEqual(["sp@test2"], p.values["@all_aliases"][1])
2941  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
2942  self.assertEqual((True,"Foo"), p.values["sp@test1"][1].values["@module_type"])
2943  self.assertEqual((True,"EDAlias"), p.values["sp@test2"][1].values["@module_edm_type"])
2944  self.assertEqual((True,"Bar"), p.values["sp@test2"][1].values["a"][1][0].values["type"])
2945 
2946  def testPrune(self):
2947  p = Process("test")
2948  p.a = EDAnalyzer("MyAnalyzer")
2949  p.b = EDAnalyzer("YourAnalyzer")
2950  p.c = EDAnalyzer("OurAnalyzer")
2951  p.d = EDAnalyzer("OurAnalyzer")
2952  p.e = EDProducer("MyProducer")
2953  p.f = EDProducer("YourProducer")
2954  p.g = EDProducer("TheirProducer")
2955  p.s = Sequence(p.d)
2956  p.t1 = Task(p.e)
2957  p.t2 = Task(p.f)
2958  p.t3 = Task(p.g, p.t1)
2959  p.path1 = Path(p.a, p.t3)
2960  p.path2 = Path(p.b)
2961  self.assertTrue(p.schedule is None)
2962  pths = p.paths
2963  keys = pths.keys()
2964  self.assertEqual(pths[keys[0]],p.path1)
2965  self.assertEqual(pths[keys[1]],p.path2)
2966  p.pset1 = PSet(parA = string("pset1"))
2967  p.pset2 = untracked.PSet(parA = string("pset2"))
2968  p.vpset1 = VPSet()
2969  p.vpset2 = untracked.VPSet()
2970  p.prune()
2971  self.assertTrue(hasattr(p, 'a'))
2972  self.assertTrue(hasattr(p, 'b'))
2973  self.assertTrue(not hasattr(p, 'c'))
2974  self.assertTrue(not hasattr(p, 'd'))
2975  self.assertTrue(hasattr(p, 'e'))
2976  self.assertTrue(not hasattr(p, 'f'))
2977  self.assertTrue(hasattr(p, 'g'))
2978  self.assertTrue(not hasattr(p, 's'))
2979  self.assertTrue(hasattr(p, 't1'))
2980  self.assertTrue(not hasattr(p, 't2'))
2981  self.assertTrue(hasattr(p, 't3'))
2982  self.assertTrue(hasattr(p, 'path1'))
2983  self.assertTrue(hasattr(p, 'path2'))
2984 # self.assertTrue(not hasattr(p, 'pset1'))
2985 # self.assertTrue(hasattr(p, 'pset2'))
2986 # self.assertTrue(not hasattr(p, 'vpset1'))
2987 # self.assertTrue(not hasattr(p, 'vpset2'))
2988 
2989  p = Process("test")
2990  p.a = EDAnalyzer("MyAnalyzer")
2991  p.b = EDAnalyzer("YourAnalyzer")
2992  p.c = EDAnalyzer("OurAnalyzer")
2993  p.d = EDAnalyzer("OurAnalyzer")
2994  p.e = EDAnalyzer("OurAnalyzer")
2995  p.f = EDProducer("MyProducer")
2996  p.g = EDProducer("YourProducer")
2997  p.h = EDProducer("TheirProducer")
2998  p.i = EDProducer("OurProducer")
2999  p.t1 = Task(p.f)
3000  p.t2 = Task(p.g)
3001  p.t3 = Task(p.h)
3002  p.t4 = Task(p.i)
3003  p.s = Sequence(p.d, p.t1)
3004  p.s2 = Sequence(p.b, p.t2)
3005  p.s3 = Sequence(p.e)
3006  p.path1 = Path(p.a, p.t3)
3007  p.path2 = Path(p.b)
3008  p.path3 = Path(p.b+p.s2)
3009  p.path4 = Path(p.b+p.s3)
3010  p.schedule = Schedule(p.path1,p.path2,p.path3)
3011  p.schedule.associate(p.t4)
3012  pths = p.paths
3013  keys = pths.keys()
3014  self.assertEqual(pths[keys[0]],p.path1)
3015  self.assertEqual(pths[keys[1]],p.path2)
3016  p.prune()
3017  self.assertTrue(hasattr(p, 'a'))
3018  self.assertTrue(hasattr(p, 'b'))
3019  self.assertTrue(not hasattr(p, 'c'))
3020  self.assertTrue(not hasattr(p, 'd'))
3021  self.assertTrue(not hasattr(p, 'e'))
3022  self.assertTrue(not hasattr(p, 'f'))
3023  self.assertTrue(hasattr(p, 'g'))
3024  self.assertTrue(hasattr(p, 'h'))
3025  self.assertTrue(hasattr(p, 'i'))
3026  self.assertTrue(not hasattr(p, 't1'))
3027  self.assertTrue(hasattr(p, 't2'))
3028  self.assertTrue(hasattr(p, 't3'))
3029  self.assertTrue(hasattr(p, 't4'))
3030  self.assertTrue(not hasattr(p, 's'))
3031  self.assertTrue(hasattr(p, 's2'))
3032  self.assertTrue(not hasattr(p, 's3'))
3033  self.assertTrue(hasattr(p, 'path1'))
3034  self.assertTrue(hasattr(p, 'path2'))
3035  self.assertTrue(hasattr(p, 'path3'))
3036  self.assertTrue(not hasattr(p, 'path4'))
3037  #test SequencePlaceholder
3038  p = Process("test")
3039  p.a = EDAnalyzer("MyAnalyzer")
3040  p.b = EDAnalyzer("YourAnalyzer")
3041  p.s = Sequence(SequencePlaceholder("a")+p.b)
3042  p.pth = Path(p.s)
3043  p.prune()
3044  self.assertTrue(hasattr(p, 'a'))
3045  self.assertTrue(hasattr(p, 'b'))
3046  self.assertTrue(hasattr(p, 's'))
3047  self.assertTrue(hasattr(p, 'pth'))
3048  #test unresolved SequencePlaceholder
3049  p = Process("test")
3050  p.b = EDAnalyzer("YourAnalyzer")
3051  p.s = Sequence(SequencePlaceholder("a")+p.b)
3052  p.pth = Path(p.s)
3053  p.prune(keepUnresolvedSequencePlaceholders=True)
3054  self.assertTrue(hasattr(p, 'b'))
3055  self.assertTrue(hasattr(p, 's'))
3056  self.assertTrue(hasattr(p, 'pth'))
3057  self.assertEqual(p.s.dumpPython(),'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3058  #test TaskPlaceholder
3059  p = Process("test")
3060  p.a = EDProducer("MyProducer")
3061  p.b = EDProducer("YourProducer")
3062  p.s = Task(TaskPlaceholder("a"),p.b)
3063  p.pth = Path(p.s)
3064  p.prune()
3065  self.assertTrue(hasattr(p, 'a'))
3066  self.assertTrue(hasattr(p, 'b'))
3067  self.assertTrue(hasattr(p, 's'))
3068  self.assertTrue(hasattr(p, 'pth'))
3069  #test unresolved SequencePlaceholder
3070  p = Process("test")
3071  p.b = EDProducer("YourAnalyzer")
3072  p.s = Task(TaskPlaceholder("a"),p.b)
3073  p.pth = Path(p.s)
3074  p.prune(keepUnresolvedSequencePlaceholders=True)
3075  self.assertTrue(hasattr(p, 'b'))
3076  self.assertTrue(hasattr(p, 's'))
3077  self.assertTrue(hasattr(p, 'pth'))
3078  self.assertEqual(p.s.dumpPython(),'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')
3080  p = Process("test")
3081  p.a = EDProducer("ma")
3082  p.b = EDAnalyzer("mb")
3083  p.t1 = Task(TaskPlaceholder("c"))
3084  p.t2 = Task(p.a, TaskPlaceholder("d"), p.t1)
3085  p.t3 = Task(TaskPlaceholder("e"))
3086  p.path1 = Path(p.b, p.t2, p.t3)
3087  p.t5 = Task(p.a, TaskPlaceholder("g"), TaskPlaceholder("t4"))
3088  p.t4 = Task(TaskPlaceholder("f"))
3089  p.endpath1 = EndPath(p.b, p.t5)
3090  p.t6 = Task(TaskPlaceholder("h"))
3091  p.t7 = Task(p.a, TaskPlaceholder("i"), p.t6)
3092  p.t8 = Task(TaskPlaceholder("j"))
3093  p.schedule = Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3094  p.c = EDProducer("mc")
3095  p.d = EDProducer("md")
3096  p.e = EDProducer("me")
3097  p.f = EDProducer("mf")
3098  p.g = EDProducer("mg")
3099  p.h = EDProducer("mh")
3100  p.i = EDProducer("mi")
3101  p.j = EDProducer("mj")
3102  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3103 """process.a = cms.EDProducer("ma")
3104 process.c = cms.EDProducer("mc")
3105 process.d = cms.EDProducer("md")
3106 process.e = cms.EDProducer("me")
3107 process.f = cms.EDProducer("mf")
3108 process.g = cms.EDProducer("mg")
3109 process.h = cms.EDProducer("mh")
3110 process.i = cms.EDProducer("mi")
3111 process.j = cms.EDProducer("mj")
3112 process.b = cms.EDAnalyzer("mb")
3113 process.t8 = cms.Task(cms.TaskPlaceholder("j"))
3114 process.t6 = cms.Task(cms.TaskPlaceholder("h"))
3115 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
3116 process.t4 = cms.Task(cms.TaskPlaceholder("f"))
3117 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
3118 process.t3 = cms.Task(cms.TaskPlaceholder("e"))
3119 process.t1 = cms.Task(cms.TaskPlaceholder("c"))
3120 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1)
3121 process.path1 = cms.Path(process.b, process.t2, process.t3)
3122 process.endpath1 = cms.EndPath(process.b, process.t5)
3123 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3124  p.resolve()
3125  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3126 """process.a = cms.EDProducer("ma")
3127 process.c = cms.EDProducer("mc")
3128 process.d = cms.EDProducer("md")
3129 process.e = cms.EDProducer("me")
3130 process.f = cms.EDProducer("mf")
3131 process.g = cms.EDProducer("mg")
3132 process.h = cms.EDProducer("mh")
3133 process.i = cms.EDProducer("mi")
3134 process.j = cms.EDProducer("mj")
3135 process.b = cms.EDAnalyzer("mb")
3136 process.t8 = cms.Task(process.j)
3137 process.t6 = cms.Task(process.h)
3138 process.t7 = cms.Task(process.a, process.i, process.t6)
3139 process.t4 = cms.Task(process.f)
3140 process.t5 = cms.Task(process.a, process.g, process.t4)
3141 process.t3 = cms.Task(process.e)
3142 process.t1 = cms.Task(process.c)
3143 process.t2 = cms.Task(process.a, process.d, process.t1)
3144 process.path1 = cms.Path(process.b, process.t2, process.t3)
3145 process.endpath1 = cms.EndPath(process.b, process.t5)
3146 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3147 
3148  def testDelete(self):
3149  p = Process("test")
3150  p.a = EDAnalyzer("MyAnalyzer")
3151  p.b = EDAnalyzer("YourAnalyzer")
3152  p.c = EDAnalyzer("OurAnalyzer")
3153  p.d = EDAnalyzer("OurAnalyzer")
3154  p.e = EDAnalyzer("OurAnalyzer")
3155  p.f = EDAnalyzer("OurAnalyzer")
3156  p.g = EDProducer("OurProducer")
3157  p.h = EDProducer("YourProducer")
3158  p.t1 = Task(p.g, p.h)
3159  t2 = Task(p.g, p.h)
3160  t3 = Task(p.g, p.h)
3161  p.s = Sequence(p.d+p.e)
3162  p.path1 = Path(p.a+p.f+p.s,t2)
3163  p.endpath1 = EndPath(p.b+p.f)
3164  p.schedule = Schedule(tasks=[t3])
3165  self.assertTrue(hasattr(p, 'f'))
3166  self.assertTrue(hasattr(p, 'g'))
3167  del p.e
3168  del p.f
3169  del p.g
3170  self.assertFalse(hasattr(p, 'f'))
3171  self.assertFalse(hasattr(p, 'g'))
3172  self.assertTrue(p.t1.dumpPython() == 'cms.Task(process.h)\n')
3173  self.assertTrue(p.s.dumpPython() == 'cms.Sequence(process.d)\n')
3174  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+process.s, cms.Task(process.h))\n')
3175  self.assertTrue(p.endpath1.dumpPython() == 'cms.EndPath(process.b)\n')
3176  del p.s
3177  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
3178  self.assertTrue(p.schedule_().dumpPython() == 'cms.Schedule(tasks=[cms.Task(process.h)])\n')
3179  def testModifier(self):
3180  m1 = Modifier()
3181  p = Process("test",m1)
3182  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3183  def _mod_fred(obj):
3184  obj.fred = 2
3185  m1.toModify(p.a,_mod_fred)
3186  self.assertEqual(p.a.fred.value(),2)
3187  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
3188  m1.toModify(p.b, wilma = 2)
3189  self.assertEqual(p.b.wilma.value(),2)
3190  self.assertTrue(p.isUsingModifier(m1))
3191  #check that Modifier not attached to a process doesn't run
3192  m1 = Modifier()
3193  p = Process("test")
3194  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3195  m1.toModify(p.a,_mod_fred)
3196  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
3197  m1.toModify(p.b, wilma = 2)
3198  self.assertEqual(p.a.fred.value(),1)
3199  self.assertEqual(p.b.wilma.value(),1)
3200  self.assertEqual(p.isUsingModifier(m1),False)
3201  #make sure clones get the changes
3202  m1 = Modifier()
3203  p = Process("test",m1)
3204  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3205  m1.toModify(p.a, fred = int32(2))
3206  p.b = p.a.clone(wilma = int32(3))
3207  self.assertEqual(p.a.fred.value(),2)
3208  self.assertEqual(p.a.wilma.value(),1)
3209  self.assertEqual(p.b.fred.value(),2)
3210  self.assertEqual(p.b.wilma.value(),3)
3211  #test removal of parameter
3212  m1 = Modifier()
3213  p = Process("test",m1)
3214  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones = PSet(fred = int32(1)))
3215  m1.toModify(p.a, fred = None, fintstones = dict(fred = None))
3216  self.assertEqual(hasattr(p.a, "fred"), False)
3217  self.assertEqual(hasattr(p.a.fintstones, "fred"), False)
3218  self.assertEqual(p.a.wilma.value(),1)
3219  #test adding a parameter
3220  m1 = Modifier()
3221  p = Process("test",m1)
3222  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3223  m1.toModify(p.a, wilma = int32(2))
3224  self.assertEqual(p.a.fred.value(), 1)
3225  self.assertEqual(p.a.wilma.value(),2)
3226  #test setting of value in PSet
3227  m1 = Modifier()
3228  p = Process("test",m1)
3229  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
3230  m1.toModify(p.a, flintstones = dict(fred = int32(2)))
3231  self.assertEqual(p.a.flintstones.fred.value(),2)
3232  self.assertEqual(p.a.flintstones.wilma.value(),1)
3233  #test proper exception from nonexisting parameter name
3234  m1 = Modifier()
3235  p = Process("test",m1)
3236  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
3237  self.assertRaises(KeyError, lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
3238  self.assertRaises(KeyError, lambda: m1.toModify(p.a, foo = 1))
3239  #test setting a value in a VPSet
3240  m1 = Modifier()
3241  p = Process("test",m1)
3242  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
3243  m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
3244  self.assertEqual(p.a.flintstones[0].fred.value(),1)
3245  self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3246  #test setting a value in a list of values
3247  m1 = Modifier()
3248  p = Process("test",m1)
3249  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
3250  m1.toModify(p.a, fred = {1:7})
3251  self.assertEqual(p.a.fred[0],1)
3252  self.assertEqual(p.a.fred[1],7)
3253  self.assertEqual(p.a.fred[2],3)
3254  #test IndexError setting a value in a list to an item key not in the list
3255  m1 = Modifier()
3256  p = Process("test",m1)
3257  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
3258  raised = False
3259  try: m1.toModify(p.a, fred = {5:7})
3260  except IndexError as e: raised = True
3261  self.assertEqual(raised, True)
3262  #test TypeError setting a value in a list using a key that is not an int
3263  m1 = Modifier()
3264  p = Process("test",m1)
3265  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
3266  raised = False
3267  try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
3268  except TypeError as e: raised = True
3269  self.assertEqual(raised, True)
3270  #test that load causes process wide methods to run
3271  def _rem_a(proc):
3272  del proc.a
3273  class ProcModifierMod(object):
3274  def __init__(self,modifier,func):
3275  self.proc_mod_ = modifier.makeProcessModifier(func)
3276  class DummyMod(object):
3277  def __init__(self):
3278  self.a = EDAnalyzer("Dummy")
3279  testMod = DummyMod()
3280  p.extend(testMod)
3281  self.assertTrue(hasattr(p,"a"))
3282  m1 = Modifier()
3283  p = Process("test",m1)
3284  testProcMod = ProcModifierMod(m1,_rem_a)
3285  p.extend(testMod)
3286  p.extend(testProcMod)
3287  self.assertTrue(not hasattr(p,"a"))
3288  #test ModifierChain
3289  m1 = Modifier()
3290  mc = ModifierChain(m1)
3291  p = Process("test",mc)
3292  self.assertTrue(p.isUsingModifier(m1))
3293  self.assertTrue(p.isUsingModifier(mc))
3294  testMod = DummyMod()
3295  p.b = EDAnalyzer("Dummy2", fred = int32(1))
3296  m1.toModify(p.b, fred = int32(3))
3297  p.extend(testMod)
3298  testProcMod = ProcModifierMod(m1,_rem_a)
3299  p.extend(testProcMod)
3300  self.assertTrue(not hasattr(p,"a"))
3301  self.assertEqual(p.b.fred.value(),3)
3302  #check cloneAndExclude
3303  m1 = Modifier()
3304  m2 = Modifier()
3305  mc = ModifierChain(m1,m2)
3306  mclone = mc.copyAndExclude([m2])
3307  self.assertTrue(not mclone._isOrContains(m2))
3308  self.assertTrue(mclone._isOrContains(m1))
3309  m3 = Modifier()
3310  mc2 = ModifierChain(mc,m3)
3311  mclone = mc2.copyAndExclude([m2])
3312  self.assertTrue(not mclone._isOrContains(m2))
3313  self.assertTrue(mclone._isOrContains(m1))
3314  self.assertTrue(mclone._isOrContains(m3))
3315  #check combining
3316  m1 = Modifier()
3317  m2 = Modifier()
3318  p = Process("test",m1)
3319  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3320  (m1 & m2).toModify(p.a, fred = int32(2))
3321  self.assertRaises(TypeError, lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3322  self.assertEqual(p.a.fred, 1)
3323  m1 = Modifier()
3324  m2 = Modifier()
3325  p = Process("test",m1,m2)
3326  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3327  (m1 & m2).toModify(p.a, fred = int32(2))
3328  self.assertEqual(p.a.fred, 2)
3329  m1 = Modifier()
3330  m2 = Modifier()
3331  m3 = Modifier()
3332  p = Process("test",m1,m2,m3)
3333  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3334  (m1 & m2 & m3).toModify(p.a, fred = int32(2))
3335  self.assertEqual(p.a.fred, 2)
3336  (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
3337  self.assertEqual(p.a.fred, 3)
3338  ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
3339  self.assertEqual(p.a.fred, 4)
3340  #check inverse
3341  m1 = Modifier()
3342  m2 = Modifier()
3343  p = Process("test", m1)
3344  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3345  (~m1).toModify(p.a, fred=2)
3346  self.assertEqual(p.a.fred, 1)
3347  (~m2).toModify(p.a, wilma=2)
3348  self.assertEqual(p.a.wilma, 2)
3349  self.assertRaises(TypeError, lambda: (~m1).toModify(p.a, 1, wilma=2))
3350  self.assertRaises(TypeError, lambda: (~m2).toModify(p.a, 1, wilma=2))
3351  # check or
3352  m1 = Modifier()
3353  m2 = Modifier()
3354  m3 = Modifier()
3355  p = Process("test", m1)
3356  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3357  (m1 | m2).toModify(p.a, fred=2)
3358  self.assertEqual(p.a.fred, 2)
3359  (m1 | m2 | m3).toModify(p.a, fred=3)
3360  self.assertEqual(p.a.fred, 3)
3361  (m3 | m2 | m1).toModify(p.a, fred=4)
3362  self.assertEqual(p.a.fred, 4)
3363  ((m1 | m2) | m3).toModify(p.a, fred=5)
3364  self.assertEqual(p.a.fred, 5)
3365  (m1 | (m2 | m3)).toModify(p.a, fred=6)
3366  self.assertEqual(p.a.fred, 6)
3367  (m2 | m3).toModify(p.a, fred=7)
3368  self.assertEqual(p.a.fred, 6)
3369  self.assertRaises(TypeError, lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3370  self.assertRaises(TypeError, lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3371  # check combinations
3372  m1 = Modifier()
3373  m2 = Modifier()
3374  m3 = Modifier()
3375  m4 = Modifier()
3376  p = Process("test", m1, m2)
3377  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3378  (m1 & ~m2).toModify(p.a, fred=2)
3379  self.assertEqual(p.a.fred, 1)
3380  (m1 & ~m3).toModify(p.a, fred=2)
3381  self.assertEqual(p.a.fred, 2)
3382  (m1 | ~m2).toModify(p.a, fred=3)
3383  self.assertEqual(p.a.fred, 3)
3384  (~m1 | ~m2).toModify(p.a, fred=4)
3385  self.assertEqual(p.a.fred, 3)
3386  (~m3 & ~m4).toModify(p.a, fred=4)
3387  self.assertEqual(p.a.fred, 4)
3388  ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3389  self.assertEqual(p.a.fred, 5)
3390  #check toReplaceWith
3391  m1 = Modifier()
3392  p = Process("test",m1)
3393  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
3394  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
3395  self.assertRaises(TypeError, lambda: m1.toReplaceWith(p.a, EDProducer("YourProducer")))
3396  p.b =EDAnalyzer("BAn")
3397  p.c =EDProducer("c")
3398  p.d =EDProducer("d")
3399  p.tc = Task(p.c)
3400  p.td = Task(p.d)
3401  p.s = Sequence(p.a, p.tc)
3402  m1.toReplaceWith(p.s, Sequence(p.a+p.b, p.td))
3403  self.assertEqual(p.a.wilma.value(),3)
3404  self.assertEqual(p.a.type_(),"YourAnalyzer")
3405  self.assertEqual(hasattr(p,"fred"),False)
3406  self.assertTrue(p.s.dumpPython() == "cms.Sequence(process.a+process.b, process.td)\n")
3407  p.e =EDProducer("e")
3408  m1.toReplaceWith(p.td, Task(p.e))
3409  self.assertTrue(p.td._collection == OrderedSet([p.e]))
3410  #check toReplaceWith doesn't activate not chosen
3411  m1 = Modifier()
3412  p = Process("test")
3413  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
3414  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
3415  self.assertEqual(p.a.type_(),"MyAnalyzer")
3416  #check toReplaceWith and and/not/or combinations
3417  m1 = Modifier()
3418  m2 = Modifier()
3419  m3 = Modifier()
3420  m4 = Modifier()
3421  p = Process("test", m1, m2)
3422  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3423  self.assertRaises(TypeError, lambda: (m1 & m2).toReplaceWith(p.a, EDProducer("YourProducer")))
3424  self.assertRaises(TypeError, lambda: (m3 & m4).toReplaceWith(p.a, EDProducer("YourProducer")))
3425  self.assertRaises(TypeError, lambda: (~m3).toReplaceWith(p.a, EDProducer("YourProducer")))
3426  self.assertRaises(TypeError, lambda: (~m1).toReplaceWith(p.a, EDProducer("YourProducer")))
3427  self.assertRaises(TypeError, lambda: (m1 | m3).toReplaceWith(p.a, EDProducer("YourProducer")))
3428  self.assertRaises(TypeError, lambda: (m3 | m4).toReplaceWith(p.a, EDProducer("YourProducer")))
3429  (m1 & m2).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer1"))
3430  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3431  (m1 & m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3432  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3433  (~m1).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3434  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3435  (~m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3436  self.assertEqual(p.a.type_(), "YourAnalyzer2")
3437  (m1 | m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer3"))
3438  self.assertEqual(p.a.type_(), "YourAnalyzer3")
3439  (m3 | m4).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer4"))
3440  self.assertEqual(p.a.type_(), "YourAnalyzer3")
3441 
3442  # EDAlias
3443  a = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
3444  m = Modifier()
3445  m._setChosen()
3446  # Modify parameters
3447  m.toModify(a, foo2 = {0: dict(type = "Foo3")})
3448  self.assertEqual(a.foo2[0].type, "Foo3")
3449  # Add an alias
3450  m.toModify(a, foo4 = VPSet(PSet(type = string("Foo4"))))
3451  self.assertEqual(a.foo2[0].type, "Foo3")
3452  self.assertEqual(a.foo4[0].type, "Foo4")
3453  # Remove an alias
3454  m.toModify(a, foo2 = None)
3455  self.assertFalse(hasattr(a, "foo2"))
3456  self.assertEqual(a.foo4[0].type, "Foo4")
3457  # Replace (doesn't work out of the box because EDAlias is not _Parameterizable
3458  m.toReplaceWith(a, EDAlias(bar = VPSet(PSet(type = string("Bar")))))
3459  self.assertFalse(hasattr(a, "foo2"))
3460  self.assertFalse(hasattr(a, "foo4"))
3461  self.assertTrue(hasattr(a, "bar"))
3462  self.assertEqual(a.bar[0].type, "Bar")
3463 
3464  # SwitchProducer
3465  sp = SwitchProducerTest(test1 = EDProducer("Foo",
3466  a = int32(1),
3467  b = PSet(c = int32(2))),
3468  test2 = EDProducer("Bar",
3469  aa = int32(11),
3470  bb = PSet(cc = int32(12))))
3471  m = Modifier()
3472  m._setChosen()
3473  # Modify parameters
3474  m.toModify(sp,
3475  test1 = dict(a = 4, b = dict(c = None)),
3476  test2 = dict(aa = 15, bb = dict(cc = 45, dd = string("foo"))))
3477  self.assertEqual(sp.test1.a.value(), 4)
3478  self.assertEqual(sp.test1.b.hasParameter("c"), False)
3479  self.assertEqual(sp.test2.aa.value(), 15)
3480  self.assertEqual(sp.test2.bb.cc.value(), 45)
3481  self.assertEqual(sp.test2.bb.dd.value(), "foo")
3482  # Replace a producer
3483  m.toReplaceWith(sp.test1, EDProducer("Fred", x = int32(42)))
3484  self.assertEqual(sp.test1.type_(), "Fred")
3485  self.assertEqual(sp.test1.x.value(), 42)
3486  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test1, EDAnalyzer("Foo")))
3487  # Alternative way (only to be allow same syntax to be used as for adding)
3488  m.toModify(sp, test2 = EDProducer("Xyzzy", x = int32(24)))
3489  self.assertEqual(sp.test2.type_(), "Xyzzy")
3490  self.assertEqual(sp.test2.x.value(), 24)
3491  self.assertRaises(TypeError, lambda: m.toModify(sp, test2 = EDAnalyzer("Foo")))
3492  # Add a producer
3493  m.toModify(sp, test3 = EDProducer("Wilma", y = int32(24)))
3494  self.assertEqual(sp.test3.type_(), "Wilma")
3495  self.assertEqual(sp.test3.y.value(), 24)
3496  self.assertRaises(TypeError, lambda: m.toModify(sp, test4 = EDAnalyzer("Foo")))
3497  # Remove a producer
3498  m.toModify(sp, test2 = None)
3499  self.assertEqual(hasattr(sp, "test2"), False)
3500  # Add an alias
3501  m.toModify(sp, test2 = EDAlias(foo = VPSet(PSet(type = string("int")))))
3502  self.assertTrue(hasattr(sp.test2, "foo"))
3503  # Replace an alias
3504  m.toReplaceWith(sp.test2, EDAlias(bar = VPSet(PSet(type = string("int")))))
3505  self.assertTrue(hasattr(sp.test2, "bar"))
3506  # Alternative way
3507  m.toModify(sp, test2 = EDAlias(xyzzy = VPSet(PSet(type = string("int")))))
3508  self.assertTrue(hasattr(sp.test2, "xyzzy"))
3509  # Replace an alias with EDProducer
3510  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test2, EDProducer("Foo")))
3511  m.toModify(sp, test2 = EDProducer("Foo"))
3513  #check defaults are not overwritten
3514  f = ProcessFragment('Fragment')
3515  p = Process('PROCESS')
3516  p.maxEvents.input = 10
3517  p.options.numberOfThreads = 4
3518  p.maxLuminosityBlocks.input = 2
3519  p.extend(f)
3520  self.assertEqual(p.maxEvents.input.value(),10)
3521  self.assertEqual(p.options.numberOfThreads.value(), 4)
3522  self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
3523  #general checks
3524  f = ProcessFragment("Fragment")
3525  f.fltr = EDFilter("Foo")
3526  p = Process('PROCESS')
3527  p.extend(f)
3528  self.assertTrue(hasattr(p,'fltr'))
3529 
3530  unittest.main()
Config.ModifierChain.__chain
__chain
Definition: Config.py:1677
Config.TestMakePSet.addVEventID
def addVEventID(self, tracked, label, value)
Definition: Config.py:1808
Types.vuint32
Definition: Types.py:874
Config.TestMakePSet.addVInt64
def addVInt64(self, tracked, label, value)
Definition: Config.py:1780
Config.Process.addSubProcess
def addSubProcess(self, mod)
Definition: Config.py:674
Config.Process.switchProducers_
def switchProducers_(self)
Definition: Config.py:197
Config._BoolModifierBase.__init__
def __init__(self, lhs, rhs=None)
Definition: Config.py:1533
Config.Process.name_
def name_(self)
Definition: Config.py:186
Config.Process.producerNames
def producerNames(self)
Definition: Config.py:149
Config.ModifierChain._isOrContains
def _isOrContains(self, other)
Definition: Config.py:1713
Config.Process._validateSequence
def _validateSequence(self, sequence, label)
Definition: Config.py:868
SequenceVisitors.NodeVisitor
Definition: SequenceVisitors.py:71
Config.Process.__isStrict
__isStrict
Definition: Config.py:136
Config.SubProcess.__outputCommands
__outputCommands
Definition: Config.py:1480
Config.SubProcess.getProcessName
def getProcessName(self)
Definition: Config.py:1488
Config.Process.__process
__process
Definition: Config.py:1282
Config.Modifier._toReplaceWith
def _toReplaceWith(toObj, fromObj)
Definition: Config.py:1639
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
Config.ProcessModifier.__modifier
__modifier
Definition: Config.py:1728
Config.TestModuleCommand.testTaskPlaceholder
def testTaskPlaceholder(self)
Definition: Config.py:3079
Config.TestModuleCommand.testSchedule
def testSchedule(self)
Definition: Config.py:2578
Config._ParameterModifier.__init__
def __init__(self, args)
Definition: Config.py:1513
Config.Process.producers_
def producers_(self)
Definition: Config.py:193
Config.Process.maxEvents
maxEvents
Definition: Config.py:139
Config._ParameterModifier._raiseUnknownKey
def _raiseUnknownKey(key)
Definition: Config.py:1528
Config.Process._placeSwitchProducer
def _placeSwitchProducer(self, name, mod)
Definition: Config.py:620
Config.Process.prune
def prune(self, verbose=False, keepUnresolvedSequencePlaceholders=False)
Definition: Config.py:1193
SequenceTypes.DecoratedNodeNameVisitor
Definition: SequenceTypes.py:993
Config.Process.psets
psets
Definition: Config.py:335
SequenceTypes.Path
Definition: SequenceTypes.py:644
Config.Modifier._toModify
def _toModify(obj, func, **kw)
Definition: Config.py:1621
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
Config.Process.__delattr__
def __delattr__(self, name)
Definition: Config.py:538
Config.Process.filterNames
def filterNames(self)
Definition: Config.py:158
SequenceVisitors.CompositeVisitor
Definition: SequenceVisitors.py:92
Config.ProcessFragment.__setattr__
def __setattr__(self, name, value)
Definition: Config.py:1421
Config.TestMakePSet.addPSet
def addPSet(self, tracked, label, value)
Definition: Config.py:1818
Config.Process.__updateOptions
def __updateOptions(self, opt)
Definition: Config.py:240
Config.Modifier._isChosen
def _isChosen(self)
Definition: Config.py:1660
Config.Modifier
Definition: Config.py:1581
Config.ProcessModifier.__func
__func
Definition: Config.py:1729
Config.TestModuleCommand.testSubProcess
def testSubProcess(self)
Definition: Config.py:2823
Config.Modifier.__processModifiers
__processModifiers
Definition: Config.py:1591
cond::hash
Definition: Time.h:19
Modules.Service
Definition: Modules.py:12
Config.Process.__findFirstUsingModule
def __findFirstUsingModule(self, seqsOrTasks, mod)
Definition: Config.py:508
Config.Process.subProcesses_
def subProcesses_(self)
Definition: Config.py:265
Config.Process.aliases_
def aliases_(self)
Definition: Config.py:328
Config.checkImportPermission
def checkImportPermission(minLevel=2, allowedPatterns=[])
Definition: Config.py:30
Config.Process.__setstate__
def __setstate__(self, pkldict)
Definition: Config.py:165
Config.Process._placeESPrefer
def _placeESPrefer(self, name, mod)
Definition: Config.py:645
Config._AndModifier
Definition: Config.py:1559
Config.TestMakePSet.addVEventRange
def addVEventRange(self, tracked, label, value)
Definition: Config.py:1816
Config.Process._dumpConfigOptionallyNamedList
def _dumpConfigOptionallyNamedList(self, items, typeName, options)
Definition: Config.py:751
Config.FilteredStream.__init__
def __init__(self, *args, **kw)
Definition: Config.py:1457
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
Modules.ESSource
Definition: Modules.py:33
Config.Process._insertOneInto
def _insertOneInto(self, parameterSet, label, item, tracked)
Definition: Config.py:1092
Config.Process.es_producers_
def es_producers_(self)
Definition: Config.py:316
Config.Process._insertPaths
def _insertPaths(self, processPSet, nodeVisitor)
Definition: Config.py:1130
ExceptionHandling.format_outerframe
def format_outerframe(number)
Definition: ExceptionHandling.py:13
Config.Process._placeESProducer
def _placeESProducer(self, name, mod)
Definition: Config.py:643
Config.Modifier._toModifyCheck
def _toModifyCheck(obj, func, **kw)
Definition: Config.py:1600
Config.Process._splitPythonList
def _splitPythonList(self, subfolder, d, options)
Definition: Config.py:847
Mixins.PrintOptions
Definition: Mixins.py:11
Config.Process.vpsets
vpsets
Definition: Config.py:339
Config.SubProcess.process
def process(self)
Definition: Config.py:1490
Config.SubProcess._place
def _place(self, label, process)
Definition: Config.py:1500
Config.ModifierChain.__chosen
__chosen
Definition: Config.py:1676
Config.TestModuleCommand.testProcessExtend
def testProcessExtend(self)
Definition: Config.py:1907
Config.Process.es_sources_
def es_sources_(self)
Definition: Config.py:320
Config.Process._placeSequence
def _placeSequence(self, name, mod)
Definition: Config.py:640
Config.TestModuleCommand.testServiceInProcess
def testServiceInProcess(self)
Definition: Config.py:2253
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
Config.Process._placeAnalyzer
def _placeAnalyzer(self, name, mod)
Definition: Config.py:624
Config._InvertModifier
Definition: Config.py:1566
Config.ModifierChain._isChosen
def _isChosen(self)
Definition: Config.py:1688
Config.Process.tasks_
def tasks_(self)
Definition: Config.py:289
Config.SubProcess.type_
def type_(self)
Definition: Config.py:1496
Config.Process.maxLuminosityBlocks
maxLuminosityBlocks
Definition: Config.py:140
Config.TestModuleCommand.testDelete
def testDelete(self)
Definition: Config.py:3148
Config.TestMakePSet.addInputTag
def addInputTag(self, tracked, label, value)
Definition: Config.py:1798
Config.Modifier.__chosen
__chosen
Definition: Config.py:1592
Config.Modifier.__or__
def __or__(self, other)
Definition: Config.py:1666
Config.Modifier._isOrContains
def _isOrContains(self, other)
Definition: Config.py:1668
SequenceTypes.NodeNameVisitor
Definition: SequenceTypes.py:924
Config.Process._pruneModules
def _pruneModules(self, d, scheduledNames)
Definition: Config.py:1259
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Config.FilteredStream.__getattr__
def __getattr__(self, attr)
Definition: Config.py:1461
Config.TestModuleCommand.testModifier
def testModifier(self)
Definition: Config.py:3179
Config.TestModuleCommand.testContains
def testContains(self)
Definition: Config.py:2520
Config.TestMakePSet.addVUInt32
def addVUInt32(self, tracked, label, value)
Definition: Config.py:1776
FastTimer.addService
def addService(process, multirun=False)
Definition: FastTimer.py:3
Config.TestMakePSet
Definition: Config.py:1756
Config.Process.setName_
def setName_(self, name)
Definition: Config.py:188
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
Config.ProcessModifier.__seenProcesses
__seenProcesses
Definition: Config.py:1730
Config.Process.__ppset
__ppset
Definition: Config.py:1281
Config.ProcessFragment.__dir__
def __dir__(self)
Definition: Config.py:1414
Types.double
Definition: Types.py:241
Config.Process.load
def load(self, moduleName)
Definition: Config.py:681
Config.Process.endpaths_
def endpaths_(self)
Definition: Config.py:281
Config.SubProcess
Definition: Config.py:1464
Options.Options
Definition: Options.py:1
Config.ProcessFragment.__getattribute__
def __getattribute__(self, name)
Definition: Config.py:1416
Config.Process.pathNames
def pathNames(self)
Definition: Config.py:161
Config.TestMakePSet.addInt64
def addInt64(self, tracked, label, value)
Definition: Config.py:1778
Config.FilteredStream._blocked_attribute
_blocked_attribute
Definition: Config.py:1437
Config.Process.extend
def extend(self, other, items=())
Definition: Config.py:685
Config.Process._okToPlace
def _okToPlace(self, name, mod, d)
Definition: Config.py:587
Config._OrModifier
Definition: Config.py:1573
Config._BoolModifierBase.makeProcessModifier
def makeProcessModifier(self, func)
Definition: Config.py:1547
Config.TestModuleCommand.testSequence2
def testSequence2(self)
Definition: Config.py:2243
Config.ModifierChain._setChosen
def _setChosen(self)
Definition: Config.py:1683
Config.Process.__init__
def __init__(self, name, *Mods)
Definition: Config.py:104
Config._ParameterModifier.__call__
def __call__(self, obj)
Definition: Config.py:1515
Config.Modifier.toReplaceWith
def toReplaceWith(self, toObj, fromObj)
Definition: Config.py:1631
Config.TestMakePSet.__getValue
def __getValue(self, tracked, label)
Definition: Config.py:1763
Config.Process._itemsInDependencyOrder
def _itemsInDependencyOrder(self, processDictionaryOfItems)
Definition: Config.py:886
Config.Process.source_
def source_(self)
Definition: Config.py:201
Config.ProcessModifier.apply
def apply(self, process)
Definition: Config.py:1731
Config._BoolModifierBase.__and__
def __and__(self, other)
Definition: Config.py:1552
Config.Process.setStrict
def setStrict(self, value)
Definition: Config.py:144
Config.TestMakePSet.__insertValue
def __insertValue(self, tracked, label, value)
Definition: Config.py:1761
Modules.EDAnalyzer
Definition: Modules.py:180
Types.vstring
Definition: Types.py:947
Config.Process.psets_
def psets_(self)
Definition: Config.py:332
Mixins._TypedParameterizable
Definition: Mixins.py:374
Config.Process.validate
def validate(self)
Definition: Config.py:1345
Mixins._Parameterizable
Definition: Mixins.py:162
Config.Process.analyzerNames
def analyzerNames(self)
Definition: Config.py:155
Config.TestModuleCommand.testParameterizable
def testParameterizable(self)
Definition: Config.py:1842
Config.TestModuleCommand.testOverride
def testOverride(self)
Definition: Config.py:2723
Config.TestMakePSet.addBool
def addBool(self, tracked, label, value)
Definition: Config.py:1790
Config.Process._placeOutputModule
def _placeOutputModule(self, name, mod)
Definition: Config.py:616
Config._OrModifier._isChosen
def _isChosen(self)
Definition: Config.py:1577
Config.TestModuleCommand.testImplicitSchedule
def testImplicitSchedule(self)
Definition: Config.py:2683
Config.Process._insertSubProcessesInto
def _insertSubProcessesInto(self, parameterSet, label, itemList, tracked)
Definition: Config.py:1117
Config.TestModuleCommand.testFreeze
def testFreeze(self)
Definition: Config.py:2805
Modules.Source
Definition: Modules.py:194
Config.Process.prefer
def prefer(self, esmodule, *args, **kargs)
Definition: Config.py:1352
Config.Modifier.__init__
def __init__(self)
Definition: Config.py:1590
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
Config.Process.setSource_
def setSource_(self, src)
Definition: Config.py:204
Config._BoolModifierBase._lhs
_lhs
Definition: Config.py:1534
Config.Process._placePath
def _placePath(self, name, mod)
Definition: Config.py:626
Config.Process.paths
paths
Definition: Config.py:280
Config.SubProcess.dumpPython
def dumpPython(self, options=PrintOptions())
Definition: Config.py:1481
Config.TestModuleCommand.testSequence
def testSequence(self)
Definition: Config.py:2228
DictTypes.SortedAndFixedKeysDict
Definition: DictTypes.py:54
Config.Modifier.makeProcessModifier
def makeProcessModifier(self, func)
Definition: Config.py:1593
Config.Process._placeEndPath
def _placeEndPath(self, name, mod)
Definition: Config.py:633
str
#define str(s)
Definition: TestProcessor.cc:48
Config.Process._replaceInTasks
def _replaceInTasks(self, label, new)
Definition: Config.py:1074
Config.FilteredStream.__new__
def __new__(cls, *args, **kw)
Definition: Config.py:1440
Config.TestMakePSet.__init__
def __init__(self)
Definition: Config.py:1759
Config.findProcess
def findProcess(module)
Definition: Config.py:83
Config.SubProcess.__SelectEvents
__SelectEvents
Definition: Config.py:1479
SequenceTypes.Sequence
Definition: SequenceTypes.py:656
Config.ModifierChain.__init__
def __init__(self, *chainedModifiers)
Definition: Config.py:1675
Config.TestModuleCommand.testOptions
def testOptions(self)
Definition: Config.py:2746
Modules.EDFilter
Definition: Modules.py:172
Config.TestMakePSet.addInt32
def addInt32(self, tracked, label, value)
Definition: Config.py:1770
Config.Process.defaultMaxLuminosityBlocks_
def defaultMaxLuminosityBlocks_()
Definition: Config.py:263
Config._ParameterModifier
Definition: Config.py:1511
Mixins._Unlabelable
Definition: Mixins.py:561
Config.Process.schedule_
def schedule_(self)
Definition: Config.py:293
Config.TestMakePSet.addVString
def addVString(self, tracked, label, value)
Definition: Config.py:1794
Config.TestModuleCommand.testUsing
def testUsing(self)
Definition: Config.py:2716
Config.TestModuleCommand.testTypedParameterizable
def testTypedParameterizable(self)
Definition: Config.py:1875
Config.ModifierChain.__copyIfExclude
def __copyIfExclude(self, toExclude)
Definition: Config.py:1704
Config.TestMakePSet.addEventID
def addEventID(self, tracked, label, value)
Definition: Config.py:1806
Config.TestModuleCommand.testMaxEvents
def testMaxEvents(self)
Definition: Config.py:2758
Config.TestMakePSet.addVDouble
def addVDouble(self, tracked, label, value)
Definition: Config.py:1788
Types.PSet
Definition: Types.py:800
Config.TestMakePSet.addEventRange
def addEventRange(self, tracked, label, value)
Definition: Config.py:1814
SequenceTypes.SequenceVisitor
Definition: SequenceTypes.py:810
SequenceTypes.TaskVisitor
Definition: SequenceTypes.py:822
Config.Process._dumpConfigESPrefers
def _dumpConfigESPrefers(self, options)
Definition: Config.py:825
Config.TestModuleCommand.testCloneSequence
def testCloneSequence(self)
Definition: Config.py:2504
Config.Process.setLooper_
def setLooper_(self, lpr)
Definition: Config.py:210
Types.SecSource
Definition: Types.py:777
Config.Process.setPartialSchedule_
def setPartialSchedule_(self, sch, label)
Definition: Config.py:296
Config.Process.__setattr__
def __setattr__(self, name, value)
Definition: Config.py:376
Config.Process.resolve
def resolve(self, keepUnresolvedSequencePlaceholders=False)
Definition: Config.py:1184
Config._AndModifier._isChosen
def _isChosen(self)
Definition: Config.py:1563
Config.Process._placeESSource
def _placeESSource(self, name, mod)
Definition: Config.py:647
Config.SwitchProducerTest
Definition: Config.py:1827
DictTypes.SortedKeysDict
Definition: DictTypes.py:3
Config.Process._placeFilter
def _placeFilter(self, name, mod)
Definition: Config.py:622
Config.TestMakePSet.newPSet
def newPSet(self)
Definition: Config.py:1824
Config.SubProcess.__process
__process
Definition: Config.py:1478
Config.TestModuleCommand.testPath
def testPath(self)
Definition: Config.py:2464
Config._BoolModifierBase
Definition: Config.py:1531
SequenceVisitors.EndPathValidator
Definition: SequenceVisitors.py:42
Config.Process.filters_
def filters_(self)
Definition: Config.py:182
Config.SubProcess.__init__
def __init__(self, process, SelectEvents=untracked.PSet(), outputCommands=untracked.vstring())
Definition: Config.py:1469
Config.FilteredStream
Definition: Config.py:1433
Config.Process
Definition: Config.py:102
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
Config.Process.__setObjectLabel
def __setObjectLabel(self, object, newLabel)
Definition: Config.py:349
Config.Process.isUsingModifier
def isUsingModifier(self, mod)
Definition: Config.py:341
Config.TestModuleCommand.testProcessInsertion
def testProcessInsertion(self)
Definition: Config.py:1882
SequenceVisitors.ScheduleTaskValidator
Definition: SequenceVisitors.py:8
Config.Process._delHelper
def _delHelper(self, name)
Definition: Config.py:521
Config.TestModuleCommand.setUp
def setUp(self)
Definition: Config.py:1839
Exception
Config.Process._replaceInSequences
def _replaceInSequences(self, label, new)
Definition: Config.py:1059
mps_setup.append
append
Definition: mps_setup.py:85
Config.Process._validateTask
def _validateTask(self, task, label)
Definition: Config.py:877
Config.Process.schedule
schedule
Definition: Config.py:311
Config.ProcessFragment.__delattr__
def __delattr__(self, name)
Definition: Config.py:1426
Config.Process._placeSubProcess
def _placeSubProcess(self, name, mod)
Definition: Config.py:671
Config.TestModuleCommand.testRefToPSet
def testRefToPSet(self)
Definition: Config.py:2846
Config.Process.defaultOptions_
def defaultOptions_()
Definition: Config.py:214
Config.Process._placeSource
def _placeSource(self, name, mod)
Definition: Config.py:658
Config._BoolModifierBase._rhs
_rhs
Definition: Config.py:1536
Modules.ESPrefer
Definition: Modules.py:74
Config.TestMakePSet.addString
def addString(self, tracked, label, value)
Definition: Config.py:1792
Config.FilteredStream.__repr__
def __repr__(self)
Definition: Config.py:1459
Config.Process.tasks
tasks
Definition: Config.py:292
SequenceTypes.TaskPlaceholder
Definition: SequenceTypes.py:1603
Config.TestModuleCommand.testProcessDumpPython
def testProcessDumpPython(self)
Definition: Config.py:1994
SequenceVisitors.PathValidator
Definition: SequenceVisitors.py:23
Modules.ESProducer
Definition: Modules.py:54
Config.TestModuleCommand.testPrune
def testPrune(self)
Definition: Config.py:2946
Types.string
Definition: Types.py:292
Modules.SwitchProducer
Definition: Modules.py:221
Config.SubProcess.SelectEvents
def SelectEvents(self)
Definition: Config.py:1492
Config.ModifierChain._applyNewProcessModifiers
def _applyNewProcessModifiers(self, process)
Definition: Config.py:1678
Config.TestModuleCommand.testGlobalReplace
def testGlobalReplace(self)
Definition: Config.py:2176
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
SequenceTypes.ignore
def ignore(seq)
Definition: SequenceTypes.py:630
Config.Process.dumpConfig
def dumpConfig(self, options=PrintOptions())
Definition: Config.py:759
Config.TestMakePSet.values
values
Definition: Config.py:1760
Config._BoolModifierBase.toModify
def toModify(self, obj, func=None, **kw)
Definition: Config.py:1537
Config.Process.dumpPython
def dumpPython(self, options=PrintOptions())
Definition: Config.py:955
Modules.EDProducer
Definition: Modules.py:164
Config.Process._placeAlias
def _placeAlias(self, name, mod)
Definition: Config.py:652
Config.Process.sequences_
def sequences_(self)
Definition: Config.py:285
Types.EDAlias
Definition: Types.py:1314
Config.TestModuleCommand.testExamples
def testExamples(self)
Definition: Config.py:2773
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
Config.SwitchProducerTest.__init__
def __init__(self, **kargs)
Definition: Config.py:1828
Config.Process._placePSet
def _placePSet(self, name, mod)
Definition: Config.py:654
Config.Process.__processPSet
__processPSet
Definition: Config.py:1271
Config.Modifier.__invert__
def __invert__(self)
Definition: Config.py:1664
Config.Process.looper_
def looper_(self)
Definition: Config.py:207
Config.TestMakePSet.addVESInputTag
def addVESInputTag(self, tracked, label, value)
Definition: Config.py:1804
DictTypes.FixedKeysDict
Definition: DictTypes.py:72
Config.Process.es_prefers_
def es_prefers_(self)
Definition: Config.py:324
Config.Process._dumpConfigNamedList
def _dumpConfigNamedList(self, items, typeName, options)
Definition: Config.py:739
Config.Process._dumpPythonSubProcesses
def _dumpPythonSubProcesses(self, l, options)
Definition: Config.py:831
Config.ModifierChain
Definition: Config.py:1672
Config.ProcessModifier.__init__
def __init__(self, modifier, func)
Definition: Config.py:1727
Modules.OutputModule
Definition: Modules.py:187
Config.TestMakePSet.addVUInt64
def addVUInt64(self, tracked, label, value)
Definition: Config.py:1784
Config.Process.splitPython
def splitPython(self, options=PrintOptions())
Definition: Config.py:989
SequenceTypes.ModuleNodeVisitor
Definition: SequenceTypes.py:840
Config.Process._insertSwitchProducersInto
def _insertSwitchProducersInto(self, parameterSet, labelModules, labelAliases, itemDict, tracked)
Definition: Config.py:1107
Config.Process.sequences
sequences
Definition: Config.py:288
Config.Modifier.__and__
def __and__(self, other)
Definition: Config.py:1662
Config.TestModuleCommand
Definition: Config.py:1838
Config.ProcessFragment.__process
__process
Definition: Config.py:1405
Config.ProcessFragment.__init__
def __init__(self, process)
Definition: Config.py:1403
Config.TestMakePSet.addUInt64
def addUInt64(self, tracked, label, value)
Definition: Config.py:1782
Types.VPSet
Definition: Types.py:1124
Config.Process.defaultMaxEvents_
def defaultMaxEvents_()
Definition: Config.py:250
Config.TestMakePSet.addDouble
def addDouble(self, tracked, label, value)
Definition: Config.py:1786
Config.Process.paths_
def paths_(self)
Definition: Config.py:277
Config.Process.add_
def add_(self, value)
Definition: Config.py:572
Config._InvertModifier._isChosen
def _isChosen(self)
Definition: Config.py:1570
Config.Process._findPreferred
def _findPreferred(self, esname, d, *args, **kargs)
Definition: Config.py:1381
Config.Process._delattrFromSetattr
def _delattrFromSetattr(self, name)
Definition: Config.py:563
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Config._OrModifier.__init__
def __init__(self, lhs, rhs)
Definition: Config.py:1575
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:92
Config.Process.setSchedule_
def setSchedule_(self, sch)
Definition: Config.py:301
Config.Process._placeTask
def _placeTask(self, name, task)
Definition: Config.py:649
Config.Modifier.toModify
def toModify(self, obj, func=None, **kw)
Definition: Config.py:1603
Types.InputTag
Definition: Types.py:568
Config.TestModuleCommand.testProcessFragment
def testProcessFragment(self)
Definition: Config.py:3512
Config._ParameterModifier.__args
__args
Definition: Config.py:1514
Config.TestMakePSet.addUInt32
def addUInt32(self, tracked, label, value)
Definition: Config.py:1774
Config.Process.services_
def services_(self)
Definition: Config.py:312
Config.Process._placeService
def _placeService(self, typeName, mod)
Definition: Config.py:676
Config.Process._placeProducer
def _placeProducer(self, name, mod)
Definition: Config.py:618
Config.Process._place
def _place(self, name, mod, d)
Definition: Config.py:608
Config.Process._dumpPythonList
def _dumpPythonList(self, d, options)
Definition: Config.py:837
SequenceTypes.Task
Definition: SequenceTypes.py:1410
Config.ProcessFragment
Definition: Config.py:1402
Types.untracked
untracked
Definition: Types.py:35
Config.Process.__thelist
__thelist
Definition: Config.py:1270
Config.ModifierChain.copyAndExclude
def copyAndExclude(self, toExclude)
Definition: Config.py:1690
Config.TestMakePSet.addVPSet
def addVPSet(self, tracked, label, value)
Definition: Config.py:1820
Config.TestModuleCommand.testSwitchProducer
def testSwitchProducer(self)
Definition: Config.py:2862
Config._lineDiff
def _lineDiff(newString, oldString)
Definition: Config.py:1741
Config.Process.endpaths
endpaths
Definition: Config.py:284
Config.Process.outputModules_
def outputModules_(self)
Definition: Config.py:273
Config.Process._splitPython
def _splitPython(self, subfolder, d, options)
Definition: Config.py:949
Config.Process._placeLooper
def _placeLooper(self, name, mod)
Definition: Config.py:666
Config._AndModifier.__init__
def __init__(self, lhs, rhs)
Definition: Config.py:1561
Config.TestModuleCommand.testPrefers
def testPrefers(self)
Definition: Config.py:2785
SequenceTypes.SequencePlaceholder
Definition: SequenceTypes.py:674
Config.SubProcess.outputCommands
def outputCommands(self)
Definition: Config.py:1494
list
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
Config.Process._insertInto
def _insertInto(self, parameterSet, itemDict)
Definition: Config.py:1089
Config.TestMakePSet.addLuminosityBlockID
def addLuminosityBlockID(self, tracked, label, value)
Definition: Config.py:1810
Config.SubProcess.nameInProcessDesc_
def nameInProcessDesc_(self, label)
Definition: Config.py:1498
Config.TestMakePSet.addESInputTag
def addESInputTag(self, tracked, label, value)
Definition: Config.py:1802
Config.TestModuleCommand.testTask
def testTask(self)
Definition: Config.py:2266
Config.TestModuleCommand.testSecSource
def testSecSource(self)
Definition: Config.py:2171
Types.int32
Definition: Types.py:170
Config.Process.analyzers_
def analyzers_(self)
Definition: Config.py:269
SequenceTypes.Schedule
Definition: SequenceTypes.py:719
SequenceTypes.EndPath
Definition: SequenceTypes.py:650
Config.Modifier._toReplaceWithCheck
def _toReplaceWithCheck(toObj, fromObj)
Definition: Config.py:1628
Config.Process.switchProducerNames
def switchProducerNames(self)
Definition: Config.py:152
Config.Process._replaceInSchedule
def _replaceInSchedule(self, label, new)
Definition: Config.py:1078
Config.Process._dumpConfigUnnamedList
def _dumpConfigUnnamedList(self, items, typeName, options)
Definition: Config.py:745
Config._BoolModifierBase.__or__
def __or__(self, other)
Definition: Config.py:1556
Config.SubProcess.getSubProcessPSet
def getSubProcessPSet(self, parameterSet)
Definition: Config.py:1502
Config.ProcessModifier
Definition: Config.py:1721
Config.Process._dumpPython
def _dumpPython(self, d, options)
Definition: Config.py:943
Config.Process.fillProcessDesc
def fillProcessDesc(self, processPSet)
Definition: Config.py:1266
Config._BoolModifierBase.__invert__
def __invert__(self)
Definition: Config.py:1554
Config.TestMakePSet.getVString
def getVString(self, tracked, label)
Definition: Config.py:1796
Config.TestMakePSet.addVInt32
def addVInt32(self, tracked, label, value)
Definition: Config.py:1772
Config.Process._placeVPSet
def _placeVPSet(self, name, mod)
Definition: Config.py:656
Config.Process.options
options
Definition: Config.py:138
Config._BoolModifierBase.toReplaceWith
def toReplaceWith(self, toObj, fromObj)
Definition: Config.py:1542
Config.Process.globalReplace
def globalReplace(self, label, new)
Definition: Config.py:1084
Config.TestModuleCommand.a
a
Definition: Config.py:2070
OrderedSet.OrderedSet
Definition: OrderedSet.py:29
Config.TestModuleCommand.proc_mod_
proc_mod_
Definition: Config.py:3275
Config.Process.vpsets_
def vpsets_(self)
Definition: Config.py:336
Config.TestMakePSet.addVInputTag
def addVInputTag(self, tracked, label, value)
Definition: Config.py:1800
SequenceTypes
Mixins._modifyParametersFromDict
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
Definition: Mixins.py:688
Config.Process.__updateMaxEvents
def __updateMaxEvents(self, ps)
Definition: Config.py:253
Config.Modifier._setChosen
def _setChosen(self)
Definition: Config.py:1657
Config._InvertModifier.__init__
def __init__(self, lhs)
Definition: Config.py:1568
update
#define update(a, b)
Definition: TrackClassifier.cc:10
Config.TestMakePSet.addFileInPath
def addFileInPath(self, tracked, label, value)
Definition: Config.py:1822
Config.Process._insertManyInto
def _insertManyInto(self, parameterSet, label, itemDict, tracked)
Definition: Config.py:1099
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23