@milabench/bujang 0.1.11 → 0.1.13

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.
@@ -13,13 +13,15 @@ import {
13
13
  Card,
14
14
  Flex,
15
15
  Spacer,
16
- Link
16
+ Link,
17
+ Input,
18
+ InputGroup
17
19
  } from '@chakra-ui/react';
18
20
  import { Link as RouterLink, useNavigate, useParams, useSearchParams } from 'react-router-dom';
19
21
  import { useBujangPaths } from '../context';
20
22
  import { NO_JOB_ID } from '../constants';
21
23
  import { toaster } from '../toast';
22
- import { LuArrowLeft, LuPencil, LuPlay, LuPlus } from 'react-icons/lu';
24
+ import { LuArrowLeft, LuPencil, LuPlay, LuPlus, LuSearch } from 'react-icons/lu';
23
25
  import { useQuery, useQueries, useMutation, useQueryClient } from '@tanstack/react-query';
24
26
  import {
25
27
  getSlurmProfiles,
@@ -36,7 +38,8 @@ import type {
36
38
  ApiError,
37
39
  PipelineRunResponse,
38
40
  PipelineRunSummary,
39
- PipelineRunStatus
41
+ PipelineRunStatus,
42
+ PipelineRunState
40
43
  } from '../types';
41
44
  import { PipelineGraph, graphIsDrawable } from './PipelineGraph';
42
45
  import { PipelineBuilder } from './PipelineEditor';
@@ -148,49 +151,57 @@ const PipelineRunProgress: React.FC<{ runId: string }> = ({ runId }) => {
148
151
  )}
149
152
 
