Skip to content

Commit d8ecb0a

Browse files

File tree

6 files changed

+242
-18
lines changed

6 files changed

+242
-18
lines changed

packages/databricks-vscode/src/configuration/SyncDestination.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,14 @@ export class SyncDestination {
110110
);
111111
return Uri.joinPath(this.repoPath, relativePath).path;
112112
}
113+
114+
remoteToLocal(remotePath: Uri): Uri {
115+
assert.equal(remotePath.scheme, "wsfs");
116+
if (!remotePath.path.startsWith(this.repoPath.path)) {
117+
throw new Error("remote path is not within the target repo");
118+
}
119+
120+
const relativePath = remotePath.path.replace(this.repoPath.path, "");
121+
return Uri.joinPath(this.vscodeWorkspacePath, relativePath);
122+
}
113123
}

packages/databricks-vscode/src/run/DatabricksDebugAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export class DatabricksDebugSession extends LoggingDebugSession {
116116
}
117117

118118
body.source = this.createSource(filePath);
119-
body.line = this.convertDebuggerLineToClient(line);
120-
body.column = this.convertDebuggerColumnToClient(column);
119+
body.line = line;
120+
body.column = column;
121121

122122
this.sendEvent(e);
123123
}

packages/databricks-vscode/src/run/DatabricksRuntime.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ describe(__filename, () => {
152152

153153
await runtime.start("/Desktop/workspaces/hello.py", [], {});
154154

155-
assert.equal(outputs.length, 7);
155+
assert.equal(outputs.length, 6);
156156
assert.equal(outputs[4].text, "something went wrong");
157-
assert.equal(outputs[5].text, "summary");
158157
});
159158
});

packages/databricks-vscode/src/run/DatabricksRuntime.ts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {ConnectionManager} from "../configuration/ConnectionManager";
1919
import {promptForClusterStart} from "./prompts";
2020
import {CodeSynchronizer} from "../sync/CodeSynchronizer";
2121
import * as fs from "node:fs/promises";
22+
import {parseErrorResult} from "./ErrorParser";
23+
import path from "node:path";
2224

2325
export interface OutputEvent {
2426
type: "prio" | "out" | "err";
@@ -175,20 +177,33 @@ export class DatabricksRuntime implements Disposable {
175177
column: 0,
176178
});
177179
} else if (result.results!.resultType === "error") {
178-
this._onDidSendOutputEmitter.fire({
179-
type: "out",
180-
text: (result.results! as any).cause,
181-
filePath: program,
182-
line: 0,
183-
column: 0,
184-
});
185-
this._onDidSendOutputEmitter.fire({
186-
type: "out",
187-
text: (result.results! as any).summary,
188-
filePath: program,
189-
line: 0,
190-
column: 0,
191-
});
180+
const frames = parseErrorResult(result.results!);
181+
for (const frame of frames) {
182+
let localFile = "";
183+
try {
184+
if (frame.file) {
185+
localFile = syncDestination.remoteToLocal(
186+
Uri.from({
187+
scheme: "wsfs",
188+
path: path.normalize(frame.file),
189+
})
190+
).fsPath;
191+
192+
frame.text = frame.text.replace(
193+
frame.file,
194+
localFile
195+
);
196+
}
197+
} catch (e) {}
198+
199+
this._onDidSendOutputEmitter.fire({
200+
type: "out",
201+
text: frame.text,
202+
filePath: localFile,
203+
line: frame.line || 0,
204+
column: 0,
205+
});
206+
}
192207
} else {
193208
this._onDidSendOutputEmitter.fire({
194209
type: "out",

0 commit comments

Comments
 (0)