CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
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__SequencePlaceholder_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 EnablePSetHistory.auto_inspect ( )

helpers for inspection ####

Definition at line 8 of file EnablePSetHistory.py.

Referenced by new__ModuleSequenceType__iadd__(), new__ModuleSequenceType__imul__(), new__ModuleSequenceType_remove(), new__ModuleSequenceType_replace(), new_Parameterizable_addParameter(), new_Parameterizable_setattr(), new_Parameterizeable_delattr(), and 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 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 EnablePSetHistory.new__Module_name (   self)

Definition at line 485 of file EnablePSetHistory.py.

486 def new__Module_name(self):
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
def EnablePSetHistory.new__ModuleSequenceType__iadd__ (   self,
  other 
)

Definition at line 540 of file EnablePSetHistory.py.

References auto_inspect().

541 def new__ModuleSequenceType__iadd__(self,other):
542  stack = auto_inspect()
543  self._isModified=True
544  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None})
545  return self.old__iadd__(other)
546 cms._ModuleSequenceType.old__iadd__ = cms._ModuleSequenceType.__iadd__
547 cms._ModuleSequenceType.__iadd__ = new__ModuleSequenceType__iadd__
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new__ModuleSequenceType__imul__ (   self,
  other 
)

Definition at line 532 of file EnablePSetHistory.py.

References auto_inspect().

533 def new__ModuleSequenceType__imul__(self,other):
534  stack = auto_inspect()
535  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None})
536  self._isModified=True
537  return self.old__iadd__(other)
538 cms._ModuleSequenceType.old__imul__ = cms._ModuleSequenceType.__imul__
539 cms._ModuleSequenceType.__imul__ = new__ModuleSequenceType__imul__
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new__ModuleSequenceType__init__ (   self,
  arg,
  argv 
)

Definition at line 493 of file EnablePSetHistory.py.

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__
def EnablePSetHistory.new__ModuleSequenceType_copy (   self)

Definition at line 508 of file EnablePSetHistory.py.

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

Definition at line 504 of file EnablePSetHistory.py.

506  return self._isModified
507 cms._ModuleSequenceType.isModified = new__ModuleSequenceType_isModified
def EnablePSetHistory.new__ModuleSequenceType_remove (   self,
  original 
)

Definition at line 524 of file EnablePSetHistory.py.

References auto_inspect().

525 def new__ModuleSequenceType_remove(self, original):
526  stack = auto_inspect()
527  self._isModified=True
528  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'remove','old':original._name_(),'new':None})
529  return self.old_remove(original)
530 cms._ModuleSequenceType.old_remove = cms._ModuleSequenceType.remove
531 cms._ModuleSequenceType.remove = new__ModuleSequenceType_remove
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new__ModuleSequenceType_replace (   self,
  original,
  replacement 
)

Definition at line 516 of file EnablePSetHistory.py.

References auto_inspect().

517 def new__ModuleSequenceType_replace(self, original, replacement):
518  stack = auto_inspect()
519  self._isModified=True
520  self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'replace','old':original._name_(),'new':replacement._name_()})
521  return self.old_replace(original, replacement)
522 cms._ModuleSequenceType.old_replace = cms._ModuleSequenceType.replace
523 cms._ModuleSequenceType.replace = new__ModuleSequenceType_replace
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new__ModuleSequenceType_resetModified (   self)

Definition at line 499 of file EnablePSetHistory.py.

501  self._isModified=False
502  self._modifications = []
503 cms._ModuleSequenceType.resetModified = new__ModuleSequenceType_resetModified
def new__ModuleSequenceType_resetModified
def EnablePSetHistory.new__place (   self,
  name,
  mod,
  d 
)

Definition at line 61 of file EnablePSetHistory.py.

References bitset_utilities.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
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new__placeLooper (   self,
  name,
  mod 
)

Definition at line 74 of file EnablePSetHistory.py.

References bitset_utilities.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
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new__placeService (   self,
  typeName,
  mod 
)

Definition at line 80 of file EnablePSetHistory.py.

References bitset_utilities.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
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new__placeSource (   self,
  name,
  mod 
)

Definition at line 68 of file EnablePSetHistory.py.

References bitset_utilities.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
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new__Sequenceable_name (   self)

sequence history ####

Definition at line 444 of file EnablePSetHistory.py.

445 def new__Sequenceable_name(self):
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
def new__Sequenceable_name
sequence history ####
def EnablePSetHistory.new__SequenceIgnore_name (   self)

Definition at line 471 of file EnablePSetHistory.py.

472 def new__SequenceIgnore_name(self):
473  if self._operand:
474  return '-'+str(self._operand._name_())
475  else:
476  return '-()'
477 _SequenceIgnore._name_ = new__SequenceIgnore_name
def EnablePSetHistory.new__SequenceNegation_name (   self)

