Upload artifact.py with huggingface_hub
Browse files- artifact.py +7 -5
artifact.py
CHANGED
@@ -215,11 +215,13 @@ class Artifact(Dataclass):
|
|
215 |
|
216 |
@classmethod
|
217 |
def load(cls, path):
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
223 |
|
224 |
def prepare(self):
|
225 |
pass
|
|
|
215 |
|
216 |
@classmethod
|
217 |
def load(cls, path):
|
218 |
+
try:
|
219 |
+
with open(path, "r") as f:
|
220 |
+
d = json.load(f)
|
221 |
+
assert "type" in d, "Saved artifact must have a type field"
|
222 |
+
return cls._recursive_load(d)
|
223 |
+
except Exception as e:
|
224 |
+
raise IOError(f"Failed loading {cls.type} from {path}")
|
225 |
|
226 |
def prepare(self):
|
227 |
pass
|