CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
python.EnablePSetHistory Namespace Reference

Classes

class  TestModificationTracking
 

Functions

def auto_inspect
 helpers for inspection #### More...
 
def new___init__
 
def new__Module_name
 
def new__ModuleSequenceType__iadd__
 
def new__ModuleSequenceType__imul__
 
def new__ModuleSequenceType__init__
 
def new__ModuleSequenceType_copy
 
def new__ModuleSequenceType_isModified
 
def new__ModuleSequenceType_remove
 
def new__ModuleSequenceType_replace
 
def new__ModuleSequenceType_resetModified
 
def new__place
 
def new__placeLooper
 
def new__placeService
 
def new__placeSource
 
def new__Sequenceable_name
 sequence history #### More...
 
def new__SequenceIgnore_name
 
def new__SequenceNegation_name
 
def new_addAction
 
def new_checkRecording
 
def new_deleteAction
 
def new_disableRecording
 
def new_dumpHistory
 
def new_dumpModifications
 
def new_dumpModificationsWithObjects
 
def new_enableRecording
 
def new_history
 
def new_items_
 
def new_modificationCheckpoint
 
def new_modifiedObjects
 
def new_moduleItems_
 
def new_Parameterizable_addParameter
 
def new_Parameterizable_init
 parameterizable history #### More...
 
def new_Parameterizable_resetModified
 
def new_Parameterizable_setattr
 
def new_Parameterizeable_delattr
 
def new_ParameterTypeBase_resetModified
 
def new_recurseDumpModifications_
 
def new_recurseResetModified_
 
def new_resetHistory
 
def new_resetModified
 
def new_resetModifiedObjects
 
def new_Sequence_name
 
def new_setattr
 
def new_setLooper_
 
def new_setSchedule_
 
def new_SortedKeysDict__copy__
 
def new_SortedKeysDict__deepcopy__
 

Variables

 _isModified
 
 _modifications
 
 ACTIVATE_INSPECTION = True
 

Function Documentation

def python.EnablePSetHistory.auto_inspect ( )

helpers for inspection ####

Definition at line 8 of file EnablePSetHistory.py.

Referenced by python.EnablePSetHistory.new__ModuleSequenceType__iadd__(), python.EnablePSetHistory.new__ModuleSequenceType__imul__(), python.EnablePSetHistory.new__ModuleSequenceType_remove(), python.EnablePSetHistory.new__ModuleSequenceType_replace(), python.EnablePSetHistory.new_Parameterizable_addParameter(), python.EnablePSetHistory.new_Parameterizable_setattr(), python.EnablePSetHistory.new_Parameterizeable_delattr(), and python.EnablePSetHistory.new_setattr().

8 
9 def auto_inspect():
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")]
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new___init__ (   self,
  name 
)

Definition at line 43 of file EnablePSetHistory.py.

43 
44 def new___init__(self,name):
45  self.old___init__(name)
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__
def python.EnablePSetHistory.new__Module_name (   self)

Definition at line 480 of file EnablePSetHistory.py.

481 def new__Module_name(self):
482  if hasattr(self,'_Labelable__label'):
483  return getattr(self,'_Labelable__label')
484  elif hasattr(self,'_TypedParameterizable__type'):
485  return 'unnamed(%s)'%getattr(self,'_TypedParameterizable__type')
486  return type(self).__name__
487 cms._Module._name = new__Module_name
def python.EnablePSetHistory.new__ModuleSequenceType__iadd__ (   self,
  other 
)

Definition at line 535 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

536 def new__ModuleSequenceType__iadd__(self,other):
537  stack = auto_inspect()
538  self._isModified=True
539  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name(),'old':None})
540  return self.old__iadd__(other)
541 cms._ModuleSequenceType.old__iadd__ = cms._ModuleSequenceType.__iadd__
542 cms._ModuleSequenceType.__iadd__ = new__ModuleSequenceType__iadd__
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new__ModuleSequenceType__imul__ (   self,
  other 
)

Definition at line 527 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

