Skip to content

Commit

Permalink
no need for launch configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fjakobs committed Jul 28, 2023
1 parent fea48f3 commit a6e2b4d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@
{
"command": "databricks.run.debugEditorContents",
"when": "resourceLangId == python"
}, {
},
{
"command": "databricks.run.runEditorContentsAsWorkflow",
"when": "resourceLangId == python || resourceExtname == .ipynb"
},
Expand Down
40 changes: 40 additions & 0 deletions packages/databricks-vscode/src/run/DatabricksRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import {
CancellationTokenSource,
commands,
debug,
Disposable,
Event,
EventEmitter,
ExtensionContext,
Uri,
workspace,
} from "vscode";

import {
Expand Down Expand Up @@ -214,6 +216,10 @@ export class DatabricksRuntime implements Disposable {
)} ...\n`
);

if (shouldDebug) {
setTimeout(this.attachDebugger.bind(this), 3000);
}

this.state = "EXECUTING";
const response = await executionContext.execute(
await this.compileCommandString(
Expand Down Expand Up @@ -291,6 +297,40 @@ export class DatabricksRuntime implements Disposable {
}
}

private async attachDebugger() {
// TODO start tunnel process
const mapper = this.connection.syncDestinationMapper;
if (!mapper) {
return;
}

const workspaceFolder =
workspace.workspaceFolders && workspace.workspaceFolders[0];

if (!workspaceFolder) {
return;
}

const debugConfig = {
type: "python",
name: "Databricks: Remote Attach Debugger",
request: "attach",
connect: {
host: "localhost",
port: 5678,
},
pathMappings: [
{
localRoot: workspaceFolder.uri.path,
remoteRoot: mapper.remoteUri.workspacePrefixPath,
},
],
justMyCode: true,
};

debug.startDebugging(workspaceFolder, debugConfig);
}

private async compileCommandString(
program: string,
args: Array<string>,
Expand Down

0 comments on commit a6e2b4d

Please sign in to comment.