Skip to content

Commit f9f6a78

Browse files
committed
Catch error on creating snapshot and log error
Relates to: #1663 Signed-off-by: Michael Engel <[email protected]>
1 parent 4e0b4c8 commit f9f6a78

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ramalama/model_store/store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ def new_snapshot(self, model_tag: str, snapshot_hash: str, snapshot_files: list[
306306
self.remove_snapshot(model_tag)
307307
raise ex
308308
except Exception as ex:
309-
perror(f"Failed to create new snapshot: {ex}")
310309
perror("Removing snapshot...")
311310
self.remove_snapshot(model_tag)
312311
raise ex

ramalama/ollama.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ def pull(self, args):
160160
self.print_pull_message(f"ollama://{name}:{tag}")
161161

162162
model_hash = ollama_repo.get_model_hash(manifest)
163-
self.model_store.new_snapshot(tag, model_hash, files)
163+
try:
164+
self.model_store.new_snapshot(tag, model_hash, files)
165+
except Exception as ex:
166+
perror(f"Failed to create snapshot for {name}:{tag} : {ex}")
164167

165168
# If a model has been downloaded via ollama cli, only create symlink in the snapshots directory
166169
if is_model_in_ollama_cache:

ramalama/url.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import shutil
33

4-
from ramalama.common import generate_sha256
4+
from ramalama.common import generate_sha256, perror
55
from ramalama.huggingface import HuggingfaceRepository
66
from ramalama.model import Model
77
from ramalama.model_store.snapshot_file import SnapshotFile, SnapshotFileType
@@ -105,6 +105,9 @@ def pull(self, args):
105105
)
106106
)
107107

108-
self.model_store.new_snapshot(tag, snapshot_hash, files)
108+
try:
109+
self.model_store.new_snapshot(tag, snapshot_hash, files)
110+
except Exception as ex:
111+
perror(f"Failed to create snapshot for {name}:{tag} : {ex}")
109112

110113
return self.model_store.get_snapshot_file_path(snapshot_hash, name)

0 commit comments

Comments
 (0)