Skip to content

Commit 5ffce16

Browse files
committed
fix: rename --lines to --events
1 parent da7715a commit 5ffce16

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

plugins/plugin-codeflare-dashboard/src/components/Dashboard/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export type State = {
5050
agoInterval: ReturnType<typeof setInterval>
5151

5252
/** Lines of raw output to be displayed */
53-
lines: UpdatePayload["lines"]
53+
events: UpdatePayload["events"]
5454

5555
/** Controller that allows us to shut down gracefully */
5656
watchers: { quit: () => void }[]
@@ -87,7 +87,7 @@ export default class Dashboard extends React.PureComponent<Props, State> {
8787
this.setState((curState) => ({
8888
firstUpdate: (curState && curState.firstUpdate) || Date.now(), // TODO pull from the events
8989
lastUpdate: Date.now(), // TODO pull from the events
90-
lines: !model.lines || model.lines.length === 0 ? curState?.lines : model.lines,
90+
events: !model.events || model.events.length === 0 ? curState?.events : model.events,
9191
workers: !curState?.workers
9292
? [model.workers]
9393
: [...curState.workers.slice(0, gridIdx), model.workers, ...curState.workers.slice(gridIdx + 1)],
@@ -101,9 +101,9 @@ export default class Dashboard extends React.PureComponent<Props, State> {
101101
return this.props.grids.filter((_) => _ !== null) as GridSpec[]
102102
}
103103

104-
/** @return current `lines` model */
105-
private get lines(): UpdatePayload["lines"] {
106-
return this.state?.lines
104+
/** @return current `events` model */
105+
private get events(): UpdatePayload["events"] {
106+
return this.state?.events
107107
}
108108

109109
/** @return first update time */
@@ -182,12 +182,12 @@ export default class Dashboard extends React.PureComponent<Props, State> {
182182
return this.ago(Date.now() - millis)
183183
}
184184

185-
/** Render log lines */
185+
/** Render log lines and events */
186186
private footer() {
187-
if (!this.lines) {
187+
if (!this.events) {
188188
return <React.Fragment />
189189
} else {
190-
const rows = this.lines.map(({ line, timestamp }) => {
190+
const rows = this.events.map(({ line, timestamp }) => {
191191
// the controller (controller/dashboard/utilization/Live)
192192
// leaves a {timestamp} breadcrumb in the raw line text, so
193193
// that we,as the view, can inject a "5m ago" text, while

plugins/plugin-codeflare-dashboard/src/components/Dashboard/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export type UpdatePayload = {
4242
/** Per-worker status info */
4343
workers: Worker[]
4444

45-
/** Lines of raw output to be displayed */
46-
lines?: { line: string; timestamp: number }[]
45+
/** Lines of raw event lines to be displayed */
46+
events?: { line: string; timestamp: number }[]
4747
}
4848

4949
/** Callback from controller when it has updated data */

plugins/plugin-codeflare-dashboard/src/controller/dashboard/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function gridFor(
8989
profile: string,
9090
jobId: string,
9191
historyConfig: HistoryConfig,
92-
opts: Pick<Options, "demo" | "theme" | "lines">
92+
opts: Pick<Options, "demo" | "theme" | "events">
9393
): Promise<GridSpec> {
9494
const tails = await tailf(kind, profile, jobId)
9595
return kind === "status" ? status(tails, historyConfig, opts) : utilization(kind, tails, historyConfig, opts)
@@ -100,7 +100,7 @@ async function allGridsFor(
100100
profile: string,
101101
jobId: string,
102102
historyConfig: HistoryConfig,
103-
opts: Pick<Options, "demo" | "theme" | "lines">
103+
opts: Pick<Options, "demo" | "theme" | "events">
104104
) {
105105
const usesGpus = opts.demo || (await import("../env.js").then((_) => _.usesGpus(profile, jobId)))
106106

@@ -124,7 +124,7 @@ async function allGridsFor(
124124
}
125125

126126
export default async function dashboard(args: Arguments<Options>, cmd: "db" | "dashboard") {
127-
const { demo, theme, lines } = args.parsedOptions
127+
const { demo, theme, events } = args.parsedOptions
128128

129129
const scale = args.parsedOptions.s || 1
130130

@@ -144,9 +144,9 @@ export default async function dashboard(args: Arguments<Options>, cmd: "db" | "d
144144
historyConfig: HistoryConfig
145145
): Promise<null | GridSpec | (null | GridSpec)[]> => {
146146
if (kind === "all") {
147-
return allGridsFor(profile, jobId, historyConfig, { demo, theme, lines })
147+
return allGridsFor(profile, jobId, historyConfig, { demo, theme, events })
148148
} else if (isSupportedGrid(kind)) {
149-
return gridFor(kind, profile, jobId, historyConfig, { demo, theme, lines })
149+
return gridFor(kind, profile, jobId, historyConfig, { demo, theme, events })
150150
} else {
151151
return null
152152
}

plugins/plugin-codeflare-dashboard/src/controller/dashboard/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ type Options = {
2424
/** Theme to use for worker status */
2525
theme: string
2626

27-
/** Number of lines of log messages to show [default: 8] */
28-
lines: number
27+
/** Number of lines of events to show [default: 8] */
28+
events: number
2929
}
3030

3131
export default Options
3232

3333
export const flags = {
3434
boolean: ["demo"],
35-
alias: { lines: ["l"], theme: ["t"], demo: ["d"], scale: ["s"] },
35+
alias: { events: ["e"], theme: ["t"], demo: ["d"], scale: ["s"] },
3636
}

plugins/plugin-codeflare-dashboard/src/controller/dashboard/status/Live.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { OnData, Worker } from "../../../components/Dashboard/types.js"
2626

2727
import { rankFor, stateFor } from "./states.js"
2828

29-
type Line = { line: string; stateRank: number; timestamp: number }
29+
type Event = { line: string; stateRank: number; timestamp: number }
3030

3131
/**
3232
* Maintain a model of live data from a given set of file streams
@@ -37,11 +37,11 @@ export default class Live {
3737
/** Model of status per worker */
3838
private readonly workers: Record<string, Worker> = {}
3939

40-
/** Number of lines of output to retain. TODO this depends on height of terminal? */
40+
/** Number of lines of event output to retain. TODO this depends on height of terminal? */
4141
private static readonly MAX_HEAP = 1000
4242

4343
/** Model of the lines of output */
44-
private readonly lines = new Heap<Line>((a, b) => {
44+
private readonly events = new Heap<Event>((a, b) => {
4545
if (a.line === b.line) {
4646
return a.timestamp - b.timestamp
4747
}
@@ -59,7 +59,7 @@ export default class Live {
5959
private readonly tails: Promise<Tail>[],
6060
cb: OnData,
6161
styleOf: Record<WorkerState, TextProps>,
62-
private readonly opts: Pick<Options, "lines">
62+
private readonly opts: Pick<Options, "events">
6363
) {
6464
tails.map((tailf) => {
6565
tailf.then(({ stream }) => {
@@ -77,7 +77,7 @@ export default class Live {
7777

7878
if (!name || !timestamp) {
7979
// console.error("Bad status record", line)
80-
// this.pushLineAndPublish(data, metric, timestamp, cb)
80+
// this.pushEventAndPublish(data, metric, timestamp, cb)
8181
return
8282
} else if (!metric) {
8383
// ignoring this line
@@ -111,7 +111,7 @@ export default class Live {
111111

112112
// inform the UI that we have updates
113113
cb({
114-
lines: this.pushLine(data, metric, timestamp),
114+
events: this.pushEvent(data, metric, timestamp),
115115
workers: Object.values(this.workers),
116116
})
117117
}
@@ -130,9 +130,9 @@ export default class Live {
130130
})
131131
}
132132

133-
private readonly lookup: Record<string, Line> = {}
134-
/** Add `line` to our circular buffer `this.lines` */
135-
private pushLine(line: string, metric: WorkerState, timestamp: number) {
133+
private readonly lookup: Record<string, Event> = {}
134+
/** Add `line` to our heap `this.events` */
135+
private pushEvent(line: string, metric: WorkerState, timestamp: number) {
136136
const key = line
137137
.replace(/\s*(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z)\s*/, "{timestamp}")
138138
.replace(/pod\/torchx-\S+ /, "") // worker name in torchx
@@ -150,29 +150,29 @@ export default class Live {
150150
const already = this.lookup[rec.line]
151151
if (already) {
152152
already.timestamp = timestamp
153-
this.lines.updateItem(already)
153+
this.events.updateItem(already)
154154
} else {
155155
this.lookup[rec.line] = rec
156-
if (this.lines.size() >= Live.MAX_HEAP) {
157-
this.lines.replace(rec)
156+
if (this.events.size() >= Live.MAX_HEAP) {
157+
this.events.replace(rec)
158158
} else {
159-
this.lines.push(rec)
159+
this.events.push(rec)
160160
}
161161
}
162162

163-
if (this.opts.lines === 0) {
163+
if (this.opts.events === 0) {
164164
return []
165165
} else {
166-
return this.lines
166+
return this.events
167167
.toArray()
168-
.slice(0, this.opts.lines || 8)
168+
.slice(0, this.opts.events || 8)
169169
.sort((a, b) => a.timestamp - b.timestamp)
170170
}
171171
}
172172

173-
/** `pushLine` and then pass the updated model to `cb` */
174-
private pushLineAndPublish(line: string, metric: WorkerState, timestamp: number, cb: OnData) {
175-
cb({ lines: this.pushLine(line, metric, timestamp), workers: Object.values(this.workers) })
173+
/** `pushEvent` and then pass the updated model to `cb` */
174+
private pushEventAndPublish(line: string, metric: WorkerState, timestamp: number, cb: OnData) {
175+
cb({ events: this.pushEvent(line, metric, timestamp), workers: Object.values(this.workers) })
176176
}
177177

178178
private asMillisSinceEpoch(timestamp: string) {

plugins/plugin-codeflare-dashboard/src/controller/dashboard/status/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { isValidStatusTheme, statusThemes } from "./theme.js"
3030
export default function statusDashboard(
3131
tails: Promise<Tail>[],
3232
historyConfig: HistoryConfig,
33-
opts: Pick<Options, "demo" | "theme" | "lines">
33+
opts: Pick<Options, "demo" | "theme" | "events">
3434
): GridSpec {
3535
const { theme: themeS = "colorbrewer6" } = opts
3636
if (!isValidStatusTheme(themeS)) {

0 commit comments

Comments
 (0)