528 def new__ModuleSequenceType__imul__(self,other):
529  stack = auto_inspect()
530  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name(),'old':None})
531  self._isModified=True
532  return self.old__iadd__(other)
533 cms._ModuleSequenceType.old__imul__ = cms._ModuleSequenceType.__imul__
534 cms._ModuleSequenceType.__imul__ = new__ModuleSequenceType__imul__
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new__ModuleSequenceType__init__ (   self,
  arg,
  argv 
)

Definition at line 488 of file EnablePSetHistory.py.

489 def new__ModuleSequenceType__init__(self,*arg,**argv):
490  self._modifications = []
491  self.old__init__(*arg,**argv)
492 cms._ModuleSequenceType.old__init__ = cms._ModuleSequenceType.__init__
493 cms._ModuleSequenceType.__init__ = new__ModuleSequenceType__init__
def python.EnablePSetHistory.new__ModuleSequenceType_copy (   self)

Definition at line 503 of file EnablePSetHistory.py.

505  returnValue = cms._ModuleSequenceType.__new__(type(self))
506  returnValue.__init__(self._seq)
507  returnValue._isModified = self._isModified
508  returnValue._modifications = deepcopy(self._modifications)
509  return returnValue
510 cms._ModuleSequenceType.copy = new__ModuleSequenceType_copy
def python.EnablePSetHistory.new__ModuleSequenceType_isModified (   self)

Definition at line 499 of file EnablePSetHistory.py.

501  return self._isModified
502 cms._ModuleSequenceType.isModified = new__ModuleSequenceType_isModified
def python.EnablePSetHistory.new__ModuleSequenceType_remove (   self,
  original 
)

Definition at line 519 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

520 def new__ModuleSequenceType_remove(self, original):
521  stack = auto_inspect()
522  self._isModified=True
523  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'remove','old':original._name(),'new':None})
524  return self.old_remove(original)
525 cms._ModuleSequenceType.old_remove = cms._ModuleSequenceType.remove
526 cms._ModuleSequenceType.remove = new__ModuleSequenceType_remove
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new__ModuleSequenceType_replace (   self,
  original,
  replacement 
)

Definition at line 511 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

512 def new__ModuleSequenceType_replace(self, original, replacement):
513  stack = auto_inspect()
514  self._isModified=True
515  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'replace','old':original._name(),'new':replacement._name()})
516  return self.old_replace(original, replacement)
517 cms._ModuleSequenceType.old_replace = cms._ModuleSequenceType.replace
518 cms._ModuleSequenceType.replace = new__ModuleSequenceType_replace
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new__ModuleSequenceType_resetModified (   self)

Definition at line 494 of file EnablePSetHistory.py.

496  self._isModified=False
497  self._modifications = []
498 cms._ModuleSequenceType.resetModified = new__ModuleSequenceType_resetModified
def python.EnablePSetHistory.new__place (   self,
  name,
  mod,
  d 
)

Definition at line 61 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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
def python.EnablePSetHistory.new__placeLooper (   self,
  name,
  mod 
)

Definition at line 74 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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
def python.EnablePSetHistory.new__placeService (   self,
  typeName,
  mod 
)

Definition at line 80 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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
def python.EnablePSetHistory.new__placeSource (   self,
  name,
  mod 
)

Definition at line 68 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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
def python.EnablePSetHistory.new__Sequenceable_name (   self)

sequence history ####

Definition at line 443 of file EnablePSetHistory.py.

444 def new__Sequenceable_name(self):
445  return ''
446 cms._Sequenceable._name = new__Sequenceable_name
447 
448 try:
449  # for backwards-compatibility with CMSSW_3_10_X
450  from FWCore.ParameterSet.SequenceTypes import _SequenceOperator
451 
452  def new__SequenceOperator_name(self):
453  return str(self._left._name())+str(self._pySymbol)+str(self._right._name())
454  _SequenceOperator._name = new__SequenceOperator_name
455 except:
456  pass
def new__Sequenceable_name
sequence history ####
def python.EnablePSetHistory.new__SequenceIgnore_name (   self)

