Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(video2scene): bind the storage client on first upload so a credentials hiccup cannot fail startup

nirholas86f6789f0e9a
diff --git a/workers/model-video2scene/README.md b/workers/model-video2scene/README.md
index 8e3f416bf..6cefd605f 100644
--- a/workers/model-video2scene/README.md
+++ b/workers/model-video2scene/README.md
@@ -110,6 +110,12 @@ docker run --rm -p 8080:8080 \
curl -s localhost:8080/health
```
+The Cloud Storage client binds on first upload, not at startup, so the service
+boots, loads the checkpoint and answers `/health` without credentials. Only the
+upload at the end of a job needs them: add
+`-v $HOME/.config/gcloud:/root/.config/gcloud:ro` after
+`gcloud auth application-default login` to finish a job locally.
+
## Deploy
Not currently deployed as its own Cloud Run service. Deploying it is one
diff --git a/workers/model-video2scene/main.py b/workers/model-video2scene/main.py
index 3c39e0bf8..8e069f8b2 100644
--- a/workers/model-video2scene/main.py
+++ b/workers/model-video2scene/main.py
@@ -237,10 +237,22 @@ def _weights_present() -> bool:
return os.path.isfile(os.path.join(WEIGHTS_DIR, MODEL_FILE))
+def _get_bucket() -> storage.Bucket:
+ """The output bucket, resolved on first use.
+
+ Binding it lazily keeps a credentials hiccup (or a local run with no ADC)
+ from taking the whole service down at startup: the model still loads, health
+ still answers, and only the upload at the end of a job needs the client.
+ """
+ global _bucket
+ if _bucket is None:
+ _bucket = storage.Client().bucket(GCS_BUCKET)
+ return _bucket
+
+
@asynccontextmanager
async def lifespan(app: FastAPI):
- global _bucket, _sem, _model_error
- _bucket = storage.Client().bucket(GCS_BUCKET)
+ global _sem, _model_error
_sem = asyncio.Semaphore(MAX_CONCURRENT)
loop = asyncio.get_event_loop()
try:
@@ -466,10 +478,9 @@ async def _run_inference(task_id: str, req: "InferRequest") -> None:
ply_bytes = result.pop("ply")
blob_name = f"scenes/video2scene/{task_id}.ply"
- blob = _bucket.blob(blob_name)
await loop.run_in_executor(
None,
- lambda: blob.upload_from_string(
+ lambda: _get_bucket().blob(blob_name).upload_from_string(
ply_bytes, content_type="application/octet-stream"
),
)