Skip to content

Commit

Permalink
Fix: Set directory and filename in Model base class
Browse files Browse the repository at this point in the history
The directory and filename of a model is determined by the
respective model implementation, e.g. Ollama or Huggingface.
If, however, these two fields are not defined in the model
base class, then accessing them for a specific model instance
might fail since these do not exist.

Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Feb 10, 2025
1 parent f88e703 commit 98aead8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions ramalama/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ def __init__(self, model):
model = model.removeprefix("hf.co/")
super().__init__(model)
self.type = "huggingface"
split = self.model.rsplit("/", 1)
self.directory = split[0] if len(split) > 1 else ""
self.filename = split[1] if len(split) > 1 else split[0]
self.hf_cli_available = is_huggingface_cli_available()

def login(self, args):
Expand Down
3 changes: 3 additions & 0 deletions ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Model:

def __init__(self, model):
self.model = model
split = self.model.rsplit("/", 1)
self.directory = split[0] if len(split) > 1 else ""
self.filename = split[1] if len(split) > 1 else split[0]

def login(self, args):
raise NotImplementedError(f"ramalama login for {self.type} not implemented")
Expand Down
1 change: 0 additions & 1 deletion ramalama/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def __init__(self, model):
super().__init__(model)
split = self.model.rsplit("/", 1)
self.directory = split[0].removeprefix("/") if len(split) > 1 else ""
self.filename = split[1] if len(split) > 1 else split[0]

def pull(self, args):
model_path = self.model_path(args)
Expand Down

0 comments on commit 98aead8

Please sign in to comment.