Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ env:
- name: GSO_WAREHOUSE_ID
valueFrom: sql-warehouse

# ---------------------------------------------------------------------------
# Resources
# ---------------------------------------------------------------------------
resources:
- name: sql-warehouse
description: "SQL Warehouse for queries and catalog discovery"
sql_warehouse:
id: "__WAREHOUSE_ID__"
permission: CAN_USE

# ---------------------------------------------------------------------------
# Deployment
# ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# GENIE_APP_NAME (optional) Databricks App name [default: genie-workbench]
# GENIE_DEPLOY_PROFILE (optional) Databricks CLI profile [default: DEFAULT]
# GENIE_LLM_MODEL (optional) LLM serving endpoint [default: databricks-claude-sonnet-4-6]
# GENIE_LAKEBASE_INSTANCE (optional) Lakebase instance name [default: <app-name>]
# GENIE_LAKEBASE_INSTANCE (optional) Lakebase instance name [default: none]
# GENIE_MLFLOW_EXPERIMENT_ID (optional) MLflow experiment ID for agent tracing [default: disabled]
#
# After sourcing, the following variables are available:
Expand All @@ -36,7 +36,7 @@ GSO_SCHEMA="genie_space_optimizer" # Fixed default — matches GSO convention
WAREHOUSE_ID="${GENIE_WAREHOUSE_ID:-}"
PROFILE="${GENIE_DEPLOY_PROFILE:-DEFAULT}"
LLM_MODEL="${GENIE_LLM_MODEL:-databricks-claude-sonnet-4-6}"
LAKEBASE_INSTANCE="${GENIE_LAKEBASE_INSTANCE:-$APP_NAME}"
LAKEBASE_INSTANCE="${GENIE_LAKEBASE_INSTANCE:-}"
MLFLOW_EXPERIMENT_ID="${GENIE_MLFLOW_EXPERIMENT_ID:-}"

# ── Validate required values ─────────────────────────────────────────────
Expand Down
16 changes: 10 additions & 6 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ echo "▸ Step $STEP/$TOTAL_STEPS: Redeploying app with freshest code..."
echo " Patching app.yaml on workspace with GSO config..."
PATCHED_APP_YAML="/tmp/app.yaml.patched"
cp "$PROJECT_DIR/app.yaml" "$PATCHED_APP_YAML"
sed -i.bak "s|__WAREHOUSE_ID__|$WAREHOUSE_ID|" "$PATCHED_APP_YAML"
sed -i.bak "s|__GSO_CATALOG__|$CATALOG|" "$PATCHED_APP_YAML"
sed -i.bak "s|__LAKEBASE_INSTANCE__|$LAKEBASE_INSTANCE|" "$PATCHED_APP_YAML"
sed -i.bak "s|__LLM_MODEL__|$LLM_MODEL|" "$PATCHED_APP_YAML"
Expand All @@ -461,7 +462,7 @@ fi

databricks workspace import "$WS_PATH/app.yaml" \
--profile "$PROFILE" --file "$PATCHED_APP_YAML" --format AUTO --overwrite 2>/dev/null && \
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>})" || \
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>})" || \
echo " ⚠ Could not patch app.yaml — config may not be set"

# Sync _metadata.py — required at runtime for the genie_space_optimizer
Expand Down Expand Up @@ -550,17 +551,20 @@ except Exception: pass
fi
fi

# ── Set app scopes + resources, then deploy ──────────────────────────────
# Merge existing resources (e.g. manually-added Lakebase) with required ones.
# ── Configure app scopes and resources ───────────────────────────────────
# The PATCH API is the mechanism that configures both user_api_scopes and
# resources on a Databricks App. app.yaml user_api_scopes are documentation
# only; apps deploy does not apply them.
echo " Configuring app scopes and resources..."
EXISTING_RESOURCES=$(databricks apps get "$APP_NAME" --profile "$PROFILE" -o json 2>/dev/null \
| python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin).get('resources',[])))" 2>/dev/null || echo "[]")

PATCH_PAYLOAD=$(python3 -c "
import json

scopes = ['sql', 'dashboards.genie', 'serving.serving-endpoints',
'catalog.catalogs:read', 'catalog.schemas:read',
'catalog.tables:read', 'files.files']
'catalog.catalogs:read', 'catalog.schemas:read',
'catalog.tables:read', 'files.files']

# Start with existing resources. The PATCH API replaces all resources,
# so we must include everything. Preserve all resources that either have
Expand Down Expand Up @@ -596,7 +600,7 @@ print(json.dumps({'user_api_scopes': scopes, 'resources': list(by_name.values())
")
databricks api patch "/api/2.0/apps/$APP_NAME" \
--profile "$PROFILE" --json "$PATCH_PAYLOAD" 2>/dev/null && \
echo " ✓ App scopes and resources configured" || \
echo " ✓ App scopes and resources configured (sql-warehouse: $WAREHOUSE_ID)" || \
echo " ⚠ Could not configure app scopes/resources"

databricks apps deploy "$APP_NAME" --profile "$PROFILE" \
Expand Down
Loading