Skip to content

Commit 837effd

Browse files
committed
raise on snapshot download
Signed-off-by: Ian Eaves <[email protected]>
1 parent 1153c43 commit 837effd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ramalama/model_store/store.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def _prepare_new_snapshot(self, model_tag: str, snapshot_hash: str, snapshot_fil
187187

188188
def _download_snapshot_files(self, model_tag: str, snapshot_hash: str, snapshot_files: Sequence[SnapshotFile]):
189189
ref_file: None | RefJSONFile = self.get_ref_file(model_tag)
190+
if ref_file is None:
191+
raise ValueError("Cannot download snapshots without a valid ref file.")
190192

191193
for file in snapshot_files:
192194
dest_path = self.get_blob_file_path(file.hash)
@@ -197,7 +199,7 @@ def _download_snapshot_files(self, model_tag: str, snapshot_hash: str, snapshot_
197199
if file.required:
198200
raise ex
199201
# remove file from ref file list to prevent a retry to download it
200-
if ex.code == HTTPStatus.NOT_FOUND and ref_file:
202+
if ex.code == HTTPStatus.NOT_FOUND:
201203
ref_file.remove_file(file.hash)
202204
continue
203205

@@ -217,8 +219,7 @@ def _download_snapshot_files(self, model_tag: str, snapshot_hash: str, snapshot_
217219
os.symlink(blob_relative_path, link_path)
218220

219221
# save updated ref file
220-
if ref_file:
221-
ref_file.write_to_file()
222+
ref_file.write_to_file()
222223

223224
def _ensure_chat_template(self, model_tag: str, snapshot_hash: str, snapshot_files: list[SnapshotFile]):
224225
model_file: SnapshotFile | None = None

0 commit comments

Comments
 (0)