Skip to content

Commit

Permalink
added support for dbutils.notebook.run in Live-mode (via mounting `…
Browse files Browse the repository at this point in the history
…dbws:/...` in VSCode workspace)
  • Loading branch information
Gerhard Brueckl committed Sep 28, 2022
1 parent 9bd9a53 commit 90220b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ The extensions can be downloaded from the official Visual Studio Code extension
# Release Notes

**v1.1.4:**
- added support for `dbutils.notebook.run` in Live-mode (via mounting `dbws:/...` in VSCode workspace)
- fixed some issues with legacy DBFS and Workspace browser
- fixed an issue with workspace browser file compare
- fixed an issue when opening a job in the browser
Expand Down
20 changes: 12 additions & 8 deletions src/vscode/notebook/DatabricksKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ export class DatabricksKernel implements vscode.NotebookController {
}
}

private parseCommand(cmd: string): [ContextLanguage, string, NotebookMagic] {
private parseCommand(cell: vscode.NotebookCell): [ContextLanguage, string, NotebookMagic] {
let cmd: string = cell.document.getText();
let magicText: string = undefined;
let commandText: string = cmd;
let language: ContextLanguage = this.Language;
if (cmd[0] == "%") {
let lines = cmd.split('\n');
let magicText = lines[0].split(" ")[0].slice(1).trim();
let commandText = lines.slice(1).join('\n');
let language: ContextLanguage = this.Language;
magicText = lines[0].split(" ")[0].slice(1).trim();
commandText = lines.slice(1).join('\n');
if (["python", "sql", "scala", "r"].includes(magicText)) {
language = magicText as ContextLanguage;
}
Expand All @@ -185,10 +188,11 @@ export class DatabricksKernel implements vscode.NotebookController {
language = "python";
commandText = cmd;
}

return [language, commandText, magicText as NotebookMagic];
}
return [this.Language, cmd, undefined];

commandText = commandText.replace(/dbutils\.notebook\.run\((["'])\./gm, "dbutils.notebook.run($1" + FSHelper.parent(cell.notebook.uri).path);

return [language, commandText, magicText as NotebookMagic];
}

private async _doExecution(cell: vscode.NotebookCell, context: ExecutionContext): Promise<void> {
Expand All @@ -203,7 +207,7 @@ export class DatabricksKernel implements vscode.NotebookController {
let language: ContextLanguage = null;
let magic: NotebookMagic = null;

[language, commandText, magic] = this.parseCommand(commandText);
[language, commandText, magic] = this.parseCommand(cell);

ThisExtension.log("Executing " + language + ":\n" + commandText);

Expand Down

0 comments on commit 90220b7

Please sign in to comment.