Upload hf_utils.py with huggingface_hub
Browse files123456789101112131415 unmodified lines303132333435363738394041424344from datasets import (disable_caching,enable_caching,is_caching_enabled,)from pathlib import Pathfrom .file_utils import get_all_files_in_dirfrom datasets.utils.py_utils import get_importsHF_CACHING_ENABLED = Falseclass HFCachingContextManager:def __init__(self, should_cache):self.should_cache = should_cache15 unmodified lineselse:disable_caching()def set_hf_caching(enabled):return HFCachingContextManager(enabled)def get_missing_imports(file, exclude=[]):src_dir = Path(__file__).parentpython_files = get_all_files_in_dir(src_dir, file_extension='.py')# get only the file without the path and extensionrequired_modules = [Path(p).stem for p in python_files]imports = get_imports(file)imported_modules = [i[1] for i in imports if i[0] == 'internal']missing_imports = [i for i in required_modules if i not in imported_modules and i not in exclude]return missing_imports1234567891011121315 unmodified lines29303132333435363738394041from pathlib import Pathfrom datasets import disable_caching, enable_caching, is_caching_enabledfrom datasets.utils.py_utils import get_importsfrom .file_utils import get_all_files_in_dirHF_CACHING_ENABLED = Falseclass HFCachingContextManager:def __init__(self, should_cache):self.should_cache = should_cache15 unmodified lineselse:disable_caching()def get_missing_imports(file, exclude=[]):src_dir = Path(__file__).parentpython_files = get_all_files_in_dir(src_dir, file_extension=".py")# get only the file without the path and extensionrequired_modules = [Path(p).stem for p in python_files]imports = get_imports(file)imported_modules = [i[1] for i in imports if i[0] == "internal"]missing_imports = [i for i in required_modules if i not in imported_modules and i not in exclude]return missing_imports
hf_utils.py+8-11