CMS 3D CMS Logo

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