Apply `_patch_kernels` for the duration of the `with` block, unless an outer patch (e.g. `patch_hub()`) is already in effect.
()
| 632 | |
| 633 | @contextlib.contextmanager |
| 634 | def _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 | |
| 649 | def _wrap_kernels_callable(attr_name): |
no test coverage detected
searching dependent graphs…