@milabench/bujang 0.1.18 → 0.1.20
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/README.md +16 -0
- package/dist/api.d.ts +46 -4
- package/dist/components/OrganizerNav.d.ts +28 -0
- package/dist/components/ProjectsNav.d.ts +15 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +6344 -4777
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +27 -3
- package/dist/routes.d.ts +7 -2
- package/dist/types.d.ts +118 -4
- package/dist/views/CollectionView.d.ts +22 -0
- package/dist/views/JobDataOverview.d.ts +1 -1
- package/dist/views/JobsTable.d.ts +1 -0
- package/dist/views/JobsView.d.ts +12 -1
- package/dist/views/OrganizerValuesView.d.ts +13 -0
- package/dist/views/OverviewPanels.d.ts +13 -2
- package/dist/views/ProjectDetailsView.d.ts +3 -0
- package/dist/views/ProjectsView.d.ts +20 -0
- package/dist/views/dataCharts.d.ts +1 -1
- package/package.json +1 -1
- package/src/api.ts +90 -8
- package/src/components/OrganizerNav.tsx +121 -0
- package/src/components/ProjectsNav.tsx +101 -0
- package/src/index.ts +11 -2
- package/src/paths.ts +50 -3
- package/src/routes.tsx +21 -4
- package/src/types.ts +117 -5
- package/src/views/CollectionView.tsx +68 -0
- package/src/views/JanitorView.tsx +2 -1
- package/src/views/JobDataOverview.tsx +23 -6
- package/src/views/JobLogs.tsx +47 -2
- package/src/views/JobSubmit.tsx +25 -0
- package/src/views/JobsTable.tsx +81 -21
- package/src/views/JobsView.tsx +49 -9
- package/src/views/OrganizerValuesView.tsx +207 -0
- package/src/views/OverviewPanels.tsx +531 -7
- package/src/views/PipelineEditor.tsx +69 -2
- package/src/views/PipelinesView.tsx +145 -4
- package/src/views/ProjectDetailsView.tsx +112 -0
- package/src/views/ProjectsView.tsx +355 -0
- package/src/views/dataCharts.tsx +1 -1
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Textarea,
|
|
17
17
|
VStack,
|
|
18
18
|
} from '@chakra-ui/react';
|
|
19
|
-
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
19
|
+
import { useMutation, useQueries, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
20
20
|
import { LuPlus, LuTrash2 } from 'react-icons/lu';
|
|
21
21
|
import { getSlurmTemplateContent, saveSlurmProfile, saveSlurmTemplate } from '../api';
|
|
22
22
|
import type { ApiError, PipelineNode, PipelineTemplatePayload, SlurmProfile } from '../types';
|
|
@@ -116,6 +116,27 @@ const changeType = (node: PipelineNode, type: NodeType, fallback: { script: stri
|
|
|
116
116
|
return { ...node, type };
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
/** The `export NAME=CONSTANT` lines of a script, read as the server does to resolve the labels (script_arguments) */
|
|
120
|
+
const exportedConstants = (script: string): Record<string, string> => {
|
|
121
|
+
const out: Record<string, string> = {};
|
|
122
|
+
for (const [, name, raw] of script.matchAll(/^[ \t]*export[ \t]+([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*([^$\n\r]*?)[ \t]*\r?$/gm)) {
|
|
123
|
+
const value = raw.trim();
|
|
124
|
+
const quoted = value.length >= 2 && value[0] === value[value.length - 1] && `"'`.includes(value[0]);
|
|
125
|
+
out[name] = quoted ? value.slice(1, -1) : value;
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** The label a job will get (resolve_label of the server): its own, its nearest group's or its script's, `{NAME}` filled */
|
|
131
|
+
const resolvedLabel = (job: Extract<PipelineNode, { type: 'job' }>, inherited: string | undefined, script: string | undefined): string => {
|
|
132
|
+
const values: Record<string, string> = { ...exportedConstants(script ?? ''), ...(job.env ?? {}) };
|
|
133
|
+
const template = job.label || inherited || values.BUJANG_JOB_LABEL || values.JR_JOB_LABEL || '';
|
|
134
|
+
return template.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (all, name: string) => String(values[name] ?? all)).split(/\s+/).filter(Boolean).join(' ').slice(0, 200);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/** The scripts of the jobs under a node */
|
|
138
|
+
const scriptsOf = (node: PipelineNode): string[] => (node.type === 'job' ? (node.script ? [node.script] : []) : node.jobs.flatMap(scriptsOf));
|
|
139
|
+
|
|
119
140
|
const TYPE_LABEL: Record<NodeType, string> = { job: 'Job', sequential: 'Sequential', parallel: 'Parallel' };
|
|
120
141
|
export const TYPE_COLOR: Record<NodeType, string> = {
|
|
121
142
|
job: 'var(--color-pipeline-job-border)',
|
|
@@ -174,12 +195,17 @@ const TreeRows: React.FC<{
|
|
|
174
195
|
onHover: (hover: Hover) => void;
|
|
175
196
|
/** the sweep variable of the nearest parallel group above: its value names a job */
|
|
176
197
|
sweepKey?: string;
|
|
177
|
-
|
|
198
|
+
/** the label of the nearest group above that has one */
|
|
199
|
+
groupLabel?: string;
|
|
200
|
+
/** the content of the scripts, to resolve the labels */
|
|
201
|
+
scripts: Record<string, string | undefined>;
|
|
202
|
+
}> = ({ node, path, marker, selected, onSelect, onType, onDelete, onAdd, root, hover, onHover, sweepKey, groupLabel, scripts }) => {
|
|
178
203
|
const depth = path.length;
|
|
179
204
|
const isSelected = samePath(selected, path);
|
|
180
205
|
const swept = node.type === 'job' ? sweepValue(node.env, sweepKey) : undefined;
|
|
181
206
|
const name = swept ?? nodeName(node);
|
|
182
207
|
const childSweep = groupSweepKey(node) || sweepKey;
|
|
208
|
+
const label = node.type === 'job' ? resolvedLabel(node, groupLabel, scripts[node.script]) : '';
|
|
183
209
|
const tint = hoverTint(hover, path, root);
|
|
184
210
|
const deleting = hover?.mode === 'delete' && !!tint;
|
|
185
211
|
return (
|
|
@@ -217,6 +243,7 @@ const TreeRows: React.FC<{
|
|
|
217
243
|
{swept && node.type === 'job' && node.script && (
|
|
218
244
|
<Text as="span" color="var(--color-text-muted)"> · {scriptStem(node.script)}</Text>
|
|
219
245
|
)}
|
|
246
|
+
{label && <Text as="span" color="var(--color-text-muted)" title={label}> · {label}</Text>}
|
|
220
247
|
</Text>
|
|
221
248
|
{depth > 0 && (
|
|
222
249
|
<IconButton
|
|
@@ -251,6 +278,8 @@ const TreeRows: React.FC<{
|
|
|
251
278
|
hover={hover}
|
|
252
279
|
onHover={onHover}
|
|
253
280
|
sweepKey={childSweep}
|
|
281
|
+
groupLabel={node.label || groupLabel}
|
|
282
|
+
scripts={scripts}
|
|
254
283
|
/>
|
|
255
284
|
))}
|
|
256
285
|
<Box
|
|
@@ -487,6 +516,21 @@ const ScriptTab: React.FC<{ script: string; content?: string; usedBy: number }>
|
|
|
487
516
|
);
|
|
488
517
|
};
|
|
489
518
|
|
|
519
|
+
/** `node` with this label, without any when it is empty */
|
|
520
|
+
const withLabel = <T extends PipelineNode, >(node: T, label: string): T => {
|
|
521
|
+
const { label: _old, ...rest } = node;
|
|
522
|
+
return (label ? { ...rest, label } : rest) as T;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
/** The label of a job, or of the jobs under a group */
|
|
526
|
+
const LabelField: React.FC<{ value?: string; help: string; onChange: (label: string) => void }> = ({ value, help, onChange }) => (
|
|
527
|
+
<Field.Root>
|
|
528
|
+
<Field.Label fontSize="xs">Label (optional)</Field.Label>
|
|
529
|
+
<Input size="sm" placeholder="train lr={LR}" value={value ?? ''} onChange={(e) => onChange(e.target.value)} />
|
|
530
|
+
<Field.HelperText fontSize="xs">{help}</Field.HelperText>
|
|
531
|
+
</Field.Root>
|
|
532
|
+
);
|
|
533
|
+
|
|
490
534
|
/** The selected job: script and resources pickers, then its arguments, its profile and its script */
|
|
491
535
|
const JobPane: React.FC<{
|
|
492
536
|
job: JobNode;
|
|
@@ -509,6 +553,11 @@ const JobPane: React.FC<{
|
|
|
509
553
|
|
|
510
554
|
return (
|
|
511
555
|
<Flex direction="column" gap={3} h="100%" minH={0}>
|
|
556
|
+
<LabelField
|
|
557
|
+
value={job.label}
|
|
558
|
+
help="Names the job in the job list, {NAME} is the value of its argument NAME. Empty: the label of its group, else the script's BUJANG_JOB_LABEL."
|
|
559
|
+
onChange={(label) => onChange(withLabel(job, label))}
|
|
560
|
+
/>
|
|
512
561
|
<HStack gap={3} align="flex-end" flexWrap="wrap">
|
|
513
562
|
<Field.Root flex="1 1 220px">
|
|
514
563
|
<Field.Label fontSize="xs">Script</Field.Label>
|
|
@@ -577,6 +626,11 @@ const GroupPane: React.FC<{
|
|
|
577
626
|
<Field.Label fontSize="xs">{group.type === 'sequential' ? 'Sequential' : 'Parallel'} group name</Field.Label>
|
|
578
627
|
<Input size="sm" value={group.name} onChange={(e) => onChange({ ...group, name: e.target.value })} />
|
|
579
628
|
</Field.Root>
|
|
629
|
+
<LabelField
|
|
630
|
+
value={group.label}
|
|
631
|
+
help="Names every job under the group in the job list, {NAME} is the value of the argument NAME of each job. The label of a job, or of a closer group, wins."
|
|
632
|
+
onChange={(label) => onChange(withLabel(group, label))}
|
|
633
|
+
/>
|
|
580
634
|
{group.type === 'parallel' && (
|
|
581
635
|
<Field.Root>
|
|
582
636
|
<Field.Label fontSize="xs">Sweep variable (optional)</Field.Label>
|
|
@@ -638,6 +692,18 @@ export const PipelineBuilder: React.FC<{
|
|
|
638
692
|
if (loadedTemplateData.definition) setRoot(loadedTemplateData.definition);
|
|
639
693
|
}, [loadedTemplateData]);
|
|
640
694
|
|
|
695
|
+
// the content of its scripts, to show the labels of its jobs
|
|
696
|
+
const scriptNames = [...new Set(scriptsOf(root))];
|
|
697
|
+
const contents = useQueries({
|
|
698
|
+
queries: scriptNames.map((script) => ({
|
|
699
|
+
queryKey: ['slurm-template-content', script],
|
|
700
|
+
queryFn: () => getSlurmTemplateContent(script),
|
|
701
|
+
retry: false,
|
|
702
|
+
staleTime: 30_000,
|
|
703
|
+
})),
|
|
704
|
+
});
|
|
705
|
+
const scripts = Object.fromEntries(scriptNames.map((script, i) => [script, contents[i]?.data]));
|
|
706
|
+
|
|
641
707
|
const selectedNode = selected ? nodeAt(root, selected) : undefined;
|
|
642
708
|
const issue = useMemo(() => problem(root), [root]);
|
|
643
709
|
|
|
@@ -739,6 +805,7 @@ export const PipelineBuilder: React.FC<{
|
|
|
739
805
|
root={root}
|
|
740
806
|
hover={hover}
|
|
741
807
|
onHover={setHover}
|
|
808
|
+
scripts={scripts}
|
|
742
809
|
/>
|
|
743
810
|
</Box>
|
|
744
811
|
<Box flex={1} minW={0} p={4} overflow="auto">
|
|
@@ -31,8 +31,13 @@ import {
|
|
|
31
31
|
loadPipelineFromFile,
|
|
32
32
|
runPipelineTemplate,
|
|
33
33
|
getPipelineRuns,
|
|
34
|
-
getPipelineRunStatus
|
|
34
|
+
getPipelineRunStatus,
|
|
35
|
+
getSlurmJobStdoutFull,
|
|
36
|
+
getSlurmJobStderrFull,
|
|
37
|
+
getSlurmJobStdoutSize,
|
|
38
|
+
getSlurmJobStderrSize
|
|
35
39
|
} from '../api';
|
|
40
|
+
import { LogDisplay } from './LogDisplay';
|
|
36
41
|
import type {
|
|
37
42
|
PipelineNode,
|
|
38
43
|
ApiError,
|
|
@@ -134,8 +139,121 @@ const groupSummary = (steps: PipelineRunStep[]): string => {
|
|
|
134
139
|
.join(', ');
|
|
135
140
|
};
|
|
136
141
|
|
|
142
|
+
// a step writing its logs (their view refreshes), a step whose job has not started (no logs yet)
|
|
143
|
+
const ACTIVE_STEP_STATES = ['RUNNING', 'COMPLETING', 'CONFIGURING', 'STARTING'];
|
|
144
|
+
const WAITING_STEP_STATES = ['PENDING', 'HELD', 'SUBMITTED'];
|
|
145
|
+
|
|
146
|
+
/** The step shown when none was picked: the running one, else the first that failed */
|
|
147
|
+
const defaultStep = (steps: PipelineRunStep[]): PipelineRunStep | undefined =>
|
|
148
|
+
steps.find((step) => ACTIVE_STEP_STATES.includes(step.state || ''))
|
|
149
|
+
?? steps.find((step) => stepStateColor(step.state) === 'red');
|
|
150
|
+
|
|
151
|
+
const formatFileSize = (bytes: number): string => {
|
|
152
|
+
if (bytes === 0) return '0 B';
|
|
153
|
+
const k = 1024;
|
|
154
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
155
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
156
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const DetailField: React.FC<{ label: string; children: React.ReactNode }> = ({ label, children }) => (
|
|
160
|
+
<HStack align="flex-start" gap={3} fontSize="xs">
|
|
161
|
+
<Text minW="88px" color="var(--color-text-muted)">{label}</Text>
|
|
162
|
+
<Box fontFamily="mono" color="var(--color-text)" minW={0} wordBreak="break-word">{children}</Box>
|
|
163
|
+
</HStack>
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
/** One step of a run: what it runs, where, and its stdout / stderr */
|
|
167
|
+
const PipelineStepDetails: React.FC<{ step: PipelineRunStep; following: boolean; onFollow: () => void }> = ({ step, following, onFollow }) => {
|
|
168
|
+
const paths = useBujangPaths();
|
|
169
|
+
const state = step.state || 'UNKNOWN';
|
|
170
|
+
const active = ACTIVE_STEP_STATES.includes(state);
|
|
171
|
+
const waiting = WAITING_STEP_STATES.includes(state);
|
|
172
|
+
const slurmJobId = step.executor === 'ssh' ? null : step.slurm_jobid;
|
|
173
|
+
const env = Object.entries(step.env || {});
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<VStack align="stretch" gap={3} p={4} borderRadius="md" border="1px solid" borderColor="var(--color-border)" bg="var(--color-bg-page)">
|
|
177
|
+
<HStack gap={3} flexWrap="wrap">
|
|
178
|
+
<Heading size="sm" color="var(--color-text)" fontFamily="mono">{stepName(step.step) || step.job_id}</Heading>
|
|
179
|
+
<Badge colorPalette={stepStateColor(step.state)}>{state}</Badge>
|
|
180
|
+
{step.job_label && <Text fontSize="sm" color="var(--color-text-muted)">{step.job_label}</Text>}
|
|
181
|
+
<Spacer />
|
|
182
|
+
{following ? (
|
|
183
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
184
|
+
{active ? 'following the running step' : 'no step running: the first that failed'}
|
|
185
|
+
</Text>
|
|
186
|
+
) : (
|
|
187
|
+
<Button size="xs" variant="outline" onClick={onFollow} borderColor="var(--color-border)" color="var(--color-text)">
|
|
188
|
+
Follow the running step
|
|
189
|
+
</Button>
|
|
190
|
+
)}
|
|
191
|
+
{step.job_id && (
|
|
192
|
+
<Button asChild size="xs" variant="outline" borderColor="var(--color-border)" color="var(--color-text)">
|
|
193
|
+
<RouterLink to={paths.jobLogs(slurmJobId || NO_JOB_ID, step.job_id)}>Open the job page</RouterLink>
|
|
194
|
+
</Button>
|
|
195
|
+
)}
|
|
196
|
+
</HStack>
|
|
197
|
+
|
|
198
|
+
<VStack align="stretch" gap={1}>
|
|
199
|
+
{step.step && <DetailField label="Step">{step.step}</DetailField>}
|
|
200
|
+
<DetailField label="Runs on">
|
|
201
|
+
{step.executor === 'ssh' ? `ssh ${step.host ?? ''}` : `slurm ${step.slurm_jobid ?? '-'}`}
|
|
202
|
+
{step.cluster && <Text as="span" color="var(--color-text-muted)"> on {step.cluster}</Text>}
|
|
203
|
+
</DetailField>
|
|
204
|
+
<DetailField label="Profile">{step.profile}</DetailField>
|
|
205
|
+
<DetailField label="Script">{step.script}</DetailField>
|
|
206
|
+
{step.job_id && <DetailField label="Job folder">{step.job_id}</DetailField>}
|
|
207
|
+
{step.sweep && <DetailField label="Sweep">{step.sweep_key ? `${step.sweep_key}=${step.sweep}` : step.sweep}</DetailField>}
|
|
208
|
+
{step.after && step.after.length > 0 && <DetailField label="After">{step.after.join(', ')}</DetailField>}
|
|
209
|
+
{env.length > 0 && (
|
|
210
|
+
<DetailField label="Environment">
|
|
211
|
+
{env.map(([key, value]) => <Text key={key}>{key}={value}</Text>)}
|
|
212
|
+
</DetailField>
|
|
213
|
+
)}
|
|
214
|
+
</VStack>
|
|
215
|
+
|
|
216
|
+
{!step.job_id ? (
|
|
217
|
+
<Text fontSize="sm" color="var(--color-text-muted)">Not submitted yet: no logs.</Text>
|
|
218
|
+
) : waiting ? (
|
|
219
|
+
<Text fontSize="sm" color="var(--color-text-muted)">The job has not started yet: no logs.</Text>
|
|
220
|
+
) : (
|
|
221
|
+
// keyed by job: the logs of another step start from scratch
|
|
222
|
+
<Flex key={step.job_id} gap={4} direction={{ base: 'column', lg: 'row' }} h={{ base: '760px', lg: '440px' }}>
|
|
223
|
+
<LogDisplay
|
|
224
|
+
logType="stdout"
|
|
225
|
+
jrJobId={step.job_id}
|
|
226
|
+
isJobFinished={!active}
|
|
227
|
+
formatFileSize={formatFileSize}
|
|
228
|
+
fetchLogData={getSlurmJobStdoutFull}
|
|
229
|
+
getSlurmJobLogSize={getSlurmJobStdoutSize}
|
|
230
|
+
/>
|
|
231
|
+
<LogDisplay
|
|
232
|
+
logType="stderr"
|
|
233
|
+
jrJobId={step.job_id}
|
|
234
|
+
isJobFinished={!active}
|
|
235
|
+
formatFileSize={formatFileSize}
|
|
236
|
+
fetchLogData={getSlurmJobStderrFull}
|
|
237
|
+
getSlurmJobLogSize={getSlurmJobStderrSize}
|
|
238
|
+
/>
|
|
239
|
+
</Flex>
|
|
240
|
+
)}
|
|
241
|
+
</VStack>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
137
245
|
// Progress of one run: steps with their state and the pipeline log, refreshed until it is over
|
|
138
246
|
const PipelineRunProgress: React.FC<{ runId: string }> = ({ runId }) => {
|
|
247
|
+
// ?step=<job id>: the step picked in the table; none: the running step (else the first that failed)
|
|
248
|
+
const [params, setParams] = useSearchParams();
|
|
249
|
+
const pickedStep = params.get('step');
|
|
250
|
+
const pickStep = (jobId: string | null) => setParams((current) => {
|
|
251
|
+
const next = new URLSearchParams(current);
|
|
252
|
+
if (jobId) next.set('step', jobId);
|
|
253
|
+
else next.delete('step');
|
|
254
|
+
return next;
|
|
255
|
+
}, { replace: true });
|
|
256
|
+
|
|
139
257
|
const { data: run, error, dataUpdatedAt, isFetching } = useQuery<PipelineRunStatus, ApiError>({
|
|
140
258
|
queryKey: ['pipeline-run', runId],
|
|
141
259
|
queryFn: () => getPipelineRunStatus(runId),
|
|
@@ -170,6 +288,9 @@ const PipelineRunProgress: React.FC<{ runId: string }> = ({ runId }) => {
|
|
|
170
288
|
}
|
|
171
289
|
|
|
172
290
|
const label = run.status === 'submitted' ? (run.state || 'unknown') : run.status;
|
|
291
|
+
const steps = run.steps ?? [];
|
|
292
|
+
const picked = pickedStep ? steps.find((step) => step.job_id === pickedStep) : undefined;
|
|
293
|
+
const selected = picked ?? defaultStep(steps);
|
|
173
294
|
|
|
174
295
|
return (
|
|
175
296
|
<VStack align="stretch" gap={4}>
|
|
@@ -239,13 +360,27 @@ const PipelineRunProgress: React.FC<{ runId: string }> = ({ runId }) => {
|
|
|
239
360
|
if (!step) return null;
|
|
240
361
|
// in the tree the parents are the rows above: "1.Sizing/0.lynx_sizing" -> "lynx_sizing"
|
|
241
362
|
const name = row.node ? stepName(step.step) : step.step;
|
|
363
|
+
const isSelected = !!selected && selected === step;
|
|
242
364
|
return (
|
|
243
|
-
<Table.Row
|
|
365
|
+
<Table.Row
|
|
366
|
+
key={step.job_id || step.step || index}
|
|
367
|
+
// the step shown below the table
|
|
368
|
+
bg={isSelected ? 'var(--color-bg-hover)' : undefined}
|
|
369
|
+
boxShadow={isSelected ? 'inset 3px 0 0 var(--color-primary)' : undefined}
|
|
370
|
+
>
|
|
244
371
|
<Table.Cell fontFamily="mono" fontSize="xs" pl={`${12 + row.depth * 20}px`} whiteSpace="nowrap">
|
|
245
372
|
{indent}
|
|
373
|
+
{/* the step name shows the step below the table, the job folder opens the job page */}
|
|
246
374
|
<Tooltip content={step.step} disabled={name === step.step}>
|
|
247
|
-
|
|
375
|
+
{step.job_id ? (
|
|
376
|
+
<Link asChild colorPalette="blue" variant="underline" fontWeight={isSelected ? 'semibold' : undefined}>
|
|
377
|
+
<button type="button" onClick={() => pickStep(step.job_id!)}>{name}</button>
|
|
378
|
+
</Link>
|
|
379
|
+
) : <Text as="span">{name}</Text>}
|
|
248
380
|
</Tooltip>
|
|
381
|
+
{step.job_label && (
|
|
382
|
+
<Text as="span" ml={2} fontFamily="body" color="var(--color-text-muted)">{step.job_label}</Text>
|
|
383
|
+
)}
|
|
249
384
|
</Table.Cell>
|
|
250
385
|
{sweepKeys.length > 0 && (
|
|
251
386
|
<Table.Cell fontFamily="mono" fontSize="xs">
|
|
@@ -271,6 +406,12 @@ const PipelineRunProgress: React.FC<{ runId: string }> = ({ runId }) => {
|
|
|
271
406
|
</Table.Root>
|
|
272
407
|
)}
|
|
273
408
|
|
|
409
|
+
{selected ? (
|
|
410
|
+
<PipelineStepDetails step={selected} following={!picked} onFollow={() => pickStep(null)} />
|
|
411
|
+
) : steps.length > 0 && (
|
|
412
|
+
<Text fontSize="xs" color="var(--color-text-muted)">Select a step to see its details and its logs.</Text>
|
|
413
|
+
)}
|
|
414
|
+
|
|
274
415
|
{run.status === 'submitted' && (
|
|
275
416
|
<Box>
|
|
276
417
|
<Text fontWeight="semibold" mb={2} color="var(--color-text)">pipeline.log</Text>
|
|
@@ -411,7 +552,7 @@ const PipelineEditor: React.FC<{
|
|
|
411
552
|
const RunButton: React.FC<{ name: string; onStarted: (run: PipelineRunResponse) => void; size?: 'xs' | 'sm' | 'md' }> = ({ name, onStarted, size = 'sm' }) => {
|
|
412
553
|
const queryClient = useQueryClient();
|
|
413
554
|
const run = useMutation({
|
|
414
|
-
mutationFn: runPipelineTemplate,
|
|
555
|
+
mutationFn: (pipeline: string) => runPipelineTemplate(pipeline),
|
|
415
556
|
onSuccess: (data) => {
|
|
416
557
|
queryClient.invalidateQueries({ queryKey: ['pipeline-runs'] });
|
|
417
558
|
toaster.create({ title: `Pipeline ${data.name} started`, description: `Run ${data.run_id}: submitting the jobs`, type: 'info', duration: 4000 });
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
3
|
+
import { Badge, Box, Button, Code, HStack, Spinner, Text } from '@chakra-ui/react';
|
|
4
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { LuFolderGit2, LuLink, LuRefreshCw } from 'react-icons/lu';
|
|
6
|
+
import { getProjects, syncProjects } from '../api';
|
|
7
|
+
import type { ApiError, ProjectsInfo } from '../types';
|
|
8
|
+
import { toaster } from '../toast';
|
|
9
|
+
import { useBujangPaths } from '../context';
|
|
10
|
+
import { JobsView } from './JobsView';
|
|
11
|
+
import { CollectionOverview, CollectionTabs, useCollectionTab } from './CollectionView';
|
|
12
|
+
import { PROJECTS_KEY, ProjectArchive, ProjectCard } from './ProjectsView';
|
|
13
|
+
import type { Project } from '../types';
|
|
14
|
+
|
|
15
|
+
/** How many scripts / pipelines / profiles the project has (the details list them) */
|
|
16
|
+
const ProjectConfigInline: React.FC<{ project: Project }> = ({ project }) => {
|
|
17
|
+
const n = (items?: string[]) => items?.length ?? 0;
|
|
18
|
+
return (
|
|
19
|
+
<Text as="span" fontSize="xs">
|
|
20
|
+
{n(project.templates)} scripts · {n(project.pipelines)} pipelines · {n(project.profiles)} profiles
|
|
21
|
+
</Text>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The repository of a project under the heading of its jobs: where the links are, relink */
|
|
26
|
+
const ProjectStrip: React.FC<{ name: string; info: ProjectsInfo | undefined }> = ({ name, info }) => {
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const project = info?.projects.find((p) => p.name === name);
|
|
29
|
+
const sync = useMutation({
|
|
30
|
+
mutationFn: () => syncProjects(name),
|
|
31
|
+
onSuccess: (report) => {
|
|
32
|
+
const r = report[name] || {};
|
|
33
|
+
toaster.create({
|
|
34
|
+
title: r.error ? `Cannot link ${name}` : `${r.added?.length ?? 0} links added, ${r.removed?.length ?? 0} removed`,
|
|
35
|
+
description: r.error,
|
|
36
|
+
type: r.error ? 'error' : 'success',
|
|
37
|
+
});
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: PROJECTS_KEY });
|
|
39
|
+
},
|
|
40
|
+
onError: (error: ApiError) => toaster.create({ title: 'Relink failed', description: error.message, type: 'error' }),
|
|
41
|
+
});
|
|
42
|
+
if (!info) return <Spinner size="sm" />;
|
|
43
|
+
if (!project) return <Text color="var(--color-status-failed)">No project {name} is registered.</Text>;
|
|
44
|
+
return (
|
|
45
|
+
<HStack gap={3} wrap="wrap" fontSize="sm" color="var(--color-text-muted)">
|
|
46
|
+
<Code fontSize="xs">{project.target}</Code>
|
|
47
|
+
<ProjectConfigInline project={project} />
|
|
48
|
+
{!project.exists && <Badge colorPalette="red">repository missing</Badge>}
|
|
49
|
+
<Badge variant="subtle"><LuLink /> {project.links} links</Badge>
|
|
50
|
+
<Button size="xs" variant="ghost" loading={sync.isPending} onClick={() => sync.mutate()}><LuRefreshCw /> Relink</Button>
|
|
51
|
+
<ProjectArchive project={project} />
|
|
52
|
+
</HStack>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** One project: its repository, then the jobs page filtered on it */
|
|
57
|
+
export const ProjectDetailsView: React.FC = () => {
|
|
58
|
+
const { projectName = '' } = useParams();
|
|
59
|
+
const paths = useBujangPaths();
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
const { data: info } = useQuery<ProjectsInfo>({ queryKey: PROJECTS_KEY, queryFn: getProjects });
|
|
62
|
+
const project = info?.projects.find((p) => p.name === projectName);
|
|
63
|
+
const [details, setDetails] = React.useState(false);
|
|
64
|
+
const [tab, setTab] = useCollectionTab();
|
|
65
|
+
const title = <HStack gap={2} as="span"><LuFolderGit2 /> {projectName}</HStack>;
|
|
66
|
+
if (tab === 'overview') {
|
|
67
|
+
return (
|
|
68
|
+
<CollectionOverview
|
|
69
|
+
organizer="projects"
|
|
70
|
+
value={projectName}
|
|
71
|
+
title={title}
|
|
72
|
+
pageTitle={projectName}
|
|
73
|
+
header={
|
|
74
|
+
<HStack mt={-3} gap={4} wrap="wrap">
|
|
75
|
+
<CollectionTabs tab={tab} onTab={setTab} />
|
|
76
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
77
|
+
its layout is saved in the project folder: {project ? `${project.target}/layouts/overview.yaml` : 'layouts/overview.yaml'}
|
|
78
|
+
</Text>
|
|
79
|
+
</HStack>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<JobsView
|
|
87
|
+
key={projectName}
|
|
88
|
+
filters={{ projects: projectName }}
|
|
89
|
+
pageTitle={projectName}
|
|
90
|
+
title={title}
|
|
91
|
+
submitPath={`${paths.submitJob()}?project=${encodeURIComponent(projectName)}`}
|
|
92
|
+
header={
|
|
93
|
+
<Box mt={-3}>
|
|
94
|
+
<HStack gap={2} wrap="wrap">
|
|
95
|
+
<CollectionTabs tab={tab} onTab={setTab} />
|
|
96
|
+
<ProjectStrip name={projectName} info={info} />
|
|
97
|
+
{project && (
|
|
98
|
+
<Button size="xs" variant="ghost" onClick={() => setDetails(!details)}>
|
|
99
|
+
{details ? 'Hide details' : 'Details'}
|
|
100
|
+
</Button>
|
|
101
|
+
)}
|
|
102
|
+
</HStack>
|
|
103
|
+
{details && project && info && (
|
|
104
|
+
<Box mt={3}>
|
|
105
|
+
<ProjectCard project={project} writable={info.writable} onRemoved={() => navigate(paths.projects())} />
|
|
106
|
+
</Box>
|
|
107
|
+
)}
|
|
108
|
+
</Box>
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
};
|