Skip to content

Commit

Permalink
Update CLI to v0.214.1 (#1099)
Browse files Browse the repository at this point in the history
## Changes
<!-- Summary of your changes that are easy to understand -->

## Tests
<!-- How is this tested? -->
  • Loading branch information
kartikgupta-db authored Feb 28, 2024
1 parent c28620a commit ea7b079
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@
"useYarn": false
},
"cli": {
"version": "0.212.3"
"version": "0.214.1"
},
"scripts": {
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && yarn run generate-telemetry",
Expand Down
7 changes: 3 additions & 4 deletions packages/databricks-vscode/src/cli/CliWrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import {promisify} from "node:util";
import {execFile as execFileCb} from "node:child_process";
import {withFile} from "tmp-promise";
import {writeFile, readFile} from "node:fs/promises";
import {when, spy, reset} from "ts-mockito";
import {when, spy, reset, instance, mock} from "ts-mockito";
import {CliWrapper} from "./CliWrapper";
import path from "node:path";
import os from "node:os";
import crypto from "node:crypto";
import {Context} from "@databricks/databricks-sdk/dist/context";
import {logging} from "@databricks/databricks-sdk";
import {LoggerManager} from "../logger";

const execFile = promisify(execFileCb);
const cliPath = path.join(__dirname, "../../bin/databricks");
Expand All @@ -35,6 +36,7 @@ function createCliWrapper(logFilePath?: string) {
return path.join(__dirname, "../..", relativePath);
},
} as any,
instance(mock(LoggerManager)),
logFilePath
);
}
Expand Down Expand Up @@ -126,14 +128,12 @@ describe(__filename, () => {
assert.equal(profiles.length, 2);
assert.equal(profiles[0].name, "DEFAULT");
assert.equal(profiles[0].host, "https://cloud.databricks.com/");
assert.equal(profiles[0].authType, "pat");

assert.equal(profiles[1].name, "STAGING");
assert.equal(
profiles[1].host,
"https://staging.cloud.databricks.com/"
);
assert.equal(profiles[1].authType, "pat");
});
});

Expand Down Expand Up @@ -164,7 +164,6 @@ nothing = true

assert.equal(profiles[0].name, "correct");
assert.equal(profiles[0].host, "https://cloud.databricks.com/");
assert.equal(profiles[0].authType, "pat");

assert.equal(profiles[1].name, "no-token");
assert.equal(profiles[1].host, "https://cloud.databricks.com/");
Expand Down
42 changes: 27 additions & 15 deletions packages/databricks-vscode/src/cli/CliWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {SyncDestinationMapper} from "../sync/SyncDestination";
import {workspaceConfigs} from "../vscode-objs/WorkspaceConfigs";
import {promisify} from "node:util";
import {logging} from "@databricks/databricks-sdk";
import {Loggers} from "../logger";
import {LoggerManager, Loggers} from "../logger";
import {Context, context} from "@databricks/databricks-sdk/dist/context";
import {Cloud} from "../utils/constants";
import {EnvVarGenerators, FileUtils, UrlUtils} from "../utils";
Expand Down Expand Up @@ -89,6 +89,7 @@ export class CliWrapper {
private clusterId?: string;
constructor(
private extensionContext: ExtensionContext,
private loggerManager: LoggerManager,
private logFilePath?: string
) {}

Expand Down Expand Up @@ -191,7 +192,13 @@ export class CliWrapper {
}
}
ctx?.logger?.error(msg, e);
this.showConfigFileWarning(msg);
window
.showWarningMessage(msg, "Open Databricks Config File")
.then(async (choice) => {
if (choice === "Open Databricks Config File") {
await FileUtils.openDatabricksConfigFile();
}
});
return [];
}

Expand All @@ -201,7 +208,7 @@ export class CliWrapper {
profiles = profiles.filter((p: any) => !p.account_id);

const result = [];

let hasError = false;
for (const profile of profiles) {
try {
result.push({
Expand All @@ -220,22 +227,27 @@ export class CliWrapper {
msg = `Error parsing profile ${profile.name}`;
}
ctx?.logger?.error(msg, e);
this.showConfigFileWarning(msg);
hasError = true;
}
}
return result;
}

private async showConfigFileWarning(msg: string) {
const openAction = "Open Databricks Config File";
const choice = await window.showWarningMessage(
msg,
openAction,
"Ignore"
);
if (choice === openAction) {
await FileUtils.openDatabricksConfigFile();
if (hasError) {
window
.showWarningMessage(
"There were errors in parsing some profiles",
"Open Databricks Config File",
"Show Error Logs"
)
.then(async (choice) => {
if (choice === "Open Databricks Config File") {
await FileUtils.openDatabricksConfigFile();
}
if (choice === "Show Error Logs") {
this.loggerManager.showOutputChannel("Databricks Logs");
}
});
}
return result;
}

public async getBundleSchema(): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function activate(
e
);
}
const cli = new CliWrapper(context, cliLogFilePath);
const cli = new CliWrapper(context, loggerManager, cliLogFilePath);
context.extensionPath;

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class DatabricksEnvFileManager implements Disposable {
logging.NamedLogger.getOrCreate(Loggers.Extension).debug(
`${this.userEnvPath.fsPath} does not exist. Not loading user env vars and continuing.`
);
return;
}
return await EnvVarGenerators.getUserEnvVars(this.userEnvPath);
}
Expand Down

0 comments on commit ea7b079

Please sign in to comment.