Skip to content

Commit

Permalink
re-add interactive kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrueckl committed Jan 2, 2025
1 parent 0af2352 commit 485ef47
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

**v2.4.0:**
- added interactive kernel again ([202](/../../issues/202))

**v2.3.6:**
- fixed another issue with expiring tokens ([196](/../../issues/196))

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "databricks-vscode",
"displayName": "Databricks Power Tools",
"description": "Run notebooks cell-by-cell, browse and edit your Databricks Workspace, DBFS, Clusters, Jobs, Secrets, Repos and SQL. Supports Azure Databricks, Databricks on AWS and Databricks on GCP.",
"version": "2.3.6",
"version": "2.4.0",
"publisher": "paiqo",
"icon": "resources/databricks_extension.png",
"author": {
Expand Down
1 change: 1 addition & 0 deletions src/vscode/notebook/DatabricksKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type NotebookMagic =
export type KernelType =
"jupyter-notebook"
| "databricks-notebook"
| "interactive"

// https://code.visualstudio.com/blogs/2021/11/08/custom-notebooks
export class DatabricksKernel implements vscode.NotebookController {
Expand Down
29 changes: 29 additions & 0 deletions src/vscode/notebook/DatabricksKernelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DatabricksKernel } from './DatabricksKernel';
export abstract class DatabricksKernelManager {
private static JupyterKernelSuffix: string = "-jupyter-notebook";
private static DatabricksKernelSuffix: string = "-databricks-notebook";
private static InteractiveKernelSuffix: string = "-databricks.interactive";

private static _kernels: Map<string, DatabricksKernel> = new Map<string, DatabricksKernel>();

Expand Down Expand Up @@ -109,6 +110,21 @@ export abstract class DatabricksKernelManager {
return false;
}

static getInteractiveKernelName(cluster: iDatabricksCluster): string {
return cluster.cluster_id + DatabricksKernelManager.InteractiveKernelSuffix;
}

static getInteractiveKernel(cluster: iDatabricksCluster): DatabricksKernel {
return this.getKernel(this.getInteractiveKernelName(cluster));
}

static interactiveKernelExists(cluster: iDatabricksCluster): boolean {
if (this.getInteractiveKernel(cluster)) {
return true;
}
return false;
}

static async createKernels(cluster: iDatabricksCluster, logMessages: boolean = true): Promise<void> {
if (!this.jupyterKernelExists(cluster)) {
let notebookKernel: DatabricksKernel = new DatabricksKernel(cluster, "jupyter-notebook");
Expand All @@ -135,6 +151,19 @@ export abstract class DatabricksKernelManager {
ThisExtension.log(`Databricks Kernel for Databricks cluster '${cluster.cluster_id}' already exists!`)
}
}

if (!this.interactiveKernelExists(cluster)) {
let interactiveKernel: DatabricksKernel = new DatabricksKernel(cluster, "interactive");
this.setKernel(this.getInteractiveKernelName(cluster), interactiveKernel);
if (logMessages) {
ThisExtension.log(`Interactive Kernel for Databricks cluster '${cluster.cluster_id}' created!`)
}
}
else {
if (logMessages) {
ThisExtension.log(`Interactive Kernel for Databricks cluster '${cluster.cluster_id}' already exists!`)
}
}
}

static async removeKernels(cluster: iDatabricksCluster, logMessages: boolean = true): Promise<void> {
Expand Down

0 comments on commit 485ef47

Please sign in to comment.