# SPDX-License-Identifier: Apache-2.0 """Production entry point. Eager V22 boot, supported native Gradio Workflow.""" from __future__ import annotations import os from pathlib import Path ROOT = Path(os.environ.get("APP_DATA_ROOT", "/tmp/viggle-mine-workflow")) ROOT.mkdir(parents=True, exist_ok=True) os.environ.setdefault("APP_DATA_ROOT", str(ROOT)) os.environ.setdefault("GRADIO_TEMP_DIR", str(ROOT / "gradio-cache")) import spaces # MUST precede every import that can initialize CUDA. import gradio as gr import v22_core as core # Eager backend boot on CPU BEFORE ZeroGPU worker fork. from backend import batch_gpu_budget from workflow_execution import install from workflow_ui import create_workflow install(core, batch_gpu_budget) demo, server_app = create_workflow(core, register_gpu=True) if __name__ == "__main__": print(f"[viggle-v22-workflow] Gradio={gr.__version__}; V22 backend eagerly initialized", flush=True) demo.queue(default_concurrency_limit=1).launch( server_name="0.0.0.0", server_port=int(os.environ.get("PORT", "7860")), ssr_mode=False, share=False, inbrowser=False, show_error=True, allowed_paths=[str(ROOT / "outputs")], _app=server_app, css=Path(__file__).with_name("workflow.css").read_text())