Skip to content

Commit

Permalink
rename connection manager Web
Browse files Browse the repository at this point in the history
allow all connection managers in web
  • Loading branch information
Gerhard Brueckl committed Dec 20, 2022
1 parent 8f490a0 commit d637dfa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ You can also change the following other settings:
# Setup and Configuration (Azure Connection Manager)
The Azure Connection Manager allows you to use your Azure Active Directory (AAD) account to interact with Databricks. This includes:
- loading Connections directly from your Azure Resources
- Use AAD authentication when using the DAtabricks API. No Personal Access Token (PAT) is needed!
- Use AAD authentication when using the Databricks API. No Personal Access Token (PAT) is needed!

VSCode will prompt you to use your Microsoft Account two times. The first time is to get a list of all available Azure Databricks workspaces that you have access to and then a second time to establish a connection to the selected/active workspace. Whenever you switch connection/workspace, you may get prompted again!

To activate the Azure Connection Manager, simply set the VSCode setting `databricks.connectionManager` to `Azure` and refresh your connections. No additional configurations need to be done. Currently most other connection settings like `useCodeCells`, `exportFormats`, etc. cannot currently be controlled and are set to their defaults.

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@
"enum": [
"VSCode Settings",
"Databricks CLI Profiles",
"Azure"
"Azure",
"ManualInput"
],
"default": "VSCode Settings",
"enumDescriptions": [
"All connection information is stored securely in the VSCode Settings (user or workspace).",
"Connection information is read from the Databricks CLI config file. Databricks CLI has to be configured upfront! Also supports the environment varialbe 'DATABRICKS_CONFIG_FILE'."
"Connection information is read from the Databricks CLI config file. Databricks CLI has to be configured upfront! Also supports the environment varialbe 'DATABRICKS_CONFIG_FILE'.",
"Connection information is loaded from Azure. All Azure Databricks workspaces that you have access to will show up atuomatically in the connection list.",
"You are prompted for connection information once you interact with the extension."
],
"description": "Defines how connection information is managed and stored",
"description": "Defines how connection information is managed and stored.",
"scope": "window"
},
"databricks.sensitiveValueStore": {
Expand Down
39 changes: 18 additions & 21 deletions src/ThisExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { iDatabricksConnection } from './vscode/treeviews/connections/iDatabrick
import { DatabricksConnectionManagerVSCode } from './vscode/treeviews/connections/DatabricksConnectionManagerVSCode';
import { SensitiveValueStore } from './vscode/treeviews/connections/_types';
import { DatabricksConnectionManagerCLI } from './vscode/treeviews/connections/DatabricksConnectionManagerCLI';
import { DatabricksKernel } from './vscode/notebook/DatabricksKernel';
import { DatabricksConnectionManagerWeb } from './vscode/treeviews/connections/DatabricksConnectionManagerWeb';
import { DatabricksConnectionManagerManualInput } from './vscode/treeviews/connections/DatabricksConnectionManagerManualInput';
import { DatabricksConnectionManagerAzure } from './vscode/treeviews/connections/DatabricksConnectionManagerAzure';

// https://vshaxe.github.io/vscode-extern/vscode/TreeDataProvider.html
Expand Down Expand Up @@ -63,25 +62,23 @@ export abstract class ThisExtension {

ThisExtension.readGlobalSettings();

if (ThisExtension.isVirtualWorkspace) {
// in a virtual workspace we dont have access to the credential manager required for VSCode Settings nor to the Databrick CLI config file
this._connectionManager = new DatabricksConnectionManagerWeb();
}
else {
let connectionManager = this.getConfigurationSetting("databricks.connectionManager");
switch (connectionManager.value) {
case "VSCode Settings":
this._connectionManager = new DatabricksConnectionManagerVSCode();
break;
case "Databricks CLI Profiles":
this._connectionManager = new DatabricksConnectionManagerCLI();
break;
case "Azure":
this._connectionManager = new DatabricksConnectionManagerAzure();
break;
default:
this.log("'" + connectionManager + "' is not a valid value for config setting 'databricks.connectionManager!");
}
let connectionManager = this.getConfigurationSetting<string>("databricks.connectionManager", this.SettingScope, true);
switch (connectionManager.value) {
case "VSCode Settings":
this._connectionManager = new DatabricksConnectionManagerVSCode();
break;
case "Databricks CLI Profiles":
this._connectionManager = new DatabricksConnectionManagerCLI();
break;
case "Azure":
this._connectionManager = new DatabricksConnectionManagerAzure();
break;
case "ManualInput":
this._connectionManager = new DatabricksConnectionManagerManualInput();
break;
default:
this.log("'" + connectionManager + "' is not a valid value for config setting 'databricks.connectionManager!");

}

await this.ConnectionManager.initialize();
Expand Down
14 changes: 9 additions & 5 deletions src/vscode/notebook/DatabricksKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export class DatabricksKernel implements vscode.NotebookController {
async _onDidOpenNotebookDocument(notebook: vscode.NotebookDocument) {
// set this controller as recommended Kernel for notebooks opened via dbws:/ file system or from or local sync folder
if (notebook.uri.scheme == "dbws" || notebook.uri.toString().startsWith(ThisExtension.ActiveConnection.localSyncFolder.toString())) {
this._controller.updateNotebookAffinity(notebook, vscode.NotebookControllerAffinity.Preferred);
this.Controller.updateNotebookAffinity(notebook, vscode.NotebookControllerAffinity.Preferred);
}

if(notebook.uri.scheme == "vscode-interactive")
{
}
}

Expand Down Expand Up @@ -219,13 +223,13 @@ export class DatabricksKernel implements vscode.NotebookController {
readonly onDidChangeSelectedNotebooks: vscode.Event<{ readonly notebook: vscode.NotebookDocument; readonly selected: boolean; }>;
updateNotebookAffinity(notebook: vscode.NotebookDocument, affinity: vscode.NotebookControllerAffinity): void { }

async executeHandler(cells: vscode.NotebookCell[], _notebook: vscode.NotebookDocument, _controller: vscode.NotebookController): Promise<void> {
let execContext: ExecutionContext = this.getNotebookContext(_notebook.uri);
async executeHandler(cells: vscode.NotebookCell[], notebook: vscode.NotebookDocument, controller: vscode.NotebookController): Promise<void> {
let execContext: ExecutionContext = this.getNotebookContext(notebook.uri);
if (!execContext) {
ThisExtension.setStatusBar("Initializing Kernel ...", true);
execContext = await this.initializeExecutionContext()
this.setNotebookContext(_notebook.uri, execContext);
await this.updateRepoContext(_notebook.uri);
this.setNotebookContext(notebook.uri, execContext);
await this.updateRepoContext(notebook.uri);
ThisExtension.setStatusBar("Kernel initialized!");
}
for (let cell of cells) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { DatabricksConnectionManager } from './DatabricksConnectionManager';
import { DatabricksConnectionTreeItem } from './DatabricksConnectionTreeItem';


export class DatabricksConnectionManagerWeb extends DatabricksConnectionManager {
export class DatabricksConnectionManagerManualInput extends DatabricksConnectionManager {

constructor() {
super();
this._initialized = false;
}

async initialize(): Promise<void> {
ThisExtension.log("Initializing ConnectionManager Web ...");
ThisExtension.log("Initializing ConnectionManager ManualInput ...");
await this.loadConnections();

if (this._connections.length == 0) {
Expand Down

0 comments on commit d637dfa

Please sign in to comment.