Spaces:
Running on Zero
Running on Zero
chore(debug): write startup prints to stderr (hf logs stream stderr more reliably)
Browse files
app.py
CHANGED
|
@@ -40,7 +40,9 @@ from __future__ import annotations
|
|
| 40 |
|
| 41 |
import os
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# Set MPS fallback BEFORE any torch import path is taken.
|
| 46 |
os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
|
|
@@ -60,7 +62,7 @@ _VENDORED_ACE_STEP = Path(__file__).resolve().parent / "vendor" / "ace-step"
|
|
| 60 |
if _VENDORED_ACE_STEP.exists() and str(_VENDORED_ACE_STEP) not in sys.path:
|
| 61 |
sys.path.insert(0, str(_VENDORED_ACE_STEP))
|
| 62 |
|
| 63 |
-
print(f"[ams] sys.path patched (vendor exists: {_VENDORED_ACE_STEP.exists()})", flush=True)
|
| 64 |
|
| 65 |
import hashlib
|
| 66 |
import random
|
|
@@ -69,7 +71,7 @@ import subprocess
|
|
| 69 |
|
| 70 |
import gradio as gr
|
| 71 |
|
| 72 |
-
print("[ams] gradio imported", flush=True)
|
| 73 |
|
| 74 |
import ace_pipeline
|
| 75 |
import backend as be
|
|
@@ -79,7 +81,7 @@ import post_process
|
|
| 79 |
import theme
|
| 80 |
import ui
|
| 81 |
|
| 82 |
-
print("[ams] local modules imported", flush=True)
|
| 83 |
|
| 84 |
_BACKEND: be.ACEStepStudioBackend | None = None
|
| 85 |
|
|
@@ -180,7 +182,7 @@ def _warm_demucs_on_spaces() -> None:
|
|
| 180 |
get_model("htdemucs")
|
| 181 |
except Exception as e:
|
| 182 |
# Warmup is best-effort. Surface in the log but don't crash startup.
|
| 183 |
-
print(f"[warmup] demucs htdemucs preload skipped: {e}", flush=True)
|
| 184 |
|
| 185 |
|
| 186 |
_GPU_BASE_BY_MODE = {
|
|
@@ -301,11 +303,11 @@ def _maybe_spaces_gpu(mode: str):
|
|
| 301 |
|
| 302 |
# Run cache bootstrap at module import so HF Spaces' startup analyzer sees
|
| 303 |
# the symlinks before the lazy backend singleton is constructed on first click.
|
| 304 |
-
print("[ams] calling _bootstrap_spaces_cache", flush=True)
|
| 305 |
_bootstrap_spaces_cache()
|
| 306 |
-
print("[ams] bootstrap done, calling _warm_demucs_on_spaces", flush=True)
|
| 307 |
_warm_demucs_on_spaces()
|
| 308 |
-
print("[ams] warm done", flush=True)
|
| 309 |
|
| 310 |
|
| 311 |
def _safe_call(fn, *args, **kwargs):
|
|
@@ -1002,12 +1004,13 @@ def build_app() -> gr.Blocks:
|
|
| 1002 |
|
| 1003 |
|
| 1004 |
if __name__ == "__main__":
|
| 1005 |
-
print("[ams] building app", flush=True)
|
| 1006 |
demo = build_app()
|
| 1007 |
-
print("[ams] queueing", flush=True)
|
| 1008 |
demo.queue(default_concurrency_limit=1)
|
| 1009 |
print(
|
| 1010 |
f"[ams] launching on port {int(os.environ.get('PORT', 7860))}",
|
| 1011 |
flush=True,
|
|
|
|
| 1012 |
)
|
| 1013 |
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
|
|
|
|
| 40 |
|
| 41 |
import os
|
| 42 |
|
| 43 |
+
import sys as _sys
|
| 44 |
+
|
| 45 |
+
print("[ams] python process started", flush=True, file=_sys.stderr)
|
| 46 |
|
| 47 |
# Set MPS fallback BEFORE any torch import path is taken.
|
| 48 |
os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
|
|
|
|
| 62 |
if _VENDORED_ACE_STEP.exists() and str(_VENDORED_ACE_STEP) not in sys.path:
|
| 63 |
sys.path.insert(0, str(_VENDORED_ACE_STEP))
|
| 64 |
|
| 65 |
+
print(f"[ams] sys.path patched (vendor exists: {_VENDORED_ACE_STEP.exists()})", flush=True, file=_sys.stderr)
|
| 66 |
|
| 67 |
import hashlib
|
| 68 |
import random
|
|
|
|
| 71 |
|
| 72 |
import gradio as gr
|
| 73 |
|
| 74 |
+
print("[ams] gradio imported", flush=True, file=_sys.stderr)
|
| 75 |
|
| 76 |
import ace_pipeline
|
| 77 |
import backend as be
|
|
|
|
| 81 |
import theme
|
| 82 |
import ui
|
| 83 |
|
| 84 |
+
print("[ams] local modules imported", flush=True, file=_sys.stderr)
|
| 85 |
|
| 86 |
_BACKEND: be.ACEStepStudioBackend | None = None
|
| 87 |
|
|
|
|
| 182 |
get_model("htdemucs")
|
| 183 |
except Exception as e:
|
| 184 |
# Warmup is best-effort. Surface in the log but don't crash startup.
|
| 185 |
+
print(f"[warmup] demucs htdemucs preload skipped: {e}", flush=True, file=_sys.stderr)
|
| 186 |
|
| 187 |
|
| 188 |
_GPU_BASE_BY_MODE = {
|
|
|
|
| 303 |
|
| 304 |
# Run cache bootstrap at module import so HF Spaces' startup analyzer sees
|
| 305 |
# the symlinks before the lazy backend singleton is constructed on first click.
|
| 306 |
+
print("[ams] calling _bootstrap_spaces_cache", flush=True, file=_sys.stderr)
|
| 307 |
_bootstrap_spaces_cache()
|
| 308 |
+
print("[ams] bootstrap done, calling _warm_demucs_on_spaces", flush=True, file=_sys.stderr)
|
| 309 |
_warm_demucs_on_spaces()
|
| 310 |
+
print("[ams] warm done", flush=True, file=_sys.stderr)
|
| 311 |
|
| 312 |
|
| 313 |
def _safe_call(fn, *args, **kwargs):
|
|
|
|
| 1004 |
|
| 1005 |
|
| 1006 |
if __name__ == "__main__":
|
| 1007 |
+
print("[ams] building app", flush=True, file=_sys.stderr)
|
| 1008 |
demo = build_app()
|
| 1009 |
+
print("[ams] queueing", flush=True, file=_sys.stderr)
|
| 1010 |
demo.queue(default_concurrency_limit=1)
|
| 1011 |
print(
|
| 1012 |
f"[ams] launching on port {int(os.environ.get('PORT', 7860))}",
|
| 1013 |
flush=True,
|
| 1014 |
+
file=_sys.stderr,
|
| 1015 |
)
|
| 1016 |
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
|