Definition at line 466 of file EnablePSetHistory.py.

467 def new__SequenceIgnore_name(self):
468  if self._operand:
469  return '-'+str(self._operand._name())
470  else:
471  return '-()'
472 _SequenceIgnore._name = new__SequenceIgnore_name
def python.EnablePSetHistory.new__SequenceNegation_name (   self)

Definition at line 459 of file EnablePSetHistory.py.

461  if self._operand:
462  return '~'+str(self._operand._name())
463  else:
464  return '~()'
465 _SequenceNegation._name = new__SequenceNegation_name
def python.EnablePSetHistory.new_addAction (   self,
  tool 
)

Definition at line 125 of file EnablePSetHistory.py.

References python.multivaluedict.append().

126 def new_addAction(self,tool):
127  if self.__dict__['_Process__enableRecording'] == 0:
128  modifiedObjects=self.modifiedObjects()
129  for m,o in self.dumpModificationsWithObjects():
130  modifiedObjects+=o
131  self.__dict__['_Process__history'].append((tool,modifiedObjects))
132  self.resetModified()
133  self.resetModifiedObjects()
134 cms.Process.addAction=new_addAction
def python.EnablePSetHistory.new_checkRecording (   self)

Definition at line 152 of file EnablePSetHistory.py.

153 def new_checkRecording(self):
154  return self.__dict__['_Process__enableRecording']==0
155 cms.Process.checkRecording=new_checkRecording
def python.EnablePSetHistory.new_deleteAction (   self,
  i 
)

Definition at line 135 of file EnablePSetHistory.py.

136 def new_deleteAction(self,i):
137  del self.__dict__['_Process__history'][i]
138 cms.Process.deleteAction=new_deleteAction
def python.EnablePSetHistory.new_disableRecording (   self)

Definition at line 139 of file EnablePSetHistory.py.

140 def new_disableRecording(self):
141  if self.__dict__['_Process__enableRecording'] == 0:
142  # remember modifications in history
143  self.__dict__['_Process__history']+=self.dumpModificationsWithObjects()
144  self.resetModified()
145  self.resetModifiedObjects()
146  self.__dict__['_Process__enableRecording'] += 1
147 cms.Process.disableRecording=new_disableRecording
def python.EnablePSetHistory.new_dumpHistory (   self,
  withImports = True 
)

Definition at line 108 of file EnablePSetHistory.py.

References join().

109 def new_dumpHistory(self,withImports=True):
110  dumpHistory=[]
111  for item,objects in self.history():
112  if isinstance(item,str):
113  dumpHistory.append(item +"\n")
114  else: # isTool
115  dump=item.dumpPython()
116  if isinstance(dump,tuple):
117  if withImports and dump[0] not in dumpHistory:
118  dumpHistory.append(dump[0])
119  dumpHistory.append(dump[1] +"\n")
120  else:
121  dumpHistory.append(dump +"\n")
122 
123  return ''.join(dumpHistory)
124 cms.Process.dumpHistory=new_dumpHistory
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def python.EnablePSetHistory.new_dumpModifications (   self,
  comments = True,
  process = True,
  module = False,
  sequence = True,
  value = True,
  sort = True,
  group = True 
)
Return some text describing all the modifications that have been made.

* comments: print out comments describing the file and line which triggered
            the modification, if determined.
* process: print "process." in front of every name
* module: only print out one entry per top-level module that has been
          changed, rather than the details
* sequence: include changes to sequences
* value: print out the latest value of each name
* sort: whether to sort all the names before printing (otherwise they're in
        more-or-less time order, within each category)

Definition at line 290 of file EnablePSetHistory.py.

References any, align_tpl.filter, join(), list(), and split.

