Elron commited on
Commit
63ba8ae
1 Parent(s): c3950db

Upload artifact.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. artifact.py +7 -5
artifact.py CHANGED
@@ -215,11 +215,13 @@ class Artifact(Dataclass):
215
 
216
  @classmethod
217
  def load(cls, path):
218
- with open(path, "r") as f:
219
- d = json.load(f)
220
-
221
- assert "type" in d, "Saved artifact must have a type field"
222
- return cls._recursive_load(d)
 
 
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