Return a wrapper around `kernels. ` that scopes the ModelScope patch on `kernels.utils._get_hf_api` to the call itself, so `from kernels import ` stays on HuggingFace unless the user explicitly calls `patch_hub()` / `patch_context()`.
(attr_name)
| 647 | |
| 648 | |
| 649 | def _wrap_kernels_callable(attr_name): |
| 650 | """Return a wrapper around `kernels.<attr_name>` that scopes the ModelScope |
| 651 | patch on `kernels.utils._get_hf_api` to the call itself, so |
| 652 | `from kernels import <attr_name>` stays on HuggingFace unless the user |
| 653 | explicitly calls `patch_hub()` / `patch_context()`. |
| 654 | """ |
| 655 | |
| 656 | def _wrapped(*args, **kwargs): |
| 657 | import kernels |
| 658 | with _kernels_patch_scope(): |
| 659 | return getattr(kernels, attr_name)(*args, **kwargs) |
| 660 | |
| 661 | _wrapped.__name__ = _wrapped.__qualname__ = attr_name |
| 662 | return _wrapped |
| 663 | |
| 664 | |
| 665 | def _patch_hub(): |
no outgoing calls
no test coverage detected
searching dependent graphs…