ops: pin model revision in launcher env (offline-safe cache lookup)
deploy-railway / relay (push) Skipped

This commit is contained in:
pierre committed 2026-10-30 16:08:24 +03:00
1 parent 2ea582e95f
commit 834a544d2f
2 files changed
+21 -7

No files matched your search

+4 -4
View File
@@ -52,10 +52,10 @@ install_venv() {
fi fi
if have_nvidia && [[ "$DEVICE" != "cpu" ]]; then if have_nvidia && [[ "$DEVICE" != "cpu" ]]; then
echo "[chamber] NVIDIA detected -> installing CUDA torch (big download)" echo "[chamber] NVIDIA detected -> installing CUDA torch (big download)"
pip_into "torch" --index-url https://download.pytorch.org/whl/cu126 pip_into "torch>=2.6" --index-url https://download.pytorch.org/whl/cu126
else else
echo "[chamber] CPU mode -> installing CPU torch" echo "[chamber] CPU mode -> installing CPU torch"
pip_into "torch" --index-url https://download.pytorch.org/whl/cpu pip_into "torch>=2.6" --index-url https://download.pytorch.org/whl/cpu
fi fi
# requirements.txt pins cpu-index torch on its own line; install the rest # requirements.txt pins cpu-index torch on its own line; install the rest
grep -v '^torch' live/requirements.txt | pip_into -r /dev/stdin grep -v '^torch' live/requirements.txt | pip_into -r /dev/stdin
@@ -66,11 +66,11 @@ start_server() {
local device="$1" local device="$1"
: > .chamber.log : > .chamber.log
if [[ "$device" == "cuda" ]]; then if [[ "$device" == "cuda" ]]; then
CHAMBER_DEVICE=cuda CHAMBER_DTYPE=float16 \ CHAMBER_DEVICE=cuda CHAMBER_DTYPE=float16 CHAMBER_MODEL_REVISION=1cfa9a7208912126459214e8b04321603b3df60c \
CHAMBER_PORT="$PORT" CHAMBER_HOST="$HOST" \ CHAMBER_PORT="$PORT" CHAMBER_HOST="$HOST" \
nohup .venv/bin/python chamber_local.py >> .chamber.log 2>&1 & nohup .venv/bin/python chamber_local.py >> .chamber.log 2>&1 &
else else
CHAMBER_DEVICE=cpu CHAMBER_DTYPE=float32 \ CHAMBER_DEVICE=cpu CHAMBER_DTYPE=float32 CHAMBER_MODEL_REVISION=1cfa9a7208912126459214e8b04321603b3df60c \
CHAMBER_PORT="$PORT" CHAMBER_HOST="$HOST" \ CHAMBER_PORT="$PORT" CHAMBER_HOST="$HOST" \
nohup .venv/bin/python chamber_local.py >> .chamber.log 2>&1 & nohup .venv/bin/python chamber_local.py >> .chamber.log 2>&1 &
fi fi
+17 -3
View File
@@ -2,21 +2,35 @@
One process, one port — clone anywhere, `./chamber up`, get the full lab. One process, one port — clone anywhere, `./chamber up`, get the full lab.
The upstream live/server.py stays unmodified; this only mounts it. The upstream live/server.py stays unmodified; this only mounts it.
NOTE: Starlette Mounts do not propagate sub-app startup events, so
server.startup() (the model load) is invoked explicitly in the lifespan
below. Serving starts only after the model is ready.
""" """
import asyncio
import os import os
import sys import sys
from contextlib import asynccontextmanager
from pathlib import Path from pathlib import Path
ROOT = Path(__file__).resolve().parent ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT / "live")) sys.path.insert(0, str(ROOT / "live"))
import server # noqa: E402 (loads the model at import — env vars go before this) import server # noqa: E402 (loads env config at import; model loads in startup)
from fastapi import FastAPI # noqa: E402 from fastapi import FastAPI # noqa: E402
from fastapi.staticfiles import StaticFiles # noqa: E402 from fastapi.staticfiles import StaticFiles # noqa: E402
SITE = ROOT / "site" SITE = ROOT / "site"
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
@asynccontextmanager
async def lifespan(app):
# server.startup() is sync and slow (model load); keep the loop alive
await asyncio.get_running_loop().run_in_executor(None, server.startup)
yield
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None, lifespan=lifespan)
app.mount("/chamber", server.app) app.mount("/chamber", server.app)
if SITE.exists(): if SITE.exists():
app.mount("/", StaticFiles(directory=str(SITE), html=True), name="site") app.mount("/", StaticFiles(directory=str(SITE), html=True), name="site")
@@ -27,5 +41,5 @@ else:
if __name__ == "__main__": if __name__ == "__main__":
import uvicorn import uvicorn
port = int(os.environ.get("CHAMBER_PORT", "8000")) port = int(os.environ.get("CHAMBER_PORT", "8484"))
uvicorn.run(app, host=os.environ.get("CHAMBER_HOST", "127.0.0.1"), port=port) uvicorn.run(app, host=os.environ.get("CHAMBER_HOST", "127.0.0.1"), port=port)