Upload data.py with huggingface_hub
Browse files1234523 unmodified lines29303130323334359 unmodified lines454647484950515228 unmodified lines8182838485868788899091929394959697982 unmodified lines1011021038810490919293949596105106107108109110111112113114115116117118119120121122123124125import os
import datasets
from .artifact import Artifact, UnitxtArtifactNotFoundError23 unmodified linesfrom .random_utils import __file__ as _from .recipe import __file__ as _from .register import __file__ as _from .register import register_all_artifactsfrom .register import _reset_env_local_catalogs, register_all_artifactsfrom .renderers import __file__ as _from .schema import __file__ as _from .split_utils import __file__ as _9 unmodified linesfrom .version import __file__ as _from .version import version
__default_recipe__ = "common_recipe"
def fetch(artifact_name): try:28 unmodified lines return result
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"] = os.environ.get("UNITXT_DEFAULT_RECIPE", __default_recipe__) recipe = Artifact.from_dict(args) return recipe
class Dataset(datasets.GeneratorBasedBuilder): """TODO: Short description of my dataset."""
2 unmodified lines
@property def generators(self): register_all_artifacts() if not hasattr(self, "_generators") or self._generators is None: recipe = fetch(self.config.name) if recipe is None: args = parse(self.config.name) if "type" not in args: args["type"] = "common_recipe" recipe = Artifact.from_dict(args) self._generators = recipe() try: from unitxt.dataset import ( get_dataset_artifact as get_dataset_artifact_installed, )
unitxt_installed = True except ImportError: unitxt_installed = False
if unitxt_installed: print("Loading with installed unitxt library...") dataset = get_dataset_artifact_installed(self.config.name) else: print("Loading with installed unitxt library...") dataset = get_dataset_artifact(self.config.name)
self._generators = dataset()
return self._generators
def _info(self):data.py+35-9