Skip to content

[VPEX][8/8] Unveil local-env: make the command visible, add help + changelog#5835

Open
rugpanov wants to merge 1 commit into
dbconnect/07-acceptancefrom
dbconnect/08-unveil
Open

[VPEX][8/8] Unveil local-env: make the command visible, add help + changelog#5835
rugpanov wants to merge 1 commit into
dbconnect/07-acceptancefrom
dbconnect/08-unveil

Conversation

@rugpanov

@rugpanov rugpanov commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Why

  • Everything for local-env python sync was built, reviewed, and tested behind Hidden: true across the earlier layers. This PR makes it visible — the single, deliberate “release” step.
  • Keeping exposure as its own tiny commit means it's trivial to review and to revert (re-hide) without touching any implementation.

What

  • cmd/localenv/localenv.go — remove Hidden: true (and the now-stale “hidden while landing” comment) so local-env appears in databricks --help and completion.
  • acceptance/help/output.txt — regenerated global-help golden now lists local-env under Developer Tools (between bundle and sync).
  • .nextchanges/cli/local-env.md — changelog fragment announcing databricks local-env python sync under the CLI section (the repo moved from a single NEXT_CHANGELOG.md to per-PR .nextchanges/ fragments).
  • 3 files. No behavior change — only visibility.

Testing strategy

  • Gates: go build ./..., golangci-lint, deadcode, gofmt — all green.
  • help and localenv acceptance suites pass without -update (golden matches reality).
  • Runtime-confirmed: local-env now appears in top-level help; sub-help still works; behavior otherwise unchanged (e.g. no-target still exits 1) — only visibility flipped.

About this stack

This is the final PR of a series of small, stacked PRs that together add the databricks local-env python sync command — it provisions a local Python environment (Python version, databricks-connect pin, and dependency constraints) matched to a selected Databricks compute target. The work was split from one large branch into single-concern layers so each is independently reviewable; the command was kept hidden until this PR so nothing was user-visible mid-stack.

