Skip to content

Commit

Permalink
Hotfix: huggingface loading
Browse files Browse the repository at this point in the history
  • Loading branch information
HCookie committed Dec 14, 2024
1 parent 3afa7ed commit 376b111
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/anemoi/inference/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Checkpoint:
"""Represents an inference checkpoint."""

def __init__(self, path, *, patch_metadata=None):
self.path = path
self._path = path
self.patch_metadata = patch_metadata

def __repr__(self):
Expand All @@ -59,17 +59,17 @@ def path(self):
import json

try:
self._model = json.loads(self._model)
except TypeError:
path = json.loads(self._path)
except Exception:
path = self._path

if isinstance(path, (Path, str)):
return path
elif isinstance(path, dict):
if "huggingface" in path:
return _download_huggingfacehub(path["huggingface"])
pass

if isinstance(self._model, str):
return self._model
elif isinstance(self._model, dict):
if "huggingface" in self._model:
return _download_huggingfacehub(self._model["huggingface"])
pass
raise TypeError(f"Cannot parse model path: {self._model}. It must be a path or dict")
raise TypeError(f"Cannot parse model path: {path}. It must be a path or dict")

@cached_property
def _metadata(self):
Expand Down

0 comments on commit 376b111

Please sign in to comment.