Download dataset_utils.py from unitxt/data: direct link, hf CLI and curl.
- Browser
- Download file 928 Bytes
-
https://huggingface.co/datasets/unitxt/data/resolve/2aa918a61ba35a1eb6644cfa3b68f0763548af48/dataset_utils.py
- Command line
-
hf download hf://datasets/unitxt/data@2aa918a61ba35a1eb6644cfa3b68f0763548af48/dataset_utils.py
-
curl -L -o dataset_utils.py https://huggingface.co/datasets/unitxt/data/resolve/2aa918a61ba35a1eb6644cfa3b68f0763548af48/dataset_utils.py
928 Bytes
| from .artifact import Artifact, UnitxtArtifactNotFoundError, fetch_artifact | |
| from .logging_utils import get_logger | |
| from .parsing_utils import parse_key_equals_value_string_to_dict | |
| from .register import _reset_env_local_catalogs, register_all_artifacts | |
| from .settings_utils import get_settings | |
| logger = get_logger() | |
| settings = get_settings() | |
| def fetch(artifact_name): | |
| try: | |
| artifact, _ = fetch_artifact(artifact_name) | |
| return artifact | |
| except UnitxtArtifactNotFoundError: | |
| return None | |
| def parse(query: str): | |
| return parse_key_equals_value_string_to_dict(query) | |
| def get_dataset_artifact(dataset_str): | |
| _reset_env_local_catalogs() | |
| register_all_artifacts() | |
| recipe = fetch(dataset_str) | |
| if recipe is None: | |
| args = parse(dataset_str) | |
| if "type" not in args: | |
| args["type"] = settings.default_recipe | |
| recipe = Artifact.from_dict(args) | |
| return recipe | |