Download scripts/deploy_env_modal.py from StarAtNyte1/beam-boot: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/scripts/deploy_env_modal.py
- Command line
-
hf download hf://StarAtNyte1/beam-boot/scripts/deploy_env_modal.py
-
curl -L -o deploy_env_modal.py https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/scripts/deploy_env_modal.py
1.35 kB
| """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) | |
| 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 | |