Skip to content

Commit 1332a9b

Browse files
authored
Check file in repos (#139)
1. Show a warning when workspace doesn't support files in Repos 2. Filter out clusters with DBRs that don't support files in Repos https://user-images.githubusercontent.com/40952/198026148-9f1f12de-b8d3-4b4d-a436-8110b0ca5e79.mov
1 parent ba7372d commit 1332a9b

25 files changed

+317
-105
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
"ts-mockito": "^2.6.1",
3838
"typescript": "^4.8.3"
3939
}
40-
}
40+
}

packages/databricks-sdk-js/src/api-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class ApiClientResponseError extends Error {
2929
export class ApiClient {
3030
private agent: https.Agent;
3131
private _host?: URL;
32-
get host() {
32+
33+
get host(): Promise<URL> {
3334
return (async () => {
3435
if (!this._host) {
3536
const credentials = await this.credentialProvider();
@@ -42,7 +43,7 @@ export class ApiClient {
4243
constructor(
4344
private readonly product: string,
4445
private readonly productVersion: string,
45-
readonly credentialProvider = fromDefaultChain
46+
private credentialProvider = fromDefaultChain
4647
) {
4748
this.agent = new https.Agent({
4849
keepAlive: true,

packages/databricks-sdk-js/src/services/Cluster.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,27 @@ describe(__filename, function () {
250250

251251
verify(token.isCancellationRequested).thrice();
252252
});
253+
254+
it("should parse DBR from spark_version", () => {
255+
const mockedClient = mock(ApiClient);
256+
const clusterDetails = {
257+
spark_version: "7.3.x-scala2.12",
258+
};
259+
const cluster = new Cluster(instance(mockedClient), clusterDetails);
260+
261+
const versions = [
262+
["11.x-snapshot-aarch64-scala2.12", [11, "x", "x"]],
263+
["10.4.x-scala2.12", [10, 4, "x"]],
264+
["7.3.x-scala2.12", [7, 3, "x"]],
265+
[
266+
"custom:custom-local__11.3.x-snapshot-cpu-ml-scala2.12__unknown__head__7335a01__cb1aa83__jenkins__641f1a5__format-2.lz4",
267+
[11, 3, "x"],
268+
],
269+
];
270+
271+
for (const [sparkVersion, expectedDbr] of versions) {
272+
clusterDetails.spark_version = sparkVersion as string;
273+
assert.deepEqual(cluster.dbrVersion, expectedDbr);
274+
}
275+
});
253276
});

packages/databricks-sdk-js/src/services/Cluster.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ export class Cluster {
5858
return this.clusterDetails.spark_version!;
5959
}
6060

61+
get dbrVersion(): Array<number | "x"> {
62+
const sparkVersion = this.clusterDetails.spark_version!;
63+
const match = sparkVersion.match(/^(custom:.*?__)?(.*?)-/);
64+
if (!match) {
65+
return ["x", "x", "x"];
66+
}
67+
const parts = match[2].split(".");
68+
return [
69+
parseInt(parts[0], 10) || "x",
70+
parseInt(parts[1], 10) || "x",
71+
parseInt(parts[2], 10) || "x",
72+
];
73+
}
74+
6175
get creator(): string {
6276
return this.clusterDetails.creator_user_name || "";
6377
}
@@ -169,7 +183,10 @@ export class Cluster {
169183
let context: ExecutionContext | undefined;
170184
try {
171185
context = await this.createExecutionContext();
172-
await context.execute("print('hello')");
186+
let result = await context.execute("print('hello')");
187+
if (result.result?.results?.resultType === "error") {
188+
return false;
189+
}
173190
return true;
174191
} catch (e) {
175192
return false;

packages/databricks-vscode-types/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export interface PublicApi {
77
connectionManager: {
88
onDidChangeState: Event<ConnectionState>;
99

10-
get profile(): string | undefined;
11-
get me(): string | undefined;
1210
get state(): ConnectionState;
1311
get cluster(): Cluster | undefined;
1412
get apiClient(): ApiClient | undefined;

packages/databricks-vscode-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
"dependencies": {
2525
"@databricks/databricks-sdk": "workspace:^"
2626
}
27-
}
27+
}

packages/databricks-vscode/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@
8686
},
8787
{
8888
"command": "databricks.connection.attachCluster",
89-
"title": "Attach cluster",
90-
"icon": "$(plug)"
89+
"title": "Configure cluster",
90+
"icon": "$(gear)"
9191
},
9292
{
9393
"command": "databricks.connection.attachClusterQuickPick",
94-
"title": "Attach cluster",
95-
"icon": "$(plug)"
94+
"title": "Configure cluster",
95+
"icon": "$(gear)"
9696
},
9797
{
9898
"command": "databricks.connection.detachCluster",
@@ -137,12 +137,12 @@
137137
},
138138
{
139139
"command": "databricks.connection.attachSyncDestination",
140-
"title": "Attach workspace",
141-
"icon": "$(plug)"
140+
"title": "Configure sync destination",
141+
"icon": "$(gear)"
142142
},
143143
{
144144
"command": "databricks.connection.detachSyncDestination",
145-
"title": "Detach workspace",
145+
"title": "Detach sync destination",
146146
"icon": "$(debug-disconnect)"
147147
},
148148
{
@@ -249,7 +249,7 @@
249249
},
250250
{
251251
"command": "databricks.connection.configureProject",
252-
"when": "view == configurationView && viewItem == profile",
252+
"when": "view == configurationView && viewItem == workspace",
253253
"group": "inline@1"
254254
},
255255
{
@@ -258,19 +258,19 @@
258258
"group": "inline@1"
259259
},
260260
{
261-
"command": "databricks.connection.detachCluster",
261+
"command": "databricks.connection.attachClusterQuickPick",
262262
"when": "view == configurationView && viewItem == clusterRunning || view == configurationView && viewItem == clusterStopped || view == configurationView && viewItem == clusterPending",
263263
"group": "inline@1"
264264
},
265265
{
266266
"command": "databricks.connection.attachSyncDestination",
267267
"when": "view == configurationView && viewItem == syncDetached",
268-
"group": "inline@0"
268+
"group": "inline@1"
269269
},
270270
{
271-
"command": "databricks.connection.detachSyncDestination",
271+
"command": "databricks.connection.attachSyncDestination",
272272
"when": "view == configurationView && viewItem == syncStopped || view == configurationView && viewItem == syncRunning",
273-
"group": "inline@0"
273+
"group": "inline@1"
274274
},
275275
{
276276
"command": "databricks.sync.start",
@@ -558,4 +558,4 @@
558558
],
559559
"report-dir": "coverage"
560560
}
561-
}
561+
}

packages/databricks-vscode/src/cli/BricksTasks.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class SyncTask extends Task {
7474
this.problemMatchers = ["$bricks-sync"];
7575
this.presentationOptions.echo = true;
7676
this.group = TaskGroup.Build;
77-
this.presentationOptions.reveal = TaskRevealKind.Silent;
77+
this.presentationOptions.reveal = TaskRevealKind.Always;
7878
}
7979

8080
static killAll() {
@@ -369,11 +369,13 @@ class LazyCustomSyncTerminal extends CustomSyncTerminal {
369369
window.showErrorMessage(
370370
"Can't start sync: No workspace opened!"
371371
);
372-
throw new Error("!!!!!");
372+
throw new Error(
373+
"Can't start sync: No workspace opened!"
374+
);
373375
}
374376

375-
const profile = this.connection.profile;
376-
if (!profile) {
377+
const dbWorkspace = this.connection.databricksWorkspace;
378+
if (!dbWorkspace) {
377379
window.showErrorMessage(
378380
"Can't start sync: Databricks connection not configured!"
379381
);
@@ -387,7 +389,7 @@ class LazyCustomSyncTerminal extends CustomSyncTerminal {
387389
env: {
388390
/* eslint-disable @typescript-eslint/naming-convention */
389391
BRICKS_ROOT: workspacePath,
390-
DATABRICKS_CONFIG_PROFILE: profile,
392+
DATABRICKS_CONFIG_PROFILE: dbWorkspace.profile,
391393
/* eslint-enable @typescript-eslint/naming-convention */
392394
},
393395
};

packages/databricks-vscode/src/cluster/ClusterListDataProvider.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ const mockListClustersResponse: cluster.ListClustersResponse = {
1515
cluster_name: "cluster-name-2",
1616
cluster_source: "UI",
1717
creator_user_name: "user-2",
18-
spark_version: "Spark 3.2.1",
18+
spark_version: "10.4.x-scala2.12",
1919
state: "TERMINATED",
2020
},
2121
{
2222
cluster_id: "cluster-id-1",
2323
cluster_name: "cluster-name-1",
2424
cluster_source: "UI",
2525
creator_user_name: "user-1",
26-
spark_version: "Spark 3.2.5",
26+
spark_version: "10.4.x-scala2.12",
2727
state: "RUNNING",
2828
},
2929
],
@@ -124,8 +124,8 @@ describe(__filename, () => {
124124
label: "URL:",
125125
},
126126
{
127-
description: "Spark 3.2.1",
128-
label: "Spark version:",
127+
description: "10.4.x",
128+
label: "Databricks Runtime:",
129129
},
130130
{
131131
description: "TERMINATED",

packages/databricks-vscode/src/cluster/ClusterListDataProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export class ClusterListDataProvider
135135
}
136136
children.push(
137137
{
138-
label: "Spark version:",
139-
description: element.sparkVersion,
138+
label: "Databricks Runtime:",
139+
description: element.dbrVersion.join("."),
140140
},
141141
{
142142
label: "State:",

0 commit comments

Comments
 (0)