Skip to content

Commit 0ac7b91

Browse files
committed
fix: index events by worker ordinal, as we attempt to do for log lines
also try not to show heartbeat events over and over again
1 parent feef0d8 commit 0ac7b91

File tree

8 files changed

+130
-121
lines changed

8 files changed

+130
-121
lines changed

Diff for: package-lock.json

+9-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare-dashboard/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
"access": "public"
2424
},
2525
"devDependencies": {
26-
"@types/heap": "^0.2.31",
2726
"@types/split2": "^3.2.1",
2827
"react-devtools-core": "^4.27.4"
2928
},
3029
"dependencies": {
3130
"@logdna/tail-file": "^3.0.1",
3231
"chokidar": "^3.5.3",
33-
"heap": "^0.2.7",
3432
"ink": "^3.2.0",
3533
"madwizard": "^8.0.13",
3634
"pretty-ms": "^7.0.1",

Diff for: plugins/plugin-codeflare-dashboard/src/components/Dashboard/Timeline.tsx

+11-12
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ export default class Timeline extends React.PureComponent<Props> {
3333
latest: "▏",
3434
}
3535

36+
/** This will help us compute whether we are about to overflow terminal width. */
3637
private get maxLabelLength() {
3738
return this.props.gridModels.filter((_) => !_.isQualitative).reduce((N, { title }) => Math.max(N, title.length), 0)
3839
}
3940

4041
/** @return max number of time cells, across all grids and all workers */
41-
private nTimeCells() {
42+
private get nTimeCells() {
4243
// outer loop: iterate across grids
4344
return this.props?.workers.reduce((nTimes, _) => {
4445
if (Array.isArray(_) && _.length > 0) {
@@ -95,25 +96,23 @@ export default class Timeline extends React.PureComponent<Props> {
9596
return <React.Fragment />
9697
}
9798

98-
const nTimes = this.nTimeCells()
99+
// timeStartIdx: once we overflow the viewport's width, we display
100+
// the suffix of history information, starting at this index
101+
// /- we have a 1-cell margin between row labels and timeline cells
102+
const timeStartIdx = Math.abs(Math.max(0, 1 + this.nTimeCells + this.maxLabelLength - process.stdout.columns))
103+
// total number of cells in the model -/ \- room for row labels \- fit in viewport
99104

100-
// to help us compute whether we are about to overflow terminal width
101-
const maxLabelLength = this.props.gridModels.reduce((N, spec) => {
102-
return Math.max(N, spec.title.length)
103-
}, 0)
104-
105-
// once we overflow, display the suffix of history information, starting at this index
106-
const timeStartIdx = Math.abs(Math.max(0, nTimes + maxLabelLength - process.stdout.columns))
107-
108-
if (nTimes === 0) {
105+
if (this.nTimeCells === 0) {
109106
// none of the grids have any temporal information, yet
110107
return <React.Fragment />
111108
} else {
112109
// render one `this.timeline()` row per grid
113110
return (
114111
<Box flexDirection="column">
115112
{this.props.workers.map((workers, gridIdx) => (
116-
<Box key={gridIdx}>{this.timeline(workers, this.props.gridModels[gridIdx], nTimes, timeStartIdx)}</Box>
113+
<Box key={gridIdx}>
114+
{this.timeline(workers, this.props.gridModels[gridIdx], this.nTimeCells, timeStartIdx)}
115+
</Box>
117116
))}
118117
</Box>
119118
)

Diff for: plugins/plugin-codeflare-dashboard/src/controller/dashboard/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export type Options = Arguments["parsedOptions"] & {
3535
p: string
3636
profile: string
3737
theme: string
38+
39+
/** Frequency of updates to the timeline, in seconds */
40+
u: number
41+
"update-frequency": number
3842
}
3943

4044
/** Behave like top, where the screen is cleared just for this process */
@@ -153,7 +157,7 @@ export default async function dashboard(args: Arguments<Options>, cmd: "db" | "d
153157
}
154158

155159
const historyConfig: HistoryConfig = {
156-
width: 5000,
160+
width: args.parsedOptions.u ? 1000 * args.parsedOptions.u : 5000,
157161
}
158162

159163
const db = dashboardUI(profile, jobId, await gridForA(kind, historyConfig), { scale })

Diff for: plugins/plugin-codeflare-dashboard/src/controller/dashboard/options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ export default Options
3535

3636
export const flags = {
3737
boolean: ["demo"],
38-
alias: { events: ["e"], lines: ["l"], theme: ["t"], demo: ["d"], scale: ["s"] },
38+
alias: { events: ["e"], lines: ["l"], theme: ["t"], demo: ["d"], scale: ["s"], "update-frequency": ["u"] },
3939
}

0 commit comments

Comments
 (0)