Upload load.py with huggingface_hub
Browse files123456789101112131415161718192021from typing import Unionfrom datasets import DatasetDictfrom .artifact import Artifactfrom .catalog import LocalCatalogfrom .operator import StreamSourcedef 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()1234567891011from typing import Unionfrom datasets import DatasetDictfrom .artifact import fetch_artifactfrom .operator import StreamSourcedef load_dataset(source: Union[StreamSource, str]) -> DatasetDict:assert isinstance(source, (StreamSource, str)), "source must be a StreamSource or a string"if isinstance(source, str):artifact, _ = fetch_artifact(source)return artifact().to_dataset()
load.py+3-13