CMS 3D CMS Logo

EnablePSetHistory.py
Go to the documentation of this file.
1 from copy import deepcopy
2 import inspect
3 import six
4 
5 ACTIVATE_INSPECTION=True
6 
7 #### helpers for inspection ####
8 
10  if not ACTIVATE_INSPECTION:
11  return [("unknown","unknown","unknown")]
12  stack = inspect.stack()
13  while len(stack)>=1 and len(stack[0])>=2 and ('FWCore/ParameterSet' in stack[0][1] or 'FWCore/GuiBrowsers' in stack[0][1]):
14  stack = stack[1:]
15  if len(stack)>=1 and len(stack[0])>=3:
16  return stack
17  else:
18  return [("unknown","unknown","unknown")]
19 
20 #### patches needed for deepcopy of process ####
21 
22 import FWCore.ParameterSet.DictTypes as typ
23 
25  return self.__class__(self)
26 typ.SortedKeysDict.__copy__ = new_SortedKeysDict__copy__
27 
28 def new_SortedKeysDict__deepcopy__(self, memo=None):
29  from copy import deepcopy
30  if memo is None:
31  memo = {}
32  d = memo.get(id(self), None)
33  if d is not None:
34  return d
35  memo[id(self)] = d = self.__class__()
36  d.__init__(deepcopy(self.items(), memo))
37  return d
38 typ.SortedKeysDict.__deepcopy__ = new_SortedKeysDict__deepcopy__
39 
40 #### process history ####
41 
42 import FWCore.ParameterSet.Config as cms
43 
44 def new___init__(self,*l,**k):
45  self.old___init__(*l,**k)
46  self.__dict__['_Process__history'] = []
47  self.__dict__['_Process__enableRecording'] = 0
48  self.__dict__['_Process__modifiedobjects'] = []
49  self.__dict__['_Process__modifiedcheckpoint'] = None
50  self.__dict__['_Process__modifications'] = []
51 cms.Process.old___init__=cms.Process.__init__
52 cms.Process.__init__=new___init__
53 
55  return self.__dict__['_Process__modifiedobjects']
56 cms.Process.modifiedObjects=new_modifiedObjects
57 
59  self.__dict__['_Process__modifiedobjects'] = []
60 cms.Process.resetModifiedObjects=new_resetModifiedObjects
61 
62 def new__place(self, name, mod, d):
63  self.old__place(name, mod, d)
64  if self._okToPlace(name, mod, d):
65  self.__dict__['_Process__modifiedobjects'].append(mod)
66 cms.Process.old__place=cms.Process._place
67 cms.Process._place=new__place
68 
69 def new__placeSource(self, name, mod):
70  self.old__placeSource(name, mod)
71  self.__dict__['_Process__modifiedobjects'].append(mod)
72 cms.Process.old__placeSource=cms.Process._placeSource
73 cms.Process._placeSource=new__placeSource
74 
75 def new__placeLooper(self, name, mod):
76  self.old__placeLooper(name, mod)
77  self.__dict__['_Process__modifiedobjects'].append(mod)
78 cms.Process.old__placeLooper=cms.Process._placeLooper
79 cms.Process._placeLooper=new__placeLooper
80 
81 def new__placeService(self, typeName, mod):
82  self.old__placeService(typeName, mod)
83  self.__dict__['_Process__modifiedobjects'].append(mod)
84 cms.Process.old__placeService=cms.Process._placeService
85 cms.Process._placeService=new__placeService
86 
87 def new_setSchedule_(self, sch):
88  self.old_setSchedule_(sch)
89  self.__dict__['_Process__modifiedobjects'].append(sch)
90 cms.Process.old_setSchedule_=cms.Process.setSchedule_
91 cms.Process.setSchedule_=new_setSchedule_
92 
93 def new_setLooper_(self, lpr):
94  self.old_setLooper_(lpr)
95  self.__dict__['_Process__modifiedobjects'].append(lpr)
96 cms.Process.old_setLooper_=cms.Process.setLooper_
97 cms.Process.setLooper_=new_setLooper_
98 
99 def new_history(self, removeDuplicates=False):
100  return self.__dict__['_Process__history']+self.dumpModificationsWithObjects(removeDuplicates)
101 cms.Process.history=new_history
102 
104  self.__dict__['_Process__history'] = []
105  self.resetModified()
106  self.resetModifiedObjects()
107 cms.Process.resetHistory=new_resetHistory
108 
109 def new_dumpHistory(self,withImports=True):
110  dumpHistory=[]
111  for item,objects in self.history():
112  if isinstance(item,(str,unicode)):
113  dumpHistory.append(item +"\n")
114  else: # isTool
115  print item
116  dump=item.dumpPython()
117  if isinstance(dump,tuple):
118  if withImports and dump[0] not in dumpHistory:
119  dumpHistory.append(dump[0])
120  dumpHistory.append(dump[1] +"\n")
121  else:
122  dumpHistory.append(dump +"\n")
123 
124  return ''.join(dumpHistory)
125 cms.Process.dumpHistory=new_dumpHistory
126 
127 def new_addAction(self,tool):
128  if self.__dict__['_Process__enableRecording'] == 0:
129  modifiedObjects=self.modifiedObjects()
130  for m,o in self.dumpModificationsWithObjects():
131  modifiedObjects+=o
132  self.__dict__['_Process__history'].append((tool,modifiedObjects))
133  self.resetModified()
134  self.resetModifiedObjects()
135 cms.Process.addAction=new_addAction
136 
137 def new_deleteAction(self,i):
138  del self.__dict__['_Process__history'][i]
139 cms.Process.deleteAction=new_deleteAction
140 
142  if self.__dict__['_Process__enableRecording'] == 0:
143  # remember modifications in history
144  self.__dict__['_Process__history']+=self.dumpModificationsWithObjects()
145  self.resetModified()
146  self.resetModifiedObjects()
147  self.__dict__['_Process__enableRecording'] += 1
148 cms.Process.disableRecording=new_disableRecording
149 
151  self.__dict__['_Process__enableRecording'] -= 1
152 cms.Process.enableRecording=new_enableRecording
153 
155  return self.__dict__['_Process__enableRecording']==0
156 cms.Process.checkRecording=new_checkRecording
157 
158 def new_setattr(self, name, value):
159  """
160  This catches modifications that occur during process.load,
161  and only records a modification if there was an existing object
162  and the version after __setattr__ has a different id().
163  This does not mean that the object is different, only redefined.
164  We still really need a recursive-comparison function for parameterizeable
165  objects to determine if a real change has been made.
166  """
167  old = None
168  existing = False
169  if not name.startswith('_Process__'):
170  existing = hasattr(self, name)
171  if existing:
172  old = getattr(self, name)
173  self.old__setattr__(name, value)
174  if existing:
175  if id(getattr(self, name)) != id(old):
176  stack = auto_inspect()
177  self.__dict__['_Process__modifications'] += [{'name': name,
178  'old': deepcopy(old),
179  'new': deepcopy(getattr(self, name)),
180  'file':stack[0][1],'line':stack[0][2],
181  'action': 'replace'}]
182 cms.Process.old__setattr__ = cms.Process.__setattr__
183 cms.Process.__setattr__ = new_setattr
184 
186  """
187  Empty all the _modifications lists for
188  all objects beneath this one.
189  """
190  properties = []
191  if isinstance(o, cms._ModuleSequenceType):
192  o.resetModified()
193  if isinstance(o, cms._Parameterizable):
194  o.resetModified()
195  for key in o.parameterNames_():
196  value = getattr(o,key)
197  self.recurseResetModified_(value)
198  if isinstance(o, cms._ValidatingListBase):
199  for index,item in enumerate(o):
200  self.recurseResetModified_(item)
201 cms.Process.recurseResetModified_=new_recurseResetModified_
202 
203 def new_recurseDumpModifications_(self, name, o):
204  """
205  Recursively return a standardised list of modifications
206  from the object hierarchy.
207  """
208  modifications = []
209  if isinstance(o, cms._ModuleSequenceType):
210  if o._isModified:
211  for mod in o._modifications:
212  modifications.append({'name':name,
213  'action':mod['action'],
214  'old': mod['old'],
215  'new': mod['new'],
216  'file': mod['file'],
217  'line': mod['line'],
218  'dump': o.dumpPython({}),
219  'type': 'seq'})
220 
221  if isinstance(o, cms._Parameterizable):
222  for mod in o._modifications:
223  paramname = mod['name']
224  if hasattr(o, paramname):
225  paramvalue = getattr(o, paramname)
226  else:
227  paramvalue = None
228  if isinstance(paramvalue,cms._ParameterTypeBase):
229  dump = paramvalue.dumpPython()
230  else:
231  dump = paramvalue
232  modifications.append({'name': '%s.%s' %(name, paramname),
233  'old': mod['old'],
234  'new': mod['new'],
235  'file': mod['file'],
236  'line': mod['line'],
237  'action': mod['action'],
238  'dump': dump,
239  'type': 'param'})
240 
241  # Loop over any child elements
242  for key in o.parameterNames_():
243  value = getattr(o,key)
244  modifications += self.recurseDumpModifications_("%s.%s" % (name, key), value)
245 
246  if isinstance(o, cms._ValidatingListBase):
247  for index, item in enumerate(o):
248  modifications += self.recurseDumpModifications_("%s[%s]" % (name, index), item)
249  if isinstance(o, cms.Process):
250  for mod in o.__dict__['_Process__modifications']:
251  if hasattr(o, mod['name']) and hasattr(getattr(o, mod['name']), 'dumpPython'):
252  dump = getattr(o, mod['name']).dumpPython()
253  else:
254  dump = None
255  modifications.append({'name': mod['name'],
256  'action': mod['action'],
257  'old': mod['old'],
258  'new': mod['new'],
259  'dump': dump,
260  'file': mod['file'],
261  'line': mod['line'],
262  'type': 'process'})
263  return modifications
264 cms.Process.recurseDumpModifications_=new_recurseDumpModifications_
265 
267  """
268  Set a checkpoint, ie get the current list of all known
269  top-level names and store them. Later, when we print out
270  modifications we ignore any modifications that do not affect
271  something in this list.
272 
273  There is currently no way of clearing this, but I think this
274  is generally a use-once feature.
275  """
276  existing_names = set()
277  for item in self.items_():
278  existing_names.add(item[0])
279  self.__dict__['_Process__modifiedcheckpoint'] = list(existing_names)
280 cms.Process.modificationCheckpoint=new_modificationCheckpoint
281 
283  """
284  Empty out all the modification lists, so we only see changes that
285  happen from now onwards.
286  """
287  self.__dict__['_Process__modified'] = []
288  for name, o in self.items_():
289  self.recurseResetModified_(o)
290 cms.Process.resetModified=new_resetModified
291 
292 def new_dumpModifications(self, comments=True, process=True, module=False, sequence=True, value=True, sort=True, group=True):
293  """
294  Return some text describing all the modifications that have been made.
295 
296  * comments: print out comments describing the file and line which triggered
297  the modification, if determined.
298  * process: print "process." in front of every name
299  * module: only print out one entry per top-level module that has been
300  changed, rather than the details
301  * sequence: include changes to sequences
302  * value: print out the latest value of each name
303  * sort: whether to sort all the names before printing (otherwise they're in
304  more-or-less time order, within each category)
305  """
306  modifications = self.recurseDumpModifications_('', self)
307  text = []
308  for name, o in self.items_():
309  modifications += self.recurseDumpModifications_(name, o)
310  if not sequence:
311  modifications = [x for x in modifications if not x['type'] == 'seq']
312  checkpoint = self.__dict__['_Process__modifiedcheckpoint']
313  if not checkpoint == None:
314  modifications = [x for x in modifications if any([x['name'].startswith(check) for check in checkpoint])]
315  if module:
316  value = False
317  comments = False
318  modules = list(set([m['name'].split('.')[0] for m in modifications]))
319  if sort:
320  modules = sorted(modules)
321  if process:
322  text = ['process.%s' % m for m in modules]
323  else:
324  text = modules
325  else:
326  if sort:
327  modifications = sorted(modifications, key=lambda x: x['name'])
328  for i, m in enumerate(modifications):
329  t = ''
330  if comments:
331  if m['action'] == 'replace':
332  t += '# %(file)s:%(line)s replace %(old)s->%(new)s\n' % m
333  elif m['action'] == 'remove':
334  t += '# %(file)s:%(line)s remove %(old)s\n' % m
335  elif m['action'] == 'append':
336  t += '# %(file)s:%(line)s append %(new)s\n' % m
337  if not group or i==len(modifications)-1 or not modifications[i+1]['name'] == m['name']:
338  if process and value:
339  t += 'process.%s = %s' % (m['name'], m['dump'])
340  elif value:
341  t += '%s = %s' % (m['name'], m['dump'])
342  elif process:
343  t += 'process.%s' % (m['name'])
344  else:
345  t += '%s' % (m['name'])
346  text += [t]
347  return '\n'.join(text)+'\n'
348 cms.Process.dumpModifications=new_dumpModifications
349 
350 def new_dumpModificationsWithObjects(self, removeDuplicates=False):
351  modifications = []
352  last_modification=""
353  for name, o in self.items_():
354  for m in self.recurseDumpModifications_(name, o):
355  # remove duplicate modifications
356  if removeDuplicates and last_modification==m['name']:
357  modifications.pop()
358  last_modification=m['name']
359  # add changes
360  text = 'process.%s = %s' % (m['name'], m['dump'])
361  modifications += [(text,[o])]
362  return modifications
363 cms.Process.dumpModificationsWithObjects=new_dumpModificationsWithObjects
364 
366  items = []
367  items += self.producers.items()
368  items += self.filters.items()
369  items += self.analyzers.items()
370  return tuple(items)
371 cms.Process.moduleItems_=new_moduleItems_
372 
373 def new_items_(self):
374  items = []
375  if self.source:
376  items += [("source", self.source)]
377  if self.looper:
378  items += [("looper", self.looper)]
379  items += self.moduleItems_()
380  items += self.outputModules.items()
381  items += self.sequences.items()
382  items += six.iteritems(self.paths)
383  items += self.endpaths.items()
384  items += self.services.items()
385  items += self.es_producers.items()
386  items += self.es_sources.items()
387  items += self.es_prefers.items()
388  items += self.psets.items()
389  items += self.vpsets.items()
390  if self.schedule:
391  items += [("schedule", self.schedule)]
392  return tuple(items)
393 cms.Process.items_=new_items_
394 
395 #### parameterizable history ####
396 
397 def new_Parameterizable_init(self,*a,**k):
398  self.__dict__['_modifications'] = []
399  self.old__init__(*a,**k)
400  self._modifications = []
401 cms._Parameterizable.old__init__ = cms._Parameterizable.__init__
402 cms._Parameterizable.__init__ = new_Parameterizable_init
403 
404 def new_Parameterizable_addParameter(self, name, value):
405  self.old__addParameter(name,value)
406  stack = auto_inspect()
407  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':None,'new':deepcopy(value),'action':'add'})
408 cms._Parameterizable.old__addParameter = cms._Parameterizable._Parameterizable__addParameter
409 cms._Parameterizable._Parameterizable__addParameter = new_Parameterizable_addParameter
410 
411 def new_Parameterizable_setattr(self, name, value):
412  if (not self.isFrozen()) and (not name.startswith('_')) and (name in self.__dict__):
413  stack = auto_inspect()
414  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]),'new':deepcopy(value),'action':'replace'})
415  self._isModified = True
416  self.old__setattr__(name,value)
417 cms._Parameterizable.old__setattr__ = cms._Parameterizable.__setattr__
418 cms._Parameterizable.__setattr__ = new_Parameterizable_setattr
419 
421  if not self.isFrozen():
422  stack = auto_inspect()
423  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]), 'new':None,'action':'delete'})
424  self.old__delattr__(name)
425 cms._Parameterizable.old__delattr__ = cms._Parameterizable.__delattr__
426 cms._Parameterizable.__delattr__ = new_Parameterizeable_delattr
427 
428 
430  self._isModified=False
431  self._modifications = []
432  for name in self.parameterNames_():
433  param = self.__dict__[name]
434  if isinstance(param, cms._Parameterizable):
435  param.resetModified()
436 cms._Parameterizable.resetModified = new_Parameterizable_resetModified
437 
439  self._isModified=False
440  self._modifications = []
441 cms._ParameterTypeBase.resetModified = new_ParameterTypeBase_resetModified
442 
443 #### sequence history ####
444 
446  return ''
447 cms._Sequenceable._name_ = new__Sequenceable_name
448 
449 try:
450  # for backwards-compatibility with CMSSW_3_10_X
451  from FWCore.ParameterSet.SequenceTypes import _SequenceOperator
452 
453  def new__SequenceOperator_name(self):
454  return str(self._left._name_())+str(self._pySymbol)+str(self._right._name_())
455  _SequenceOperator._name_ = new__SequenceOperator_name
456 except:
457  pass
458 
459 from FWCore.ParameterSet.SequenceTypes import _SequenceNegation, _SequenceIgnore, SequencePlaceholder
460 
462  return self._name
463 SequencePlaceholder._name_ = new__SequencePlaceholder_name
464 
466  if self._operand:
467  return '~'+str(self._operand._name_())
468  else:
469  return '~()'
470 _SequenceNegation._name_ = new__SequenceNegation_name
471 
473  if self._operand:
474  return '-'+str(self._operand._name_())
475  else:
476  return '-()'
477 _SequenceIgnore._name_ = new__SequenceIgnore_name
478 
480  if self._seq:
481  return '('+str(self._seq._name_())+')'
482  else:
483  return '()'
484 cms.Sequence._name_ = new_Sequence_name
485 
487  if hasattr(self,'_Labelable__label'):
488  return getattr(self,'_Labelable__label')
489  elif hasattr(self,'_TypedParameterizable__type'):
490  return 'unnamed(%s)'%getattr(self,'_TypedParameterizable__type')
491  return type(self).__name__
492 cms._Module._name_ = new__Module_name
493 
494 def new__ModuleSequenceType__init__(self,*arg,**argv):
495  self._modifications = []
496  self.old__init__(*arg,**argv)
497 cms._ModuleSequenceType.old__init__ = cms._ModuleSequenceType.__init__
498 cms._ModuleSequenceType.__init__ = new__ModuleSequenceType__init__
499 
501  self._isModified=False
502  self._modifications = []
503 cms._ModuleSequenceType.resetModified = new__ModuleSequenceType_resetModified
504 
506  return self._isModified
507 cms._ModuleSequenceType.isModified = new__ModuleSequenceType_isModified
508 
510  returnValue = cms._ModuleSequenceType.__new__(type(self))
511  returnValue.__init__(self._seq)
512  returnValue._isModified = self._isModified
513  returnValue._modifications = deepcopy(self._modifications)
514  return returnValue
515 cms._ModuleSequenceType.copy = new__ModuleSequenceType_copy
516 
517 def new__ModuleSequenceType_replace(self, original, replacement):
518  stack = auto_inspect()
519  self._isModified=True
520  if replacement is None:
521  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'replace','old':original._name_(),'new':None})
522  else:
523  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'replace','old':original._name_(),'new':replacement._name_()})
524  return self.old_replace(original, replacement)
525 cms._ModuleSequenceType.old_replace = cms._ModuleSequenceType.replace
526 cms._ModuleSequenceType.replace = new__ModuleSequenceType_replace
527 
528 def new__ModuleSequenceType_remove(self, original):
529  stack = auto_inspect()
530  self._isModified=True
531  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'remove','old':original._name_(),'new':None})
532  return self.old_remove(original)
533 cms._ModuleSequenceType.old_remove = cms._ModuleSequenceType.remove
534 cms._ModuleSequenceType.remove = new__ModuleSequenceType_remove
535 
537  stack = auto_inspect()
538  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None})
539  self._isModified=True
540  return self.old__iadd__(other)
541 cms._ModuleSequenceType.old__imul__ = cms._ModuleSequenceType.__imul__
542 cms._ModuleSequenceType.__imul__ = new__ModuleSequenceType__imul__
543 
545  stack = auto_inspect()
546  self._isModified=True
547  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None})
548  return self.old__iadd__(other)
549 cms._ModuleSequenceType.old__iadd__ = cms._ModuleSequenceType.__iadd__
550 cms._ModuleSequenceType.__iadd__ = new__ModuleSequenceType__iadd__
551 
552 from FWCore.ParameterSet.Modules import Source
553 from FWCore.GuiBrowsers.editorTools import changeSource
554 
555 if __name__=='__main__':
556  import unittest
557  class TestModificationTracking(unittest.TestCase):
558  def setUp(self):
559  pass
560  def testPSet(self):
561  ex = cms.EDAnalyzer("Example",
562  one = cms.double(0),
563  two = cms.bool(True),
564  ps = cms.PSet(
565  three = cms.int32(10),
566  four = cms.string('abc')
567  ),
568  vps = cms.VPSet(
569  cms.PSet(
570  five = cms.InputTag('alpha')
571  ),
572  cms.PSet(
573  six = cms.vint32(1,2,3)
574  )
575  ),
576  seven = cms.vstring('alpha','bravo','charlie'),
577  eight = cms.vuint32(range(10)),
578  nine = cms.int32(0)
579  )
580  ex.zero = cms.string('hello')
581  self.assertEqual(ex._modifications[-1]['name'],'zero')
582  ex.one = cms.double(1)
583  ex.one = cms.double(2)
584  ex.one = cms.double(3)
585  self.assertEqual(ex._modifications[-1]['name'],'one')
586  self.assertEqual(ex._modifications[-2]['name'],'one')
587  self.assertEqual(ex._modifications[-3]['name'],'one')
588  ex.two = False
589  self.assertEqual(ex._modifications[-1]['name'],'two')
590  ex.ps.three.setValue(100) # MISSED
591  #self.assertEqual(ex.ps._modifications.pop()['name'],'three')
592  ex.ps.four = 'def'
593  self.assertEqual(ex.ps._modifications[-1]['name'],'four')
594  ex.vps[0].five = cms.string('beta')
595  self.assertEqual(ex.vps[0]._modifications[-1]['name'],'five')
596  ex.vps[1].__dict__['six'] = cms.vint32(1,4,9) # MISSED
597  #self.assertEqual(ex.vps[1]._modifications[-1]['name'],'six')
598  ex.seven[0] = 'delta' # MISSED
599  #self.assertEqual(ex._modifications[-1]['name'],'seven')
600  ex.eight.pop() # MISSED
601  #self.assertEqual(ex._modifications[-1]['name'],'eight')
602  del ex.nine
603  #self.assertEqual(ex._modifications[-1]['name'],'nine')
604  ex.newvpset = cms.VPSet()
605  self.assertEqual(ex._modifications[-1]['name'],'newvpset')
606 
607  process = cms.Process('unittest')
608  process.ex = ex
609  mods = process.dumpModifications()
610  self.assert_('process.ex.zero' in mods)
611  self.assert_('process.ex.one' in mods)
612  self.assert_('process.ex.two' in mods)
613  #self.assert_('process.ex.three' in mods)
614  self.assert_('process.ex.ps.four' in mods)
615  self.assert_('process.ex.vps[0].five' in mods)
616  #self.assert_('process.ex.vps[1].six' in mods)
617  #self.assert_('process.ex.seven[0]' in mods)
618  #self.assert_('process.ex.eight' in mods)
619  self.assert_('process.ex.nine' in mods)
620  self.assert_('process.ex.newvpset' in mods)
621 
622 
623 
624  def testSeq(self):
625  process = cms.Process('unittest')
626  for i in range(10):
627  setattr(process,'f%s'%i,cms.EDFilter('f%s'%i))
628  process.seq1 = cms.Sequence(process.f1*process.f2*process.f3)
629  self.assertEqual(process.seq1._modifications,[])
630  process.seq2 = cms.Sequence(process.f4+process.f5+process.f6)
631  self.assertEqual(process.seq2._modifications,[])
632 
633  process.seq1.replace(process.f1,process.f0*process.f1)
634  self.assertEqual(process.seq1._modifications[-1]['action'],'replace')
635 
636  process.seq2.remove(process.f5)
637  self.assertEqual(process.seq2._modifications[-1]['action'],'remove')
638 
639  process.path = cms.Path(process.seq1*process.f7)
640  self.assertEqual(process.path._modifications,[])
641 
642  process.path *= process.seq2
643  self.assertEqual(process.path._modifications[-1]['action'],'append')
644  process.path.remove(process.f6)
645  self.assertEqual(process.path._modifications[-1]['action'],'remove')
646  process.path.replace(process.f2,~process.f2)
647  self.assertEqual(process.path._modifications[-1]['action'],'replace')
648 
649  mods = process.dumpModifications()
650  self.assert_('process.seq1' in mods)
651  self.assert_('process.seq2' in mods)
652  self.assert_('process.path' in mods)
653 
654  def testdumpHistory(self):
655  process = cms.Process('unittest')
656  process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
657 
658  changeSource(process,"file:filename.root")
659  self.assertEqual(changeSource._parameters['source'].value,"file:filename.root")
660 
661  changeSource(process,"file:filename2.root")
662  self.assertEqual(changeSource._parameters['source'].value,"file:filename2.root")
663 
664  changeSource(process,"file:filename3.root")
665  self.assertEqual(changeSource._parameters['source'].value,"file:filename3.root")
666 
667  self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n")
668 
669  process.source.fileNames=cms.untracked.vstring("file:replacedfile.root")
670  self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n")
671 
672  process.disableRecording()
673  changeSource.setParameter('source',"file:filename4.root")
674  action=changeSource.__copy__()
675  process.addAction(action)
676  self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n")
677 
678  process.enableRecording()
679  changeSource.setParameter('source',"file:filename5.root")
680  action=changeSource.__copy__()
681  process.addAction(action)
682  process.deleteAction(3)
683  self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n")
684 
685  process.deleteAction(0)
686  self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n")
687 
689  process = cms.Process('unittest')
690  process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
691 
692  changeSource(process,"file:filename.root")
693  self.assertEqual(len(process.history()[0][1]),1)
694 
695  process.source.fileNames=cms.untracked.vstring("file:replacedfile.root")
696  self.assertEqual(len(process.history()[0][1]),1)
697  self.assertEqual(len(process.history()[1][1]),1)
698 
699  process.source.fileNames=["test2"]
700  self.assertEqual(len(process.history()[0][1]),1)
701  self.assertEqual(len(process.history()[1][1]),1)
702 
703  changeSource(process,"file:filename2.root")
704  self.assertEqual(len(process.history()[0][1]),1)
705  self.assertEqual(len(process.history()[1][1]),1)
706  self.assertEqual(len(process.history()[2][1]),1)
707 
708  process.source.fileNames=cms.untracked.vstring("file:replacedfile2.root")
709  self.assertEqual(len(process.history()[0][1]),1)
710  self.assertEqual(len(process.history()[1][1]),1)
711  self.assertEqual(len(process.history()[2][1]),1)
712  self.assertEqual(len(process.history()[3][1]),1)
713 
714  unittest.main()
715 
def new__placeLooper(self, name, mod)
def new__ModuleSequenceType_resetModified(self)
def new_modificationCheckpoint(self)
def new__ModuleSequenceType__iadd__(self, other)
def new__Sequenceable_name(self)
sequence history ####
def new_dumpModifications(self, comments=True, process=True, module=False, sequence=True, value=True, sort=True, group=True)
def new_Parameterizeable_delattr(self, name)
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def new_modifiedObjects(self)
def new__ModuleSequenceType_copy(self)
def new_SortedKeysDict__copy__(self)
def new_Parameterizable_setattr(self, name, value)
def new_Parameterizable_resetModified(self)
def new_SortedKeysDict__deepcopy__(self, memo=None)
def new__ModuleSequenceType_replace(self, original, replacement)
def new_setLooper_(self, lpr)
def new_Parameterizable_init(self, a, k)
parameterizable history ####
def new__SequencePlaceholder_name(self)
def new__SequenceNegation_name(self)
def new_enableRecording(self)
def new_recurseResetModified_(self, o)
def new_resetModifiedObjects(self)
def new_history(self, removeDuplicates=False)
def new_setSchedule_(self, sch)
def new__ModuleSequenceType__imul__(self, other)
def new__SequenceIgnore_name(self)
def new_deleteAction(self, i)
def new__placeService(self, typeName, mod)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def new__ModuleSequenceType_isModified(self)
def new_addAction(self, tool)
def new_disableRecording(self)
def new_checkRecording(self)
def dumpPython(process, name)
def new__ModuleSequenceType__init__(self, arg, argv)
def new_recurseDumpModifications_(self, name, o)
def new_ParameterTypeBase_resetModified(self)
def new_dumpModificationsWithObjects(self, removeDuplicates=False)
def new__ModuleSequenceType_remove(self, original)
def new_setattr(self, name, value)
def auto_inspect()
helpers for inspection ####
#define str(s)
def new__placeSource(self, name, mod)
double split
Definition: MVATrainer.cc:139
def new_dumpHistory(self, withImports=True)
def new___init__(self, l, k)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def new_Parameterizable_addParameter(self, name, value)
def new__place(self, name, mod, d)