techfreakworm commited on
Commit
851d183
·
unverified ·
1 Parent(s): f118cd9

chore(debug): add startup phase prints to diagnose hf spaces hang

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -40,6 +40,8 @@ from __future__ import annotations
40
 
41
  import os
42
 
 
 
43
  # Set MPS fallback BEFORE any torch import path is taken.
44
  os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
45
 
@@ -58,6 +60,8 @@ _VENDORED_ACE_STEP = Path(__file__).resolve().parent / "vendor" / "ace-step"
58
  if _VENDORED_ACE_STEP.exists() and str(_VENDORED_ACE_STEP) not in sys.path:
59
  sys.path.insert(0, str(_VENDORED_ACE_STEP))
60
 
 
 
61
  import hashlib
62
  import random
63
  import shutil # noqa: F401 (reserved for future cleanup paths)
@@ -65,6 +69,8 @@ import subprocess
65
 
66
  import gradio as gr
67
 
 
 
68
  import ace_pipeline
69
  import backend as be
70
  import lora_stack
@@ -73,6 +79,8 @@ import post_process
73
  import theme
74
  import ui
75
 
 
 
76
  _BACKEND: be.ACEStepStudioBackend | None = None
77
 
78
 
@@ -293,8 +301,11 @@ def _maybe_spaces_gpu(mode: str):
293
 
294
  # Run cache bootstrap at module import so HF Spaces' startup analyzer sees
295
  # the symlinks before the lazy backend singleton is constructed on first click.
 
296
  _bootstrap_spaces_cache()
 
297
  _warm_demucs_on_spaces()
 
298
 
299
 
300
  def _safe_call(fn, *args, **kwargs):
@@ -991,6 +1002,12 @@ def build_app() -> gr.Blocks:
991
 
992
 
993
  if __name__ == "__main__":
 
994
  demo = build_app()
 
995
  demo.queue(default_concurrency_limit=1)
 
 
 
 
996
  demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
 
40
 
41
  import os
42
 
43
+ print("[ams] python process started", flush=True)
44
+
45
  # Set MPS fallback BEFORE any torch import path is taken.
46
  os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
47
 
 
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
67
  import shutil # noqa: F401 (reserved for future cleanup paths)
 
69
 
70
  import gradio as gr
71
 
72
+ print("[ams] gradio imported", flush=True)
73
+
74
  import ace_pipeline
75
  import backend as be
76
  import lora_stack
 
79
  import theme
80
  import ui
81
 
82
+ print("[ams] local modules imported", flush=True)
83
+
84
  _BACKEND: be.ACEStepStudioBackend | None = None
85
 
86
 
 
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
 
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)))