@milabench/bujang 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5017 -4744
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +13 -3
- package/dist/views/OverviewPanels.d.ts +2 -0
- package/dist/views/dataCharts.d.ts +28 -0
- package/package.json +1 -1
- package/src/types.ts +16 -2
- package/src/views/JobDataOverview.tsx +40 -3
- package/src/views/JobLogs.tsx +71 -11
- package/src/views/OverviewPanels.tsx +191 -45
- package/src/views/dataCharts.tsx +144 -5
package/dist/types.d.ts
CHANGED
|
@@ -886,7 +886,11 @@ export interface StatsMetric {
|
|
|
886
886
|
event: string;
|
|
887
887
|
field: string;
|
|
888
888
|
title?: string;
|
|
889
|
+
/** comma separated fields: a row per value of them */
|
|
890
|
+
by?: string;
|
|
889
891
|
}
|
|
892
|
+
/** A statistic of a stats block; busy: the total over the time from the first `start` to the last `end` */
|
|
893
|
+
export type StatName = 'total' | 'busy' | 'count' | 'mean' | 'std' | 'min' | 'median' | 'p95' | 'p99' | 'max';
|
|
890
894
|
/** A block of the Overview tab: the log view, the media of the artifact folders, or a chart (Vega-Lite) of one or several events */
|
|
891
895
|
export type OverviewBlock = {
|
|
892
896
|
kind: 'artifacts';
|
|
@@ -899,6 +903,7 @@ export type OverviewBlock = {
|
|
|
899
903
|
kind: 'stats';
|
|
900
904
|
title?: string;
|
|
901
905
|
metrics?: StatsMetric[];
|
|
906
|
+
show?: StatName[];
|
|
902
907
|
} | {
|
|
903
908
|
kind: 'logs';
|
|
904
909
|
title?: string;
|
|
@@ -913,6 +918,8 @@ export type OverviewBlock = {
|
|
|
913
918
|
files?: string;
|
|
914
919
|
/** Vega-Lite, its data the named dataset "rows"; else the builder fields below; neither: guessed */
|
|
915
920
|
spec?: Record<string, unknown>;
|
|
921
|
+
/** first x values left out, of each event of each file */
|
|
922
|
+
skip?: number;
|
|
916
923
|
mark?: string;
|
|
917
924
|
x?: string;
|
|
918
925
|
y?: string;
|
|
@@ -924,11 +931,14 @@ export type OverviewBlock = {
|
|
|
924
931
|
log_y?: boolean;
|
|
925
932
|
zero?: boolean;
|
|
926
933
|
};
|
|
927
|
-
/**
|
|
928
|
-
export
|
|
934
|
+
/** Blocks side by side, of the same width or of relative widths */
|
|
935
|
+
export interface ColumnsPanel {
|
|
929
936
|
kind: 'columns';
|
|
930
937
|
columns: OverviewBlock[][];
|
|
931
|
-
|
|
938
|
+
widths?: number[];
|
|
939
|
+
}
|
|
940
|
+
/** A panel of the Overview tab: a block, or columns of blocks side by side */
|
|
941
|
+
export type OverviewPanel = OverviewBlock | ColumnsPanel;
|
|
932
942
|
export interface OverviewLayout {
|
|
933
943
|
panels: OverviewPanel[];
|
|
934
944
|
}
|
|
@@ -55,7 +55,9 @@ export declare const LayoutBar: React.FC<{
|
|
|
55
55
|
/** The panels of a layout */
|
|
56
56
|
export declare const LayoutPanels: React.FC<{
|
|
57
57
|
jrJobId: string;
|
|
58
|
+
/** those of the picked rank with `oneRank` */
|
|
58
59
|
files: JobData['files'];
|
|
60
|
+
oneRank: boolean;
|
|
59
61
|
layout: OverviewLayout;
|
|
60
62
|
/** the charts of the built-in layout */
|
|
61
63
|
available: OverviewBlock[];
|
|
@@ -37,15 +37,42 @@ export declare const guessBuilder: (fields: JobDataField[], multipleFiles: boole
|
|
|
37
37
|
/** The fields a spec reads (to fetch only those): every `field` of it */
|
|
38
38
|
export declare const specFields: (spec: unknown, out?: Set<string>) => Set<string>;
|
|
39
39
|
export declare const isDarkPage: () => boolean;
|
|
40
|
+
type Param = {
|
|
41
|
+
name?: string;
|
|
42
|
+
value?: unknown;
|
|
43
|
+
select?: unknown;
|
|
44
|
+
bind?: {
|
|
45
|
+
input?: string;
|
|
46
|
+
options?: unknown;
|
|
47
|
+
labels?: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** The params of a spec with an input. The options of a select can be those of a field of the rows
|
|
51
|
+
* (`options: {field: "epoch"}`), after "all" (null) */
|
|
52
|
+
export declare const boundParams: (spec: Record<string, unknown>, rows: Record<string, unknown>[], values: Map<string, unknown>) => Param[] | undefined;
|
|
53
|
+
/** The rows without the first `skip` x values of each event of each file. An x the spec computes: their `start`, else their `time` */
|
|
54
|
+
export declare const skipFirst: <T extends Record<string, unknown>>(rows: T[], spec: unknown, skip: number) => T[];
|
|
55
|
+
/** The number of first x values a chart leaves out */
|
|
56
|
+
export declare const SkipInput: React.FC<{
|
|
57
|
+
value: number;
|
|
58
|
+
onChange: (skip: number) => void;
|
|
59
|
+
onDone?: () => void;
|
|
60
|
+
}>;
|
|
61
|
+
/** The signals holding the zoom of a spec: those of its interval params bound to the scales (`<param>_<field>`), null: no zoom */
|
|
62
|
+
export declare const zoomSignals: (spec: Record<string, unknown>) => string[];
|
|
40
63
|
/** A Vega-Lite spec rendered with vega-embed (loaded on first use), `rows` as the dataset "rows" */
|
|
41
64
|
export declare const VegaChart: React.FC<{
|
|
42
65
|
spec: Record<string, unknown>;
|
|
43
66
|
rows: Record<string, unknown>[];
|
|
67
|
+
/** where the inputs of the params go, under the chart when absent */
|
|
68
|
+
controls?: HTMLElement | null;
|
|
44
69
|
}>;
|
|
45
70
|
/** The events of a panel (`event`: comma separated, "" for the records without event) */
|
|
46
71
|
export declare const panelEvents: (event?: string) => string[];
|
|
47
72
|
/** The files that have rows of `event` (comma separated events) */
|
|
48
73
|
export declare const filesWithEvent: (files: JobData["files"], event: string) => JobData["files"];
|
|
74
|
+
/** The rank of each file (null: of none). In a job whose files have a `rank`, the others are told by their name, <name>.<rank>.jsonl */
|
|
75
|
+
export declare const fileRanks: (files: JobData["files"]) => Map<string, number | null>;
|
|
49
76
|
/** The fields of `event` (comma separated events) in `files`, merged (counts added, ranges widened, values joined) */
|
|
50
77
|
export declare const mergeFields: (files: JobData["files"], event: string) => JobDataField[];
|
|
51
78
|
/** The files a panel reads (`files`: comma separated paths or globs, all when empty) */
|
|
@@ -58,3 +85,4 @@ export declare const panelOfBuilder: (b: Builder, event: string, title?: string)
|
|
|
58
85
|
export declare const builderOfPanel: (p: Extract<OverviewBlock, {
|
|
59
86
|
kind: "chart";
|
|
60
87
|
}>) => Builder | null;
|
|
88
|
+
export {};
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -943,13 +943,18 @@ export interface StatsMetric {
|
|
|
943
943
|
event: string;
|
|
944
944
|
field: string;
|
|
945
945
|
title?: string;
|
|
946
|
+
/** comma separated fields: a row per value of them */
|
|
947
|
+
by?: string;
|
|
946
948
|
}
|
|
947
949
|
|
|
950
|
+
/** A statistic of a stats block; busy: the total over the time from the first `start` to the last `end` */
|
|
951
|
+
export type StatName = 'total' | 'busy' | 'count' | 'mean' | 'std' | 'min' | 'median' | 'p95' | 'p99' | 'max';
|
|
952
|
+
|
|
948
953
|
/** A block of the Overview tab: the log view, the media of the artifact folders, or a chart (Vega-Lite) of one or several events */
|
|
949
954
|
export type OverviewBlock =
|
|
950
955
|
| { kind: 'artifacts'; title?: string; files?: string }
|
|
951
956
|
| { kind: 'files'; title?: string }
|
|
952
|
-
| { kind: 'stats'; title?: string; metrics?: StatsMetric[] }
|
|
957
|
+
| { kind: 'stats'; title?: string; metrics?: StatsMetric[]; show?: StatName[] }
|
|
953
958
|
| { kind: 'logs'; title?: string; levels?: string[]; files?: string }
|
|
954
959
|
| {
|
|
955
960
|
kind: 'chart';
|
|
@@ -960,6 +965,8 @@ export type OverviewBlock =
|
|
|
960
965
|
files?: string;
|
|
961
966
|
/** Vega-Lite, its data the named dataset "rows"; else the builder fields below; neither: guessed */
|
|
962
967
|
spec?: Record<string, unknown>;
|
|
968
|
+
/** first x values left out, of each event of each file */
|
|
969
|
+
skip?: number;
|
|
963
970
|
mark?: string;
|
|
964
971
|
x?: string;
|
|
965
972
|
y?: string;
|
|
@@ -972,8 +979,15 @@ export type OverviewBlock =
|
|
|
972
979
|
zero?: boolean;
|
|
973
980
|
};
|
|
974
981
|
|
|
982
|
+
/** Blocks side by side, of the same width or of relative widths */
|
|
983
|
+
export interface ColumnsPanel {
|
|
984
|
+
kind: 'columns';
|
|
985
|
+
columns: OverviewBlock[][];
|
|
986
|
+
widths?: number[];
|
|
987
|
+
}
|
|
988
|
+
|
|
975
989
|
/** A panel of the Overview tab: a block, or columns of blocks side by side */
|
|
976
|
-
export type OverviewPanel = OverviewBlock |
|
|
990
|
+
export type OverviewPanel = OverviewBlock | ColumnsPanel;
|
|
977
991
|
|
|
978
992
|
export interface OverviewLayout {
|
|
979
993
|
panels: OverviewPanel[];
|
|
@@ -35,6 +35,9 @@ import {
|
|
|
35
35
|
MARKS,
|
|
36
36
|
ROLE_ORDER,
|
|
37
37
|
ROW_LIMIT,
|
|
38
|
+
SkipInput,
|
|
39
|
+
fileRanks,
|
|
40
|
+
skipFirst,
|
|
38
41
|
VegaChart,
|
|
39
42
|
buildSpec,
|
|
40
43
|
filesWithEvent,
|
|
@@ -124,6 +127,21 @@ export const JobDataOverview: React.FC<{
|
|
|
124
127
|
}, [data, dataUpdatedAt, version, jrJobId, queryClient]);
|
|
125
128
|
|
|
126
129
|
const files = useMemo(() => (data?.files || []).filter((f) => !f.error), [data]);
|
|
130
|
+
// a job of several processes, each with its files: the panels show one of them, the first by default
|
|
131
|
+
const ranks = useMemo(() => fileRanks(files), [files]);
|
|
132
|
+
const rankList = useMemo(
|
|
133
|
+
() => [...new Set([...ranks.values()].filter((r): r is number => r !== null))].sort((a, b) => a - b),
|
|
134
|
+
[ranks],
|
|
135
|
+
);
|
|
136
|
+
const [pickedRank, setPickedRank] = useState<number | 'all' | null>(null);
|
|
137
|
+
const rank = rankList.length < 2
|
|
138
|
+
? 'all'
|
|
139
|
+
: pickedRank === 'all' || (pickedRank !== null && rankList.includes(pickedRank)) ? pickedRank : rankList[0];
|
|
140
|
+
const rankFiles = useMemo(
|
|
141
|
+
// the files of no rank are always there
|
|
142
|
+
() => (rank === 'all' ? files : files.filter((f) => (ranks.get(f.path) ?? rank) === rank)),
|
|
143
|
+
[files, ranks, rank],
|
|
144
|
+
);
|
|
127
145
|
const [selectedFiles, setSelectedFiles] = useState<string[] | null>(null);
|
|
128
146
|
const activeFiles = useMemo(
|
|
129
147
|
() => files.filter((f) => selectedFiles === null || selectedFiles.includes(f.path)),
|
|
@@ -240,10 +258,12 @@ export const JobDataOverview: React.FC<{
|
|
|
240
258
|
const columnTargets = (layout?.panels || []).flatMap((p, i) => (
|
|
241
259
|
p.kind === 'columns' ? p.columns.map((_, c) => ({ value: `${i}.${c}`, label: `row ${i + 1}, column ${c + 1}` })) : []
|
|
242
260
|
));
|
|
261
|
+
const [skip, setSkip] = useState(0);
|
|
262
|
+
const shownRows = useMemo(() => rows && skipFirst(rows, spec, skip), [rows, spec, skip]);
|
|
243
263
|
const addToLayout = () => {
|
|
244
264
|
const base = layout ?? { panels: [] };
|
|
245
265
|
const chosen = selectedFiles === null ? {} : { files: activeFiles.map((f) => f.path).join(',') };
|
|
246
|
-
const panel: OverviewBlock = { ...panelOfBuilder(builder, activeEvent), ...chosen };
|
|
266
|
+
const panel: OverviewBlock = { ...panelOfBuilder(builder, activeEvent), ...chosen, ...(skip ? { skip } : {}) };
|
|
247
267
|
const [row, col] = columnTargets.some((t) => t.value === target) ? target.split('.').map(Number) : [-1, -1];
|
|
248
268
|
changeLayout({
|
|
249
269
|
panels: row < 0
|
|
@@ -318,8 +338,24 @@ export const JobDataOverview: React.FC<{
|
|
|
318
338
|
}
|
|
319
339
|
}}
|
|
320
340
|
/>
|
|
341
|
+
{view === 'job' && rankList.length > 1 && (
|
|
342
|
+
<HStack gap={2} justify="flex-end">
|
|
343
|
+
<Text fontSize="xs" color="var(--color-text-muted)">Rank</Text>
|
|
344
|
+
<NativeSelect.Root size="xs" w="110px" title="The process whose data the panels show">
|
|
345
|
+
<NativeSelect.Field
|
|
346
|
+
aria-label="Rank"
|
|
347
|
+
value={String(rank)}
|
|
348
|
+
onChange={(e) => setPickedRank(e.target.value === 'all' ? 'all' : Number(e.target.value))}
|
|
349
|
+
>
|
|
350
|
+
{rankList.map((r) => <option key={r} value={r}>rank {r}</option>)}
|
|
351
|
+
<option value="all">all ranks</option>
|
|
352
|
+
</NativeSelect.Field>
|
|
353
|
+
<NativeSelect.Indicator />
|
|
354
|
+
</NativeSelect.Root>
|
|
355
|
+
</HStack>
|
|
356
|
+
)}
|
|
321
357
|
{view === 'job' && (
|
|
322
|
-
<LayoutPanels jrJobId={jrJobId} files={
|
|
358
|
+
<LayoutPanels jrJobId={jrJobId} files={rankFiles} oneRank={rank !== 'all'} layout={layout} available={found.blocks ?? []} editing={editing} onChange={setDraft} onEditor={(open) => setFrozen(open ? layout : null)} />
|
|
323
359
|
)}
|
|
324
360
|
</>
|
|
325
361
|
)}
|
|
@@ -438,6 +474,7 @@ export const JobDataOverview: React.FC<{
|
|
|
438
474
|
<NativeSelect.Indicator />
|
|
439
475
|
</NativeSelect.Root>
|
|
440
476
|
)}
|
|
477
|
+
<SkipInput value={skip} onChange={setSkip} />
|
|
441
478
|
<Button size="2xs" variant="outline" ml={columnTargets.length ? undefined : 'auto'} onClick={addToLayout} disabled={!layout}
|
|
442
479
|
title="Add this chart to the layout of the job (then save the layout)">
|
|
443
480
|
<LuPlus /> Add to job layout
|
|
@@ -449,7 +486,7 @@ export const JobDataOverview: React.FC<{
|
|
|
449
486
|
<Alert.Description>{rowsError.message}</Alert.Description>
|
|
450
487
|
</Alert.Root>
|
|
451
488
|
)}
|
|
452
|
-
{
|
|
489
|
+
{shownRows && <VegaChart spec={spec} rows={shownRows} />}
|
|
453
490
|
</Card.Body>
|
|
454
491
|
</Card.Root>
|
|
455
492
|
|
package/src/views/JobLogs.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
SegmentGroup,
|
|
22
22
|
} from '@chakra-ui/react';
|
|
23
23
|
import { toaster } from '../toast';
|
|
24
|
-
import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil } from 'react-icons/lu';
|
|
24
|
+
import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil, LuTimer } from 'react-icons/lu';
|
|
25
25
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
26
26
|
import { getSlurmJobStdoutFull, getSlurmJobStderrFull, getSlurmJobStdoutSize, getSlurmJobStderrSize, getSlurmJobStatusSimple, getSshJobStatus, getSlurmJobAccounting, rerunSlurmJob, cancelSlurmJob, getSlurmJobInfo, getSlurmJobCluster, getSlurmClusterStatus, earlySyncJob, getSlurmJobScript, getSlurmTemplates, getSlurmProfiles, getSlurmClusters } from '../api';
|
|
27
27
|
import { JobSubmissionForm } from './JobSubmit';
|
|
@@ -35,6 +35,9 @@ import type { SlurmJobDetail, ApiError } from '../types';
|
|
|
35
35
|
type JobLogsViewProps = Record<string, never>;
|
|
36
36
|
type JobLogsTab = 'logs' | 'overview';
|
|
37
37
|
|
|
38
|
+
// Seconds before a failed automatic early sync is tried again (a failure can be immediate)
|
|
39
|
+
const AUTO_SYNC_RETRY = 5;
|
|
40
|
+
|
|
38
41
|
const getStatusColor = (status: string) => {
|
|
39
42
|
switch (status?.toLowerCase()) {
|
|
40
43
|
case 'running':
|
|
@@ -120,6 +123,9 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
120
123
|
|
|
121
124
|
// Early sync state
|
|
122
125
|
const [isEarlySync, setIsEarlySync] = useState(false);
|
|
126
|
+
// the job synced automatically: off when the page moves to another job
|
|
127
|
+
const [autoSyncJob, setAutoSyncJob] = useState<string | null>(null);
|
|
128
|
+
const autoSync = !!jrJobId && autoSyncJob === jrJobId;
|
|
123
129
|
|
|
124
130
|
// Edit & Resubmit state
|
|
125
131
|
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
|
@@ -501,6 +507,34 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
501
507
|
}
|
|
502
508
|
};
|
|
503
509
|
|
|
510
|
+
// Automatic early sync, while the job runs: again after twice the time the last one took. A failed
|
|
511
|
+
// one is tried again (the error is shown on the button)
|
|
512
|
+
const { data: autoSyncResult, error: autoSyncFailure } = useQuery({
|
|
513
|
+
queryKey: ['bujang-auto-early-sync', jrJobId, slurmJobId],
|
|
514
|
+
queryFn: async () => {
|
|
515
|
+
const start = performance.now();
|
|
516
|
+
const result = await earlySyncJob(jrJobId!, slurmJobId!);
|
|
517
|
+
const took = (performance.now() - start) / 1000;
|
|
518
|
+
if (result.status === 'ok') {
|
|
519
|
+
queryClient.invalidateQueries({ queryKey: ['slurm-job-logs'] });
|
|
520
|
+
queryClient.invalidateQueries({ queryKey: ['bujang-job-data', jrJobId] });
|
|
521
|
+
}
|
|
522
|
+
return { ...result, took };
|
|
523
|
+
},
|
|
524
|
+
enabled: autoSync && !!slurmJobId && slurmJobId !== '-' && jobStatus?.toUpperCase() === 'RUNNING',
|
|
525
|
+
refetchInterval: ({ state }) => 1000 * (
|
|
526
|
+
state.data?.status === 'ok' && !state.error ? 2 * state.data.took : AUTO_SYNC_RETRY
|
|
527
|
+
),
|
|
528
|
+
refetchOnWindowFocus: false,
|
|
529
|
+
retry: false,
|
|
530
|
+
gcTime: 0,
|
|
531
|
+
});
|
|
532
|
+
const autoSyncError = autoSyncFailure
|
|
533
|
+
? ((autoSyncFailure as unknown as ApiError).message || 'An unexpected error occurred')
|
|
534
|
+
: autoSyncResult && autoSyncResult.status !== 'ok'
|
|
535
|
+
? (autoSyncResult.error || 'Could not sync the job results early')
|
|
536
|
+
: null;
|
|
537
|
+
|
|
504
538
|
// Lazy-loaded templates & profiles for the edit modal
|
|
505
539
|
const { data: templateNames } = useQuery<string[]>({
|
|
506
540
|
queryKey: ['slurm-templates'],
|
|
@@ -666,16 +700,42 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
666
700
|
<LuPencil />
|
|
667
701
|
</Button>
|
|
668
702
|
</HStack>
|
|
669
|
-
<
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
703
|
+
<HStack gap={0}>
|
|
704
|
+
<Button
|
|
705
|
+
variant="outline"
|
|
706
|
+
colorScheme="orange"
|
|
707
|
+
onClick={handleEarlySync}
|
|
708
|
+
loading={isEarlySync}
|
|
709
|
+
disabled={!slurmJobId || slurmJobId === '-' || isJobTerminal}
|
|
710
|
+
borderRightRadius={0}
|
|
711
|
+
>
|
|
712
|
+
<LuClock />
|
|
713
|
+
Early Sync
|
|
714
|
+
</Button>
|
|
715
|
+
<Button
|
|
716
|
+
variant={autoSync && !isJobTerminal ? 'solid' : 'outline'}
|
|
717
|
+
{...(autoSync && !isJobTerminal && !autoSyncError ? {
|
|
718
|
+
bg: 'var(--color-primary)',
|
|
719
|
+
color: 'var(--color-primary-text)',
|
|
720
|
+
_hover: { bg: 'var(--color-primary-hover)' },
|
|
721
|
+
} : {})}
|
|
722
|
+
colorPalette={autoSync && autoSyncError ? 'red' : undefined}
|
|
723
|
+
onClick={() => setAutoSyncJob(autoSync ? null : jrJobId ?? null)}
|
|
724
|
+
disabled={!slurmJobId || slurmJobId === '-' || isJobTerminal}
|
|
725
|
+
aria-pressed={autoSync}
|
|
726
|
+
borderLeftRadius={0}
|
|
727
|
+
borderLeft="none"
|
|
728
|
+
px={2}
|
|
729
|
+
title={autoSync && autoSyncError
|
|
730
|
+
? `Automatic early sync failed, trying again: ${autoSyncError}`
|
|
731
|
+
: autoSync
|
|
732
|
+
? `Automatic early sync is on${autoSyncResult ? ` (every ${(2 * autoSyncResult.took).toFixed(1)} s, 2× the last sync)` : ''}: click to stop`
|
|
733
|
+
: 'Early sync again and again while the job runs, every 2× the time a sync takes'}
|
|
734
|
+
>
|
|
735
|
+
<LuTimer />
|
|
736
|
+
Auto
|
|
737
|
+
</Button>
|
|
738
|
+
</HStack>
|
|
679
739
|
{canCancelJob(jobStatus) && (
|
|
680
740
|
<Button
|
|
681
741
|
variant="outline"
|