Spaces:
Running on Zero
Running on Zero
Wait for the worker's own download thread instead of failing the first request.
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ HINT_DURATION = 30.0 # seconds of MusicGen hint audio generated for beat detec
|
|
| 45 |
MAX_RETRIES = 5 # beat-alignment retries before falling back to a fixed length (default: 5, per repo)
|
| 46 |
|
| 47 |
beat_checkpoint_path = None
|
| 48 |
-
beat_checkpoint_ready =
|
| 49 |
beat_checkpoint_error = None
|
| 50 |
|
| 51 |
musicgen = None
|
|
@@ -59,7 +59,7 @@ def download_beat_checkpoint():
|
|
| 59 |
start immediately. Read from the weights repository that Beat-This itself
|
| 60 |
reads, rather than from that Space's own files, so neither deployment
|
| 61 |
depends on the other's layout."""
|
| 62 |
-
global beat_checkpoint_path,
|
| 63 |
try:
|
| 64 |
beat_checkpoint_path = hf_hub_download(
|
| 65 |
repo_id="teamup-tech/Beat-This-weights",
|
|
@@ -71,7 +71,7 @@ def download_beat_checkpoint():
|
|
| 71 |
beat_checkpoint_error = str(e)
|
| 72 |
print(f"Beat checkpoint download error: {e}")
|
| 73 |
finally:
|
| 74 |
-
beat_checkpoint_ready
|
| 75 |
|
| 76 |
|
| 77 |
threading.Thread(target=download_beat_checkpoint, daemon=True).start()
|
|
@@ -173,7 +173,7 @@ def process_fn(description: str, min_length: float, max_length: float, seed: int
|
|
| 173 |
made inside an @spaces.GPU-decorated call, not from a background thread."""
|
| 174 |
global musicgen, loopgen, file2beats
|
| 175 |
|
| 176 |
-
if not beat_checkpoint_ready:
|
| 177 |
raise gr.Error("Beat-tracking checkpoint is still downloading, please try again shortly.")
|
| 178 |
if beat_checkpoint_error is not None:
|
| 179 |
raise gr.Error(f"Beat-tracking checkpoint failed to download: {beat_checkpoint_error}")
|
|
|
|
| 45 |
MAX_RETRIES = 5 # beat-alignment retries before falling back to a fixed length (default: 5, per repo)
|
| 46 |
|
| 47 |
beat_checkpoint_path = None
|
| 48 |
+
beat_checkpoint_ready = threading.Event()
|
| 49 |
beat_checkpoint_error = None
|
| 50 |
|
| 51 |
musicgen = None
|
|
|
|
| 59 |
start immediately. Read from the weights repository that Beat-This itself
|
| 60 |
reads, rather than from that Space's own files, so neither deployment
|
| 61 |
depends on the other's layout."""
|
| 62 |
+
global beat_checkpoint_path, beat_checkpoint_error
|
| 63 |
try:
|
| 64 |
beat_checkpoint_path = hf_hub_download(
|
| 65 |
repo_id="teamup-tech/Beat-This-weights",
|
|
|
|
| 71 |
beat_checkpoint_error = str(e)
|
| 72 |
print(f"Beat checkpoint download error: {e}")
|
| 73 |
finally:
|
| 74 |
+
beat_checkpoint_ready.set()
|
| 75 |
|
| 76 |
|
| 77 |
threading.Thread(target=download_beat_checkpoint, daemon=True).start()
|
|
|
|
| 173 |
made inside an @spaces.GPU-decorated call, not from a background thread."""
|
| 174 |
global musicgen, loopgen, file2beats
|
| 175 |
|
| 176 |
+
if not beat_checkpoint_ready.wait(timeout=90):
|
| 177 |
raise gr.Error("Beat-tracking checkpoint is still downloading, please try again shortly.")
|
| 178 |
if beat_checkpoint_error is not None:
|
| 179 |
raise gr.Error(f"Beat-tracking checkpoint failed to download: {beat_checkpoint_error}")
|