def EnablePSetHistory::auto_inspect | ( | ) |
helpers for inspection ####
Definition at line 8 of file EnablePSetHistory.py.
00009 : 00010 if not ACTIVATE_INSPECTION: 00011 return [("unknown","unknown","unknown")] 00012 stack = inspect.stack() 00013 while len(stack)>=1 and len(stack[0])>=2 and ('FWCore/ParameterSet' in stack[0][1] or 'FWCore/GuiBrowsers' in stack[0][1]): 00014 stack = stack[1:] 00015 if len(stack)>=1 and len(stack[0])>=3: 00016 return stack 00017 else: 00018 return [("unknown","unknown","unknown")]
def EnablePSetHistory::new___init__ | ( | self, | |
name | |||
) |
Definition at line 43 of file EnablePSetHistory.py.
00044 : 00045 self.old___init__(name) 00046 self.__dict__['_Process__history'] = [] 00047 self.__dict__['_Process__enableRecording'] = 0 00048 self.__dict__['_Process__modifiedobjects'] = [] 00049 self.__dict__['_Process__modifiedcheckpoint'] = None 00050 self.__dict__['_Process__modifications'] = [] 00051 cms.Process.old___init__=cms.Process.__init__ 00052 cms.Process.__init__=new___init__
def EnablePSetHistory::new__Module_name | ( | self | ) |
Definition at line 485 of file EnablePSetHistory.py.
00486 : 00487 if hasattr(self,'_Labelable__label'): 00488 return getattr(self,'_Labelable__label') 00489 elif hasattr(self,'_TypedParameterizable__type'): 00490 return 'unnamed(%s)'%getattr(self,'_TypedParameterizable__type') 00491 return type(self).__name__ 00492 cms._Module._name_ = new__Module_name
def EnablePSetHistory::new__ModuleSequenceType__iadd__ | ( | self, | |
other | |||
) |
Definition at line 540 of file EnablePSetHistory.py.
00541 : 00542 stack = auto_inspect() 00543 self._isModified=True 00544 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None}) 00545 return self.old__iadd__(other) 00546 cms._ModuleSequenceType.old__iadd__ = cms._ModuleSequenceType.__iadd__ 00547 cms._ModuleSequenceType.__iadd__ = new__ModuleSequenceType__iadd__
def EnablePSetHistory::new__ModuleSequenceType__imul__ | ( | self, | |
other | |||
) |
Definition at line 532 of file EnablePSetHistory.py.
00533 : 00534 stack = auto_inspect() 00535 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'append','new':other._name_(),'old':None}) 00536 self._isModified=True 00537 return self.old__iadd__(other) 00538 cms._ModuleSequenceType.old__imul__ = cms._ModuleSequenceType.__imul__ 00539 cms._ModuleSequenceType.__imul__ = new__ModuleSequenceType__imul__
def EnablePSetHistory::new__ModuleSequenceType__init__ | ( | self, | |
arg, | |||
argv | |||
) |
Definition at line 493 of file EnablePSetHistory.py.
def EnablePSetHistory::new__ModuleSequenceType_copy | ( | self | ) |
Definition at line 508 of file EnablePSetHistory.py.
00509 : 00510 returnValue = cms._ModuleSequenceType.__new__(type(self)) 00511 returnValue.__init__(self._seq) 00512 returnValue._isModified = self._isModified 00513 returnValue._modifications = deepcopy(self._modifications) 00514 return returnValue 00515 cms._ModuleSequenceType.copy = new__ModuleSequenceType_copy
def EnablePSetHistory::new__ModuleSequenceType_isModified | ( | self | ) |
Definition at line 504 of file EnablePSetHistory.py.
def EnablePSetHistory::new__ModuleSequenceType_remove | ( | self, | |
original | |||
) |
Definition at line 524 of file EnablePSetHistory.py.
00525 : 00526 stack = auto_inspect() 00527 self._isModified=True 00528 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'remove','old':original._name_(),'new':None}) 00529 return self.old_remove(original) 00530 cms._ModuleSequenceType.old_remove = cms._ModuleSequenceType.remove 00531 cms._ModuleSequenceType.remove = new__ModuleSequenceType_remove
def EnablePSetHistory::new__ModuleSequenceType_replace | ( | self, | |
original, | |||
replacement | |||
) |
Definition at line 516 of file EnablePSetHistory.py.
00517 : 00518 stack = auto_inspect() 00519 self._isModified=True 00520 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'action':'replace','old':original._name_(),'new':replacement._name_()}) 00521 return self.old_replace(original, replacement) 00522 cms._ModuleSequenceType.old_replace = cms._ModuleSequenceType.replace 00523 cms._ModuleSequenceType.replace = new__ModuleSequenceType_replace
def EnablePSetHistory::new__ModuleSequenceType_resetModified | ( | self | ) |
Definition at line 499 of file EnablePSetHistory.py.
def EnablePSetHistory::new__place | ( | self, | |
name, | |||
mod, | |||
d | |||
) |
Definition at line 61 of file EnablePSetHistory.py.
def EnablePSetHistory::new__placeLooper | ( | self, | |
name, | |||
mod | |||
) |
Definition at line 74 of file EnablePSetHistory.py.
def EnablePSetHistory::new__placeService | ( | self, | |
typeName, | |||
mod | |||
) |
Definition at line 80 of file EnablePSetHistory.py.
def EnablePSetHistory::new__placeSource | ( | self, | |
name, | |||
mod | |||
) |
Definition at line 68 of file EnablePSetHistory.py.
def EnablePSetHistory::new__Sequenceable_name | ( | self | ) |
sequence history ####
Definition at line 444 of file EnablePSetHistory.py.
00445 : 00446 return '' 00447 cms._Sequenceable._name_ = new__Sequenceable_name 00448 00449 try: 00450 # for backwards-compatibility with CMSSW_3_10_X 00451 from FWCore.ParameterSet.SequenceTypes import _SequenceOperator 00452 00453 def new__SequenceOperator_name(self): 00454 return str(self._left._name_())+str(self._pySymbol)+str(self._right._name_()) 00455 _SequenceOperator._name_ = new__SequenceOperator_name 00456 except: 00457 pass
def EnablePSetHistory::new__SequenceIgnore_name | ( | self | ) |
Definition at line 471 of file EnablePSetHistory.py.
def EnablePSetHistory::new__SequenceNegation_name | ( | self | ) |
Definition at line 464 of file EnablePSetHistory.py.
def EnablePSetHistory::new__SequencePlaceholder_name | ( | self | ) |
Definition at line 460 of file EnablePSetHistory.py.
def EnablePSetHistory::new_addAction | ( | self, | |
tool | |||
) |
Definition at line 126 of file EnablePSetHistory.py.
00127 : 00128 if self.__dict__['_Process__enableRecording'] == 0: 00129 modifiedObjects=self.modifiedObjects() 00130 for m,o in self.dumpModificationsWithObjects(): 00131 modifiedObjects+=o 00132 self.__dict__['_Process__history'].append((tool,modifiedObjects)) 00133 self.resetModified() 00134 self.resetModifiedObjects() 00135 cms.Process.addAction=new_addAction
def EnablePSetHistory::new_checkRecording | ( | self | ) |
Definition at line 153 of file EnablePSetHistory.py.
def EnablePSetHistory::new_deleteAction | ( | self, | |
i | |||
) |
Definition at line 136 of file EnablePSetHistory.py.
def EnablePSetHistory::new_disableRecording | ( | self | ) |
Definition at line 140 of file EnablePSetHistory.py.
00141 : 00142 if self.__dict__['_Process__enableRecording'] == 0: 00143 # remember modifications in history 00144 self.__dict__['_Process__history']+=self.dumpModificationsWithObjects() 00145 self.resetModified() 00146 self.resetModifiedObjects() 00147 self.__dict__['_Process__enableRecording'] += 1 00148 cms.Process.disableRecording=new_disableRecording
def EnablePSetHistory::new_dumpHistory | ( | self, | |
withImports = True |
|||
) |
Definition at line 108 of file EnablePSetHistory.py.
00109 : 00110 dumpHistory=[] 00111 for item,objects in self.history(): 00112 if isinstance(item,(str,unicode)): 00113 dumpHistory.append(item +"\n") 00114 else: # isTool 00115 print item 00116 dump=item.dumpPython() 00117 if isinstance(dump,tuple): 00118 if withImports and dump[0] not in dumpHistory: 00119 dumpHistory.append(dump[0]) 00120 dumpHistory.append(dump[1] +"\n") 00121 else: 00122 dumpHistory.append(dump +"\n") 00123 00124 return ''.join(dumpHistory) 00125 cms.Process.dumpHistory=new_dumpHistory
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.
00292 : 00293 """ 00294 Return some text describing all the modifications that have been made. 00295 00296 * comments: print out comments describing the file and line which triggered 00297 the modification, if determined. 00298 * process: print "process." in front of every name 00299 * module: only print out one entry per top-level module that has been 00300 changed, rather than the details 00301 * sequence: include changes to sequences 00302 * value: print out the latest value of each name 00303 * sort: whether to sort all the names before printing (otherwise they're in 00304 more-or-less time order, within each category) 00305 """ 00306 modifications = self.recurseDumpModifications_('', self) 00307 text = [] 00308 for name, o in self.items_(): 00309 modifications += self.recurseDumpModifications_(name, o) 00310 if not sequence: 00311 modifications = filter(lambda x: not x['type'] == 'seq', modifications) 00312 checkpoint = self.__dict__['_Process__modifiedcheckpoint'] 00313 if not checkpoint == None: 00314 modifications = filter(lambda x: any([x['name'].startswith(check) for check in checkpoint]), modifications) 00315 if module: 00316 value = False 00317 comments = False 00318 modules = list(set([m['name'].split('.')[0] for m in modifications])) 00319 if sort: 00320 modules = sorted(modules) 00321 if process: 00322 text = ['process.%s' % m for m in modules] 00323 else: 00324 text = modules 00325 else: 00326 if sort: 00327 modifications = sorted(modifications, key=lambda x: x['name']) 00328 for i, m in enumerate(modifications): 00329 t = '' 00330 if comments: 00331 if m['action'] == 'replace': 00332 t += '# %(file)s:%(line)s replace %(old)s->%(new)s\n' % m 00333 elif m['action'] == 'remove': 00334 t += '# %(file)s:%(line)s remove %(old)s\n' % m 00335 elif m['action'] == 'append': 00336 t += '# %(file)s:%(line)s append %(new)s\n' % m 00337 if not group or i==len(modifications)-1 or not modifications[i+1]['name'] == m['name']: 00338 if process and value: 00339 t += 'process.%s = %s' % (m['name'], m['dump']) 00340 elif value: 00341 t += '%s = %s' % (m['name'], m['dump']) 00342 elif process: 00343 t += 'process.%s' % (m['name']) 00344 else: 00345 t += '%s' % (m['name']) 00346 text += [t] 00347 return '\n'.join(text)+'\n' 00348 cms.Process.dumpModifications=new_dumpModifications
def EnablePSetHistory::new_dumpModificationsWithObjects | ( | self, | |
removeDuplicates = False |
|||
) |
Definition at line 349 of file EnablePSetHistory.py.
00350 : 00351 modifications = [] 00352 last_modification="" 00353 for name, o in self.items_(): 00354 for m in self.recurseDumpModifications_(name, o): 00355 # remove duplicate modifications 00356 if removeDuplicates and last_modification==m['name']: 00357 modifications.pop() 00358 last_modification=m['name'] 00359 # add changes 00360 text = 'process.%s = %s' % (m['name'], m['dump']) 00361 modifications += [(text,[o])] 00362 return modifications 00363 cms.Process.dumpModificationsWithObjects=new_dumpModificationsWithObjects
def EnablePSetHistory::new_enableRecording | ( | self | ) |
Definition at line 149 of file EnablePSetHistory.py.
def EnablePSetHistory::new_history | ( | self, | |
removeDuplicates = False |
|||
) |
Definition at line 98 of file EnablePSetHistory.py.
def EnablePSetHistory::new_items_ | ( | self | ) |
Definition at line 372 of file EnablePSetHistory.py.
00373 : 00374 items = [] 00375 if self.source: 00376 items += [("source", self.source)] 00377 if self.looper: 00378 items += [("looper", self.looper)] 00379 items += self.moduleItems_() 00380 items += self.outputModules.items() 00381 items += self.sequences.items() 00382 items += self.paths.iteritems() 00383 items += self.endpaths.items() 00384 items += self.services.items() 00385 items += self.es_producers.items() 00386 items += self.es_sources.items() 00387 items += self.es_prefers.items() 00388 items += self.psets.items() 00389 items += self.vpsets.items() 00390 if self.schedule: 00391 items += [("schedule", self.schedule)] 00392 return tuple(items) 00393 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.
00266 : 00267 """ 00268 Set a checkpoint, ie get the current list of all known 00269 top-level names and store them. Later, when we print out 00270 modifications we ignore any modifications that do not affect 00271 something in this list. 00272 00273 There is currently no way of clearing this, but I think this 00274 is generally a use-once feature. 00275 """ 00276 existing_names = set() 00277 for item in self.items_(): 00278 existing_names.add(item[0]) 00279 self.__dict__['_Process__modifiedcheckpoint'] = list(existing_names) 00280 cms.Process.modificationCheckpoint=new_modificationCheckpoint
def EnablePSetHistory::new_modifiedObjects | ( | self | ) |
Definition at line 53 of file EnablePSetHistory.py.
def EnablePSetHistory::new_moduleItems_ | ( | self | ) |
Definition at line 364 of file EnablePSetHistory.py.
def EnablePSetHistory::new_Parameterizable_addParameter | ( | self, | |
name, | |||
value | |||
) |
Definition at line 403 of file EnablePSetHistory.py.
00404 : 00405 self.old__addParameter(name,value) 00406 stack = auto_inspect() 00407 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':None,'new':deepcopy(value),'action':'add'}) 00408 cms._Parameterizable.old__addParameter = cms._Parameterizable._Parameterizable__addParameter 00409 cms._Parameterizable._Parameterizable__addParameter = new_Parameterizable_addParameter
def EnablePSetHistory::new_Parameterizable_init | ( | self, | |
a, | |||
k | |||
) |
parameterizable history ####
Definition at line 396 of file EnablePSetHistory.py.
def EnablePSetHistory::new_Parameterizable_resetModified | ( | self | ) |
Definition at line 428 of file EnablePSetHistory.py.
def EnablePSetHistory::new_Parameterizable_setattr | ( | self, | |
name, | |||
value | |||
) |
Definition at line 410 of file EnablePSetHistory.py.
00411 : 00412 if (not self.isFrozen()) and (not name.startswith('_')) and (name in self.__dict__): 00413 stack = auto_inspect() 00414 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]),'new':deepcopy(value),'action':'replace'}) 00415 self._isModified = True 00416 self.old__setattr__(name,value) 00417 cms._Parameterizable.old__setattr__ = cms._Parameterizable.__setattr__ 00418 cms._Parameterizable.__setattr__ = new_Parameterizable_setattr
def EnablePSetHistory::new_Parameterizeable_delattr | ( | self, | |
name | |||
) |
Definition at line 419 of file EnablePSetHistory.py.
00420 : 00421 if not self.isFrozen(): 00422 stack = auto_inspect() 00423 self._modifications.append({'file':stack[0][1],'line':stack[0][2],'name':name,'old':deepcopy(self.__dict__[name]), 'new':None,'action':'delete'}) 00424 self.old__delattr__(name) 00425 cms._Parameterizable.old__delattr__ = cms._Parameterizable.__delattr__ 00426 cms._Parameterizable.__delattr__ = new_Parameterizeable_delattr 00427
def EnablePSetHistory::new_ParameterTypeBase_resetModified | ( | self | ) |
Definition at line 437 of file EnablePSetHistory.py.
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.
00203 : 00204 """ 00205 Recursively return a standardised list of modifications 00206 from the object hierarchy. 00207 """ 00208 modifications = [] 00209 if isinstance(o, cms._ModuleSequenceType): 00210 if o._isModified: 00211 for mod in o._modifications: 00212 modifications.append({'name':name, 00213 'action':mod['action'], 00214 'old': mod['old'], 00215 'new': mod['new'], 00216 'file': mod['file'], 00217 'line': mod['line'], 00218 'dump': o.dumpPython({}), 00219 'type': 'seq'}) 00220 00221 if isinstance(o, cms._Parameterizable): 00222 for mod in o._modifications: 00223 paramname = mod['name'] 00224 if hasattr(o, paramname): 00225 paramvalue = getattr(o, paramname) 00226 else: 00227 paramvalue = None 00228 if isinstance(paramvalue,cms._ParameterTypeBase): 00229 dump = paramvalue.dumpPython() 00230 else: 00231 dump = paramvalue 00232 modifications.append({'name': '%s.%s' %(name, paramname), 00233 'old': mod['old'], 00234 'new': mod['new'], 00235 'file': mod['file'], 00236 'line': mod['line'], 00237 'action': mod['action'], 00238 'dump': dump, 00239 'type': 'param'}) 00240 00241 # Loop over any child elements 00242 for key in o.parameterNames_(): 00243 value = getattr(o,key) 00244 modifications += self.recurseDumpModifications_("%s.%s" % (name, key), value) 00245 00246 if isinstance(o, cms._ValidatingListBase): 00247 for index, item in enumerate(o): 00248 modifications += self.recurseDumpModifications_("%s[%s]" % (name, index), item) 00249 if isinstance(o, cms.Process): 00250 for mod in o.__dict__['_Process__modifications']: 00251 if hasattr(o, mod['name']) and hasattr(getattr(o, mod['name']), 'dumpPython'): 00252 dump = getattr(o, mod['name']).dumpPython() 00253 else: 00254 dump = None 00255 modifications.append({'name': mod['name'], 00256 'action': mod['action'], 00257 'old': mod['old'], 00258 'new': mod['new'], 00259 'dump': dump, 00260 'file': mod['file'], 00261 'line': mod['line'], 00262 'type': 'process'}) 00263 return modifications 00264 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.
00185 : 00186 """ 00187 Empty all the _modifications lists for 00188 all objects beneath this one. 00189 """ 00190 properties = [] 00191 if isinstance(o, cms._ModuleSequenceType): 00192 o.resetModified() 00193 if isinstance(o, cms._Parameterizable): 00194 o.resetModified() 00195 for key in o.parameterNames_(): 00196 value = getattr(o,key) 00197 self.recurseResetModified_(value) 00198 if isinstance(o, cms._ValidatingListBase): 00199 for index,item in enumerate(o): 00200 self.recurseResetModified_(item) 00201 cms.Process.recurseResetModified_=new_recurseResetModified_
def EnablePSetHistory::new_resetHistory | ( | self | ) |
Definition at line 102 of file EnablePSetHistory.py.
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.
def EnablePSetHistory::new_resetModifiedObjects | ( | self | ) |
Definition at line 57 of file EnablePSetHistory.py.
def EnablePSetHistory::new_Sequence_name | ( | self | ) |
Definition at line 478 of file EnablePSetHistory.py.
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.
00158 : 00159 """ 00160 This catches modifications that occur during process.load, 00161 and only records a modification if there was an existing object 00162 and the version after __setattr__ has a different id(). 00163 This does not mean that the object is different, only redefined. 00164 We still really need a recursive-comparison function for parameterizeable 00165 objects to determine if a real change has been made. 00166 """ 00167 old = None 00168 existing = False 00169 if not name.startswith('_Process__'): 00170 existing = hasattr(self, name) 00171 if existing: 00172 old = getattr(self, name) 00173 self.old__setattr__(name, value) 00174 if existing: 00175 if id(getattr(self, name)) != id(old): 00176 stack = auto_inspect() 00177 self.__dict__['_Process__modifications'] += [{'name': name, 00178 'old': deepcopy(old), 00179 'new': deepcopy(getattr(self, name)), 00180 'file':stack[0][1],'line':stack[0][2], 00181 'action': 'replace'}] 00182 cms.Process.old__setattr__ = cms.Process.__setattr__ 00183 cms.Process.__setattr__ = new_setattr
def EnablePSetHistory::new_setLooper_ | ( | self, | |
lpr | |||
) |
Definition at line 92 of file EnablePSetHistory.py.
def EnablePSetHistory::new_setSchedule_ | ( | self, | |
sch | |||
) |
Definition at line 86 of file EnablePSetHistory.py.
def EnablePSetHistory::new_SortedKeysDict__copy__ | ( | self | ) |
Definition at line 23 of file EnablePSetHistory.py.
def EnablePSetHistory::new_SortedKeysDict__deepcopy__ | ( | self, | |
memo = None |
|||
) |
Definition at line 27 of file EnablePSetHistory.py.
00028 : 00029 from copy import deepcopy 00030 if memo is None: 00031 memo = {} 00032 d = memo.get(id(self), None) 00033 if d is not None: 00034 return d 00035 memo[id(self)] = d = self.__class__() 00036 d.__init__(deepcopy(self.items(), memo)) 00037 return d 00038 typ.SortedKeysDict.__deepcopy__ = new_SortedKeysDict__deepcopy__
Definition at line 410 of file EnablePSetHistory.py.
Definition at line 396 of file EnablePSetHistory.py.
Definition at line 4 of file EnablePSetHistory.py.