Skip to content

Commit efe63c9

Browse files
committed
chore: improve comments in Events ui code
1 parent b7100c2 commit efe63c9

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

plugins/plugin-codeflare/src/controller/events/Events.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface EventState {
3131
torchEvents: TorchEvent[]
3232
}
3333

34+
/** State for the `<Events/>` component */
3435
type State = EventState & {
3536
/** Total number of Kubernetes events */
3637
nKubeEvents: number
@@ -48,6 +49,7 @@ type State = EventState & {
4849
catastrophicError?: Error
4950
}
5051

52+
/** Props for the `<Events/>` component */
5153
type Props = EventState & {
5254
/** Follow kube events? */
5355
onKube?(eventType: "data", cb: (data: any) => void): void
@@ -61,7 +63,11 @@ type Props = EventState & {
6163

6264
/**
6365
* This component manages the `Event` state for the events UI. It uses
64-
* the `Grid` component to render the UI.
66+
* the `<Grid/>` component to render the UI, and requires a controller
67+
* (see below) to feed it an initial set of parsed `Event` objects,
68+
* and a stream of unparsed log lines. (why unparsed for the streaming
69+
* case? because some kinds of events require some recent
70+
* history/context in order to be meaningfully parsed).
6571
*
6672
*/
6773
class Events extends React.PureComponent<Props, State> {
@@ -170,6 +176,12 @@ class Events extends React.PureComponent<Props, State> {
170176
}
171177
}
172178

179+
/**
180+
* Controller portion of the events UI. It will set up the data
181+
* streams, and feed parsed events to the `<Events/>` component. That
182+
* component will manage the state of the events, and in turn pass off
183+
* to the `<Grid/>` component for final rendering.
184+
*/
173185
async function eventsUI(filepath: string, REPL: Arguments["REPL"]) {
174186
const jobFilepath = join(expand(filepath), "logs/job.txt")
175187
const kubeFilepath = join(expand(filepath), "events/kubernetes.txt")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { Registrar } from "@kui-shell/core"
1818

19-
/** Register Kui Commands for rendering dashboard event UIs */
19+
/** Command registration part of the Events UI */
2020
export default function registerEventCommands(registrar: Registrar) {
2121
registrar.listen("/chart/events", (args) => import("./Events").then((_) => _.default(args)), { needsUI: true })
2222
}

plugins/plugin-codeflare/src/controller/events/torch.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616

1717
import Event from "./Event"
1818

19+
/** The Torch events that we currently model */
1920
type EventType =
2021
| "Data Fetch from Upstream"
2122
| "Data Store in Cache"
2223
| "Data Fetch from Cache"
2324
| "Data Uncompress"
24-
| "Evaluation"
25-
| "EvaluationStep"
26-
| "Epoch"
27-
| "Iteration"
28-
| "Marker"
29-
type Detail = { epoch: number; step: number; nSteps: number; ip: string }
30-
export type TorchEvent = Event<EventType, Detail>
25+
| "Evaluation" // marks the beginning of an Evaluation stage
26+
| "EvaluationStep" // a step in an Evaluation stage; 2/9, 3/9, ...
27+
| "Epoch" // a torch training Epoch
28+
| "Iteration" // a torch training Iteration
29+
| "Marker" // currently used to manufacture a timestamp for non-timestamped events, sigh
30+
31+
/** A `TorchEvent` is a subclass of `Event` with our own `EventType` and our own event details */
32+
export type TorchEvent = Event<EventType, { epoch: number; step: number; nSteps: number; ip: string }>
3133

3234
function findPrevious(
3335
M: TorchEvent[],

0 commit comments

Comments
 (0)