CMS 3D CMS Logo

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