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

Function _kernels_patch_scope

modelscope/utils/hf_util/patcher.py:634–646  ·  view source on GitHub ↗

Apply `_patch_kernels` for the duration of the `with` block, unless an outer patch (e.g. `patch_hub()`) is already in effect.

()

Source from the content-addressed store, hash-verified

632
633@contextlib.contextmanager
634def _kernels_patch_scope():
635 """Apply `_patch_kernels` for the duration of the `with` block, unless an
636 outer patch (e.g. `patch_hub()`) is already in effect.
637 """
638 from kernels import utils as kernels_utils
639 if hasattr(kernels_utils, '_get_hf_api_origin'):
640 yield
641 return
642 _patch_kernels()
643 try:
644 yield
645 finally:
646 _unpatch_kernels()
647
648
649def _wrap_kernels_callable(attr_name):

Callers 1

_wrappedFunction · 0.85

Calls 2

_patch_kernelsFunction · 0.85
_unpatch_kernelsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…