291 def new_dumpModifications(self, comments=True, process=True, module=False, sequence=True, value=True, sort=True, group=True):
292  """
293  Return some text describing all the modifications that have been made.
294 
295  * comments: print out comments describing the file and line which triggered
296  the modification, if determined.
297  * process: print "process." in front of every name
298  * module: only print out one entry per top-level module that has been
299  changed, rather than the details
300  * sequence: include changes to sequences
301  * value: print out the latest value of each name
302  * sort: whether to sort all the names before printing (otherwise they're in
303  more-or-less time order, within each category)
304  """
305  modifications = self.recurseDumpModifications_('', self)
306  text = []
307  for name, o in self.items_():
308  modifications += self.recurseDumpModifications_(name, o)
309  if not sequence:
310  modifications = filter(lambda x: not x['type'] == 'seq', modifications)
311  checkpoint = self.__dict__['_Process__modifiedcheckpoint']
312  if not checkpoint == None:
313  modifications = filter(lambda x: any([x['name'].startswith(check) for check in checkpoint]), modifications)
314  if module:
315  value = False
316  comments = False
317  modules = list(set([m['name'].split('.')[0] for m in modifications]))
318  if sort:
319  modules = sorted(modules)
320  if process:
321  text = ['process.%s' % m for m in modules]
322  else:
323  text = modules
324  else:
325  if sort:
326  modifications = sorted(modifications, key=lambda x: x['name'])
327  for i, m in enumerate(modifications):
328  t = ''
329  if comments:
330  if m['action'] == 'replace':
331  t += '# %(file)s:%(line)s replace %(old)s->%(new)s\n' % m
332  elif m['action'] == 'remove':
333  t += '# %(file)s:%(line)s remove %(old)s\n' % m
334  elif m['action'] == 'append':
335  t += '# %(file)s:%(line)s append %(new)s\n' % m
336  if not group or i==len(modifications)-1 or not modifications[i+1]['name'] == m['name']:
337  if process and value:
338  t += 'process.%s = %s' % (m['name'], m['dump'])
339  elif value:
340  t += '%s = %s' % (m['name'], m['dump'])
341  elif process:
342  t += 'process.%s' % (m['name'])
343  else:
344  t += '%s' % (m['name'])
345  text += [t]
346  return '\n'.join(text)+'\n'
347 cms.Process.dumpModifications=new_dumpModifications
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
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
def python.EnablePSetHistory.new_dumpModificationsWithObjects (   self,
  removeDuplicates = False 
)

Definition at line 348 of file EnablePSetHistory.py.

349 def new_dumpModificationsWithObjects(self, removeDuplicates=False):
350  modifications = []
351  last_modification=""
352  for name, o in self.items_():
353  for m in self.recurseDumpModifications_(name, o):
354  # remove duplicate modifications
355  if removeDuplicates and last_modification==m['name']:
356  modifications.pop()
357  last_modification=m['name']
358  # add changes
359  text = 'process.%s = %s' % (m['name'], m['dump'])
360  modifications += [(text,[o])]
361  return modifications
362 cms.Process.dumpModificationsWithObjects=new_dumpModificationsWithObjects
def python.EnablePSetHistory.new_enableRecording (   self)

Definition at line 148 of file EnablePSetHistory.py.

149 def new_enableRecording(self):
150  self.__dict__['_Process__enableRecording'] -= 1
151 cms.Process.enableRecording=new_enableRecording
def python.EnablePSetHistory.new_history (   self,
  removeDuplicates = False 
)

Definition at line 98 of file EnablePSetHistory.py.

98 
99 def new_history(self, removeDuplicates=False):
100  return self.__dict__['_Process__history']+self.dumpModificationsWithObjects(removeDuplicates)
101 cms.Process.history=new_history
def python.EnablePSetHistory.new_items_ (   self)

Definition at line 371 of file EnablePSetHistory.py.

