@@ -187,6 +187,8 @@ def _prepare_new_snapshot(self, model_tag: str, snapshot_hash: str, snapshot_fil
187
187
188
188
def _download_snapshot_files (self , model_tag : str , snapshot_hash : str , snapshot_files : Sequence [SnapshotFile ]):
189
189
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." )
190
192
191
193
for file in snapshot_files :
192
194
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_
197
199
if file .required :
198
200
raise ex
199
201
# 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 :
201
203
ref_file .remove_file (file .hash )
202
204
continue
203
205
@@ -217,8 +219,7 @@ def _download_snapshot_files(self, model_tag: str, snapshot_hash: str, snapshot_
217
219
os .symlink (blob_relative_path , link_path )
218
220
219
221
# save updated ref file
220
- if ref_file :
221
- ref_file .write_to_file ()
222
+ ref_file .write_to_file ()
222
223
223
224
def _ensure_chat_template (self , model_tag : str , snapshot_hash : str , snapshot_files : list [SnapshotFile ]):
224
225
model_file : SnapshotFile | None = None
0 commit comments