150
153
  {run.steps && run.steps.length > 0 && (
151
- <Table.Root size="sm" variant="line">
152
- <Table.Header bg="var(--color-bg-header)">
154
+ <Table.Root size="sm" variant="outline">
155
+ <Table.Header>
153
156
  <Table.Row>
154
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Step</Table.ColumnHeader>
157
+ <Table.ColumnHeader>Step</Table.ColumnHeader>
155
158
  {sweepKeys.length > 0 && (
156
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)" fontFamily="mono">
159
+ <Table.ColumnHeader fontFamily="mono">
157
160
  {sweepKeys.length === 1 ? sweepKeys[0] : 'Sweep'}
158
161
  </Table.ColumnHeader>
159
162
  )}
160
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Runs on</Table.ColumnHeader>
161
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Waits on</Table.ColumnHeader>
162
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">State</Table.ColumnHeader>
163
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Job folder</Table.ColumnHeader>
163
+ <Table.ColumnHeader>Runs on</Table.ColumnHeader>
164
+ <Table.ColumnHeader>Waits on</Table.ColumnHeader>
165
+ <Table.ColumnHeader>State</Table.ColumnHeader>
166
+ <Table.ColumnHeader>Job folder</Table.ColumnHeader>
164
167
  </Table.Row>
165
168
  </Table.Header>
166
169
  <Table.Body>
167
- {run.steps.map((step) => (
168
- <Table.Row key={step.job_id || step.step} borderColor="var(--color-border)">
169
- <Table.Cell fontFamily="mono" fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">
170
- <JobLogsLink jobId={step.job_id} slurmJobId={step.executor === 'ssh' ? null : step.slurm_jobid}>{step.step}</JobLogsLink>
171
- </Table.Cell>
172
- {sweepKeys.length > 0 && (
173
- <Table.Cell fontFamily="mono" fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">
174
- {step.sweep
175
- ? <>{step.sweep}{sweepKeys.length > 1 && <Text as="span" color="var(--color-text-muted)"> ({step.sweep_key})</Text>}</>
176
- : <Text as="span" color="var(--color-text-muted)">-</Text>}
170
+ {run.steps.map((step) => {
171
+ const after = step.after && step.after.length > 0 ? step.after.join(', ') : null;
172
+ return (
173
+ <Table.Row key={step.job_id || step.step}>
174
+ <Table.Cell fontFamily="mono" fontSize="xs">
175
+ <JobLogsLink jobId={step.job_id} slurmJobId={step.executor === 'ssh' ? null : step.slurm_jobid}>{step.step}</JobLogsLink>
177
176
  </Table.Cell>
178
- )}
179
- <Table.Cell fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">
180
- {step.executor === 'ssh' ? `ssh ${step.host}` : `slurm ${step.slurm_jobid ?? '-'}`}
181
- <Text as="span" color="var(--color-text-muted)"> ({step.profile})</Text>
182
- </Table.Cell>
183
- <Table.Cell fontFamily="mono" fontSize="sm" color="var(--color-text-muted)" borderColor="var(--color-border)">
184
- {step.after && step.after.length > 0 ? step.after.join(', ') : '-'}
185
- </Table.Cell>
186
- <Table.Cell borderColor="var(--color-border)">
187
- <Badge colorPalette={stepStateColor(step.state)}>{step.state || 'UNKNOWN'}</Badge>
188
- </Table.Cell>
189
- <Table.Cell fontFamily="mono" fontSize="xs" color="var(--color-text-muted)" borderColor="var(--color-border)">
190
- <JobLogsLink jobId={step.job_id} slurmJobId={step.executor === 'ssh' ? null : step.slurm_jobid}>{step.job_id}</JobLogsLink>
191
- </Table.Cell>
192
- </Table.Row>
193
- ))}
177
+ {sweepKeys.length > 0 && (
178
+ <Table.Cell fontFamily="mono" fontSize="xs">
179
+ {step.sweep
180
+ ? <>{step.sweep}{sweepKeys.length > 1 && <Text as="span" color="var(--color-text-muted)"> ({step.sweep_key})</Text>}</>
181
+ : <Text as="span" color="var(--color-text-muted)">-</Text>}
182
+ </Table.Cell>
183
+ )}
184
+ <Table.Cell fontSize="xs" whiteSpace="nowrap">
185
+ {step.executor === 'ssh' ? `ssh ${step.host}` : `slurm ${step.slurm_jobid ?? '-'}`}
186
+ <Text as="span" color="var(--color-text-muted)"> ({step.profile})</Text>
187
+ </Table.Cell>
188
+ {/* a step after a wide parallel group waits on many: clipped, all of them in the tooltip */}
189
+ <Table.Cell fontFamily="mono" fontSize="xs" color="var(--color-text-muted)" maxW="200px">
190
+ {after ? (
191
+ <Tooltip content={<Text fontFamily="mono" fontSize="xs" whiteSpace="pre-wrap">{step.after!.join('\n')}</Text>}>
192
+ <Text truncate cursor="default">{after}</Text>
193
+ </Tooltip>
194
+ ) : '-'}
195
+ </Table.Cell>
196
+ <Table.Cell>
197
+ <Badge colorPalette={stepStateColor(step.state)}>{step.state || 'UNKNOWN'}</Badge>
198
+ </Table.Cell>
199
+ <Table.Cell fontFamily="mono" fontSize="xs" color="var(--color-text-muted)">
200
+ <JobLogsLink jobId={step.job_id} slurmJobId={step.executor === 'ssh' ? null : step.slurm_jobid}>{step.job_id}</JobLogsLink>
201
+ </Table.Cell>
202
+ </Table.Row>
203
+ );
204
+ })}
194
205
  </Table.Body>
195
206
  </Table.Root>
196
207
  )}
@@ -234,6 +245,51 @@ const usePipelineRuns = () => useQuery<PipelineRunSummary[], ApiError>({
234
245
  refetchInterval: 15000,
235
246
  });
236
247
 