Review bottom-up. Layers 1–5 have merged (the original layer-5 PR #5828 was split into 5a/5b/5c during review).

# PR What Status
1 #5823 foundation: result types + env-key mapping merged
2 #5824 compute-target resolution merged
3 #5826 constraint fetch + offline cache merged
4 #5827 formatting-preserving pyproject.toml merge merged
5a #5850 package-manager interface + detection merged
5b #5851 six-phase pipeline orchestrator merged
5c #5854 --check cache purity, greenfield name, dbc insertion merged
6 #5832 uv backend + CLI command (registered hidden)
7 #5833 acceptance tests
8 #5835 ← you are here unveil (unhide + help + changelog)

This pull request and its description were written by Isaac.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @janniklasrose -- recent work in .nextchanges/cli/, acceptance/help/

Eligible reviewers: @andrewnester, @anton-107, @denik, @lennartkats-db, @pietern, @renaudhartert-db, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: c4961cd

Run: 29344446442

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 230 1099 5:30
💚​ aws windows 4 4 232 1097 7:16
🔄​ aws-ucws linux 2 4 4 314 1016 6:57
💚​ aws-ucws windows 4 4 318 1014 8:11
💚​ azure linux 4 4 230 1098 5:29
💚​ azure windows 4 4 232 1096 7:53
💚​ azure-ucws linux 4 4 318 1013 6:13
💚​ azure-ucws windows 4 4 320 1011 7:40
💚​ gcp linux 4 4 229 1100 5:23
💚​ gcp windows 4 4 231 1098 7:24
10 interesting tests: 4 RECOVERED, 4 SKIP, 2 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestFilerWorkspaceNotebook ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestFilerWorkspaceNotebook/pythonJupyterNb.ipynb ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 10 slowest tests (at least 2 minutes):
duration env testname
6:49 aws-ucws windows TestAccept
6:45 azure windows TestAccept
6:30 azure-ucws windows TestAccept
6:22 gcp windows TestAccept
6:08 aws windows TestAccept
3:08 gcp linux TestAccept
2:58 aws-ucws linux TestAccept
2:56 azure linux TestAccept
2:52 aws linux TestAccept
2:51 azure-ucws linux TestAccept

@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from 6c2fadc to c45ca0c Compare July 6, 2026 11:47
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from 3123548 to 8008a65 Compare July 6, 2026 11:47
@rugpanov rugpanov temporarily deployed to test-trigger-is July 6, 2026 11:48 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 6, 2026 11:48 — with GitHub Actions Inactive
@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from c45ca0c to 25d07fe Compare July 7, 2026 08:35
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from 8008a65 to 27f8064 Compare July 7, 2026 08:35
@rugpanov rugpanov temporarily deployed to test-trigger-is July 7, 2026 08:35 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 7, 2026 08:35 — with GitHub Actions Inactive
ZaSkittles pushed a commit to ZaSkittles/cli that referenced this pull request Jul 7, 2026
databricks#5823)

## Why

- The `local-env` feature needs a shared vocabulary before any behavior
can be built: the result shape, the error taxonomy, and how a compute
target maps to an environment key.
- Landing these contract types first lets every later layer (resolve /
fetch / merge / pipeline / command) depend on stable, reviewed
definitions.
- Kept deliberately minimal and dependency-free so it reviews on its own
and stays `unused`/`deadcode`-clean with no consumers yet.

## What

- **`result.go`** — the `--json` / `E_*` output contract: `Result`,
`PipelineError`, `ErrorCode`, `PhaseName`, `PhaseStatus`, `Mode`,
`TargetInfo`, `ResolvedInfo`, `Plan`, `Warning`; plus the command-path
constants (`local-env` / `python` / `sync`) defined in one place.
- **`envkey.go`** — `EnvKeyForServerless` / `EnvKeyForSparkVersion` /
`NormalizeServerless`, and `PythonMinorFromRequires` (clause-aware:
returns the effective highest lower bound of a `requires-python`).
- No wiring into `cmd/`, so the CLI is unchanged. Filesystem/artifact
constants and the phase-order slice deliberately live with their
consumer (PR 5).

## Testing strategy

- Unit tests for the error/type contract (`result_test.go`) and env-key
mapping incl. multi-clause / strict-`>` / no-floor `requires-python`
cases (`envkey_test.go`).
- Gates: `go build`, `go test`, `golangci-lint`, `deadcode`, `gofmt` —
all green.
- Reviewed with codex across several rounds to convergence (all findings
fixed or explicitly rejected as speculative).

---

## About this stack

This is one of a series of small, stacked PRs that together add the
`databricks local-env python sync` command — it provisions a local
Python environment (Python version, `databricks-connect` pin, and
dependency constraints) matched to a selected Databricks compute target.
The work was split from one large branch into single-concern layers so
each is independently reviewable; the command is kept hidden until the
final PR so nothing is user-visible mid-stack.

**Review bottom-up.** Each PR targets the previous one as its base
branch, so its diff shows only that layer.

| # | PR | What |
|---|----|------|
| 1 | **databricks#5823 ← you are here** | foundation: result types + env-key
mapping |
| 2 | databricks#5824 | compute-target resolution |
| 3 | databricks#5826 | constraint fetch + offline cache |
| 4 | databricks#5827 | formatting-preserving pyproject.toml merge |
| 5 | databricks#5828 | six-phase pipeline + detection + package-manager interface
|
| 6 | databricks#5832 | uv backend + CLI command (registered hidden) |
| 7 | databricks#5833 | acceptance tests |
| 8 | databricks#5835 | unveil (unhide + help + changelog) |

This pull request and its description were written by Isaac.
ZaSkittles pushed a commit to ZaSkittles/cli that referenced this pull request Jul 7, 2026
## Why

- `local-env` must turn the user's compute selection into a single
environment key before it can fetch anything, and the selection can come
from several places with a defined precedence.
- Isolating resolution behind a narrow seam keeps it testable without a
live workspace and keeps SDK details out of the engine.

## What

- **`target.go`** — `ResolveTarget` with ordered precedence `--cluster`
→ `--serverless` → `--job` → bundle target, producing a `TargetInfo` +
env key.
- Compute lookups go through the narrow `ComputeClient` interface
(stubbable in tests).
- `ValidateTargetFlags` rejects more than one target flag;
`ResolveTarget` runs it up front so a non-Cobra caller can't silently
resolve the wrong target.
- Classic-compute jobs read the Spark version from the documented first
return of `GetJobSparkVersion` (not the recorded-version third return).

## Testing strategy

- Unit tests against a stub `ComputeClient` covering each precedence
branch, the mutually-exclusive-flags error, and the job classic-compute
contract (`target_test.go`).
- Gates: `go build`, `go test`, `golangci-lint`, `deadcode`, `gofmt` —
all green.
- Reviewed with codex to a clean pass.

---

## About this stack

This is one of a series of small, stacked PRs that together add the
`databricks local-env python sync` command — it provisions a local
Python environment (Python version, `databricks-connect` pin, and
dependency constraints) matched to a selected Databricks compute target.
The work was split from one large branch into single-concern layers so
each is independently reviewable; the command is kept hidden until the
final PR so nothing is user-visible mid-stack.

**Review bottom-up.** Each PR targets the previous one as its base
branch, so its diff shows only that layer.

| # | PR | What |
|---|----|------|
| 1 | databricks#5823 | foundation: result types + env-key mapping |
| 2 | **databricks#5824 ← you are here** | compute-target resolution |
| 3 | databricks#5826 | constraint fetch + offline cache |
| 4 | databricks#5827 | formatting-preserving pyproject.toml merge |
| 5 | databricks#5828 | six-phase pipeline + detection + package-manager interface
|
| 6 | databricks#5832 | uv backend + CLI command (registered hidden) |
| 7 | databricks#5833 | acceptance tests |
| 8 | databricks#5835 | unveil (unhide + help + changelog) |

This pull request and its description were written by Isaac.
ZaSkittles pushed a commit to ZaSkittles/cli that referenced this pull request Jul 7, 2026
…icks#5826)

## Why

- Once a target resolves to an env key, `local-env` needs the pinned
Python version, `databricks-connect` version, and dependency constraints
published for that key.
- The fetch must degrade gracefully offline and distinguish “this
environment isn't published” from “the network is down,” because those
call for different user action.
- The artifact host must be a Databricks-owned, access-controlled
location and must never default to a personal repo — whoever controls
the host controls what the CLI installs.

## What

- **`constraints.go`** — fetches the per-environment `pyproject.toml`,
parses `requires-python`, the `databricks-connect` pin, and `[tool.uv]`
`constraint-dependencies`, and caches it on disk.
- **Host parameterization** — no host is hardcoded:
`RepoConstraintBaseURL` reads the repo (`owner/name`) from the temporary
`DATABRICKS_LOCALENV_CONSTRAINT_REPO` env var and builds a
`raw.githubusercontent.com/<repo>/main` URL; the built-in default is
empty. When unset it returns `""` and `FetchConstraints` reports the
missing source as a fetch-phase `E_FETCH` error (so there is no
untrusted default, and the failure flows through the normal phase/JSON
reporting). Once `databricks/environments` can publish, that becomes the
hardcoded default and the env var is no longer required.
- Failure classification: **404** → `E_ENV_UNSUPPORTED` (no cache
fallback — a distinct non-transient condition); **transport / non-404**
→ `E_FETCH` with fallback to the last-good cached copy.
- Robustness: validate the body (parse + require `requires-python`)
**before** caching so a bad 2xx can't poison the cache; atomic cache
write (mkdir + temp-file + rename); dedicated `http.Client` with a 30s
timeout; body read bounded by `io.LimitReader` at 1 MiB;
`databricks-connect` matched by leading package name under PEP 503
normalization (so `Databricks_Connect` matches, `databricks-connectors`
does not); cache filename = readable slug + sha256 suffix to prevent
collisions.

## Testing strategy

- Unit tests with an `httptest` server: 200-parse, 404 →
`E_ENV_UNSUPPORTED`, transport failure + cache fallback,
missing-`requires-python` rejection, PEP 503 name matching, cache-dir
creation, collision-free filenames, oversized-body rejection
(`constraints_test.go`).
- Host resolution: `TestRepoConstraintBaseURL` (env var → URL, unset →
`""`, whitespace treated as unset) and
`TestFetchConstraintsNoSourceConfigured` (empty host → `E_FETCH` naming
the env var).
- Gates: `go build`, `go test`, `golangci-lint`, `deadcode`, `gofmt` —
all green.
- Reviewed with codex to a clean pass (several fetch/cache edge-case
fixes landed from review).

---

## About this stack

This is one of a series of small, stacked PRs that together add the
`databricks local-env python sync` command — it provisions a local
Python environment (Python version, `databricks-connect` pin, and
dependency constraints) matched to a selected Databricks compute target.
The work was split from one large branch into single-concern layers so
each is independently reviewable; the command is kept hidden until the
final PR so nothing is user-visible mid-stack.

**Review bottom-up.** Each PR targets the previous one as its base
branch, so its diff shows only that layer.

| # | PR | What |
|---|----|------|
| 1 | databricks#5823 | foundation: result types + env-key mapping |
| 2 | databricks#5824 | compute-target resolution |
| 3 | **databricks#5826 ← you are here** | constraint fetch + offline cache |
| 4 | databricks#5827 | formatting-preserving pyproject.toml merge |
| 5 | databricks#5828 | six-phase pipeline + detection + package-manager interface
|
| 6 | databricks#5832 | uv backend + CLI command (registered hidden) |
| 7 | databricks#5833 | acceptance tests |
| 8 | databricks#5835 | unveil (unhide + help + changelog) |

This pull request and its description were written by Isaac.
ZaSkittles pushed a commit to ZaSkittles/cli that referenced this pull request Jul 7, 2026
…atabricks#5827)

## Why

- `local-env` must apply the resolved Python version and constraints to
the user's `pyproject.toml` without disturbing their own content —
comments, ordering, formatting, and unrelated config must survive
untouched.
- Re-running must be safe and idempotent, and a greenfield project needs
a sensible file created from scratch.
- This is the most intricate logic in the feature, so it lands in its
own PR for focused review.

## What

- **`merge.go`** — a formatting-preserving merge that rewrites only the
env-owned regions (`requires-python`, the `databricks-connect` entry in
`[dependency-groups].dev`, and a marker-bracketed managed `[tool.uv]`
block) and preserves every other byte incl. CRLF; idempotent.
`RenderFreshPyproject` builds a complete managed file for a greenfield
project.
- Scoping/robustness: managed `constraint-dependencies` nests
header-less inside an existing user `[tool.uv]` (never a duplicate
header); single- vs multi-line array detection tracks real bracket depth
outside strings/comments; the `databricks-connect` rewrite is confined
to `dev` and leaves trailing comments alone; `requires-python`'s inline
comment is preserved; table-header parsing tolerates inline comments and
recognizes `[[array.of.tables]]`.

## Testing strategy

- Unit tests that parse the merged output as TOML (not just substring
checks), covering idempotency, CRLF preservation, user-key preservation,
the duplicate-`[tool.uv]` case, bracket-in-element arrays,
sibling-group/comment non-clobbering, and `[[tool.uv.index]]` children
(`merge_test.go`).
- Gates: `go build`, `go test`, `golangci-lint`, `deadcode`, `gofmt` —
all green.
- Reviewed with codex to a clean pass (multiple TOML-corruption edge
cases were caught and fixed).

---

## About this stack

This is one of a series of small, stacked PRs that together add the
`databricks local-env python sync` command — it provisions a local
Python environment (Python version, `databricks-connect` pin, and
dependency constraints) matched to a selected Databricks compute target.
The work was split from one large branch into single-concern layers so
each is independently reviewable; the command is kept hidden until the
final PR so nothing is user-visible mid-stack.

**Review bottom-up.** Each PR targets the previous one as its base
branch, so its diff shows only that layer.

| # | PR | What |
|---|----|------|
| 1 | databricks#5823 | foundation: result types + env-key mapping |
| 2 | databricks#5824 | compute-target resolution |
| 3 | databricks#5826 | constraint fetch + offline cache |
| 4 | **databricks#5827 ← you are here** | formatting-preserving pyproject.toml
merge |
| 5 | databricks#5828 | six-phase pipeline + detection + package-manager interface
|
| 6 | databricks#5832 | uv backend + CLI command (registered hidden) |
| 7 | databricks#5833 | acceptance tests |
| 8 | databricks#5835 | unveil (unhide + help + changelog) |

This pull request and its description were written by Isaac.
@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from 25d07fe to da5bf75 Compare July 14, 2026 11:51
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from 27f8064 to 8fb5ea2 Compare July 14, 2026 11:52
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 11:52 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 11:52 — with GitHub Actions Inactive
@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from da5bf75 to b537940 Compare July 14, 2026 12:50
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from 8fb5ea2 to d3c1357 Compare July 14, 2026 12:50
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 12:51 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 12:51 — with GitHub Actions Inactive
@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from b537940 to 1b472ab Compare July 14, 2026 12:56
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from d3c1357 to 73bf723 Compare July 14, 2026 12:56
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 12:57 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 12:57 — with GitHub Actions Inactive
@rugpanov rugpanov force-pushed the dbconnect/07-acceptance branch from 1b472ab to f450684 Compare July 14, 2026 13:03
@rugpanov rugpanov force-pushed the dbconnect/08-unveil branch from 73bf723 to 84efcd1 Compare July 14, 2026 13:03
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 13:04 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 13:04 — with GitHub Actions Inactive
Eighth and final PR in the stacked series. Flips the feature from
implemented-but-hidden to released:

- cmd/localenv/localenv.go: remove Hidden:true so `local-env` appears in
  `databricks --help` and completion.
- acceptance/help/output.txt: regenerated global-help golden now lists
  local-env under Developer Tools.
- NEXT_CHANGELOG.md: announce `databricks local-env python sync`.

This is the only PR that changes user-visible surface; everything it exposes
was reviewed and tested in PRs 1-7. Reverting this PR alone re-hides the
feature without touching any implementation.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants