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