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
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("PythonSetupEnvironmentSetup.setup", () => {
expect(adopted).to.deep.equal([SUCCESS_REAL_RUN.venvPath]);
expect(saved).to.deep.equal([
{
envKey: SUCCESS_REAL_RUN.target!.envKey,
envKey: SUCCESS_REAL_RUN.compute!.envKey,
pythonVersion: SUCCESS_REAL_RUN.resolved!.pythonVersion,
},
]);
Expand Down Expand Up @@ -248,12 +248,12 @@ describe("PythonSetupEnvironmentSetup.setup", () => {
const shownErrors: string[] = [];
const adopted: string[] = [];
const saved: unknown[] = [];
// ok:true with a venvPath but no target/resolved: we could adopt an
// ok:true with a venvPath but no compute/resolved: we could adopt an
// interpreter, but drift detection would have no baseline to persist —
// so this is treated as a failure rather than a hollow "ready".
const withoutBaseline: PythonSetupResult = {
...SUCCESS_REAL_RUN,
target: undefined,
compute: undefined,
resolved: undefined,
};
const setup = new PythonSetupEnvironmentSetup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export interface PythonSetupPersistedState {
}

type ReadyLocalEnvironmentResult = PythonSetupResult &
Required<Pick<PythonSetupResult, "venvPath" | "target" | "resolved">>;
Required<Pick<PythonSetupResult, "venvPath" | "compute" | "resolved">>;

function isLocalEnvironmentReady(
r: PythonSetupResult
): r is ReadyLocalEnvironmentResult {
return (
isPythonSetupSuccess(r) &&
r.venvPath !== undefined &&
r.target !== undefined &&
r.compute !== undefined &&
r.resolved !== undefined
);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ export class PythonSetupEnvironmentSetup implements Disposable {
}

this.deps.saveState({
envKey: result.target.envKey,
envKey: result.compute.envKey,
pythonVersion: result.resolved.pythonVersion,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ describe("parsePythonSetupResult", () => {
expect(r.schemaVersion).to.equal(1);
expect(r.mode).to.equal("default");
expect(r.dryRun).to.equal(true);
expect(r.target?.serverlessVersion).to.equal("v4");
expect(r.target?.envKey).to.equal("serverless/serverless-v4");
expect(r.compute?.serverlessVersion).to.equal("v4");
expect(r.compute?.envKey).to.equal("serverless/serverless-v4");
expect(r.resolved?.pythonVersion).to.equal("3.12");
expect(r.resolved?.dbconnectVersion).to.equal("17.2.0");
expect(r.error).to.equal(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type PythonSetupErrorCode =
| "E_PROVISION"
| "E_VALIDATE";

export interface PythonSetupTargetInfo {
export interface PythonSetupComputeInfo {
source: string;
clusterId?: string;
serverlessVersion?: string;
Expand Down Expand Up @@ -97,11 +97,13 @@ export interface PythonSetupResult {
ok: boolean;
mode: PythonSetupMode;
dryRun: boolean;
// TODO: rename to `compute` (+ PythonSetupTargetInfo -> PythonSetupComputeInfo)
// to match SetupLocalInvocation.compute. This field mirrors the CLI's wire
// key `target`, so the rename must land in the CLI's --output json first
// (with a schemaVersion bump), then here.
target?: PythonSetupTargetInfo;
/**
* The resolved compute the environment was provisioned against. Mirrors the
* CLI's `compute` result key (renamed from `target` in databricks/cli#6100)
* so the structural cast in {@link parsePythonSetupResult} keeps matching the
* wire shape.
*/
compute?: PythonSetupComputeInfo;
resolved?: PythonSetupResolvedInfo;
greenfield: boolean;
plan?: PythonSetupPlan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const SUCCESS_DEFAULT: PythonSetupResult = {
ok: true,
mode: "default",
dryRun: true,
target: {
compute: {
source: "serverless",
serverlessVersion: "v4",
envKey: "serverless/serverless-v4",
Expand Down Expand Up @@ -67,7 +67,7 @@ export const SUCCESS_CONSTRAINTS_ONLY: PythonSetupResult = {
ok: true,
mode: "constraints-only",
dryRun: true,
target: {
compute: {
source: "serverless",
serverlessVersion: "v4",
envKey: "serverless/serverless-v4",
Expand Down Expand Up @@ -164,7 +164,7 @@ export const SUCCESS_REAL_RUN: PythonSetupResult = {
ok: true,
mode: "default",
dryRun: false,
target: {
compute: {
source: "serverless",
serverlessVersion: "v4",
envKey: "serverless/serverless-v4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ describe("getPythonSetupErrorMessage", () => {
const r = failure(
"E_ENV_UNSUPPORTED",
{failurePhase: "fetch"},
{target: {source: "cluster", envKey: "dbr/15.4.x-scala2.12"}}
{compute: {source: "cluster", envKey: "dbr/15.4.x-scala2.12"}}
);
const msg = getPythonSetupErrorMessage(r);
expect(msg).to.contain("dbr/15.4.x-scala2.12");
expect(msg).to.match(/lts|latest/i);
});

it("maps E_ENV_UNSUPPORTED without a target gracefully", () => {
it("maps E_ENV_UNSUPPORTED without a compute gracefully", () => {
const msg = getPythonSetupErrorMessage(failure("E_ENV_UNSUPPORTED"));
expect(msg).to.match(/no matched environment/i);
expect(msg).to.not.contain("undefined");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BASE_MESSAGE: Record<
E_RESOLVE: () =>
"Could not resolve the selected compute. Check the cluster/serverless selection and try again.",
E_ENV_UNSUPPORTED: (r) => {
const key = r.target?.envKey;
const key = r.compute?.envKey;
const which = key ? `for ${key}` : "for the selected compute";
return (
`No matched environment ${which}. ` +
Expand Down
Loading