372 def new_items_(self):
373  items = []
374  if self.source:
375  items += [("source", self.source)]
376  if self.looper:
377  items += [("looper", self.looper)]
378  items += self.moduleItems_()
379  items += self.outputModules.items()
380  items += self.sequences.items()
381  items += self.paths.iteritems()
382  items += self.endpaths.items()
383  items += self.services.items()
384  items += self.es_producers.items()
385  items += self.es_sources.items()
386  items += self.es_prefers.items()
387  items += self.psets.items()
388  items += self.vpsets.items()
389  if self.schedule:
390  items += [("schedule", self.schedule)]
391  return tuple(items)
392 cms.Process.items_=new_items_
def python.EnablePSetHistory.new_modificationCheckpoint (   self)
Set a checkpoint, ie get the current list of all known
top-level names and store them. Later, when we print out
modifications we ignore any modifications that do not affect
something in this list.

There is currently no way of clearing this, but I think this
is generally a use-once feature.

Definition at line 264 of file EnablePSetHistory.py.

References list().

266  """
267  Set a checkpoint, ie get the current list of all known
268  top-level names and store them. Later, when we print out
269  modifications we ignore any modifications that do not affect
270  something in this list.
271 
272  There is currently no way of clearing this, but I think this
273  is generally a use-once feature.
274  """
275  existing_names = set()
276  for item in self.items_():
277  existing_names.add(item[0])
278  self.__dict__['_Process__modifiedcheckpoint'] = list(existing_names)
279 cms.Process.modificationCheckpoint=new_modificationCheckpoint
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 python.EnablePSetHistory.new_modifiedObjects (   self)

Definition at line 53 of file EnablePSetHistory.py.

53 
54 def new_modifiedObjects(self):
55  return self.__dict__['_Process__modifiedobjects']
56 cms.Process.modifiedObjects=new_modifiedObjects
def python.EnablePSetHistory.new_moduleItems_ (   self)

Definition at line 363 of file EnablePSetHistory.py.

364 def new_moduleItems_(self):
365  items = []
366  items += self.producers.items()
367  items += self.filters.items()
368  items += self.analyzers.items()
369  return tuple(items)
370 cms.Process.moduleItems_=new_moduleItems_
def python.EnablePSetHistory.new_Parameterizable_addParameter (   self,
  name,
  value 
)

Definition at line 402 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

403 def new_Parameterizable_addParameter(self, name, value):
404  self.old__addParameter(name,value)
405  stack = auto_inspect()
406  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':None,'new':deepcopy(value),'action':'add'})
407 cms._Parameterizable.old__addParameter = cms._Parameterizable._Parameterizable__addParameter
408 cms._Parameterizable._Parameterizable__addParameter = new_Parameterizable_addParameter
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new_Parameterizable_init (   self,
  a,
  k 
)

parameterizable history ####

Definition at line 395 of file EnablePSetHistory.py.

396 def new_Parameterizable_init(self,*a,**k):
397  self.__dict__['_modifications'] = []
398  self.old__init__(*a,**k)
399  self._modifications = []
400 cms._Parameterizable.old__init__ = cms._Parameterizable.__init__
401 cms._Parameterizable.__init__ = new_Parameterizable_init
def new_Parameterizable_init
parameterizable history ####
def python.EnablePSetHistory.new_Parameterizable_resetModified (   self)

Definition at line 427 of file EnablePSetHistory.py.

429  self._isModified=False
430  self._modifications = []
431  for name in self.parameterNames_():
432  param = self.__dict__[name]
433  if isinstance(param, cms._Parameterizable):
434  param.resetModified()
435 cms._Parameterizable.resetModified = new_Parameterizable_resetModified
def python.EnablePSetHistory.new_Parameterizable_setattr (   self,
  name,
  value 
)

Definition at line 409 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

410 def new_Parameterizable_setattr(self, name, value):
411  if (not self.isFrozen()) and (not name.startswith('_')) and (name in self.__dict__):
412  stack = auto_inspect()
413  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]),'new':deepcopy(value),'action':'replace'})
414  self._isModified = True
415  self.old__setattr__(name,value)
416 cms._Parameterizable.old__setattr__ = cms._Parameterizable.__setattr__
417 cms._Parameterizable.__setattr__ = new_Parameterizable_setattr
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new_Parameterizeable_delattr (   self,
  name 
)

Definition at line 418 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

