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
1 change: 0 additions & 1 deletion packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ export async function activate(
try {
const result = await pythonSetupClient.run(
{
mode: "default",
dryRun: true,
compute: resolution.compute,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ export class PythonSetupEnvironmentSetup implements Disposable {
const compute = resolved.compute;

const invocation: SetupLocalInvocation = {
mode: "default",
compute,
};

Expand Down Expand Up @@ -635,7 +634,9 @@ export class PythonSetupEnvironmentSetup implements Disposable {
targetType: compute.kind,
serverlessVersion:
compute.kind === "serverless" ? compute.version : undefined,
mode: invocation.mode,
// --no-dbconnect is the orthogonal spelling of the legacy
// --constraints-only, so it maps to that telemetry mode.
mode: invocation.skipDbconnect ? "constraints-only" : "default",
isGreenfield,
// A run against a project already marked ready this session is a
// re-run (the ready row's Re-run button / row click); anything
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function fakeSpawn(script: {
}

const inv = {
mode: "default" as const,
compute: {kind: "serverless" as const, version: "5"},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {buildSetupLocalArgs, SetupLocalInvocation} from "./setupLocalArgs";
describe("buildSetupLocalArgs", () => {
it("builds a default serverless invocation with JSON output", () => {
const inv: SetupLocalInvocation = {
mode: "default",
compute: {kind: "serverless", version: "5"},
};
expect(buildSetupLocalArgs(inv)).to.deep.equal([
Expand All @@ -19,7 +18,6 @@ describe("buildSetupLocalArgs", () => {

it("uses --cluster-id for a cluster target", () => {
const args = buildSetupLocalArgs({
mode: "default",
compute: {kind: "cluster", clusterId: "0710-abc"},
});
const i = args.indexOf("--cluster-id");
Expand All @@ -28,33 +26,63 @@ describe("buildSetupLocalArgs", () => {
expect(args).to.not.include("--serverless-version");
});

it("adds --constraints-only in constraints-only mode", () => {
it("adds --no-constraints when constraints are skipped", () => {
const args = buildSetupLocalArgs({
mode: "constraints-only",
skipConstraints: true,
compute: {kind: "serverless", version: "5"},
});
expect(args).to.include("--constraints-only");
expect(args).to.include("--no-constraints");
expect(args).to.not.include("--no-dbconnect");
});

it("omits --constraints-only in default mode", () => {
it("adds --no-dbconnect when databricks-connect is skipped", () => {
const args = buildSetupLocalArgs({
mode: "default",
skipDbconnect: true,
compute: {kind: "serverless", version: "5"},
});
expect(args).to.include("--no-dbconnect");
expect(args).to.not.include("--no-constraints");
});

it("adds both negative flags when both are skipped, --no-constraints first", () => {
const args = buildSetupLocalArgs({
skipConstraints: true,
skipDbconnect: true,
compute: {kind: "serverless", version: "5"},
});
const c = args.indexOf("--no-constraints");
const d = args.indexOf("--no-dbconnect");
expect(c).to.be.greaterThan(-1);
expect(d).to.be.greaterThan(-1);
expect(c).to.be.lessThan(d);
});

it("emits no behavioral flags for the default (full) invocation", () => {
const args = buildSetupLocalArgs({
compute: {kind: "serverless", version: "5"},
});
expect(args).to.not.include("--no-constraints");
expect(args).to.not.include("--no-dbconnect");
});

it("never emits the deprecated --constraints-only flag", () => {
const args = buildSetupLocalArgs({
skipConstraints: true,
skipDbconnect: true,
compute: {kind: "cluster", clusterId: "c"},
});
expect(args).to.not.include("--constraints-only");
});

it("never passes --profile (auth is forwarded via the environment)", () => {
const args = buildSetupLocalArgs({
mode: "default",
compute: {kind: "serverless", version: "5"},
});
expect(args).to.not.include("--profile");
});

it("passes the hidden --constraint-source-url when provided", () => {
const args = buildSetupLocalArgs({
mode: "default",
compute: {kind: "serverless", version: "5"},
constraintSourceUrl: "http://localhost:8077",
});
Expand All @@ -65,7 +93,8 @@ describe("buildSetupLocalArgs", () => {

it("always ends with --output json", () => {
const args = buildSetupLocalArgs({
mode: "constraints-only",
skipConstraints: true,
skipDbconnect: true,
compute: {kind: "cluster", clusterId: "c"},
constraintSourceUrl: "u",
});
Expand All @@ -74,7 +103,6 @@ describe("buildSetupLocalArgs", () => {

it("adds --dry-run when the invocation is a dry run", () => {
const args = buildSetupLocalArgs({
mode: "default",
compute: {kind: "serverless", version: "5"},
dryRun: true,
});
Expand All @@ -85,7 +113,6 @@ describe("buildSetupLocalArgs", () => {

it("omits --dry-run by default", () => {
const args = buildSetupLocalArgs({
mode: "default",
compute: {kind: "serverless", version: "5"},
});
expect(args).to.not.include("--dry-run");
Expand Down
32 changes: 22 additions & 10 deletions packages/databricks-vscode/src/python-setup/utils/setupLocalArgs.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import {PythonSetupMode} from "../models/PythonSetupResult";

/**
* A resolved `environments setup-local` invocation: the mode, the compute
* target (cluster or serverless), and an optional dev-only constraint-source
* override. This is the pure input to {@link buildSetupLocalArgs}; the gateway
* turns the argv into a spawned process.
* A resolved `environments setup-local` invocation: the compute target (cluster
* or serverless), which of the two behavioral steps to skip, and an optional
* dev-only constraint-source override. This is the pure input to
* {@link buildSetupLocalArgs}; the gateway turns the argv into a spawned process.
*
* There is deliberately no profile here: authentication reaches the CLI through
* the spawned process's environment (see `CliWrapper.getSetupLocalEnvVars`),
* matching how the bundle and ssh-connect flows forward it, so a `--profile`
* flag would be a redundant second source of truth.
*/
export interface SetupLocalInvocation {
mode: PythonSetupMode;
/**
* When true, pass `--dry-run`: the CLI resolves compute and reports the
* environment key without provisioning or writing to disk. Used by drift
Expand All @@ -23,6 +20,17 @@ export interface SetupLocalInvocation {
compute:
| {kind: "cluster"; clusterId: string}
| {kind: "serverless"; version: string};
/**
* When true, pass `--no-constraints`: don't write the remote Python-version
* and dependency pins. Orthogonal to {@link skipDbconnect}.
*/
skipConstraints?: boolean;
/**
* When true, pass `--no-dbconnect`: don't add the databricks-connect
* dependency. The orthogonal replacement for the deprecated
* `--constraints-only`. Orthogonal to {@link skipConstraints}.
*/
skipDbconnect?: boolean;
/**
* Hidden `--constraint-source-url` override (dev/testing only). The
* serverless version is passed verbatim as a bare number, e.g. "5" — the
Expand All @@ -34,7 +42,8 @@ export interface SetupLocalInvocation {
/**
* Build the argv for `databricks environments setup-local --output json`.
* Deterministic and side-effect-free so it is trivially unit-testable; the
* order is fixed (compute → mode → source → output) for stable tests.
* order is fixed (compute → skip flags → dry-run → source → output) for stable
* tests.
*/
export function buildSetupLocalArgs(inv: SetupLocalInvocation): string[] {
const args = ["environments", "setup-local"];
Expand All @@ -45,8 +54,11 @@ export function buildSetupLocalArgs(inv: SetupLocalInvocation): string[] {
args.push("--serverless-version", inv.compute.version);
}

if (inv.mode === "constraints-only") {
args.push("--constraints-only");
if (inv.skipConstraints) {
args.push("--no-constraints");
}
if (inv.skipDbconnect) {
args.push("--no-dbconnect");
}
if (inv.dryRun) {
args.push("--dry-run");
Expand Down
Loading