Skip to content

Commit e6f5cf5

Browse files
mangod12claude
andcommitted
fix: add GCS_MODEL_BUCKET to Settings + google-cloud-storage dependency
- Add GCS_MODEL_BUCKET field to Settings (pydantic-settings was dropping it with extra="ignore") - Use settings.GCS_MODEL_BUCKET directly instead of getattr - Add google-cloud-storage to requirements.txt for Cloud Run model download Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4233974 commit e6f5cf5

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

backend/app/core/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def emotion_onnx_effective_path(self) -> str:
8888
int8 = Path(self.EMOTION_ONNX_INT8_PATH)
8989
return str(int8) if int8.exists() else self.EMOTION_ONNX_PATH
9090

91+
# ---- GCS model download (Cloud Run) ------------------------------------
92+
GCS_MODEL_BUCKET: str = ""
93+
9194
# ---- Whisper STT (local, no paid API) ---------------------------------
9295
# Model size: tiny | base | small | medium | large
9396
# "small" balances accuracy + speed on CPU. Override via WHISPER_MODEL_SIZE env.

backend/app/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ async def lifespan(app: FastAPI):
9292
log.warning("Database init failed — tables may already exist or DB not ready", error=str(exc))
9393

9494
# 3b. Download ML models from GCS if available (Cloud Run)
95-
gcs_bucket = getattr(settings, "GCS_MODEL_BUCKET", "")
96-
if gcs_bucket:
95+
if settings.GCS_MODEL_BUCKET:
9796
from app.core.model_downloader import download_models_from_gcs
9897
model_paths = await asyncio.get_running_loop().run_in_executor(
99-
None, download_models_from_gcs, gcs_bucket
98+
None, download_models_from_gcs, settings.GCS_MODEL_BUCKET
10099
)
101100
# Override config paths with downloaded models
102101
if "intent_model.onnx" in model_paths:

backend/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ twilio>=9.0.0,<10.0
5050
jinja2>=3.1.0,<4.0
5151
aiofiles>=23.0.0,<24.0
5252

53+
# ---- Cloud (GCS model download for Cloud Run) ----------------------------
54+
google-cloud-storage>=2.14.0,<3.0
55+
5356
# ---- HTTP clients -------------------------------------------------------
5457
httpx>=0.25.2,<1.0
5558

0 commit comments

Comments
 (0)