"""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()