@milabench/bujang 0.1.12 → 0.1.14
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/api.d.ts +23 -5
- package/dist/constants.d.ts +6 -0
- package/dist/index.js +6231 -5068
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +113 -12
- package/dist/views/JobDataOverview.d.ts +4 -3
- package/dist/views/OverviewPanels.d.ts +37 -0
- package/dist/views/PipelineEditor.d.ts +5 -0
- package/dist/views/PipelinesView.d.ts +1 -1
- package/dist/views/ScheduleDialog.d.ts +14 -0
- package/dist/views/SweepDialog.d.ts +51 -0
- package/dist/views/dataCharts.d.ts +56 -0
- package/package.json +1 -1
- package/src/api.ts +52 -4
- package/src/constants.ts +3 -0
- package/src/types.ts +113 -13
- package/src/views/JanitorView.tsx +101 -32
- package/src/views/JobDataOverview.tsx +126 -213
- package/src/views/JobLogs.tsx +13 -6
- package/src/views/JobSubmit.tsx +377 -318
- package/src/views/JobsView.tsx +34 -21
- package/src/views/LogDisplay.tsx +2 -2
- package/src/views/OverviewPanels.tsx +341 -0
- package/src/views/PipelineEditor.tsx +3 -3
- package/src/views/PipelinesView.tsx +387 -164
- package/src/views/ScheduleDialog.tsx +98 -0
- package/src/views/SettingsView.tsx +131 -1
- package/src/views/SweepDialog.tsx +520 -0
- package/src/views/dataCharts.tsx +261 -0
package/src/views/JobsView.tsx
CHANGED
|
@@ -46,7 +46,7 @@ import type { SlurmJob, PersitedJobInfo, ApiError, OrganizerGroups, SyncStatus }
|
|
|
46
46
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
47
47
|
import { AgentBadge } from './AgentActivityView';
|
|
48
48
|
import { SshConnectButton } from '../components/SshConnectDialog';
|
|
49
|
-
import { NO_JOB_ID, NO_JOB_STATE, NO_JR_JOB_ID } from '../constants';
|
|
49
|
+
import { COMPACT_ROWS, NO_JOB_ID, NO_JOB_STATE, NO_JR_JOB_ID } from '../constants';
|
|
50
50
|
|
|
51
51
|
type JobsViewProps = Record<string, never>;
|
|
52
52
|
|
|
@@ -94,14 +94,22 @@ const getStatusIcon = (status: string) => {
|
|
|
94
94
|
const AUTO_REFRESH_KEY = 'bujang-jobs-auto-refresh';
|
|
95
95
|
const AUTO_REFRESH_MS = 30_000;
|
|
96
96
|
|
|
97
|
+
/** On unless turned off on this browser: the page follows the background sync of the server */
|
|
97
98
|
function readAutoRefresh(): boolean {
|
|
98
99
|
try {
|
|
99
|
-
return localStorage.getItem(AUTO_REFRESH_KEY)
|
|
100
|
+
return localStorage.getItem(AUTO_REFRESH_KEY) !== '0';
|
|
100
101
|
} catch {
|
|
101
|
-
return
|
|
102
|
+
return true;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
/** "in 12s", "now" */
|
|
107
|
+
const until = (ts: number, now: number): string => {
|
|
108
|
+
const s = Math.round(ts - now / 1000);
|
|
109
|
+
if (s <= 0) return 'now';
|
|
110
|
+
return s < 60 ? `in ${s}s` : `in ${Math.round(s / 60)} min`;
|
|
111
|
+
};
|
|
112
|
+
|
|
105
113
|
/** "12s ago", "3 min ago" */
|
|
106
114
|
const ago = (ts: number | null | undefined, now: number): string => {
|
|
107
115
|
if (!ts) return 'never';
|
|
@@ -182,9 +190,17 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
182
190
|
}
|
|
183
191
|
setAutoRefresh(on);
|
|
184
192
|
};
|
|
185
|
-
const refetchInterval = autoRefresh ? AUTO_REFRESH_MS : false;
|
|
186
|
-
|
|
187
193
|
// Queries
|
|
194
|
+
const { data: sync } = useQuery<SyncStatus>({
|
|
195
|
+
queryKey: ['bujang-sync'],
|
|
196
|
+
queryFn: getSyncStatus,
|
|
197
|
+
refetchOnWindowFocus: false,
|
|
198
|
+
refetchInterval: 10_000,
|
|
199
|
+
retry: false,
|
|
200
|
+
});
|
|
201
|
+
// the pages read the index the background sync keeps: refresh as often as it runs
|
|
202
|
+
const refetchInterval = autoRefresh ? (sync?.interval ? sync.interval * 1000 : AUTO_REFRESH_MS) : false;
|
|
203
|
+
|
|
188
204
|
const { data: activeJobsData, isLoading: activeJobsLoading, error: activeJobsError } = useQuery({
|
|
189
205
|
queryKey: ['slurm-jobs'],
|
|
190
206
|
queryFn: getSlurmJobs,
|
|
@@ -201,13 +217,6 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
201
217
|
refetchInterval,
|
|
202
218
|
});
|
|
203
219
|
|
|
204
|
-
const { data: sync } = useQuery<SyncStatus>({
|
|
205
|
-
queryKey: ['bujang-sync'],
|
|
206
|
-
queryFn: getSyncStatus,
|
|
207
|
-
refetchOnWindowFocus: false,
|
|
208
|
-
refetchInterval: 10_000,
|
|
209
|
-
retry: false,
|
|
210
|
-
});
|
|
211
220
|
// re-render the "synced 12s ago" every few seconds
|
|
212
221
|
const [now, setNow] = React.useState(() => Date.now());
|
|
213
222
|
React.useEffect(() => {
|
|
@@ -350,7 +359,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
350
359
|
|
|
351
360
|
{/* Header Section */}
|
|
352
361
|
<Box>
|
|
353
|
-
<HStack justify="space-between" align="center"
|
|
362
|
+
<HStack justify="space-between" align="center">
|
|
354
363
|
<HStack gap={3} align="center">
|
|
355
364
|
<Heading size="xl" fontWeight="bold" color="var(--color-text)">
|
|
356
365
|
Jobs
|
|
@@ -394,7 +403,9 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
394
403
|
onClick={() => toggleAutoRefresh(!autoRefresh)}
|
|
395
404
|
aria-pressed={autoRefresh}
|
|
396
405
|
aria-label="Auto refresh every 30 seconds"
|
|
397
|
-
title={autoRefresh
|
|
406
|
+
title={autoRefresh
|
|
407
|
+
? `Auto refresh is on (every ${sync?.interval ?? 30}s): click to stop`
|
|
408
|
+
: `Refresh the jobs every ${sync?.interval ?? 30} seconds`}
|
|
398
409
|
size="sm"
|
|
399
410
|
px={2}
|
|
400
411
|
fontWeight="medium"
|
|
@@ -414,7 +425,9 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
414
425
|
whiteSpace="nowrap"
|
|
415
426
|
title={sync.interval ? `The server syncs the clusters with active jobs every ${sync.interval}s` : undefined}
|
|
416
427
|
>
|
|
417
|
-
|
|
428
|
+
{sync.running && sync.running.length > 0
|
|
429
|
+
? `syncing ${sync.running.join(', ')}…`
|
|
430
|
+
: <>synced {ago(sync.last ?? sync.scanned, now)}{sync.next ? ` · next ${until(sync.next, now)}` : ''}</>}
|
|
418
431
|
</Text>
|
|
419
432
|
)}
|
|
420
433
|
</Box>
|
|
@@ -498,7 +511,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
498
511
|
</Box>
|
|
499
512
|
) : (
|
|
500
513
|
<Table.ScrollArea maxH="35vh" overflowY="auto">
|
|
501
|
-
<Table.Root variant="line" size="
|
|
514
|
+
<Table.Root variant="line" size="sm" stickyHeader css={COMPACT_ROWS}>
|
|
502
515
|
<Table.Header bg="var(--color-bg-header)">
|
|
503
516
|
<Table.Row>
|
|
504
517
|
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} pl={6} pr={4} fontSize="sm">Job ID</Table.ColumnHeader>
|
|
@@ -570,7 +583,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
570
583
|
>
|
|
571
584
|
<IconButton
|
|
572
585
|
aria-label="View job logs"
|
|
573
|
-
size="
|
|
586
|
+
size="xs"
|
|
574
587
|
variant="ghost"
|
|
575
588
|
>
|
|
576
589
|
<LuEye />
|
|
@@ -585,7 +598,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
585
598
|
>
|
|
586
599
|
<IconButton
|
|
587
600
|
aria-label="Cancel job"
|
|
588
|
-
size="
|
|
601
|
+
size="xs"
|
|
589
602
|
variant="ghost"
|
|
590
603
|
colorScheme="red"
|
|
591
604
|
onClick={() => job.job_id && handleCancelJob(job.job_id)}
|
|
@@ -673,7 +686,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
673
686
|
</Text>
|
|
674
687
|
</Box>
|
|
675
688
|
) : (
|
|
676
|
-
<Table.Root variant="line" size="
|
|
689
|
+
<Table.Root variant="line" size="sm" stickyHeader css={COMPACT_ROWS}>
|
|
677
690
|
<Table.Header bg="var(--color-bg-header)">
|
|
678
691
|
<Table.Row>
|
|
679
692
|
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} pl={6} pr={4} fontSize="sm">Job ID</Table.ColumnHeader>
|
|
@@ -826,7 +839,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
826
839
|
>
|
|
827
840
|
<IconButton
|
|
828
841
|
aria-label="View job logs"
|
|
829
|
-
size="
|
|
842
|
+
size="xs"
|
|
830
843
|
variant="ghost"
|
|
831
844
|
>
|
|
832
845
|
<LuEye />
|
|
@@ -839,7 +852,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
839
852
|
>
|
|
840
853
|
<IconButton
|
|
841
854
|
aria-label="Rerun job"
|
|
842
|
-
size="
|
|
855
|
+
size="xs"
|
|
843
856
|
variant="ghost"
|
|
844
857
|
colorScheme="blue"
|
|
845
858
|
onClick={() => handleRerunJob(jrJobId)}
|
package/src/views/LogDisplay.tsx
CHANGED
|
@@ -100,7 +100,7 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
|
|
|
100
100
|
|
|
101
101
|
return (
|
|
102
102
|
<Card.Root bg="var(--color-bg-card)" padding="10px" border="1px solid" borderColor="var(--color-border)" className="logview" flex={1} minH={0} display="flex" flexDirection="column">
|
|
103
|
-
<Card.Header paddingBottom="5px" flexShrink={0}>
|
|
103
|
+
<Card.Header p={0} paddingBottom="5px" flexShrink={0}>
|
|
104
104
|
<HStack justify="space-between">
|
|
105
105
|
<Heading size="md">{displayName}</Heading>
|
|
106
106
|
|
|
@@ -116,7 +116,7 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
|
|
|
116
116
|
</HStack>
|
|
117
117
|
</HStack>
|
|
118
118
|
</Card.Header>
|
|
119
|
-
<Card.Body flex="1" minH={0} display="flex" flexDirection="column">
|
|
119
|
+
<Card.Body p={0} flex="1" minH={0} display="flex" flexDirection="column">
|
|
120
120
|
{error ? (
|
|
121
121
|
<Alert.Root status="error">
|
|
122
122
|
<Alert.Indicator />
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/** The panels of a job's Overview layout: the log view and the charts, and the bar saying where the layout comes from. */
|
|
2
|
+
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import { Alert, Badge, Box, Button, Card, Code, HStack, Input, Spinner, Text, VStack, Wrap } from '@chakra-ui/react';
|
|
4
|
+
import { useQuery } from '@tanstack/react-query';
|
|
5
|
+
import { LuArrowDown, LuArrowUp, LuX } from 'react-icons/lu';
|
|
6
|
+
import { getJobDataRows } from '../api';
|
|
7
|
+
import type { ApiError, JobData, JobOverviewLayout, OverviewLayout, OverviewPanel } from '../types';
|
|
8
|
+
import {
|
|
9
|
+
FILE_FIELDS,
|
|
10
|
+
ROW_LIMIT,
|
|
11
|
+
VegaChart,
|
|
12
|
+
buildSpec,
|
|
13
|
+
builderOfPanel,
|
|
14
|
+
filesWithEvent,
|
|
15
|
+
guessBuilder,
|
|
16
|
+
mergeFields,
|
|
17
|
+
panelFiles,
|
|
18
|
+
specFields,
|
|
19
|
+
} from './dataCharts';
|
|
20
|
+
|
|
21
|
+
/** Log rows fetched for a log panel */
|
|
22
|
+
const LOG_LIMIT = 5000;
|
|
23
|
+
const cardProps = { bg: 'var(--color-bg-card)', border: '1px solid', borderColor: 'var(--color-border)' } as const;
|
|
24
|
+
|
|
25
|
+
const splitFiles = (files?: string) => {
|
|
26
|
+
const list = (files || '').split(',').map((f) => f.trim()).filter(Boolean);
|
|
27
|
+
return list.length ? list : undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const levelColor = (level: string) => {
|
|
31
|
+
if (/^(error|critical|fatal)$/i.test(level)) return 'var(--color-status-failed)';
|
|
32
|
+
if (/^warn/i.test(level)) return 'var(--color-status-pending)';
|
|
33
|
+
if (/^debug$/i.test(level)) return 'var(--color-text-muted)';
|
|
34
|
+
return 'var(--color-text)';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const clock = (time: unknown) => {
|
|
38
|
+
if (typeof time !== 'number') return '';
|
|
39
|
+
const d = new Date(time * 1000);
|
|
40
|
+
return Number.isNaN(d.getTime()) ? '' : d.toLocaleTimeString([], { hour12: false });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Title, kind and (when editing) the move / remove buttons of a panel */
|
|
44
|
+
const PanelFrame: React.FC<{
|
|
45
|
+
title: string;
|
|
46
|
+
kind: string;
|
|
47
|
+
info?: React.ReactNode;
|
|
48
|
+
editing: boolean;
|
|
49
|
+
onMove: (by: number) => void;
|
|
50
|
+
onRemove: () => void;
|
|
51
|
+
children: React.ReactNode;
|
|
52
|
+
}> = ({ title, kind, info, editing, onMove, onRemove, children }) => (
|
|
53
|
+
<Card.Root {...cardProps}>
|
|
54
|
+
<Card.Header py={2}>
|
|
55
|
+
<HStack justify="space-between">
|
|
56
|
+
<HStack gap={2}>
|
|
57
|
+
<Text fontSize="sm" fontWeight="semibold">{title}</Text>
|
|
58
|
+
<Badge size="xs" variant="subtle">{kind}</Badge>
|
|
59
|
+
<HStack gap={2} fontSize="xs" color="var(--color-text-muted)">{info}</HStack>
|
|
60
|
+
</HStack>
|
|
61
|
+
{editing && (
|
|
62
|
+
<HStack gap={0}>
|
|
63
|
+
<Button size="2xs" variant="ghost" onClick={() => onMove(-1)} title="Move up"><LuArrowUp /></Button>
|
|
64
|
+
<Button size="2xs" variant="ghost" onClick={() => onMove(1)} title="Move down"><LuArrowDown /></Button>
|
|
65
|
+
<Button size="2xs" variant="ghost" onClick={onRemove} title="Remove from the layout"><LuX /></Button>
|
|
66
|
+
</HStack>
|
|
67
|
+
)}
|
|
68
|
+
</HStack>
|
|
69
|
+
</Card.Header>
|
|
70
|
+
<Card.Body pt={0}>{children}</Card.Body>
|
|
71
|
+
</Card.Root>
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
type PanelProps<K extends OverviewPanel['kind']> = {
|
|
75
|
+
jrJobId: string;
|
|
76
|
+
files: JobData['files'];
|
|
77
|
+
panel: Extract<OverviewPanel, { kind: K }>;
|
|
78
|
+
editing: boolean;
|
|
79
|
+
onMove: (by: number) => void;
|
|
80
|
+
onRemove: () => void;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** The log view: the rows of role `log` (the `logging` records of the job) */
|
|
84
|
+
export const LogPanel: React.FC<PanelProps<'logs'>> = ({ jrJobId, panel, editing, onMove, onRemove }) => {
|
|
85
|
+
const query = { roles: ['log' as const], files: splitFiles(panel.files), limit: LOG_LIMIT };
|
|
86
|
+
const { data: rows, isFetching, error } = useQuery<Record<string, unknown>[], ApiError>({
|
|
87
|
+
queryKey: ['bujang-job-data-rows', jrJobId, query],
|
|
88
|
+
queryFn: () => getJobDataRows(jrJobId, query),
|
|
89
|
+
staleTime: 30_000,
|
|
90
|
+
placeholderData: (previous) => previous,
|
|
91
|
+
});
|
|
92
|
+
const present = useMemo(
|
|
93
|
+
() => [...new Set((rows || []).map((r) => String(r.level ?? '')).filter(Boolean))],
|
|
94
|
+
[rows],
|
|
95
|
+
);
|
|
96
|
+
const [levels, setLevels] = useState<string[] | null>(panel.levels ?? null);
|
|
97
|
+
const [search, setSearch] = useState('');
|
|
98
|
+
const [open, setOpen] = useState<number | null>(null);
|
|
99
|
+
const shown = useMemo(() => {
|
|
100
|
+
const needle = search.trim().toLowerCase();
|
|
101
|
+
return (rows || [])
|
|
102
|
+
.filter((r) => levels === null || levels.includes(String(r.level ?? '')))
|
|
103
|
+
.filter((r) => !needle || `${r.logger ?? ''} ${r.message ?? ''}`.toLowerCase().includes(needle))
|
|
104
|
+
.sort((a, b) => (Number(a.time) || 0) - (Number(b.time) || 0));
|
|
105
|
+
}, [rows, levels, search]);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<PanelFrame
|
|
109
|
+
title={panel.title || 'Logs'}
|
|
110
|
+
kind="logs"
|
|
111
|
+
editing={editing}
|
|
112
|
+
onMove={onMove}
|
|
113
|
+
onRemove={onRemove}
|
|
114
|
+
info={<>
|
|
115
|
+
{isFetching && <Spinner size="xs" />}
|
|
116
|
+
{rows && <Text>{shown.length} / {rows.length}{rows.length >= LOG_LIMIT ? '+' : ''} records</Text>}
|
|
117
|
+
</>}
|
|
118
|
+
>
|
|
119
|
+
<Wrap gap={1} mb={2} align="center">
|
|
120
|
+
{present.map((level) => {
|
|
121
|
+
const on = levels === null || levels.includes(level);
|
|
122
|
+
return (
|
|
123
|
+
<Button
|
|
124
|
+
key={level}
|
|
125
|
+
size="2xs"
|
|
126
|
+
variant={on ? 'solid' : 'outline'}
|
|
127
|
+
onClick={() => {
|
|
128
|
+
const current = levels ?? present;
|
|
129
|
+
setLevels(on ? current.filter((l) => l !== level) : [...current, level]);
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{level}
|
|
133
|
+
</Button>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
{levels !== null && <Button size="2xs" variant="ghost" onClick={() => setLevels(null)}>all levels</Button>}
|
|
137
|
+
<Input size="xs" w="220px" placeholder="search logger / message" value={search} onChange={(e) => setSearch(e.target.value)} />
|
|
138
|
+
</Wrap>
|
|
139
|
+
{error && (
|
|
140
|
+
<Alert.Root status="error" mb={2}><Alert.Indicator /><Alert.Description>{error.message}</Alert.Description></Alert.Root>
|
|
141
|
+
)}
|
|
142
|
+
{rows && !rows.length && (
|
|
143
|
+
<Text fontSize="sm" color="var(--color-text-muted)">
|
|
144
|
+
No log records. A job writes them with <Code>bujang.logs.setup_jsonl()</Code>.
|
|
145
|
+
</Text>
|
|
146
|
+
)}
|
|
147
|
+
<Box maxH="360px" overflowY="auto" fontFamily="mono" fontSize="xs">
|
|
148
|
+
{shown.map((r, i) => (
|
|
149
|
+
<Box
|
|
150
|
+
key={i}
|
|
151
|
+
py="1px"
|
|
152
|
+
borderBottom="1px solid"
|
|
153
|
+
borderColor="var(--color-border)"
|
|
154
|
+
cursor={r.exception ? 'pointer' : undefined}
|
|
155
|
+
onClick={() => r.exception && setOpen(open === i ? null : i)}
|
|
156
|
+
>
|
|
157
|
+
<HStack gap={2} align="start">
|
|
158
|
+
<Text color="var(--color-text-muted)" flexShrink={0}>{clock(r.time)}</Text>
|
|
159
|
+
<Text color={levelColor(String(r.level ?? ''))} w="60px" flexShrink={0}>{String(r.level ?? '')}</Text>
|
|
160
|
+
<Text color="var(--color-text-muted)" flexShrink={0}>{String(r.logger ?? '')}</Text>
|
|
161
|
+
<Text whiteSpace="pre-wrap" wordBreak="break-word">
|
|
162
|
+
{String(r.message ?? '')}{r.exception ? ' ▸' : ''}
|
|
163
|
+
</Text>
|
|
164
|
+
</HStack>
|
|
165
|
+
{open === i && !!r.exception && (
|
|
166
|
+
<Box as="pre" whiteSpace="pre-wrap" color="var(--color-status-failed)" pl={4}>{String(r.exception)}</Box>
|
|
167
|
+
)}
|
|
168
|
+
</Box>
|
|
169
|
+
))}
|
|
170
|
+
</Box>
|
|
171
|
+
</PanelFrame>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** A chart of an event: the panel's Vega-Lite spec, else its builder fields, else guessed ones */
|
|
176
|
+
export const ChartPanel: React.FC<PanelProps<'chart'>> = ({ jrJobId, files, panel, editing, onMove, onRemove }) => {
|
|
177
|
+
const event = panel.event ?? '';
|
|
178
|
+
const used = useMemo(() => panelFiles(files, panel.files), [files, panel.files]);
|
|
179
|
+
const fields = useMemo(() => mergeFields(used, event), [used, event]);
|
|
180
|
+
const fieldMap = useMemo(() => new Map([...fields, ...FILE_FIELDS].map((f) => [f.name, f])), [fields]);
|
|
181
|
+
const builder = useMemo(
|
|
182
|
+
() => (panel.spec ? null : builderOfPanel(panel) ?? guessBuilder(fields, filesWithEvent(used, event).length > 1)),
|
|
183
|
+
[panel, fields, used, event],
|
|
184
|
+
);
|
|
185
|
+
const spec = useMemo(() => {
|
|
186
|
+
if (panel.spec) return { data: { name: 'rows' }, ...panel.spec };
|
|
187
|
+
return builder ? buildSpec(builder, fieldMap) : null;
|
|
188
|
+
}, [panel.spec, builder, fieldMap]);
|
|
189
|
+
|
|
190
|
+
const query = useMemo(() => {
|
|
191
|
+
// a built chart: only its fields, only the rows having its x and y; a spec: whole rows
|
|
192
|
+
const wanted = builder && spec ? [...specFields(spec)].filter((f) => !f.startsWith('_') && fieldMap.has(f)) : [];
|
|
193
|
+
const required = builder
|
|
194
|
+
? [builder.x, builder.yAggregate === 'count' ? '' : builder.y].filter((f) => f && !f.startsWith('_') && fieldMap.has(f))
|
|
195
|
+
: [];
|
|
196
|
+
return {
|
|
197
|
+
files: splitFiles(panel.files),
|
|
198
|
+
events: event ? [event] : undefined,
|
|
199
|
+
fields: wanted.length ? wanted : undefined,
|
|
200
|
+
require: required.length ? required : undefined,
|
|
201
|
+
limit: ROW_LIMIT,
|
|
202
|
+
};
|
|
203
|
+
}, [builder, spec, fieldMap, panel.files, event]);
|
|
204
|
+
const ready = !!spec && fields.length > 0;
|
|
205
|
+
const { data: rows, isFetching, error } = useQuery<Record<string, unknown>[], ApiError>({
|
|
206
|
+
queryKey: ['bujang-job-data-rows', jrJobId, query],
|
|
207
|
+
queryFn: () => getJobDataRows(jrJobId, query),
|
|
208
|
+
enabled: ready,
|
|
209
|
+
staleTime: 30_000,
|
|
210
|
+
placeholderData: (previous) => previous,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<PanelFrame
|
|
215
|
+
title={panel.title || event || 'records'}
|
|
216
|
+
kind={event ? `chart · ${event}` : 'chart'}
|
|
217
|
+
editing={editing}
|
|
218
|
+
onMove={onMove}
|
|
219
|
+
onRemove={onRemove}
|
|
220
|
+
info={<>
|
|
221
|
+
{isFetching && <Spinner size="xs" />}
|
|
222
|
+
{rows && <Text>{rows.length}{rows.length >= ROW_LIMIT ? '+' : ''} rows</Text>}
|
|
223
|
+
</>}
|
|
224
|
+
>
|
|
225
|
+
{!fields.length && (
|
|
226
|
+
<Text fontSize="sm" color="var(--color-text-muted)">
|
|
227
|
+
No <Code>{event || 'records'}</Code> rows in {panel.files ? <Code>{panel.files}</Code> : 'the data files'} of this job.
|
|
228
|
+
</Text>
|
|
229
|
+
)}
|
|
230
|
+
{error && (
|
|
231
|
+
<Alert.Root status="error" mb={2}><Alert.Indicator /><Alert.Description>{error.message}</Alert.Description></Alert.Root>
|
|
232
|
+
)}
|
|
233
|
+
{ready && rows && <VegaChart spec={spec} rows={rows} />}
|
|
234
|
+
</PanelFrame>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const SOURCE_TEXT: Record<JobOverviewLayout['source']['kind'], string> = {
|
|
239
|
+
experiment: 'saved for the experiment',
|
|
240
|
+
script: 'saved for the script',
|
|
241
|
+
plugin: 'from the plugin',
|
|
242
|
+
setting: 'the default layout (settings)',
|
|
243
|
+
default: 'the built-in layout',
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/** Where the layout comes from, and the buttons to edit, save and reset it */
|
|
247
|
+
export const LayoutBar: React.FC<{
|
|
248
|
+
found: JobOverviewLayout;
|
|
249
|
+
dirty: boolean;
|
|
250
|
+
editing: boolean;
|
|
251
|
+
saving: boolean;
|
|
252
|
+
onEdit: (on: boolean) => void;
|
|
253
|
+
onSave: (target: 'experiment' | 'script' | 'default') => void;
|
|
254
|
+
onDiscard: () => void;
|
|
255
|
+
onReset: () => void;
|
|
256
|
+
}> = ({ found, dirty, editing, saving, onEdit, onSave, onDiscard, onReset }) => {
|
|
257
|
+
const { source, keys } = found;
|
|
258
|
+
const saved = source.kind === 'experiment' || source.kind === 'script';
|
|
259
|
+
return (
|
|
260
|
+
<Card.Root {...cardProps}>
|
|
261
|
+
<Card.Body py={2}>
|
|
262
|
+
<Wrap gap={2} align="center" justify="space-between">
|
|
263
|
+
<HStack gap={2} fontSize="sm">
|
|
264
|
+
<Text fontWeight="semibold">Layout</Text>
|
|
265
|
+
<Text color="var(--color-text-muted)">
|
|
266
|
+
{SOURCE_TEXT[source.kind]} {source.name && <Code>{source.name}</Code>}
|
|
267
|
+
</Text>
|
|
268
|
+
{dirty && <Badge size="xs" colorPalette="orange">not saved</Badge>}
|
|
269
|
+
</HStack>
|
|
270
|
+
<Wrap gap={1}>
|
|
271
|
+
<Button size="xs" variant={editing ? 'solid' : 'outline'} onClick={() => onEdit(!editing)}>
|
|
272
|
+
{editing ? 'Done' : 'Edit'}
|
|
273
|
+
</Button>
|
|
274
|
+
{dirty && (
|
|
275
|
+
<>
|
|
276
|
+
{keys.experiment && (
|
|
277
|
+
<Button size="xs" variant="outline" loading={saving} onClick={() => onSave('experiment')}
|
|
278
|
+
title="Every job of this experiment gets this layout">
|
|
279
|
+
Save for experiment <Code ml={1}>{keys.experiment}</Code>
|
|
280
|
+
</Button>
|
|
281
|
+
)}
|
|
282
|
+
<Button size="xs" variant="outline" loading={saving} onClick={() => onSave('script')}
|
|
283
|
+
title="Every job of this script gets this layout (unless its experiment has one)">
|
|
284
|
+
Save for script <Code ml={1}>{keys.script}</Code>
|
|
285
|
+
</Button>
|
|
286
|
+
<Button size="xs" variant="outline" loading={saving} onClick={() => onSave('default')}
|
|
287
|
+
title="The overview_layout setting: the jobs without a saved or plugin layout">
|
|
288
|
+
Save as default
|
|
289
|
+
</Button>
|
|
290
|
+
<Button size="xs" variant="ghost" onClick={onDiscard}>Discard</Button>
|
|
291
|
+
</>
|
|
292
|
+
)}
|
|
293
|
+
{saved && !dirty && (
|
|
294
|
+
<Button size="xs" variant="ghost" loading={saving} onClick={onReset}
|
|
295
|
+
title={`Remove the layout saved for the ${source.kind} ${source.name}`}>
|
|
296
|
+
Reset
|
|
297
|
+
</Button>
|
|
298
|
+
)}
|
|
299
|
+
</Wrap>
|
|
300
|
+
</Wrap>
|
|
301
|
+
</Card.Body>
|
|
302
|
+
</Card.Root>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/** The panels of a layout */
|
|
307
|
+
export const LayoutPanels: React.FC<{
|
|
308
|
+
jrJobId: string;
|
|
309
|
+
files: JobData['files'];
|
|
310
|
+
layout: OverviewLayout;
|
|
311
|
+
editing: boolean;
|
|
312
|
+
onChange: (layout: OverviewLayout) => void;
|
|
313
|
+
}> = ({ jrJobId, files, layout, editing, onChange }) => {
|
|
314
|
+
const move = (i: number, by: number) => {
|
|
315
|
+
const j = i + by;
|
|
316
|
+
if (j < 0 || j >= layout.panels.length) return;
|
|
317
|
+
const panels = [...layout.panels];
|
|
318
|
+
[panels[i], panels[j]] = [panels[j], panels[i]];
|
|
319
|
+
onChange({ panels });
|
|
320
|
+
};
|
|
321
|
+
const remove = (i: number) => onChange({ panels: layout.panels.filter((_, k) => k !== i) });
|
|
322
|
+
if (!layout.panels.length) {
|
|
323
|
+
return (
|
|
324
|
+
<Text fontSize="sm" color="var(--color-text-muted)">
|
|
325
|
+
The layout has no panel: add charts from the explorer below.
|
|
326
|
+
</Text>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return (
|
|
330
|
+
<VStack align="stretch" gap={4}>
|
|
331
|
+
{layout.panels.map((panel, i) => {
|
|
332
|
+
const props = { jrJobId, files, editing, onMove: (by: number) => move(i, by), onRemove: () => remove(i) };
|
|
333
|
+
// a panel edited or moved starts again (its filters, its rows)
|
|
334
|
+
const key = `${i}:${JSON.stringify(panel)}`;
|
|
335
|
+
return panel.kind === 'logs'
|
|
336
|
+
? <LogPanel key={key} {...props} panel={panel} />
|
|
337
|
+
: <ChartPanel key={key} {...props} panel={panel} />;
|
|
338
|
+
})}
|
|
339
|
+
</VStack>
|
|
340
|
+
);
|
|
341
|
+
};
|
|
@@ -40,7 +40,7 @@ export interface PipelineTemplateFileData {
|
|
|
40
40
|
|
|
41
41
|
// Profile names repeat between clusters and between the node types of a cluster (1-gpu, 4-gpu, ...):
|
|
42
42
|
// jobs reference "<cluster>/<node>/<name>" ("<cluster>/<name>" for profiles without a node type)
|
|
43
|
-
const profileKey = (profile?: SlurmProfile): string => {
|
|
43
|
+
export const profileKey = (profile?: SlurmProfile): string => {
|
|
44
44
|
if (!profile) return '';
|
|
45
45
|
const cluster = profile.cluster || 'mila';
|
|
46
46
|
return profile.node ? `${cluster}/${profile.node}/${profile.name}` : `${cluster}/${profile.name}`;
|
|
@@ -59,7 +59,7 @@ const findProfile = (value: string | undefined, profiles: SlurmProfile[]): Slurm
|
|
|
59
59
|
&& (node === undefined || p.node === node));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const profileLabel = (p: SlurmProfile) =>
|
|
62
|
+
export const profileLabel = (p: SlurmProfile) =>
|
|
63
63
|
`${p.cluster || 'mila'} / ${p.name}${p.node ? ` (${p.node})` : ''}${p.executor === 'ssh' ? ' - ssh' : ''}`;
|
|
64
64
|
|
|
65
65
|
type Path = number[];
|
|
@@ -117,7 +117,7 @@ const changeType = (node: PipelineNode, type: NodeType, fallback: { script: stri
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const TYPE_LABEL: Record<NodeType, string> = { job: 'Job', sequential: 'Sequential', parallel: 'Parallel' };
|
|
120
|
-
const TYPE_COLOR: Record<NodeType, string> = {
|
|
120
|
+
export const TYPE_COLOR: Record<NodeType, string> = {
|
|
121
121
|
job: 'var(--color-pipeline-job-border)',
|
|
122
122
|
sequential: 'var(--color-pipeline-seq-border)',
|
|
123
123
|
parallel: 'var(--color-pipeline-par-border)',
|