MCPcopy Create free account
hub / github.com/modelscope/modelscope / _restore

Function _restore

modelscope/utils/hf_util/patcher.py:484–493  ·  view source on GitHub ↗
(var, attr, origin_attr)

Source from the content-addressed store, hash-verified

482 # returns a bound method. Re-wrap as classmethod so subclasses still get
483 # `cls` bound to themselves (not to the ancestor that was patched).
484 def _restore(var, attr, origin_attr):
485 origin = getattr(var, origin_attr)
486 if isinstance(origin, MethodType):
487 setattr(var, attr, classmethod(origin.__func__))
488 else:
489 setattr(var, attr, origin)
490 try:
491 delattr(var, origin_attr)
492 except Exception: # noqa
493 pass
494
495 for var in all_imported_modules:
496 if var is None:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…