CMS 3D CMS Logo

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