-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Event Log section to the pipeline subtree (#1444)
## Changes Running state: <img width="533" alt="Screenshot 2024-11-08 at 15 15 23" src="https://github.com/user-attachments/assets/f518a051-6d1d-4ffb-bf4b-33af7482d1c8"> Completed state: <img width="515" alt="Screenshot 2024-11-08 at 15 15 50" src="https://github.com/user-attachments/assets/9f79d65d-f4de-402c-98b8-5ac447150d45"> Currently event log items aren't interactive. Requires this JS SDK PR to be merged first: databricks/databricks-sdk-js#272 ## Tests Manually
- Loading branch information
Showing
5 changed files
with
174 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/databricks-vscode/src/ui/bundle-resource-explorer/PipelineRunEventsTreeNode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { | ||
BundleResourceExplorerTreeItem, | ||
BundleResourceExplorerTreeNode, | ||
} from "./types"; | ||
import {ThemeColor, ThemeIcon, TreeItemCollapsibleState} from "vscode"; | ||
import {ContextUtils} from "./utils"; | ||
import {PipelineRunStatus} from "../../bundle/run/PipelineRunStatus"; | ||
import {TreeItemTreeNode} from "../TreeItemTreeNode"; | ||
import {ConnectionManager} from "../../configuration/ConnectionManager"; | ||
import {EventLevel} from "@databricks/databricks-sdk/dist/apis/pipelines"; | ||
|
||
export class PipelineRunEventsTreeNode | ||
implements BundleResourceExplorerTreeNode | ||
{ | ||
readonly type = "pipeline_run_events"; | ||
|
||
private get update() { | ||
return this.runMonitor?.data?.update; | ||
} | ||
|
||
private get events() { | ||
return this.runMonitor?.events; | ||
} | ||
|
||
public get url() { | ||
const {host} = this.connectionManager.databricksWorkspace ?? {}; | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const {pipeline_id, update_id} = this.update ?? {}; | ||
if (!host || !pipeline_id || !update_id) { | ||
return undefined; | ||
} | ||
return `${host}#joblist/pipelines/${pipeline_id}/updates/${update_id}`; | ||
} | ||
|
||
constructor( | ||
private readonly connectionManager: ConnectionManager, | ||
private readonly runMonitor: PipelineRunStatus, | ||
public parent?: BundleResourceExplorerTreeNode | ||
) {} | ||
|
||
getChildren(): BundleResourceExplorerTreeNode[] { | ||
if (this.events === undefined || this.events.length === 0) { | ||
return []; | ||
} | ||
const children: BundleResourceExplorerTreeNode[] = []; | ||
|
||
for (const event of this.events) { | ||
children.push( | ||
new TreeItemTreeNode( | ||
{ | ||
label: event.message ?? event.event_type ?? "unknown", | ||
iconPath: getEventIcon(event.level), | ||
tooltip: event.message, | ||
contextValue: "pipeline_event", | ||
}, | ||
this | ||
) | ||
); | ||
} | ||
|
||
return children; | ||
} | ||
|
||
getTreeItem(): BundleResourceExplorerTreeItem { | ||
if (this.events === undefined || this.events.length === 0) { | ||
return { | ||
label: "Event Log", | ||
iconPath: new ThemeIcon("loading~spin"), | ||
contextValue: ContextUtils.getContextString({ | ||
nodeType: this.type, | ||
}), | ||
collapsibleState: TreeItemCollapsibleState.None, | ||
}; | ||
} | ||
|
||
return { | ||
label: "Event Log", | ||
iconPath: new ThemeIcon("inbox"), | ||
contextValue: ContextUtils.getContextString({ | ||
nodeType: this.type, | ||
hasUrl: this.url !== undefined, | ||
}), | ||
collapsibleState: TreeItemCollapsibleState.Expanded, | ||
}; | ||
} | ||
} | ||
|
||
function getEventIcon(level: EventLevel | undefined): ThemeIcon { | ||
switch (level) { | ||
case "ERROR": | ||
return new ThemeIcon( | ||
"error", | ||
new ThemeColor("list.errorForeground") | ||
); | ||
case "INFO": | ||
return new ThemeIcon("info"); | ||
case "METRICS": | ||
return new ThemeIcon("dashboard"); | ||
case "WARN": | ||
return new ThemeIcon( | ||
"warning", | ||
new ThemeColor("list.warningForeground") | ||
); | ||
default: | ||
return new ThemeIcon("question"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters