-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathdatabricks.yml
More file actions
239 lines (230 loc) · 10.5 KB
/
databricks.yml
File metadata and controls
239 lines (230 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# OntoBricks Dev Sandbox — Databricks Asset Bundle
#
# This bundle deploys two apps:
#
# - ``ontobricks_dev_app`` → app name ``ontobricks-030`` (FastAPI UI,
# ``source_code_path: .``). Uses the repository root as source.
# - ``mcp_ontobricks_app`` → app name ``mcp-ontobricks`` (FastMCP
# server, ``source_code_path: src/mcp-server``). Calls back to
# the main app over HTTP.
#
# The bundle is intentionally separate from any previous
# ``ontobricks_bundle`` deployment:
#
# - Distinct ``bundle.name`` (``ontobricks_dev_bundle``) so DAB
# state does not collide.
# - Distinct ``workspace.root_path`` so the sync directory and the
# ``.bundle/state/`` tracking files live under their own folder
# (``/Workspace/Users/<me>/.bundle/ontobricks-030/<target>``).
#
# When this bundle takes over an app that was previously deployed
# from a different bundle (e.g. ``ontobricks_bundle``), DAB requires
# a one-time bind step:
#
# databricks bundle deployment bind mcp_ontobricks_app mcp-ontobricks --auto-approve
#
# ``scripts/deploy.sh --bind`` does both binds in one go.
#
# Source code paths:
# - The main app is shipped from the repository root. The
# sandbox auto-detects its app name (``ontobricks-030``) from the
# Databricks-Apps-injected ``DATABRICKS_APP_NAME`` env var — see
# ``Settings.ontobricks_app_name`` for the alias-chain logic.
# - The MCP server is shipped from ``src/mcp-server`` (its own
# ``pyproject.toml`` + ``app.yaml`` + ``server/`` package live there).
#
# Usage:
# databricks bundle validate -t dev-lakebase # validate
# databricks bundle deploy -t dev-lakebase # deploy both apps + Lakebase binding
# databricks bundle run ontobricks_dev_app -t dev-lakebase # start the UI
# databricks bundle run mcp_ontobricks_app -t dev-lakebase # start the MCP server
# databricks bundle deploy -t dev # Volume-only fallback (no postgres)
bundle:
name: ontobricks_dev_bundle
workspace:
# Sandbox path — distinct from any other ``ontobricks*`` bundle so
# we cannot share/clobber sync state with the production apps.
root_path: /Workspace/Users/${workspace.current_user.userName}/.bundle/ontobricks-030/${bundle.target}
sync:
exclude:
- tests/
- data/
- .venv/
- .git/
- .cursor/
- .pytest_cache/
- htmlcov/
- logs/
- fastapi_session/
- mlruns/
- mlartifacts/
- "*.pid"
- "*.log"
- ".env"
- scripts/
- Makefile
- CHANGELOG.md
# Keep deploy payload minimal for sandbox runtime: no docs/ or markdown.
- docs/
- "*.md"
variables:
warehouse_id:
description: "SQL Warehouse ID for query execution"
default: "d2096aa075ad44a3"
registry_catalog:
description: "Unity Catalog catalog for the domain registry"
default: "benoit_cayla"
registry_schema:
description: "Unity Catalog schema for the domain registry"
default: "ontobricks_030"
registry_volume:
description: "Volume name for the domain registry"
default: "registry"
# ── Lakebase resource binding (Autoscaling-only) ────────────────
# OntoBricks targets **Lakebase Autoscaling** exclusively (the
# default tier for every instance created after 2026-03-12). The
# legacy Provisioned tier is no longer supported — the runtime
# auth code (``LakebaseAuth``) and the admin UI both assume an
# Autoscaling project resource.
#
# Autoscaling uses the Apps ``postgres: { branch, database }``
# binding where both fields are *full project-relative resource
# paths*. New instances created via ``databricks api create
# /database/instances`` show up as Autoscaling projects with a
# default branch named ``production`` (NOT ``main``).
#
# Override defaults for your Autoscaling project / branch / database.
# Example: ``-t dev-lakebase --var=lakebase_project=my-project``.
#
# The Apps ``postgres`` binding requires **full** branch and database
# resource paths. The bundle composes them as
# ``projects/<project>/branches/<branch>`` and
# ``…/databases/<lakebase_database_resource_segment>``.
#
# **Important:** The final segment must be the Lakebase **resource id**
# (``db-…``) from the API ``name`` field — **not** the Postgres
# ``datname`` / ``status.postgres_database`` string (e.g. you cannot use
# ``databricks_postgres`` or ``ontobricks_registry`` here even though
# those appear in the SQL UI). Resolve the id with::
#
# databricks postgres list-databases \
# "projects/<project>/branches/<branch>" -o json
#
# Pick the row whose ``status.postgres_database`` matches the database
# you want, then set ``lakebase_database_resource_segment`` to the
# substring after ``…/databases/`` in that row's ``name``.
#
# Caveat — **resource id** vs **registry schema**: ``ontobricks_registry``
# in OntoBricks is usually the **schema** (``lakebase_registry_schema`` /
# ``LAKEBASE_SCHEMA``), not the ``db-…`` segment. A separate Postgres
# database named ``ontobricks_registry`` would show both in
# ``status.postgres_database`` and as its own ``db-…`` row — do not
# confuse schema name with resource id.
#
# ``lakebase_registry_schema`` is the OntoBricks registry **Postgres
# schema** (default ``ontobricks_registry``). Mirror it in
# ``app.yaml`` / ``src/mcp-server/app.yaml`` as ``LAKEBASE_SCHEMA``.
lakebase_project:
description: "Lakebase Autoscaling project id (``projects/<this>/…``)"
default: "ontobricks-app"
lakebase_branch:
description: "Branch id within the project (resource segment after ``…/branches/``, e.g. ``production``)"
default: "v030"
lakebase_database_resource_segment:
description: "Final segment of Postgres API ``name`` (``db-…``) for the Apps ``postgres.database`` path — from ``list-databases``, not ``datname``"
# Example: row with ``status.postgres_database`` ``ontobricks_registry`` (or
# ``databricks_postgres`` on older single-DB layouts) on
# ``ontobricks-app`` / ``production`` — replace when your project/branch/DB differs.
#
# Print each ``db-…`` segment next to ``postgres_database`` (pick the row, use the first column)::
#
# databricks postgres list-databases \
# "projects/ontobricks-app/branches/production" -o json \
# | jq -r '.[] | [.name | split("/") | last, .status.postgres_database] | @tsv'
#
# Same without ``jq`` (one line)::
#
# databricks postgres list-databases "projects/ontobricks-app/branches/production" -o json | python3 -c "import json,sys;[print(r['name'].split('/')[-1], (r.get('status')or{}).get('postgres_database')) for r in json.load(sys.stdin)]"
#
# Replace ``ontobricks-app`` / ``production`` with your ``lakebase_project`` / ``lakebase_branch`` when they differ.
default: "db-8u4l-0na72ub5sp"
lakebase_registry_schema:
description: "OntoBricks registry schema inside Postgres (``LAKEBASE_SCHEMA`` in app.yaml)"
default: "ontobricks_registry"
resources:
apps:
# ── Dev sandbox app (FastAPI UI) ────────────────────────────
ontobricks_dev_app:
name: "ontobricks-030"
description: "OntoBricks (development sandbox app)"
source_code_path: .
resources:
- name: sql-warehouse
description: "SQL Warehouse for executing queries and metadata operations"
sql_warehouse:
id: ${var.warehouse_id}
permission: CAN_USE
- name: volume
description: "Unity Catalog Volume for the OntoBricks domain registry"
uc_securable:
securable_type: "VOLUME"
securable_full_name: "${var.registry_catalog}.${var.registry_schema}.${var.registry_volume}"
permission: WRITE_VOLUME
# ── MCP companion server ────────────────────────────────────
# FastMCP server exposing OntoBricks Digital Twin tools to the
# Databricks Playground. Deployed from ``src/mcp-server`` (its own
# ``pyproject.toml`` + ``app.yaml``). The MCP server's service
# principal needs ``CAN_USE`` on ``ontobricks-030`` so it can call
# back into the UI's REST API — ``scripts/deploy.sh`` grants this
# automatically after every deploy.
mcp_ontobricks_app:
name: "mcp-ontobricks"
description: "OntoBricks MCP companion server (FastMCP)"
source_code_path: ./src/mcp-server
resources:
- name: sql-warehouse
description: "SQL Warehouse for executing queries and metadata operations"
sql_warehouse:
id: ${var.warehouse_id}
permission: CAN_USE
- name: volume
description: "Unity Catalog Volume for the OntoBricks domain registry"
uc_securable:
securable_type: "VOLUME"
securable_full_name: "${var.registry_catalog}.${var.registry_schema}.${var.registry_volume}"
permission: WRITE_VOLUME
targets:
# Default sandbox: Volume-only registry backend.
dev:
mode: development
default: true
# Sandbox with the Lakebase Postgres registry backend bound
# (Autoscaling-only). Uses the Apps ``postgres`` resource type
# with ``branch`` + ``database`` resource paths — both must be
# full project-relative paths, not bare names. See the
# ``lakebase_*`` variables above; paths are composed automatically.
#
# The Apps runtime injects PGHOST / PGPORT / PGDATABASE /
# PGUSER / PGAPPNAME / PGSSLMODE for the bound database, so the
# in-app code path (``LakebaseAuth``) keeps working without any
# extra config.
dev-lakebase:
mode: development
resources:
apps:
ontobricks_dev_app:
resources:
- name: postgres
description: "Lakebase Autoscaling Postgres database for the OntoBricks registry"
postgres:
branch: projects/${var.lakebase_project}/branches/${var.lakebase_branch}
database: projects/${var.lakebase_project}/branches/${var.lakebase_branch}/databases/${var.lakebase_database_resource_segment}
permission: "CAN_CONNECT_AND_CREATE"
mcp_ontobricks_app:
resources:
- name: postgres
description: "Lakebase Autoscaling Postgres database for the OntoBricks registry"
postgres:
branch: projects/${var.lakebase_project}/branches/${var.lakebase_branch}
database: projects/${var.lakebase_project}/branches/${var.lakebase_branch}/databases/${var.lakebase_database_resource_segment}
permission: "CAN_CONNECT_AND_CREATE"