File size: 1,464 Bytes
a960e15
f822421
6bacf18
f822421
e3ebc72
 
f822421
4e3cac9
f822421
6bacf18
e3ebc72
 
 
6bacf18
e3ebc72
a960e15
28febab
f822421
 
a960e15
f822421
 
 
6bacf18
 
4e3cac9
 
 
 
a960e15
4e3cac9
 
 
a960e15
 
 
8c9985e
f822421
8c9985e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Space entry point: assembly only. The layout and the turn live in japanese_avatar.ui.blocks."""

import logging
import os
import sys
from pathlib import Path

import spaces

# The Space never pip-installs this repo, so the src/ layout is not on sys.path there.
_SRC = Path(__file__).resolve().parent / "src"
if str(_SRC) not in sys.path:
    sys.path.insert(0, str(_SRC))
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(name)s: %(message)s")

from japanese_avatar.ui.blocks import build_blocks  # noqa: E402


def gpu_disabled() -> bool:
    """SC-4's kill switch, read per call so a restart with the variable flipped takes effect."""
    return os.environ.get("DISABLE_GPU", "0").strip().lower() in {"1", "true", "yes"}


# ZeroGPU refuses to run a Space with no @spaces.GPU function (docs/HOSTING.md). This probe only
# satisfies that scan: nothing calls it, and tests/test_no_gpu_on_turn_path.py proves both.
@spaces.GPU(duration=1)
def zerogpu_probe() -> str:
    """The GPU entry point ZeroGPU requires to exist. Deliberately unreachable in Phase 1."""
    if gpu_disabled():
        raise RuntimeError("zerogpu_probe called with DISABLE_GPU=1; Phase 1 has no GPU work")
    return "zerogpu reachable"


# Module level and named `demo`: the Space runner looks it up by that name (docs/HOSTING.md).
# It is the app itself, not shared state; nothing mutates it per session.
demo = build_blocks()

if __name__ == "__main__":
    demo.launch()