Skip to content

Commit 8d184bf

Browse files
committed
Reconcile dbconnect with the VPEX CLI spec: single sync command, E_* taxonomy, camelCase JSON
Aligns `databricks dbconnect` with the reconciled cli-spec: - Collapse `init`+`sync` into a single `dbconnect sync` that auto-detects greenfield (no pyproject.toml) vs. merge; command path lives in one constant. - Add `--constraints-only` (Python + constraints, no databricks-connect pin; still builds .venv, omits dbconnectVersion, skips the DB Connect assertion). - Rewrite the `--output json` contract to the camelCase schema: schemaVersion, command, ok, mode, dryRun, target, resolved, greenfield, plan, phases[] (all six phases with pending), warnings[], error{code,failurePhase,diskMutated}. - Rename error codes to the E_* set; report failurePhase at the phase that detects the failure so it always matches the errored phase in phases[]. - Detect non-uv managers (conda/pip) in preflight and exit cleanly with E_MANAGER_UNSUPPORTED; a plain PEP 621 pyproject.toml resolves to uv. - Classify a 404 for a resolved env key as E_ENV_UNSUPPORTED (latest-LTS hint, no cache fallback) vs. transport failure as E_FETCH; add a writable preflight. - Default the constraint repo to rugpanov/databricks-environments. Fixes two bugs the real `uv sync`/validate path exposed (both masked by the fake package manager and --check in tests): - uvManager.Validate no longer requires databricks-connect to be importable (constraints-only left it uninstalled), so validate stops failing after it has already provisioned the venv. - Greenfield render now emits project.version, which uv requires for a [project] table; without it every real greenfield `uv sync` failed. Co-authored-by: Isaac
1 parent 8f656d9 commit 8d184bf

46 files changed

Lines changed: 1145 additions & 691 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NEXT_CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### Notable Changes
66

77
### CLI
8-
* Add `databricks dbconnect init` and `databricks dbconnect sync` to provision a local Python environment (Python version, `databricks-connect` pin, and dependency constraints) matched to the selected Databricks compute target.
8+
* Add `databricks dbconnect sync` to provision a local Python environment (Python version, `databricks-connect` pin, and dependency constraints) matched to the selected Databricks compute target. A project with no `pyproject.toml` is initialized from scratch; an existing one is merged in place. Supports `--cluster`/`--serverless`/`--job` target selection, `--constraints-only` (skip `databricks-connect`), `--check` (dry run), and `--output json` for the VS Code extension.
99

1010
### Bundles
1111
* `bundle run` now prints the modern job run URL (`/jobs/<id>/runs/<id>`) so that non-admin users permitted to view the run are taken to the run instead of the workspace homepage.

acceptance/dbconnect/cluster-unsupported/output.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

acceptance/dbconnect/cluster-unsupported/script

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
>>> [CLI] dbconnect sync --serverless v4 --constraints-only --check --output json
3+
{
4+
"schemaVersion": 1,
5+
"command": "dbconnect sync",
6+
"ok": true,
7+
"mode": "constraints-only",
8+
"dryRun": true,
9+
"target": {
10+
"source": "serverless",
11+
"serverlessVersion": "v4",
12+
"envKey": "serverless/serverless-v4"
13+
},
14+
"resolved": {
15+
"pythonVersion": "3.12",
16+
"artifactSource": "network"
17+
},
18+
"greenfield": true,
19+
"plan": {
20+
"wouldWrite": "[TEST_TMP_DIR]/pyproject.toml",
21+
"wouldInstallPython": "3.12",
22+
"diff": "--- pyproject.toml\n+++ pyproject.toml\n@@ -1 +1,15 @@\n+[project]\n+name = \"001\"\n+version = \"0.0.0\"\n+requires-python = \"\u003e=3.12\"\n+\n+[dependency-groups]\n+dev = []\n+\n+# managed by databricks dbconnect — do not edit\n+[tool.uv]\n+constraint-dependencies = [\n+ \"pyarrow\u003c19\",\n+ \"pandas\u003c3\",\n+]\n+# end managed by databricks dbconnect\n"
23+
},
24+
"phases": [
25+
{
26+
"phase": "preflight",
27+
"status": "ok"
28+
},
29+
{
30+
"phase": "resolve",
31+
"status": "ok"
32+
},
33+
{
34+
"phase": "fetch",
35+
"status": "ok"
36+
},
37+
{
38+
"phase": "merge",
39+
"status": "ok"
40+
},
41+
{
42+
"phase": "provision",
43+
"status": "ok"
44+
},
45+
{
46+
"phase": "validate",
47+
"status": "ok"
48+
}
49+
],
50+
"warnings": [],
51+
"error": null,
52+
"durationMs": 0
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI dbconnect sync --serverless v4 --constraints-only --check --output json
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = []
2+
3+
[Env]
4+
DATABRICKS_DBCONNECT_CONSTRAINT_SOURCE = "$DATABRICKS_HOST"
5+
6+
[[Server]]
7+
Pattern = "GET /serverless/serverless-v4/pyproject.toml"
8+
Response.Body = '''
9+
[project]
10+
requires-python = ">=3.12"
11+
12+
[dependency-groups]
13+
dev = ["databricks-connect~=17.2.0"]
14+
15+
[tool.uv]
16+
constraint-dependencies = ["pyarrow<19", "pandas<3"]
17+
'''
18+
19+
[[Repls]]
20+
Old = 'uv uv \S+(?: \([^)]+\))?'
21+
New = 'uv [UV_VERSION]'

acceptance/dbconnect/env-unsupported/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
preflight ok uv [UV_VERSION]
2+
resolve ok source=cluster envKey=dbr/15.4.x-scala2.12
3+
fetch error no published environment for "dbr/15.4.x-scala2.12". If this is a new runtime, try the latest LTS target (e.g. --serverless v4 or a supported --cluster DBR): GET [DATABRICKS_URL]/dbr/15.4.x-scala2.12/pyproject.toml: environment key not found
4+
merge pending
5+
provision pending
6+
validate pending
7+
For more detail, re-run with --debug, or --output json to share a structured report.
8+
Error: no published environment for "dbr/15.4.x-scala2.12". If this is a new runtime, try the latest LTS target (e.g. --serverless v4 or a supported --cluster DBR): GET [DATABRICKS_URL]/dbr/15.4.x-scala2.12/pyproject.toml: environment key not found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
musterr $CLI dbconnect sync --cluster test-cluster-id --check

0 commit comments

Comments
 (0)