Download load.py from unitxt/data: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/datasets/unitxt/data/resolve/2bada9c99bc4e82ef94f5daec8c0cb73818aa382/load.py
- Command line
-
hf download hf://datasets/unitxt/data@2bada9c99bc4e82ef94f5daec8c0cb73818aa382/load.py
-
curl -L -o load.py https://huggingface.co/datasets/unitxt/data/resolve/2bada9c99bc4e82ef94f5daec8c0cb73818aa382/load.py
658 Bytes
| from .operator import StreamSource | |
| from datasets import DatasetDict | |
| from typing import Union | |
| from .catalog import LocalCatalog | |
| from .artifact import Artifact | |
| def load_stream(source_name_or_path: str) -> StreamSource: | |
| if Artifact.is_artifact_file(source_name_or_path): | |
| return Artifact.load(source_name_or_path) | |
| else: | |
| return LocalCatalog().load(source_name_or_path) | |
| def load_dataset(source: Union[StreamSource, str]) -> DatasetDict: | |
| assert isinstance(source, (StreamSource, str)), "source must be a StreamSource or a string" | |
| if isinstance(source, str): | |
| source = load_stream(source) | |
| return source().to_dataset() | |