419 def new_Parameterizeable_delattr(self, name):
420  if not self.isFrozen():
421  stack = auto_inspect()
422  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]), 'new':None,'action':'delete'})
423  self.old__delattr__(name)
424 cms._Parameterizable.old__delattr__ = cms._Parameterizable.__delattr__
425 cms._Parameterizable.__delattr__ = new_Parameterizeable_delattr
426 
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new_ParameterTypeBase_resetModified (   self)

Definition at line 436 of file EnablePSetHistory.py.

438  self._isModified=False
439  self._modifications = []
440 cms._ParameterTypeBase.resetModified = new_ParameterTypeBase_resetModified
def python.EnablePSetHistory.new_recurseDumpModifications_ (   self,
  name,
  o 
)
Recursively return a standardised list of modifications
from the object hierarchy.

Definition at line 201 of file EnablePSetHistory.py.

References ConfigBuilder.dumpPython().

202 def new_recurseDumpModifications_(self, name, o):
203  """
204  Recursively return a standardised list of modifications
205  from the object hierarchy.
206  """
207  modifications = []
208  if isinstance(o, cms._ModuleSequenceType):
209  if o._isModified:
210  for mod in o._modifications:
211  modifications.append({'name':name,
212  'action':mod['action'],
213  'old': mod['old'],
214  'new': mod['new'],
215  'file': mod['file'],
216  'line': mod['line'],
217  'dump': o.dumpPython({}),
218  'type': 'seq'})
219 
220  if isinstance(o, cms._Parameterizable):
221  for mod in o._modifications:
222  paramname = mod['name']
223  if hasattr(o, paramname):
224  paramvalue = getattr(o, paramname)
225  else:
226  paramvalue = None
227  if isinstance(paramvalue,cms._ParameterTypeBase):
228  dump = paramvalue.dumpPython()
229  else:
230  dump = paramvalue
231  modifications.append({'name': '%s.%s' %(name, paramname),
232  'old': mod['old'],
233  'new': mod['new'],
234  'file': mod['file'],
235  'line': mod['line'],
236  'action': mod['action'],
237  'dump': dump,
238  'type': 'param'})
239 
240  # Loop over any child elements
241  for key in o.parameterNames_():
242  value = getattr(o,key)
243  modifications += self.recurseDumpModifications_("%s.%s" % (name, key), value)
244 
245  if isinstance(o, cms._ValidatingListBase):
246  for index, item in enumerate(o):
247  modifications += self.recurseDumpModifications_("%s[%s]" % (name, index), item)
248  if isinstance(o, cms.Process):
249  for mod in o.__dict__['_Process__modifications']:
250  if hasattr(o, mod['name']) and hasattr(getattr(o, mod['name']), 'dumpPython'):
251  dump = getattr(o, mod['name']).dumpPython()
252  else:
253  dump = None
254  modifications.append({'name': mod['name'],
255  'action': mod['action'],
256  'old': mod['old'],
257  'new': mod['new'],
258  'dump': dump,
259  'file': mod['file'],
260  'line': mod['line'],
261  'type': 'process'})
262  return modifications
263 cms.Process.recurseDumpModifications_=new_recurseDumpModifications_
def python.EnablePSetHistory.new_recurseResetModified_ (   self,
  o 
)
Empty all the _modifications lists for
all objects beneath this one.

Definition at line 183 of file EnablePSetHistory.py.

184 def new_recurseResetModified_(self, o):
185  """
186  Empty all the _modifications lists for
187  all objects beneath this one.
188  """
189  properties = []
190  if isinstance(o, cms._ModuleSequenceType):
191  o.resetModified()
192  if isinstance(o, cms._Parameterizable):
193  o.resetModified()
194  for key in o.parameterNames_():
195  value = getattr(o,key)
196  self.recurseResetModified_(value)
197  if isinstance(o, cms._ValidatingListBase):
198  for index,item in enumerate(o):
199  self.recurseResetModified_(item)
200 cms.Process.recurseResetModified_=new_recurseResetModified_
def python.EnablePSetHistory.new_resetHistory (   self)

