"""Host the SUPERBEAM OpenEnv server (envs/superbeam_env) as a Modal web endpoint. A free alternative to a Docker Space (HF requires PRO for Docker Spaces on free hardware). Scales to zero when idle (min_containers=0), so it costs nothing while unused. python scripts/prepare_superbeam_env.py # bundle the game files into envs/superbeam_env/vendor modal deploy scripts/deploy_env_modal.py # prints the public URL Clients use that URL exactly like a Space URL (base_url=...), e.g. envs/superbeam_env/client.py. """ from pathlib import Path import modal ENV_DIR = Path(__file__).resolve().parent.parent / "envs" / "superbeam_env" image = ( modal.Image.debian_slim(python_version="3.12") .pip_install("openenv==0.11.0", "fastapi", "uvicorn[standard]", "websockets", "numpy", "pydantic") .env({"PYTHONPATH": "/app/env", "ENABLE_WEB_INTERFACE": "true", "SUPERBEAM_LEVEL": "classic"}) .add_local_dir(str(ENV_DIR), "/app/env", ignore=["__pycache__", "*.pyc", ".venv*"]) ) app = modal.App("superbeam-env", image=image) @app.function(min_containers=0, scaledown_window=300, timeout=3600) @modal.concurrent(max_inputs=16) @modal.asgi_app() def web(): import os import sys os.chdir("/app/env") sys.path.insert(0, "/app/env") from server.app import app as fastapi_app return fastapi_app