248
+ const OVER_STATES: (PipelineRunState | null | undefined)[] = ['completed', 'failed'];
249
+
250
+ /** What a run shows: the submission when it is not submitted, else the state of its jobs */
251
+ const runLabel = (run: PipelineRunSummary, state?: PipelineRunState | null): string =>
252
+ run.status !== 'submitted' ? run.status : (state || 'submitted');
253
+
254
+ // runs older than this are not polled: their jobs may be gone from sacct, they would look running forever
255
+ const LIVE_RUN_MAX_AGE_S = 3 * 24 * 3600;
256
+ const LIVE_RUN_MAX = 5;
257
+
258
+ /**
259
+ * The state of the jobs of the listed runs. The runs list only has the state saved the last time a run's
260
+ * progress was read: the recent runs that are not over are read here (same query, so same cache, as the
261
+ * progress of the run shown) until they are.
262
+ */
263
+ const useLiveRunStates = (runs: PipelineRunSummary[]): Record<string, PipelineRunState | null | undefined> => {
264
+ const now = Date.now() / 1000;
265
+ const live = runs
266
+ .filter((run) => run.status !== 'failed' && !OVER_STATES.includes(run.state) && now - run.started < LIVE_RUN_MAX_AGE_S)
267
+ .slice(0, LIVE_RUN_MAX);
268
+ const results = useQueries({
269
+ queries: live.map((run) => ({
270
+ queryKey: ['pipeline-run', run.run_id],
271
+ queryFn: () => getPipelineRunStatus(run.run_id),
272
+ refetchInterval: (query: { state: { data?: PipelineRunStatus } }) => (isRunOver(query.state.data) ? false : 15000),
273
+ })),
274
+ });
275
+ const out: Record<string, PipelineRunState | null | undefined> = {};
276
+ for (const run of runs) out[run.run_id] = run.state;
277
+ live.forEach((run, index) => {
278
+ const data = results[index]?.data;
279
+ if (data?.state && data.state !== 'unknown') out[run.run_id] = data.state;
280
+ });
281
+ return out;
282
+ };
283
+
284
+ const formatAgo = (epoch: number): string => {
285
+ const s = Math.max(0, Date.now() / 1000 - epoch);
286
+ if (s < 60) return 'just now';
287
+ if (s < 3600) return `${Math.floor(s / 60)} min ago`;
288
+ if (s < 86400) return `${Math.floor(s / 3600)} h ago`;
289
+ if (s < 30 * 86400) return `${Math.floor(s / 86400)} d ago`;
290
+ return new Date(epoch * 1000).toLocaleDateString();
291
+ };
292
+
237
293
  const usePipelineDefinition = (name: string) => useQuery<PipelineTemplateFileData, ApiError>({
238
294
  queryKey: ['pipeline-definition', name],
239
295
  queryFn: async () => (await loadPipelineFromFile(name)) as PipelineTemplateFileData,
@@ -313,12 +369,16 @@ const RunButton: React.FC<{ name: string; onStarted: (run: PipelineRunResponse)
313
369
  );
314
370
  };
315
371
 
316
- /** /pipelines: the saved pipelines */
372
+ // the list shows the pipelines run most recently, the search finds the others
373
+ const PIPELINES_SHOWN = 10;
374
+
375
+ /** /pipelines: the saved pipelines, most recently run first */
317
376
  export const PipelinesView: React.FC = () => {
318
377
  usePageTitle('Pipelines');
319
378
  const paths = useBujangPaths();
320
379
  const navigate = useNavigate();
321
380
  const [isCreateOpen, setIsCreateOpen] = useState(false);
381
+ const [search, setSearch] = useState('');
322
382
 
323
383
  const { data: names = [], isLoading, error } = useQuery<string[], ApiError>({
324
384
  queryKey: ['pipeline-template-files'],
@@ -333,6 +393,19 @@ export const PipelinesView: React.FC = () => {
333
393
  });
334
394
  const { data: runs = [] } = usePipelineRuns();
335
395
 
396
+ const rows = names.map((name, index) => {
397
+ const data = definitions[index]?.data;
398
+ return { name, data, last: runsOf(runs, name, data?.name)[0] as PipelineRunSummary | undefined };
399
+ });
400
+ // most recently run first, then the ones never run by name
401
+ rows.sort((a, b) => (b.last?.started ?? -1) - (a.last?.started ?? -1) || a.name.localeCompare(b.name));
402
+ const needle = search.trim().toLowerCase();
403
+ const matching = needle
404
+ ? rows.filter((row) => row.name.toLowerCase().includes(needle) || (row.data?.description || '').toLowerCase().includes(needle))
405
+ : rows;
406
+ const shown = matching.slice(0, PIPELINES_SHOWN);
407
+ const states = useLiveRunStates(shown.map((row) => row.last).filter(Boolean) as PipelineRunSummary[]);
408
+
336
409
  return (
337
410
  <Box p={6} bg="var(--color-bg-page)" minH="100vh">
338
411
  <VStack gap={6} align="stretch">
@@ -370,56 +443,80 @@ export const PipelinesView: React.FC = () => {
370
443
 
371
444
  {names.length > 0 && (
372
445
  <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
373
- <Card.Body p={0}>
374
- <Table.Root>
375
- <Table.Header bg="var(--color-bg-header)">
376
- <Table.Row>
377
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)" pl={4}>Name</Table.ColumnHeader>
378
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Description</Table.ColumnHeader>
379
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Steps</Table.ColumnHeader>
380
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Last run</Table.ColumnHeader>
381
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)" pr={4} />
382
- </Table.Row>
383
- </Table.Header>
384
- <Table.Body>
385
- {names.map((name, index) => {
386
- const data = definitions[index]?.data;
387
- const last = runsOf(runs, name, data?.name)[0];
388
- return (
389
- <Table.Row
390
- key={name}
391
- cursor="pointer"
392
- onClick={() => navigate(paths.pipelineDetails(name))}
393
- _hover={{ bg: 'var(--color-bg-hover)' }}
394
- borderColor="var(--color-border)"
395
- >
396
- <Table.Cell fontWeight="medium" borderColor="var(--color-border)" pl={4} py={3}>
397
- <Link asChild color="var(--color-text)" fontWeight="semibold">
398
- <RouterLink to={paths.pipelineDetails(name)} onClick={(e) => e.stopPropagation()}>{name}</RouterLink>
399
- </Link>
400
- </Table.Cell>
401
- <Table.Cell fontSize="sm" color="var(--color-text-muted)" borderColor="var(--color-border)" maxW="520px">
402
- <Text lineClamp={2}>{data?.description || '-'}</Text>
403
- </Table.Cell>
404
- <Table.Cell fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">
405
- {data?.definition ? countSteps(data.definition) : '-'}
406
- </Table.Cell>
407
- <Table.Cell fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)" whiteSpace="nowrap">
408
- {last ? (
409
- <HStack gap={2}>
410
- <Text>{formatStarted(last.started)}</Text>
411
- {last.status !== 'submitted' && <Badge colorPalette={runStateColor(last.status)}>{last.status}</Badge>}
412
- </HStack>
413
- ) : <Text color="var(--color-text-muted)">never</Text>}
414
- </Table.Cell>
415
- <Table.Cell borderColor="var(--color-border)" pr={4} textAlign="end">
416
- <RunButton name={name} size="xs" onStarted={(run) => navigate(paths.pipelineDetails(name, run.run_id))} />
417
- </Table.Cell>
446
+ <Card.Body>
447
+ <VStack align="stretch" gap={3}>
448
+ <HStack gap={3} flexWrap="wrap">
449
+ <InputGroup startElement={<LuSearch />} maxW="360px">
450
+ <Input
451
+ size="sm"
452
+ placeholder="Search the pipelines"
453
+ value={search}
454
+ onChange={(e) => setSearch(e.target.value)}
455
+ bg="var(--color-input-bg)"
456
+ borderColor="var(--color-input-border)"
457
+ color="var(--color-text)"
458
+ />
459
+ </InputGroup>
460
+ <Spacer />
461
+ <Text fontSize="xs" color="var(--color-text-muted)">
462
+ {matching.length > shown.length
463
+ ? `${shown.length} of ${matching.length} shown, most recently run first: search to find the others`
464
+ : `${matching.length} ${matching.length === 1 ? 'pipeline' : 'pipelines'}, most recently run first`}
465
+ </Text>
466
+ </HStack>
467
+ {shown.length === 0 ? (
468
+ <Text fontSize="sm" color="var(--color-text-muted)">No pipeline matches {search}.</Text>
469
+ ) : (
470
+ <Table.Root size="sm" variant="outline">
471
+ <Table.Header>
472
+ <Table.Row>
473
+ <Table.ColumnHeader>Name</Table.ColumnHeader>
474
+ <Table.ColumnHeader>Description</Table.ColumnHeader>
475
+ <Table.ColumnHeader textAlign="end">Steps</Table.ColumnHeader>
476
+ <Table.ColumnHeader>Last run</Table.ColumnHeader>
477
+ <Table.ColumnHeader />
418
478
  </Table.Row>
419
- );
420
- })}
421
- </Table.Body>
422
- </Table.Root>
479
+ </Table.Header>
480
+ <Table.Body>
481
+ {shown.map(({ name, data, last }) => (
482
+ <Table.Row
483
+ key={name}
484
+ cursor="pointer"
485
+ onClick={() => navigate(paths.pipelineDetails(name))}
486
+ _hover={{ bg: 'var(--color-bg-hover)' }}
487
+ >
488
+ <Table.Cell fontWeight="semibold">
489
+ <Link asChild color="var(--color-text)">
490
+ <RouterLink to={paths.pipelineDetails(name)} onClick={(e) => e.stopPropagation()}>{name}</RouterLink>
491
+ </Link>
492
+ </Table.Cell>
493
+ <Table.Cell fontSize="xs" color="var(--color-text-muted)" maxW="520px">
494
+ <Text lineClamp={2}>{data?.description || '-'}</Text>
495
+ </Table.Cell>
496
+ <Table.Cell textAlign="end">
497
+ {data?.definition ? countSteps(data.definition) : '-'}
498
+ </Table.Cell>
499
+ <Table.Cell fontSize="xs" whiteSpace="nowrap">
500
+ {last ? (
501
+ <HStack gap={2}>
502
+ <Badge colorPalette={runStateColor(last.status, states[last.run_id] ?? undefined)}>
503
+ {runLabel(last, states[last.run_id])}
504
+ </Badge>
505
+ <Tooltip content={formatStarted(last.started)}>
506
+ <Text>{formatAgo(last.started)}</Text>
507
+ </Tooltip>
508
+ </HStack>
509
+ ) : <Text color="var(--color-text-muted)">never</Text>}
510
+ </Table.Cell>
511
+ <Table.Cell textAlign="end">
512
+ <RunButton name={name} size="xs" onStarted={(run) => navigate(paths.pipelineDetails(name, run.run_id))} />
513
+ </Table.Cell>
514
+ </Table.Row>
515
+ ))}
516
+ </Table.Body>
517
+ </Table.Root>
518
+ )}
519
+ </VStack>
423
520
  </Card.Body>
424
521
  </Card.Root>
425
522
  )}
@@ -467,6 +564,7 @@ export const PipelineDetailsView: React.FC = () => {
467
564
  const graphDefinition = shownRun?.definition ?? pipeline?.definition;
468
565
 
469
566
  const selectRun = (runId: string) => setParams({ run: runId });
567
+ const runStates = useLiveRunStates(runs);
470
568
 
471
569
  return (
472
570
  <Box p={6} bg="var(--color-bg-page)" minH="100vh">
@@ -501,84 +599,106 @@ export const PipelineDetailsView: React.FC = () => {
501
599
  <Alert.Content>
502
600
  <Alert.Description>
503
601
  {error.status === 404
504
- ? `No saved pipeline named ${pipelineName}${runs.length ? ': its runs are below' : ''}.`
602
+ ? `No saved pipeline named ${pipelineName}${runs.length ? ': its runs are on the left' : ''}.`
505
603
  : `Failed to load the pipeline: ${error.message}`}
506
604
  </Alert.Description>
507
605
  </Alert.Content>
508
606
  </Alert.Root>
509
607
  )}
510
608
 
511
- {(graphDefinition ? graphIsDrawable(graphDefinition) : isLoading) && (
512
- <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
513
- <Card.Header pb={0}>
609
+ {/* the runs on the left choose what the rest of the page shows */}
610
+ <Flex gap={6} align={{ base: 'stretch', lg: 'flex-start' }} direction={{ base: 'column', lg: 'row' }}>
611
+ <Card.Root
612
+ bg="var(--color-bg-card)"
613
+ borderColor="var(--color-border)"
614
+ borderRadius="lg"
615
+ boxShadow="sm"
616
+ w={{ base: '100%', lg: '280px' }}
617
+ flexShrink={0}
618
+ position={{ lg: 'sticky' }}
619
+ top={4}
620
+ overflow="hidden"
621
+ >
622
+ <Card.Header py={3} borderBottom="1px solid" borderColor="var(--color-border)">
514
623
  <HStack>
515
- <Heading size="md" color="var(--color-text)">Graph</Heading>
624
+ <Heading size="sm" color="var(--color-text)">Runs</Heading>
516
625
  <Spacer />
517
- {shownRunId && Object.keys(states).length > 0 && (
518
- <Text fontSize="xs" color="var(--color-text-muted)">
519
- {shownRun?.definition ? 'definition and step states' : 'step states'} of run {shownRunId}
520
- </Text>
521
- )}
626
+ <Text fontSize="xs" color="var(--color-text-muted)">{runs.length}</Text>
522
627
  </HStack>
523
628
  </Card.Header>
524
- <Card.Body>
525
- {graphDefinition
526
- ? <PipelineGraph definition={graphDefinition} states={states} />
527
- : <Text color="var(--color-text-muted)">Loading...</Text>}
629
+ <Card.Body p={0} maxH={{ lg: 'calc(100vh - 140px)' }} overflowY="auto">
630
+ {runs.length === 0 ? (
631
+ <Text p={4} fontSize="sm" color="var(--color-text-muted)">No run yet: use Run.</Text>
632
+ ) : (
633
+ <VStack gap={0} align="stretch">
634
+ {runs.map((run) => {
635
+ const selected = run.run_id === shownRunId;
636
+ const state = selected && shownRun?.state && shownRun.state !== 'unknown' ? shownRun.state : runStates[run.run_id];
637
+ return (
638
+ <Box
639
+ key={run.run_id}
640
+ as="button"
641
+ textAlign="start"
642
+ px={4}
643
+ py={2}
644
+ cursor="pointer"
645
+ onClick={() => selectRun(run.run_id)}
646
+ bg={selected ? 'var(--color-bg-hover)' : undefined}
647
+ _hover={{ bg: 'var(--color-bg-hover)' }}
648
+ borderLeft="3px solid"
649
+ borderLeftColor={selected ? 'var(--color-primary)' : 'transparent'}
650
+ borderBottom="1px solid"
651
+ borderBottomColor="var(--color-border)"
652
+ aria-current={selected ? 'true' : undefined}
653
+ >
654
+ <HStack gap={2}>
655
+ <Badge size="sm" colorPalette={runStateColor(run.status, state ?? undefined)}>{runLabel(run, state)}</Badge>
656
+ <Spacer />
657
+ <Text fontSize="xs" color="var(--color-text-muted)" title={formatStarted(run.started)}>
658
+ {formatAgo(run.started)}
659
+ </Text>
660
+ </HStack>
661
+ <Text mt={1} fontFamily="mono" fontSize="xs" color="var(--color-text)" truncate>{run.run_id}</Text>
662
+ {run.error && <Text fontSize="xs" color="var(--color-text-muted)" lineClamp={2}>{run.error}</Text>}
663
+ </Box>
664
+ );
665
+ })}
666
+ </VStack>
667
+ )}
528
668
  </Card.Body>
529
669
  </Card.Root>
530
- )}
531
670
 
532
- {shownRunId && (
533
- <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
534
- <Card.Body>
535
- <PipelineRunProgress key={shownRunId} runId={shownRunId} />
536
- </Card.Body>
537
- </Card.Root>
538
- )}
671
+ <VStack gap={6} align="stretch" flex={1} minW={0}>
672
+ {(graphDefinition ? graphIsDrawable(graphDefinition) : isLoading) && (
673
+ <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
674
+ <Card.Header pb={0}>
675
+ <HStack>
676
+ <Heading size="md" color="var(--color-text)">Graph</Heading>
677
+ <Spacer />
678
+ {shownRunId && Object.keys(states).length > 0 && (
679
+ <Text fontSize="xs" color="var(--color-text-muted)">
680
+ {shownRun?.definition ? 'definition and step states' : 'step states'} of run {shownRunId}
681
+ </Text>
682
+ )}
683
+ </HStack>
684
+ </Card.Header>
685
+ <Card.Body>
686
+ {graphDefinition
687
+ ? <PipelineGraph definition={graphDefinition} states={states} />
688
+ : <Text color="var(--color-text-muted)">Loading...</Text>}
689
+ </Card.Body>
690
+ </Card.Root>
691
+ )}
539
692
 
540
- <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
541
- <Card.Header borderBottom="1px" borderColor="var(--color-border)">
542
- <Heading size="md" color="var(--color-text)">Runs</Heading>
543
- </Card.Header>
544
- <Card.Body pt={4}>
545
- {runs.length === 0 ? (
546
- <Text color="var(--color-text-muted)">No run yet: use Run.</Text>
547
- ) : (
548
- <Table.Root size="sm" variant="line">
549
- <Table.Header bg="var(--color-bg-header)">
550
- <Table.Row>
551
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Run</Table.ColumnHeader>
552
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Started</Table.ColumnHeader>
553
- <Table.ColumnHeader color="var(--color-text)" borderColor="var(--color-border)">Submission</Table.ColumnHeader>
554
- </Table.Row>
555
- </Table.Header>
556
- <Table.Body>
557
- {runs.map((run) => (
558
- <Table.Row
559
- key={run.run_id}
560
- cursor="pointer"
561
- onClick={() => selectRun(run.run_id)}
562
- bg={run.run_id === shownRunId ? 'var(--color-bg-hover)' : undefined}
563
- _hover={{ bg: 'var(--color-bg-hover)' }}
564
- borderColor="var(--color-border)"
565
- >
566
- <Table.Cell fontFamily="mono" fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">
567
- {run.run_id}
568
- {run.run_id === shownRunId && <Badge ml={2} size="sm" variant="outline">shown</Badge>}
569
- </Table.Cell>
570
- <Table.Cell fontSize="sm" color="var(--color-text)" borderColor="var(--color-border)">{formatStarted(run.started)}</Table.Cell>
571
- <Table.Cell borderColor="var(--color-border)">
572
- <Badge colorPalette={runStateColor(run.status)}>{run.status}</Badge>
573
- {run.error && <Text as="span" fontSize="xs" color="var(--color-text-muted)" ml={2}>{run.error}</Text>}
574
- </Table.Cell>
575
- </Table.Row>
576
- ))}
577
- </Table.Body>
578
- </Table.Root>
693
+ {shownRunId && (
694
+ <Card.Root bg="var(--color-bg-card)" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm">
695
+ <Card.Body>
696
+ <PipelineRunProgress key={shownRunId} runId={shownRunId} />
697
+ </Card.Body>
698
+ </Card.Root>
579
699
  )}
580
- </Card.Body>
581
- </Card.Root>
700
+ </VStack>
701
+ </Flex>
582
702
  </VStack>
583
703
 
584
704
  {isEditOpen && (
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Schedule: the job of the submit page as a scheduled job (a name and a cron expression). The
3
+ * submit page builds the request (script, Slurm settings) and closes the dialog once it is saved.
4
+ */
5
+ import React, { useState } from 'react';
6
+ import { Button, Dialog, HStack, Input, NativeSelect, Text, VStack } from '@chakra-ui/react';
7
+
8
+ const CRON_PRESETS: { label: string; cron: string }[] = [
9
+ { label: 'Daily at midnight', cron: '0 0 * * *' },
10
+ { label: 'Weekly on Sunday at 2am', cron: '0 2 * * 0' },
11
+ { label: 'Monthly on the 1st', cron: '0 0 1 * *' },
12
+ { label: 'Weekdays at midnight', cron: '0 0 * * 1-5' },
13
+ { label: 'Custom', cron: '' },
14
+ ];
15
+
16
+ interface ScheduleDialogProps {
17
+ onClose: () => void;
18
+ onSave: (name: string, cron: string) => void;
19
+ isSaving: boolean;
20
+ /** default name: the template or job name */
21
+ baseName: string;
22
+ }
23
+
24
+ const ScheduleDialog: React.FC<ScheduleDialogProps> = ({ onClose, onSave, isSaving, baseName }) => {
25
+ const [name, setName] = useState(baseName.replace(/\.sh$/, ''));
26
+ const [preset, setPreset] = useState(CRON_PRESETS[0].cron);
27
+ const [custom, setCustom] = useState(CRON_PRESETS[0].cron);
28
+ const cron = (preset === '' ? custom : preset).trim();
29
+ const issue = !name.trim() ? 'give the schedule a name' : !cron ? 'give a cron expression' : null;
30
+
31
+ return (
32
+ <Dialog.Root open onOpenChange={(details) => { if (!details.open) onClose(); }} size="md">
33
+ <Dialog.Backdrop />
34
+ <Dialog.Positioner>
35
+ <Dialog.Content>
36
+ <Dialog.Header py={3} px={4} borderBottom="1px solid" borderColor="var(--color-border)">
37
+ <Dialog.Title fontSize="md" color="var(--color-text)">Schedule this job</Dialog.Title>
38
+ </Dialog.Header>
39
+ <Dialog.Body px={4} py={4}>
40
+ <VStack align="stretch" gap={3}>
41
+ <HStack gap={3}>
42
+ <Text minW="90px" fontSize="sm" color="var(--color-text)">Name</Text>
43
+ <Input size="sm" value={name} onChange={(e) => setName(e.target.value)} placeholder="Schedule name" />
44
+ </HStack>
45
+ <HStack gap={3}>
46
+ <Text minW="90px" fontSize="sm" color="var(--color-text)">When</Text>
47
+ <NativeSelect.Root size="sm">
48
+ <NativeSelect.Field
49
+ value={preset}
50
+ onChange={(e) => {
51
+ setPreset(e.target.value);
52
+ if (e.target.value !== '') setCustom(e.target.value);
53
+ }}
54
+ >
55
+ {CRON_PRESETS.map(p => (
56
+ <option key={p.cron || '__custom'} value={p.cron}>{p.label}</option>
57
+ ))}
58
+ </NativeSelect.Field>
59
+ <NativeSelect.Indicator />
60
+ </NativeSelect.Root>
61
+ </HStack>
62
+ <HStack gap={3}>
63
+ <Text minW="90px" fontSize="sm" color="var(--color-text)">Cron</Text>
64
+ <Input
65
+ size="sm"
66
+ fontFamily="mono"
67
+ placeholder="* * * * *"
68
+ value={preset === '' ? custom : preset}
69
+ onChange={(e) => { setCustom(e.target.value); setPreset(''); }}
70
+ />
71
+ </HStack>
72
+ <Text fontSize="xs" color="var(--color-text-muted)">
73
+ Saves the script and the Slurm settings of the form as they are now.
74
+ </Text>
75
+ </VStack>
76
+ </Dialog.Body>
77
+ <Dialog.Footer py={3} px={4} borderTop="1px solid" borderColor="var(--color-border)">
78
+ {issue && <Text fontSize="sm" color="var(--color-text-muted)" mr="auto">{issue}</Text>}
79
+ <Button variant="ghost" size="sm" onClick={onClose} color="var(--color-text)">Cancel</Button>
80
+ <Button
81
+ size="sm"
82
+ onClick={() => onSave(name.trim(), cron)}
83
+ disabled={!!issue}
84
+ loading={isSaving}
85
+ bg="var(--color-primary)"
86
+ color="var(--color-primary-text)"
87
+ _hover={{ bg: 'var(--color-primary-hover)' }}
88
+ >
89
+ Schedule
90
+ </Button>
91
+ </Dialog.Footer>
92
+ </Dialog.Content>
93
+ </Dialog.Positioner>
94
+ </Dialog.Root>
95
+ );
96
+ };
97
+
98
+ export default ScheduleDialog;