Skip to content

Commit c1eefa7

Browse files
Fix run on cluster for multi file setups (#463)
1 parent bdf610d commit c1eefa7

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,9 @@ export class DatabricksRuntime implements Disposable {
130130
await executionContext.destroy();
131131
});
132132

133-
const currentFsRoot =
134-
this.connection.databricksWorkspace?.currentFsRoot;
135133
// We wait for sync to complete so that the local files are consistant
136134
// with the remote repo files
137-
log(
138-
`Synchronizing code to ${syncDestination.remoteUri.relativePath(
139-
new RemoteUri(currentFsRoot ?? "")
140-
)} ...`
141-
);
135+
log(`Synchronizing code to ${syncDestination.remoteUri.path} ...`);
142136

143137
this.disposables.push(
144138
this.codeSynchronizer.onDidChangeState((state) => {
@@ -252,7 +246,8 @@ export class DatabricksRuntime implements Disposable {
252246
);
253247

254248
const argv = [
255-
syncDestination.localToRemote(new LocalUri(Uri.file(program))).path,
249+
syncDestination.localToRemote(new LocalUri(Uri.file(program)))
250+
.workspacePrefixPath,
256251
...args,
257252
];
258253

@@ -276,7 +271,7 @@ export class DatabricksRuntime implements Disposable {
276271
);
277272
bootstrap = bootstrap.replace(
278273
'"REPO_PATH"',
279-
`"${syncDestination.remoteUri.path}"`
274+
`"${syncDestination.remoteUri.workspacePrefixPath}"`
280275
);
281276
bootstrap = bootstrap.replace(
282277
"args = []",

packages/databricks-vscode/src/test/e2e/run_on_cluster.e2e.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ describe("Run python on cluster", async function () {
3535
workspacePath: process.env["TEST_REPO_PATH"],
3636
})
3737
);
38+
await fs.mkdir(path.join(projectDir, "nested"));
3839
await fs.writeFile(
39-
path.join(projectDir, "hello.py"),
40-
`spark.sql('SELECT "hello world"').show()`
40+
path.join(projectDir, "nested", "hello.py"),
41+
[`from lib import func`, "func(spark)"].join("\n")
42+
);
43+
44+
await fs.writeFile(
45+
path.join(projectDir, "lib.py"),
46+
[
47+
"def func(spark):",
48+
`\tspark.sql('SELECT "hello world"').show()`,
49+
].join("\n")
4150
);
4251
await dismissNotifications();
4352
});

0 commit comments

Comments
 (0)