Skip to content

Commit 2a94d57

Browse files
authored
Retry failed model downloads
1 parent 2679039 commit 2a94d57

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

core/download.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ def download_from_drive(model, custom_model, run_path):
3030
if not os.path.exists(os.path.join(run_path, "models")):
3131
os.mkdir(os.path.join(run_path, "models"))
3232
if not os.path.exists(os.path.join(run_path, "models", drive_id)):
33-
os.mkdir(os.path.join(run_path, "models", drive_id))
34-
zip_path = os.path.join(run_path, "models", drive_id, "model.zip")
33+
zip_path = os.path.join(run_path, "models", "model_temp.zip")
34+
if os.path.exists(zip_path):
35+
os.remove(zip_path)
3536
gdown.download(
3637
d + drive_id,
3738
zip_path,
@@ -44,6 +45,7 @@ def download_from_drive(model, custom_model, run_path):
4445
os.remove(zip_path)
4546
os.rmdir(os.path.join(run_path, "models", drive_id))
4647
return ("Model zip is empty", None, None)
48+
os.mkdir(os.path.join(run_path, "models", drive_id))
4749
with zipfile.ZipFile(zip_path, "r") as zip_ref:
4850
zip_ref.extractall(os.path.join(run_path, "models", drive_id))
4951
os.remove(zip_path)

0 commit comments

Comments
 (0)