Skip to content

Commit 613e8f1

Browse files
authored
Some polish (#187)
- make run log less verbose - show loading indicator when loading profile - rename dbfs to wsfs because we call it `Workspace File System`
1 parent c631fdd commit 613e8f1

13 files changed

+165
-154
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe(__filename, () => {
1818
let provider = new BricksTaskProvider(connection, cli);
1919
let tasks = provider.provideTasks();
2020

21-
assert.equal(tasks.length, 1);
21+
assert.equal(tasks.length, 2);
2222
assert.equal(tasks[0].definition.type, "databricks");
2323
assert.equal(tasks[0].definition.task, "sync");
2424
});

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ export class BricksTaskProvider implements TaskProvider {
3232
"incremental",
3333
(state: SyncState) => {}
3434
),
35+
new SyncTask(
36+
this.connection,
37+
this.cli,
38+
"full",
39+
(state: SyncState) => {}
40+
),
3541
];
3642
}
3743
resolveTask(): Task | undefined {
@@ -43,20 +49,16 @@ export class SyncTask extends Task {
4349
constructor(
4450
connection: ConnectionManager,
4551
cli: CliWrapper,
46-
// TODO: https://github.com/databricks/databricks-vscode/issues/111
47-
// use syncType to decide the sync type for bricks cli. Right now bricks cli
48-
// only supports full sync for multiple profiles.
49-
// see: https://github.com/databricks/bricks/issues/71
5052
syncType: SyncType,
5153
syncStateCallback: (state: SyncState) => void
5254
) {
5355
super(
5456
{
5557
type: "databricks",
56-
task: "sync",
58+
task: syncType === "full" ? "sync-full" : "sync",
5759
},
5860
TaskScope.Workspace,
59-
"sync",
61+
syncType === "full" ? "sync-full" : "sync",
6062
"databricks",
6163
new CustomExecution(async (): Promise<Pseudoterminal> => {
6264
return new LazyCustomSyncTerminal(

packages/databricks-vscode/src/cli/CliWrapper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe(__filename, () => {
2626
const mapper = new SyncDestination(
2727
instance(mock(Repo)),
2828
Uri.from({
29-
scheme: "dbws",
29+
scheme: "wsfs",
3030
path: "/Workspace/Repos/fabian.jakobs@databricks.com/notebook-best-practices",
3131
}),
3232
Uri.file("/Users/fabian.jakobs/Desktop/notebook-best-practices")

packages/databricks-vscode/src/configuration/ConfigurationDataProvider.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe(__filename, () => {
2020
beforeEach(() => {
2121
disposables = [];
2222
connectionManagerMock = mock(ConnectionManager);
23+
when(connectionManagerMock.state).thenReturn("DISCONNECTED");
2324
onChangeClusterListener = () => {};
2425
onChangeSyncDestinationListener = () => {};
2526

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

Lines changed: 136 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -53,145 +53,152 @@ export class ConfigurationDataProvider
5353
return element;
5454
}
5555

56-
getChildren(
56+
async getChildren(
5757
element?: TreeItem | undefined
58-
): ProviderResult<Array<TreeItem>> {
59-
if (this.connectionManager.state !== "CONNECTED") {
60-
return [];
58+
): Promise<Array<TreeItem>> {
59+
switch (this.connectionManager.state) {
60+
case "CONNECTED":
61+
break;
62+
case "CONNECTING":
63+
await this.connectionManager.waitForConnect();
64+
break;
65+
case "DISCONNECTED":
66+
return [];
6167
}
62-
return (async () => {
63-
let cluster = this.connectionManager.cluster;
64-
let syncDestination = this.connectionManager.syncDestination;
6568

66-
if (!element) {
67-
let children: Array<TreeItem> = [];
69+
let cluster = this.connectionManager.cluster;
70+
let syncDestination = this.connectionManager.syncDestination;
71+
72+
if (!element) {
73+
let children: Array<TreeItem> = [];
74+
children.push({
75+
label: `Workspace`,
76+
iconPath: new ThemeIcon("account"),
77+
id: "WORKSPACE",
78+
collapsibleState: TreeItemCollapsibleState.Expanded,
79+
contextValue: "workspace",
80+
});
81+
82+
if (cluster) {
6883
children.push({
69-
label: `Workspace`,
70-
iconPath: new ThemeIcon("account"),
71-
id: "WORKSPACE",
84+
label: "Cluster",
85+
iconPath: new ThemeIcon("server"),
86+
id: "CLUSTER",
7287
collapsibleState: TreeItemCollapsibleState.Expanded,
73-
contextValue: "workspace",
88+
contextValue:
89+
cluster.state === "RUNNING"
90+
? "clusterRunning"
91+
: cluster.state === "PENDING"
92+
? "clusterPending"
93+
: "clusterStopped",
94+
});
95+
} else {
96+
children.push({
97+
label: `Cluster - "None attached"`,
98+
iconPath: new ThemeIcon("server"),
99+
id: "CLUSTER",
100+
collapsibleState: TreeItemCollapsibleState.Expanded,
101+
contextValue: "clusterDetached",
74102
});
75-
76-
if (cluster) {
77-
children.push({
78-
label: "Cluster",
79-
iconPath: new ThemeIcon("server"),
80-
id: "CLUSTER",
81-
collapsibleState: TreeItemCollapsibleState.Expanded,
82-
contextValue:
83-
cluster.state === "RUNNING"
84-
? "clusterRunning"
85-
: cluster.state === "PENDING"
86-
? "clusterPending"
87-
: "clusterStopped",
88-
});
89-
} else {
90-
children.push({
91-
label: `Cluster - "None attached"`,
92-
iconPath: new ThemeIcon("server"),
93-
id: "CLUSTER",
94-
collapsibleState: TreeItemCollapsibleState.Expanded,
95-
contextValue: "clusterDetached",
96-
});
97-
}
98-
99-
if (syncDestination) {
100-
// TODO: Add another icon over here for in_progress state
101-
// DECO-220
102-
children.push({
103-
label: `Repo`,
104-
iconPath: new ThemeIcon("repo"),
105-
id: "REPO",
106-
collapsibleState: TreeItemCollapsibleState.Expanded,
107-
contextValue:
108-
this.sync.state === "WATCHING_FOR_CHANGES" ||
109-
this.sync.state === "IN_PROGRESS"
110-
? "syncRunning"
111-
: "syncStopped",
112-
});
113-
} else {
114-
children.push({
115-
label: `Repo - "None attached"`,
116-
iconPath: new ThemeIcon("repo"),
117-
id: "REPO",
118-
collapsibleState: TreeItemCollapsibleState.Expanded,
119-
contextValue: "syncDetached",
120-
});
121-
}
122-
123-
return children;
124103
}
125104

126-
const dbWorkspace = this.connectionManager.databricksWorkspace;
127-
if (element.id === "WORKSPACE" && dbWorkspace) {
128-
return [
129-
{
130-
label: "Profile",
131-
description: dbWorkspace.profile,
132-
collapsibleState: TreeItemCollapsibleState.None,
133-
},
134-
{
135-
label: "User",
136-
description: dbWorkspace.userName,
137-
collapsibleState: TreeItemCollapsibleState.None,
138-
},
139-
{
140-
label: "Host",
141-
description: dbWorkspace.host.toString(),
142-
collapsibleState: TreeItemCollapsibleState.None,
143-
contextValue: "databricks-link",
144-
},
145-
];
105+
if (syncDestination) {
106+
// TODO: Add another icon over here for in_progress state
107+
// DECO-220
108+
children.push({
109+
label: `Repo`,
110+
iconPath: new ThemeIcon("repo"),
111+
id: "REPO",
112+
collapsibleState: TreeItemCollapsibleState.Expanded,
113+
contextValue:
114+
this.sync.state === "WATCHING_FOR_CHANGES" ||
115+
this.sync.state === "IN_PROGRESS"
116+
? "syncRunning"
117+
: "syncStopped",
118+
});
119+
} else {
120+
children.push({
121+
label: `Repo - "None attached"`,
122+
iconPath: new ThemeIcon("repo"),
123+
id: "REPO",
124+
collapsibleState: TreeItemCollapsibleState.Expanded,
125+
contextValue: "syncDetached",
126+
});
146127
}
147128

148-
if (element.id?.startsWith("CLUSTER") && cluster) {
149-
let clusterItem =
150-
ClusterListDataProvider.clusterNodeToTreeItem(cluster);
151-
152-
return [
153-
{
154-
label: "Name:",
155-
description: cluster.name,
156-
iconPath: clusterItem.iconPath,
157-
collapsibleState: TreeItemCollapsibleState.None,
158-
},
159-
...(await ClusterListDataProvider.clusterNodeToTreeItems(
160-
cluster
161-
)),
162-
];
163-
}
129+
return children;
130+
}
164131

165-
if (element.id === "REPO" && syncDestination) {
166-
return [
167-
{
168-
label: `Name:`,
169-
description: syncDestination.name,
170-
iconPath:
171-
this.sync.state === "WATCHING_FOR_CHANGES" ||
172-
this.sync.state === "IN_PROGRESS"
173-
? new ThemeIcon("debug-start")
174-
: new ThemeIcon("debug-stop"),
175-
collapsibleState: TreeItemCollapsibleState.None,
176-
},
177-
{
178-
label: `URL:`,
179-
description: await this.connectionManager
180-
.syncDestination?.repo.url,
181-
contextValue: "databricks-link",
182-
},
183-
{
184-
label: `State:`,
185-
description: this.sync.state,
186-
collapsibleState: TreeItemCollapsibleState.None,
187-
},
188-
{
189-
label: `Path:`,
190-
description: syncDestination.path.path,
191-
collapsibleState: TreeItemCollapsibleState.None,
192-
},
193-
];
194-
}
195-
})();
132+
const dbWorkspace = this.connectionManager.databricksWorkspace;
133+
if (element.id === "WORKSPACE" && dbWorkspace) {
134+
return [
135+
{
136+
label: "Profile",
137+
description: dbWorkspace.profile,
138+
collapsibleState: TreeItemCollapsibleState.None,
139+
},
140+
{
141+
label: "User",
142+
description: dbWorkspace.userName,
143+
collapsibleState: TreeItemCollapsibleState.None,
144+
},
145+
{
146+
label: "Host",
147+
description: dbWorkspace.host.toString(),
148+
collapsibleState: TreeItemCollapsibleState.None,
149+
contextValue: "databricks-link",
150+
},
151+
];
152+
}
153+
154+
if (element.id?.startsWith("CLUSTER") && cluster) {
155+
let clusterItem =
156+
ClusterListDataProvider.clusterNodeToTreeItem(cluster);
157+
158+
return [
159+
{
160+
label: "Name:",
161+
description: cluster.name,
162+
iconPath: clusterItem.iconPath,
163+
collapsibleState: TreeItemCollapsibleState.None,
164+
},
165+
...(await ClusterListDataProvider.clusterNodeToTreeItems(
166+
cluster
167+
)),
168+
];
169+
}
170+
171+
if (element.id === "REPO" && syncDestination) {
172+
return [
173+
{
174+
label: `Name:`,
175+
description: syncDestination.name,
176+
iconPath:
177+
this.sync.state === "WATCHING_FOR_CHANGES" ||
178+
this.sync.state === "IN_PROGRESS"
179+
? new ThemeIcon("debug-start")
180+
: new ThemeIcon("debug-stop"),
181+
collapsibleState: TreeItemCollapsibleState.None,
182+
},
183+
{
184+
label: `URL:`,
185+
description: await this.connectionManager.syncDestination
186+
?.repo.url,
187+
contextValue: "databricks-link",
188+
},
189+
{
190+
label: `State:`,
191+
description: this.sync.state,
192+
collapsibleState: TreeItemCollapsibleState.None,
193+
},
194+
{
195+
label: `Path:`,
196+
description: syncDestination.path.path,
197+
collapsibleState: TreeItemCollapsibleState.None,
198+
},
199+
];
200+
}
201+
202+
return [];
196203
}
197204
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class ConnectionCommands implements Disposable {
238238
const repoPath = quickPick.selectedItems[0].path;
239239
await this.connectionManager.attachSyncDestination(
240240
Uri.from({
241-
scheme: "dbws",
241+
scheme: "wsfs",
242242
path: repoPath,
243243
})
244244
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class ConnectionManager {
189189
if (projectConfigFile.config.workspacePath) {
190190
await this.attachSyncDestination(
191191
Uri.from({
192-
scheme: "dbws",
192+
scheme: "wsfs",
193193
path: projectConfigFile.config.workspacePath,
194194
}),
195195
false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ProjectConfigFileWatcher implements Disposable {
4343
if (configFile.workspacePath) {
4444
await connectionManager.attachSyncDestination(
4545
Uri.from({
46-
scheme: "dbws",
46+
scheme: "wsfs",
4747
path: configFile.workspacePath,
4848
})
4949
);

0 commit comments

Comments
 (0)