Spaces:
Running
Running
Download files beside their final path, then move them into place
Browse filesA download cut short left a partial file at the path whose existence skips the download, so every later start used it. See Model Weights in HARP's deployment guide.
- backend_worker.py +4 -1
backend_worker.py
CHANGED
|
@@ -69,7 +69,10 @@ def _ensure_model(model_name):
|
|
| 69 |
out = os.path.join(dest, fname)
|
| 70 |
if not os.path.exists(out):
|
| 71 |
url = f"https://storage.googleapis.com/{_GCS_BUCKET}/{urllib.parse.quote(obj, safe='')}"
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
if not os.path.exists(gin_file):
|
| 74 |
raise RuntimeError(f"Downloaded {model_name!r} but operative_config-0.gin is missing.")
|
| 75 |
return dest
|
|
|
|
| 69 |
out = os.path.join(dest, fname)
|
| 70 |
if not os.path.exists(out):
|
| 71 |
url = f"https://storage.googleapis.com/{_GCS_BUCKET}/{urllib.parse.quote(obj, safe='')}"
|
| 72 |
+
# Fetched beside its final path and moved there once complete, so that a download
|
| 73 |
+
# cut short cannot leave a file the check above would take for the checkpoint
|
| 74 |
+
urllib.request.urlretrieve(url, out + ".part")
|
| 75 |
+
os.replace(out + ".part", out)
|
| 76 |
if not os.path.exists(gin_file):
|
| 77 |
raise RuntimeError(f"Downloaded {model_name!r} but operative_config-0.gin is missing.")
|
| 78 |
return dest
|