Upload data.py with huggingface_hub
Browse files
data.py
CHANGED
@@ -65,10 +65,15 @@ from .text_utils import __file__ as _
|
|
65 |
#############
|
66 |
|
67 |
from .register import register_blocks
|
68 |
-
from .artifact import Artifact
|
69 |
|
70 |
import datasets
|
71 |
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
def parse(query: str):
|
74 |
"""
|
@@ -97,11 +102,13 @@ class Dataset(datasets.GeneratorBasedBuilder):
|
|
97 |
def generators(self):
|
98 |
register_blocks()
|
99 |
if not hasattr(self, "_generators") or self._generators is None:
|
100 |
-
|
101 |
-
if
|
102 |
-
args
|
103 |
-
|
104 |
-
|
|
|
|
|
105 |
return self._generators
|
106 |
|
107 |
def _info(self):
|
|
|
65 |
#############
|
66 |
|
67 |
from .register import register_blocks
|
68 |
+
from .artifact import Artifact, fetch_artifact, UnitxtArtifactNotFoundError
|
69 |
|
70 |
import datasets
|
71 |
|
72 |
+
def fetch(artifact_name):
|
73 |
+
try:
|
74 |
+
return fetch_artifact(artifact_name)
|
75 |
+
except UnitxtArtifactNotFoundError:
|
76 |
+
return None
|
77 |
|
78 |
def parse(query: str):
|
79 |
"""
|
|
|
102 |
def generators(self):
|
103 |
register_blocks()
|
104 |
if not hasattr(self, "_generators") or self._generators is None:
|
105 |
+
recipe = fetch(self.config.name)
|
106 |
+
if recipe is None:
|
107 |
+
args = parse(self.config.name)
|
108 |
+
if "type" not in args:
|
109 |
+
args["type"] = "common_recipe"
|
110 |
+
recipe = Artifact.from_dict(args)
|
111 |
+
self._generators = recipe()
|
112 |
return self._generators
|
113 |
|
114 |
def _info(self):
|