From 98aead8c40b1433d03410d925105d5cdecf092a2 Mon Sep 17 00:00:00 2001 From: Michael Engel Date: Mon, 10 Feb 2025 09:56:25 +0100 Subject: [PATCH] Fix: Set directory and filename in Model base class 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 --- ramalama/huggingface.py | 3 --- ramalama/model.py | 3 +++ ramalama/url.py | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ramalama/huggingface.py b/ramalama/huggingface.py index 675c76f4..cdc21348 100644 --- a/ramalama/huggingface.py +++ b/ramalama/huggingface.py @@ -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): diff --git a/ramalama/model.py b/ramalama/model.py index e1d8f102..4fd2ad21 100644 --- a/ramalama/model.py +++ b/ramalama/model.py @@ -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") diff --git a/ramalama/url.py b/ramalama/url.py index 8e11dfe4..992dc074 100644 --- a/ramalama/url.py +++ b/ramalama/url.py @@ -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)