Skip to content

Commit ca5daf9

Browse files
committed
fix(ops): default core GCP env on Cloud Run deploy
CI and minimal shell envs omitted GOOGLE_CLOUD_PROJECT and BQ pins, so the runtime BigQuery tool had no compute project; always set project, Vertex, and dataset when deploying.
1 parent 0d3663c commit ca5daf9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

backend/deployment/deploy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,15 @@ def _commands() -> list[list[str]]:
117117

118118
# repo root holds the Dockerfile + .gcloudignore; --source . builds it via Cloud Build.
119119
repo_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
120-
env_pairs = [f"{k}={os.environ[k]}" for k in _RUNTIME_ENV_KEYS if os.environ.get(k)]
120+
# Always pin project/Vertex/BQ dataset when PROJECT is set — CI deploy often omits these in the shell env,
121+
# which leaves settings.project empty and BigQueryToolset fails with "project not found".
122+
runtime: dict[str, str] = {k: os.environ[k] for k in _RUNTIME_ENV_KEYS if os.environ.get(k)}
123+
if PROJECT:
124+
runtime.setdefault("GOOGLE_CLOUD_PROJECT", PROJECT)
125+
runtime.setdefault("GOOGLE_CLOUD_LOCATION", REGION)
126+
runtime.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "true")
127+
runtime.setdefault("BQ_DATASET", "dry_lab")
128+
env_pairs = [f"{k}={runtime[k]}" for k in _RUNTIME_ENV_KEYS if k in runtime]
121129
secret_pairs = [f"{env}={name}:latest" for env, name in _SECRET_REFS.items()]
122130
deploy = [
123131
"gcloud", "run", "deploy", SERVICE,

0 commit comments

Comments
 (0)