Download hf_utils.py from unitxt/data: direct link, hf CLI and curl.
- Browser
- Download file 640 Bytes
-
https://huggingface.co/datasets/unitxt/data/resolve/2aa918a61ba35a1eb6644cfa3b68f0763548af48/hf_utils.py
- Command line
-
hf download hf://datasets/unitxt/data@2aa918a61ba35a1eb6644cfa3b68f0763548af48/hf_utils.py
-
curl -L -o hf_utils.py https://huggingface.co/datasets/unitxt/data/resolve/2aa918a61ba35a1eb6644cfa3b68f0763548af48/hf_utils.py
640 Bytes
| from pathlib import Path | |
| from datasets.utils.py_utils import get_imports | |
| from .file_utils import get_all_files_in_dir | |
| def get_missing_imports(file, exclude=None): | |
| if exclude is None: | |
| exclude = [] | |
| src_dir = Path(__file__).parent | |
| python_files = get_all_files_in_dir(src_dir, file_extension=".py") | |
| # get only the file without the path and extension | |
| required_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"] | |
| return [ | |
| i for i in required_modules if i not in imported_modules and i not in exclude | |
| ] | |