macayaven commited on
Commit
c1bb73f
·
verified ·
1 Parent(s): 9f02b70

Deploy relay entrypoint

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -31,22 +31,30 @@ warnings.filterwarnings(
31
  ON_SPACE = bool(os.environ.get("SPACE_ID"))
32
  ENGINE_MODE = bool(os.environ.get("SMALL_CUTS_ENGINE_URL", "").strip())
33
 
 
 
 
 
 
34
  try:
35
  import spaces # noqa: F401 (must precede torch imports for ZeroGPU)
36
  except ImportError: # local dev / CI: no ZeroGPU
37
  spaces = None
38
 
39
- if ON_SPACE and not ENGINE_MODE:
40
  os.environ.setdefault("SMALL_CUTS_BACKEND", "transformers")
41
  os.environ.setdefault("SMALL_CUTS_TTS_BACKEND", "kokoro")
42
 
43
  from small_cuts import narrator # noqa: E402
 
44
  from small_cuts.viewer import THEME, build_viewer_app # noqa: E402
45
 
 
 
46
  # Eager load: download + pack weights at startup, not on the first click.
47
  # The @spaces.GPU mark lives on the viewer's go-live handler (via ui._gpu;
48
  # ZeroGPU's startup scan only finds GPU functions on what Gradio binds).
49
- if not ENGINE_MODE:
50
  _backend = narrator.get_backend()
51
  if spaces is not None and _backend.name == "transformers":
52
  _backend._load()
 
31
  ON_SPACE = bool(os.environ.get("SPACE_ID"))
32
  ENGINE_MODE = bool(os.environ.get("SMALL_CUTS_ENGINE_URL", "").strip())
33
 
34
+ from small_cuts.hf_relay import RELAY_BUCKET_ENV # noqa: E402
35
+
36
+ RELAY_MODE = bool(os.environ.get(RELAY_BUCKET_ENV, "").strip())
37
+ VIEWER_ONLY_MODE = ENGINE_MODE or RELAY_MODE
38
+
39
  try:
40
  import spaces # noqa: F401 (must precede torch imports for ZeroGPU)
41
  except ImportError: # local dev / CI: no ZeroGPU
42
  spaces = None
43
 
44
+ if ON_SPACE and not VIEWER_ONLY_MODE:
45
  os.environ.setdefault("SMALL_CUTS_BACKEND", "transformers")
46
  os.environ.setdefault("SMALL_CUTS_TTS_BACKEND", "kokoro")
47
 
48
  from small_cuts import narrator # noqa: E402
49
+ from small_cuts.observability import init_sentry # noqa: E402
50
  from small_cuts.viewer import THEME, build_viewer_app # noqa: E402
51
 
52
+ init_sentry()
53
+
54
  # Eager load: download + pack weights at startup, not on the first click.
55
  # The @spaces.GPU mark lives on the viewer's go-live handler (via ui._gpu;
56
  # ZeroGPU's startup scan only finds GPU functions on what Gradio binds).
57
+ if not VIEWER_ONLY_MODE:
58
  _backend = narrator.get_backend()
59
  if spaces is not None and _backend.name == "transformers":
60
  _backend._load()