Definition at line 102 of file EnablePSetHistory.py.

103 def new_resetHistory(self):
104  self.__dict__['_Process__history'] = []
105  self.resetModified()
106  self.resetModifiedObjects()
107 cms.Process.resetHistory=new_resetHistory
def python.EnablePSetHistory.new_resetModified (   self)
Empty out all the modification lists, so we only see changes that
happen from now onwards.

Definition at line 280 of file EnablePSetHistory.py.

281 def new_resetModified(self):
282  """
283  Empty out all the modification lists, so we only see changes that
284  happen from now onwards.
285  """
286  self.__dict__['_Process__modified'] = []
287  for name, o in self.items_():
288  self.recurseResetModified_(o)
289 cms.Process.resetModified=new_resetModified
def python.EnablePSetHistory.new_resetModifiedObjects (   self)

Definition at line 57 of file EnablePSetHistory.py.

57 
58 def new_resetModifiedObjects(self):
59  self.__dict__['_Process__modifiedobjects'] = []
60 cms.Process.resetModifiedObjects=new_resetModifiedObjects
def python.EnablePSetHistory.new_Sequence_name (   self)

Definition at line 473 of file EnablePSetHistory.py.

474 def new_Sequence_name(self):
475  if self._seq:
476  return '('+str(self._seq._name())+')'
477  else:
478  return '()'
479 cms.Sequence._name = new_Sequence_name
def python.EnablePSetHistory.new_setattr (   self,
  name,
  value 
)
This catches modifications that occur during process.load,
and only records a modification if there was an existing object
and the version after __setattr__ has a different id().
This does not mean that the object is different, only redefined.
We still really need a recursive-comparison function for parameterizeable
objects to determine if a real change has been made.

Definition at line 156 of file EnablePSetHistory.py.

References python.EnablePSetHistory.auto_inspect().

157 def new_setattr(self, name, value):
158  """
159  This catches modifications that occur during process.load,
160  and only records a modification if there was an existing object
161  and the version after __setattr__ has a different id().
162  This does not mean that the object is different, only redefined.
163  We still really need a recursive-comparison function for parameterizeable
164  objects to determine if a real change has been made.
165  """
166  old = None
167  existing = False
168  if not name.startswith('_Process__'):
169  existing = hasattr(self, name)
170  if existing:
171  old = getattr(self, name)
172  self.old__setattr__(name, value)
173  if existing:
174  if id(getattr(self, name)) != id(old):
175  stack = auto_inspect()
176  self.__dict__['_Process__modifications'] += [{'name': name,
177  'old': deepcopy(old),
178  'new': deepcopy(getattr(self, name)),
179  'file':stack[0][1],'line':stack[0][2],
180  'action': 'replace'}]
181 cms.Process.old__setattr__ = cms.Process.__setattr__
182 cms.Process.__setattr__ = new_setattr
def auto_inspect
helpers for inspection ####
def python.EnablePSetHistory.new_setLooper_ (   self,
  lpr 
)

Definition at line 92 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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_
def python.EnablePSetHistory.new_setSchedule_ (   self,
  sch 
)

Definition at line 86 of file EnablePSetHistory.py.

References python.multivaluedict.append().

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_
def python.EnablePSetHistory.new_SortedKeysDict__copy__ (   self)

Definition at line 23 of file EnablePSetHistory.py.

23 
25  return self.__class__(self)
26 typ.SortedKeysDict.__copy__ = new_SortedKeysDict__copy__
def python.EnablePSetHistory.new_SortedKeysDict__deepcopy__ (   self,
  memo = None 
)

Definition at line 27 of file EnablePSetHistory.py.

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__

Variable Documentation

python.EnablePSetHistory._isModified

Definition at line 413 of file EnablePSetHistory.py.

python.EnablePSetHistory._modifications

Definition at line 398 of file EnablePSetHistory.py.

python.EnablePSetHistory.ACTIVATE_INSPECTION = True

Definition at line 4 of file EnablePSetHistory.py.