Definition at line 464 of file EnablePSetHistory.py.

466  if self._operand:
467  return '~'+str(self._operand._name_())
468  else:
469  return '~()'
470 _SequenceNegation._name_ = new__SequenceNegation_name
def EnablePSetHistory.new__SequencePlaceholder_name (   self)

Definition at line 460 of file EnablePSetHistory.py.

462  return self._name
463 SequencePlaceholder._name_ = new__SequencePlaceholder_name
def EnablePSetHistory.new_addAction (   self,
  tool 
)

Definition at line 126 of file EnablePSetHistory.py.

References bitset_utilities.append().

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
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new_checkRecording (   self)

Definition at line 153 of file EnablePSetHistory.py.

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

Definition at line 136 of file EnablePSetHistory.py.

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

Definition at line 140 of file EnablePSetHistory.py.

141 def new_disableRecording(self):
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
def 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,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
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def 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 291 of file EnablePSetHistory.py.

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

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 = filter(lambda x: not x['type'] == 'seq', modifications)
312  checkpoint = self.__dict__['_Process__modifiedcheckpoint']
313  if not checkpoint == None:
314  modifications = filter(lambda x: any([x['name'].startswith(check) for check in checkpoint]), modifications)
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
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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 EnablePSetHistory.new_dumpModificationsWithObjects (   self,
  removeDuplicates = False 
)

Definition at line 349 of file EnablePSetHistory.py.

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

Definition at line 149 of file EnablePSetHistory.py.

150 def new_enableRecording(self):
151  self.__dict__['_Process__enableRecording'] -= 1
152 cms.Process.enableRecording=new_enableRecording
def 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 EnablePSetHistory.new_items_ (   self)

Definition at line 372 of file EnablePSetHistory.py.

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 += self.paths.iteritems()
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_
def 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 265 of file EnablePSetHistory.py.

References list().

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
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 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 EnablePSetHistory.new_moduleItems_ (   self)

Definition at line 364 of file EnablePSetHistory.py.

365 def new_moduleItems_(self):
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_
def EnablePSetHistory.new_Parameterizable_addParameter (   self,
  name,
  value 
)

Definition at line 403 of file EnablePSetHistory.py.

References auto_inspect().

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
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new_Parameterizable_init (   self,
  a,
  k 
)

parameterizable history ####

Definition at line 396 of file EnablePSetHistory.py.

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
def new_Parameterizable_init
parameterizable history ####
def EnablePSetHistory.new_Parameterizable_resetModified (   self)

Definition at line 428 of file EnablePSetHistory.py.

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
def EnablePSetHistory.new_Parameterizable_setattr (   self,
  name,
  value 
)

Definition at line 410 of file EnablePSetHistory.py.

References auto_inspect().

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
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new_Parameterizeable_delattr (   self,
  name 
)

Definition at line 419 of file EnablePSetHistory.py.

References auto_inspect().

420 def new_Parameterizeable_delattr(self, name):
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 
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new_ParameterTypeBase_resetModified (   self)

Definition at line 437 of file EnablePSetHistory.py.

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

Definition at line 202 of file EnablePSetHistory.py.

References ConfigBuilder.dumpPython().

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_
def EnablePSetHistory.new_recurseResetModified_ (   self,
  o 
)
Empty all the _modifications lists for
all objects beneath this one.

Definition at line 184 of file EnablePSetHistory.py.

185 def new_recurseResetModified_(self, o):
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_
def 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 EnablePSetHistory.new_resetModified (   self)
Empty out all the modification lists, so we only see changes that
happen from now onwards.

Definition at line 281 of file EnablePSetHistory.py.

282 def new_resetModified(self):
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
def 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 EnablePSetHistory.new_Sequence_name (   self)

Definition at line 478 of file EnablePSetHistory.py.

479 def new_Sequence_name(self):
480  if self._seq:
481  return '('+str(self._seq._name_())+')'
482  else:
483  return '()'
484 cms.Sequence._name_ = new_Sequence_name
def 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 157 of file EnablePSetHistory.py.

References auto_inspect().

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
def auto_inspect
helpers for inspection ####
def EnablePSetHistory.new_setLooper_ (   self,
  lpr 
)

Definition at line 92 of file EnablePSetHistory.py.

References bitset_utilities.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_
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def EnablePSetHistory.new_setSchedule_ (   self,
  sch 
)

Definition at line 86 of file EnablePSetHistory.py.

References bitset_utilities.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_
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def 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 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

EnablePSetHistory._isModified

Definition at line 414 of file EnablePSetHistory.py.

EnablePSetHistory._modifications

Definition at line 399 of file EnablePSetHistory.py.

EnablePSetHistory.ACTIVATE_INSPECTION = True

Definition at line 4 of file EnablePSetHistory.py.