@@ -442,6 +442,7 @@ echo "▸ Step $STEP/$TOTAL_STEPS: Redeploying app with freshest code..."
442442echo " Patching app.yaml on workspace with GSO config..."
443443PATCHED_APP_YAML=" /tmp/app.yaml.patched"
444444cp " $PROJECT_DIR /app.yaml" " $PATCHED_APP_YAML "
445+ sed -i.bak " s|__WAREHOUSE_ID__|$WAREHOUSE_ID |" " $PATCHED_APP_YAML "
445446sed -i.bak " s|__GSO_CATALOG__|$CATALOG |" " $PATCHED_APP_YAML "
446447sed -i.bak " s|__LAKEBASE_INSTANCE__|$LAKEBASE_INSTANCE |" " $PATCHED_APP_YAML "
447448sed -i.bak " s|__LLM_MODEL__|$LLM_MODEL |" " $PATCHED_APP_YAML "
461462
462463databricks workspace import " $WS_PATH /app.yaml" \
463464 --profile " $PROFILE " --file " $PATCHED_APP_YAML " --format AUTO --overwrite 2> /dev/null && \
464- echo " ✓ app.yaml patched (GSO_CATALOG=$CATALOG , GSO_JOB_ID=${JOB_ID:- <none>} , LAKEBASE_INSTANCE=$LAKEBASE_INSTANCE , LLM_MODEL=$LLM_MODEL , MLFLOW=${MLFLOW_EXPERIMENT_ID:- <disabled>} )" || \
465+ echo " ✓ app.yaml patched (WAREHOUSE= $WAREHOUSE_ID , GSO_CATALOG=$CATALOG , GSO_JOB_ID=${JOB_ID:- <none>} , LAKEBASE_INSTANCE=$LAKEBASE_INSTANCE , LLM_MODEL=$LLM_MODEL , MLFLOW=${MLFLOW_EXPERIMENT_ID:- <disabled>} )" || \
465466echo " ⚠ Could not patch app.yaml — config may not be set"
466467
467468# Sync _metadata.py — required at runtime for the genie_space_optimizer
@@ -550,17 +551,20 @@ except Exception: pass
550551 fi
551552fi
552553
553- # ── Set app scopes + resources, then deploy ──────────────────────────────
554- # Merge existing resources (e.g. manually-added Lakebase) with required ones.
554+ # ── Configure app scopes and resources ───────────────────────────────────
555+ # The PATCH API is the mechanism that configures both user_api_scopes and
556+ # resources on a Databricks App. app.yaml user_api_scopes are documentation
557+ # only; apps deploy does not apply them.
555558echo " Configuring app scopes and resources..."
556559EXISTING_RESOURCES=$( databricks apps get " $APP_NAME " --profile " $PROFILE " -o json 2> /dev/null \
557560 | python3 -c " import sys,json; print(json.dumps(json.load(sys.stdin).get('resources',[])))" 2> /dev/null || echo " []" )
558561
559562PATCH_PAYLOAD=$( python3 -c "
560563import json
564+
561565scopes = ['sql', 'dashboards.genie', 'serving.serving-endpoints',
562- 'catalog.catalogs:read', 'catalog.schemas:read',
563- 'catalog.tables:read', 'files.files']
566+ 'catalog.catalogs:read', 'catalog.schemas:read',
567+ 'catalog.tables:read', 'files.files']
564568
565569# Start with existing resources. The PATCH API replaces all resources,
566570# so we must include everything. Preserve all resources that either have
@@ -596,7 +600,7 @@ print(json.dumps({'user_api_scopes': scopes, 'resources': list(by_name.values())
596600" )
597601databricks api patch " /api/2.0/apps/$APP_NAME " \
598602 --profile " $PROFILE " --json " $PATCH_PAYLOAD " 2> /dev/null && \
599- echo " ✓ App scopes and resources configured" || \
603+ echo " ✓ App scopes and resources configured (sql-warehouse: $WAREHOUSE_ID ) " || \
600604 echo " ⚠ Could not configure app scopes/resources"
601605
602606databricks apps deploy " $APP_NAME " --profile " $PROFILE " \
0 commit comments