@milabench/bujang 0.1.14 → 0.1.15
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 +4327 -4190
- package/dist/index.js.map +1 -1
- package/dist/theme.css +26 -0
- package/dist/types.d.ts +11 -0
- package/dist/views/AgentActivityView.d.ts +2 -1
- package/dist/views/JobsTable.d.ts +54 -0
- package/package.json +1 -1
- package/src/components/SshConnectDialog.tsx +1 -1
- package/src/theme.css +26 -0
- package/src/types.ts +8 -0
- package/src/views/AgentActivityView.tsx +14 -5
- package/src/views/JobLogs.tsx +1 -1
- package/src/views/JobMarks.tsx +1 -1
- package/src/views/JobsTable.tsx +688 -0
- package/src/views/JobsView.tsx +99 -502
- package/src/views/PipelineEditor.tsx +1 -1
- package/src/views/PipelinesView.tsx +3 -0
- package/src/views/ScheduleDialog.tsx +1 -1
- package/src/views/ScheduledJobsView.tsx +2 -2
- package/src/views/SweepDialog.tsx +1 -1
package/src/views/JobsView.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useNavigate, useSearchParams } from 'react-router-dom';
|
|
3
3
|
import { useBujangPaths } from '../context';
|
|
4
4
|
import {
|
|
5
5
|
Box,
|
|
@@ -8,29 +8,11 @@ import {
|
|
|
8
8
|
VStack,
|
|
9
9
|
HStack,
|
|
10
10
|
Button,
|
|
11
|
-
Badge,
|
|
12
|
-
Table,
|
|
13
|
-
Card,
|
|
14
|
-
Spinner,
|
|
15
|
-
Alert,
|
|
16
|
-
IconButton,
|
|
17
11
|
Group,
|
|
18
12
|
NativeSelect,
|
|
19
13
|
} from '@chakra-ui/react';
|
|
20
14
|
import { toaster } from '../toast';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
LuPlus,
|
|
24
|
-
LuEye,
|
|
25
|
-
LuTrash2,
|
|
26
|
-
LuRefreshCw,
|
|
27
|
-
LuInfo,
|
|
28
|
-
LuStar,
|
|
29
|
-
LuCircleCheck,
|
|
30
|
-
LuTriangleAlert,
|
|
31
|
-
LuClock,
|
|
32
|
-
LuTimer,
|
|
33
|
-
} from 'react-icons/lu';
|
|
15
|
+
import { LuPlus, LuRefreshCw, LuStar, LuTimer, LuRows2, LuTable } from 'react-icons/lu';
|
|
34
16
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
35
17
|
import {
|
|
36
18
|
getSlurmJobs,
|
|
@@ -41,58 +23,25 @@ import {
|
|
|
41
23
|
getSyncStatus,
|
|
42
24
|
syncNow,
|
|
43
25
|
} from '../api';
|
|
44
|
-
import { JobImportantStar } from './JobMarks';
|
|
45
26
|
import type { SlurmJob, PersitedJobInfo, ApiError, OrganizerGroups, SyncStatus } from '../types';
|
|
46
27
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
47
|
-
import { AgentBadge } from './AgentActivityView';
|
|
48
28
|
import { SshConnectButton } from '../components/SshConnectDialog';
|
|
49
|
-
import {
|
|
29
|
+
import { JobsTable, fromActive, fromPersisted, mergeRows } from './JobsTable';
|
|
50
30
|
|
|
51
31
|
type JobsViewProps = Record<string, never>;
|
|
52
32
|
|
|
53
|
-
const getStatusColor = (status: string) => {
|
|
54
|
-
switch (status?.toLowerCase()) {
|
|
55
|
-
case 'running':
|
|
56
|
-
case 'r':
|
|
57
|
-
return 'green';
|
|
58
|
-
case 'pending':
|
|
59
|
-
case 'pd':
|
|
60
|
-
return 'yellow';
|
|
61
|
-
case 'completed':
|
|
62
|
-
case 'cd':
|
|
63
|
-
return 'blue';
|
|
64
|
-
case 'failed':
|
|
65
|
-
case 'f':
|
|
66
|
-
return 'red';
|
|
67
|
-
case 'cancelled':
|
|
68
|
-
case 'ca':
|
|
69
|
-
return 'gray';
|
|
70
|
-
default:
|
|
71
|
-
return 'gray';
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const getStatusIcon = (status: string) => {
|
|
76
|
-
switch (status?.toLowerCase()) {
|
|
77
|
-
case 'running':
|
|
78
|
-
case 'r':
|
|
79
|
-
return <LuCircleCheck color="var(--color-status-running)" />;
|
|
80
|
-
case 'pending':
|
|
81
|
-
case 'pd':
|
|
82
|
-
return <LuClock color="var(--color-status-pending)" />;
|
|
83
|
-
case 'completed':
|
|
84
|
-
case 'cd':
|
|
85
|
-
return <LuCircleCheck color="var(--color-status-completed)" />;
|
|
86
|
-
case 'failed':
|
|
87
|
-
case 'f':
|
|
88
|
-
return <LuTriangleAlert color="var(--color-status-failed)" />;
|
|
89
|
-
default:
|
|
90
|
-
return <LuInfo color="var(--color-status-cancelled)" />;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
33
|
const AUTO_REFRESH_KEY = 'bujang-jobs-auto-refresh';
|
|
95
34
|
const AUTO_REFRESH_MS = 30_000;
|
|
35
|
+
const MERGED_KEY = 'bujang-jobs-merged';
|
|
36
|
+
|
|
37
|
+
/** One table for the active and the persisted jobs unless split on this browser */
|
|
38
|
+
function readMerged(): boolean {
|
|
39
|
+
try {
|
|
40
|
+
return localStorage.getItem(MERGED_KEY) !== '0';
|
|
41
|
+
} catch {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
96
45
|
|
|
97
46
|
/** On unless turned off on this browser: the page follows the background sync of the server */
|
|
98
47
|
function readAutoRefresh(): boolean {
|
|
@@ -169,18 +118,6 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
169
118
|
const navigate = useNavigate();
|
|
170
119
|
const paths = useBujangPaths();
|
|
171
120
|
|
|
172
|
-
const freshnessGreen = getComputedStyle(document.documentElement).getPropertyValue('--color-freshness-good').trim() || '#48bb78';
|
|
173
|
-
const freshnessBrown = getComputedStyle(document.documentElement).getPropertyValue('--color-freshness-stale').trim() || '#7b341e';
|
|
174
|
-
|
|
175
|
-
// Helper function to convert hex to RGB
|
|
176
|
-
const hexToRgb = (hex: string): [number, number, number] => {
|
|
177
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
178
|
-
return result
|
|
179
|
-
? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]
|
|
180
|
-
: [72, 187, 120]; // fallback to green
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
|
|
184
121
|
const [autoRefresh, setAutoRefresh] = React.useState(readAutoRefresh);
|
|
185
122
|
const toggleAutoRefresh = (on: boolean) => {
|
|
186
123
|
try {
|
|
@@ -190,6 +127,15 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
190
127
|
}
|
|
191
128
|
setAutoRefresh(on);
|
|
192
129
|
};
|
|
130
|
+
const [merged, setMerged] = React.useState(readMerged);
|
|
131
|
+
const toggleMerged = (on: boolean) => {
|
|
132
|
+
try {
|
|
133
|
+
localStorage.setItem(MERGED_KEY, on ? '1' : '0');
|
|
134
|
+
} catch {
|
|
135
|
+
// private mode: for this page only
|
|
136
|
+
}
|
|
137
|
+
setMerged(on);
|
|
138
|
+
};
|
|
193
139
|
// Queries
|
|
194
140
|
const { data: sync } = useQuery<SyncStatus>({
|
|
195
141
|
queryKey: ['bujang-sync'],
|
|
@@ -288,8 +234,18 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
288
234
|
const persistedJobs = allPersistedJobs.filter(
|
|
289
235
|
(job) => (!allowed || allowed.has(job.name)) && (!importantOnly || job.important),
|
|
290
236
|
);
|
|
291
|
-
const
|
|
292
|
-
|
|
237
|
+
const activeRows = React.useMemo(() => activeJobs.map(fromActive), [activeJobs]);
|
|
238
|
+
const persistedRows = React.useMemo(() => persistedJobs.map(fromPersisted), [persistedJobs]);
|
|
239
|
+
// the important filter only knows the job folders: a job only in squeue is not marked
|
|
240
|
+
const allRows = React.useMemo(
|
|
241
|
+
() => mergeRows(activeJobs, persistedJobs).filter((r) => !importantOnly || r.important),
|
|
242
|
+
[activeJobs, persistedJobs, importantOnly],
|
|
243
|
+
);
|
|
244
|
+
// a job in squeue and in the job folders is one row
|
|
245
|
+
const duplicates = React.useMemo(() => {
|
|
246
|
+
const names = new Set(allPersistedJobs.map((p) => p.name));
|
|
247
|
+
return allActiveJobs.filter((j: SlurmJob) => j.jr_job_id && names.has(j.jr_job_id)).length;
|
|
248
|
+
}, [allActiveJobs, allPersistedJobs]);
|
|
293
249
|
|
|
294
250
|
|
|
295
251
|
|
|
@@ -350,6 +306,11 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
350
306
|
rerunJobMutation.mutate(jrJobId);
|
|
351
307
|
}
|
|
352
308
|
};
|
|
309
|
+
const tableActions = {
|
|
310
|
+
onCancel: handleCancelJob,
|
|
311
|
+
onRerun: handleRerunJob,
|
|
312
|
+
onGroup: (g: string) => setFilter('groups', g),
|
|
313
|
+
};
|
|
353
314
|
|
|
354
315
|
|
|
355
316
|
|
|
@@ -446,432 +407,68 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
446
407
|
<LuStar fill={importantOnly ? 'currentColor' : 'none'} /> Important
|
|
447
408
|
</Button>
|
|
448
409
|
<OrganizerFilters organizers={organizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
|
|
410
|
+
<Group attached ml="auto">
|
|
411
|
+
<Button
|
|
412
|
+
size="sm"
|
|
413
|
+
variant={merged ? 'solid' : 'outline'}
|
|
414
|
+
onClick={() => toggleMerged(true)}
|
|
415
|
+
aria-pressed={merged}
|
|
416
|
+
title="The active and the persisted jobs in one table"
|
|
417
|
+
>
|
|
418
|
+
<LuTable /> Merged
|
|
419
|
+
</Button>
|
|
420
|
+
<Button
|
|
421
|
+
size="sm"
|
|
422
|
+
variant={merged ? 'outline' : 'solid'}
|
|
423
|
+
onClick={() => toggleMerged(false)}
|
|
424
|
+
aria-pressed={!merged}
|
|
425
|
+
title="One table for the active jobs, one for the persisted jobs"
|
|
426
|
+
>
|
|
427
|
+
<LuRows2 /> Split
|
|
428
|
+
</Button>
|
|
429
|
+
</Group>
|
|
449
430
|
</HStack>
|
|
450
431
|
|
|
451
|
-
{
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
</Alert.Description>
|
|
492
|
-
</Alert.Content>
|
|
493
|
-
</Alert.Root>
|
|
494
|
-
) : (activeJobsLoading) ? (
|
|
495
|
-
<Box textAlign="center" py={12}>
|
|
496
|
-
<Spinner size="lg" color="var(--color-primary)" />
|
|
497
|
-
<Text mt={4} color="var(--color-text-muted)" fontSize="sm">
|
|
498
|
-
Loading active jobs...
|
|
499
|
-
</Text>
|
|
500
|
-
</Box>
|
|
501
|
-
) : (
|
|
502
|
-
<Box overflowX="auto">
|
|
503
|
-
{activeJobs.length === 0 ? (
|
|
504
|
-
<Box textAlign="center" py={12}>
|
|
505
|
-
<Text color="var(--color-text-muted)" fontSize="md">
|
|
506
|
-
No active jobs found
|
|
507
|
-
</Text>
|
|
508
|
-
<Text color="var(--color-text-muted)" fontSize="sm" mt={2}>
|
|
509
|
-
Submit a new job to get started
|
|
510
|
-
</Text>
|
|
511
|
-
</Box>
|
|
512
|
-
) : (
|
|
513
|
-
<Table.ScrollArea maxH="35vh" overflowY="auto">
|
|
514
|
-
<Table.Root variant="line" size="sm" stickyHeader css={COMPACT_ROWS}>
|
|
515
|
-
<Table.Header bg="var(--color-bg-header)">
|
|
516
|
-
<Table.Row>
|
|
517
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} pl={6} pr={4} fontSize="sm">Job ID</Table.ColumnHeader>
|
|
518
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">JR Job ID</Table.ColumnHeader>
|
|
519
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Name</Table.ColumnHeader>
|
|
520
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Status</Table.ColumnHeader>
|
|
521
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Cluster</Table.ColumnHeader>
|
|
522
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Partition</Table.ColumnHeader>
|
|
523
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">User</Table.ColumnHeader>
|
|
524
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Time</Table.ColumnHeader>
|
|
525
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Actions</Table.ColumnHeader>
|
|
526
|
-
</Table.Row>
|
|
527
|
-
</Table.Header>
|
|
528
|
-
<Table.Body>
|
|
529
|
-
{activeJobs.map((job: SlurmJob, index: number) => (
|
|
530
|
-
<Table.Row
|
|
531
|
-
key={job.job_id}
|
|
532
|
-
_hover={{ bg: 'var(--color-bg-hover)' }}
|
|
533
|
-
bg={index % 2 === 0 ? 'transparent' : 'var(--color-bg-stripe)'}
|
|
534
|
-
>
|
|
535
|
-
<Table.Cell pl={6} pr={4}>
|
|
536
|
-
<Text fontWeight="semibold" color="var(--color-text)">
|
|
537
|
-
{job.job_id}
|
|
538
|
-
</Text>
|
|
539
|
-
</Table.Cell>
|
|
540
|
-
<Table.Cell>
|
|
541
|
-
<Text fontFamily="mono" fontSize="sm" color="var(--color-text-muted)">
|
|
542
|
-
{job.jr_job_id}
|
|
543
|
-
</Text>
|
|
544
|
-
</Table.Cell>
|
|
545
|
-
<Table.Cell>
|
|
546
|
-
<Text color="var(--color-text)">{job.name || 'N/A'}<AgentBadge tag={job.agent} /></Text>
|
|
547
|
-
</Table.Cell>
|
|
548
|
-
<Table.Cell>
|
|
549
|
-
<HStack gap={2}>
|
|
550
|
-
{getStatusIcon(job.job_state?.[0] || '')}
|
|
551
|
-
<Badge colorScheme={getStatusColor(job.job_state?.[0] || '')}>
|
|
552
|
-
{job.job_state?.[0] || NO_JOB_STATE}
|
|
553
|
-
</Badge>
|
|
554
|
-
</HStack>
|
|
555
|
-
</Table.Cell>
|
|
556
|
-
<Table.Cell>
|
|
557
|
-
<Text color="var(--color-text)" fontSize="sm">mila</Text>
|
|
558
|
-
</Table.Cell>
|
|
559
|
-
<Table.Cell>
|
|
560
|
-
<Text color="var(--color-text)">{job.partition || 'N/A'}</Text>
|
|
561
|
-
</Table.Cell>
|
|
562
|
-
<Table.Cell>
|
|
563
|
-
<Text color="var(--color-text)">{job.user_name || 'N/A'}</Text>
|
|
564
|
-
</Table.Cell>
|
|
565
|
-
<Table.Cell>
|
|
566
|
-
<Text color="var(--color-text)">
|
|
567
|
-
{typeof job.time_limit === 'string'
|
|
568
|
-
? job.time_limit
|
|
569
|
-
: job.time_limit?.number
|
|
570
|
-
? `${job.time_limit.number}min`
|
|
571
|
-
: 'N/A'
|
|
572
|
-
}
|
|
573
|
-
</Text>
|
|
574
|
-
</Table.Cell>
|
|
575
|
-
<Table.Cell>
|
|
576
|
-
<HStack gap={2}>
|
|
577
|
-
<Tooltip
|
|
578
|
-
positioning={{ placement: 'top', offset: { mainAxis: 8 } }}
|
|
579
|
-
content="View Logs"
|
|
580
|
-
>
|
|
581
|
-
<Link
|
|
582
|
-
to={paths.jobLogs(job.job_id || NO_JOB_ID, job.jr_job_id || NO_JR_JOB_ID)}
|
|
583
|
-
>
|
|
584
|
-
<IconButton
|
|
585
|
-
aria-label="View job logs"
|
|
586
|
-
size="xs"
|
|
587
|
-
variant="ghost"
|
|
588
|
-
>
|
|
589
|
-
<LuEye />
|
|
590
|
-
</IconButton>
|
|
591
|
-
</Link>
|
|
592
|
-
</Tooltip>
|
|
593
|
-
{(job.job_state?.[0]?.toLowerCase() === 'running' ||
|
|
594
|
-
job.job_state?.[0]?.toLowerCase() === 'pending') && (
|
|
595
|
-
<Tooltip
|
|
596
|
-
positioning={{ placement: 'top', offset: { mainAxis: 8 } }}
|
|
597
|
-
content="Cancel Job"
|
|
598
|
-
>
|
|
599
|
-
<IconButton
|
|
600
|
-
aria-label="Cancel job"
|
|
601
|
-
size="xs"
|
|
602
|
-
variant="ghost"
|
|
603
|
-
colorScheme="red"
|
|
604
|
-
onClick={() => job.job_id && handleCancelJob(job.job_id)}
|
|
605
|
-
>
|
|
606
|
-
<LuTrash2 />
|
|
607
|
-
</IconButton>
|
|
608
|
-
</Tooltip>
|
|
609
|
-
)}
|
|
610
|
-
</HStack>
|
|
611
|
-
</Table.Cell>
|
|
612
|
-
</Table.Row>
|
|
613
|
-
))}
|
|
614
|
-
</Table.Body>
|
|
615
|
-
</Table.Root>
|
|
616
|
-
</Table.ScrollArea>
|
|
617
|
-
)}
|
|
618
|
-
</Box>
|
|
619
|
-
)}
|
|
620
|
-
</Card.Body>
|
|
621
|
-
</Card.Root>
|
|
622
|
-
|
|
623
|
-
{/* Persisted Jobs Table */}
|
|
624
|
-
<Card.Root
|
|
625
|
-
bg="var(--color-bg-card)"
|
|
626
|
-
borderWidth="1px"
|
|
627
|
-
borderColor="var(--color-border)"
|
|
628
|
-
borderRadius="lg"
|
|
629
|
-
boxShadow="sm"
|
|
630
|
-
overflow="hidden"
|
|
631
|
-
flex="1"
|
|
632
|
-
minH="300px"
|
|
633
|
-
display="flex"
|
|
634
|
-
flexDirection="column"
|
|
635
|
-
padding="10px"
|
|
636
|
-
>
|
|
637
|
-
<Card.Header
|
|
638
|
-
bg="var(--color-bg-header)"
|
|
639
|
-
borderBottomWidth="1px"
|
|
640
|
-
borderBottomColor="var(--color-border)"
|
|
641
|
-
py={4}
|
|
642
|
-
px={6}
|
|
643
|
-
>
|
|
644
|
-
<HStack justify="space-between" align="center">
|
|
645
|
-
<Heading size="md" fontWeight="semibold" color="var(--color-text)">
|
|
646
|
-
Persisted Jobs
|
|
647
|
-
</Heading>
|
|
648
|
-
<Badge
|
|
649
|
-
colorScheme="purple"
|
|
650
|
-
variant="subtle"
|
|
651
|
-
fontSize="xs"
|
|
652
|
-
px={2}
|
|
653
|
-
py={1}
|
|
654
|
-
>
|
|
655
|
-
{countLabel(persistedJobs.length, allPersistedJobs.length)}
|
|
656
|
-
</Badge>
|
|
657
|
-
</HStack>
|
|
658
|
-
</Card.Header>
|
|
659
|
-
<Card.Body overflowY="auto" p={0} flex="1" minH={0} maxH="70vh">
|
|
660
|
-
{(persistedJobsError) ? (
|
|
661
|
-
<Alert.Root status="error">
|
|
662
|
-
<Alert.Indicator />
|
|
663
|
-
<Alert.Content>
|
|
664
|
-
<Alert.Title>Error loading persisted jobs!</Alert.Title>
|
|
665
|
-
<Alert.Description>
|
|
666
|
-
{persistedJobsError?.message || 'Failed to load persisted jobs'}
|
|
667
|
-
</Alert.Description>
|
|
668
|
-
</Alert.Content>
|
|
669
|
-
</Alert.Root>
|
|
670
|
-
) : (persistedJobsLoading) ? (
|
|
671
|
-
<Box textAlign="center" py={12}>
|
|
672
|
-
<Spinner size="lg" color="var(--color-primary)" />
|
|
673
|
-
<Text mt={4} color="var(--color-text-muted)" fontSize="sm">
|
|
674
|
-
Loading persisted jobs...
|
|
675
|
-
</Text>
|
|
676
|
-
</Box>
|
|
677
|
-
) : (
|
|
678
|
-
<>
|
|
679
|
-
{persistedJobs.length === 0 ? (
|
|
680
|
-
<Box textAlign="center" py={12}>
|
|
681
|
-
<Text color="var(--color-text-muted)" fontSize="md">
|
|
682
|
-
No persisted jobs found
|
|
683
|
-
</Text>
|
|
684
|
-
<Text color="var(--color-text-muted)" fontSize="sm" mt={2}>
|
|
685
|
-
Completed jobs will appear here
|
|
686
|
-
</Text>
|
|
687
|
-
</Box>
|
|
688
|
-
) : (
|
|
689
|
-
<Table.Root variant="line" size="sm" stickyHeader css={COMPACT_ROWS}>
|
|
690
|
-
<Table.Header bg="var(--color-bg-header)">
|
|
691
|
-
<Table.Row>
|
|
692
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} pl={6} pr={4} fontSize="sm">Job ID</Table.ColumnHeader>
|
|
693
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">JR Job ID</Table.ColumnHeader>
|
|
694
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Name</Table.ColumnHeader>
|
|
695
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Status</Table.ColumnHeader>
|
|
696
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Cluster</Table.ColumnHeader>
|
|
697
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Partition</Table.ColumnHeader>
|
|
698
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">User</Table.ColumnHeader>
|
|
699
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Time</Table.ColumnHeader>
|
|
700
|
-
<Table.ColumnHeader fontWeight="semibold" color="var(--color-text)" py={2} px={4} fontSize="sm">Actions</Table.ColumnHeader>
|
|
701
|
-
</Table.Row>
|
|
702
|
-
</Table.Header>
|
|
703
|
-
<Table.Body>
|
|
704
|
-
{persistedJobs.map((persistedJobInfo: PersitedJobInfo, index: number) => {
|
|
705
|
-
const job = persistedJobInfo.info;
|
|
706
|
-
const acc = persistedJobInfo.acc;
|
|
707
|
-
const jrJobId = persistedJobInfo.name;
|
|
708
|
-
|
|
709
|
-
// Use accounting data when available, fallback to info object
|
|
710
|
-
const jobId = acc?.job_id?.toString() || job.job_id || '-';
|
|
711
|
-
const jobName = persistedJobInfo.label || acc?.name || job.name || job.job_name || 'Persisted Job';
|
|
712
|
-
const jobStatus = acc?.state?.current?.[0] || job.job_state?.[0] || 'PENDING';
|
|
713
|
-
const partition = acc?.partition || job.partition || 'N/A';
|
|
714
|
-
const user = acc?.user || job.user_name || job.user || 'N/A';
|
|
715
|
-
|
|
716
|
-
// Calculate freshness - 2 weeks = 14 * 24 * 60 * 60 = 1209600 seconds
|
|
717
|
-
const maxAge = 14 * 24 * 60 * 60; // 2 weeks in seconds
|
|
718
|
-
const freshnessRatio = Math.min(persistedJobInfo.freshness / maxAge, 1);
|
|
719
|
-
|
|
720
|
-
// Calculate color from green (0) to brown (1)
|
|
721
|
-
const getFreshnessColor = (ratio: number) => {
|
|
722
|
-
if (ratio <= 0) return freshnessGreen;
|
|
723
|
-
if (ratio >= 1) return freshnessBrown;
|
|
724
|
-
|
|
725
|
-
// Interpolate between green and brown
|
|
726
|
-
const green = hexToRgb(freshnessGreen);
|
|
727
|
-
const brown = hexToRgb(freshnessBrown);
|
|
728
|
-
|
|
729
|
-
const r = Math.round(green[0] + (brown[0] - green[0]) * ratio);
|
|
730
|
-
const g = Math.round(green[1] + (brown[1] - green[1]) * ratio);
|
|
731
|
-
const b = Math.round(green[2] + (brown[2] - green[2]) * ratio);
|
|
732
|
-
|
|
733
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// Format duration for tooltip
|
|
737
|
-
const formatDuration = (seconds: number) => {
|
|
738
|
-
const days = Math.floor(seconds / (24 * 60 * 60));
|
|
739
|
-
const hours = Math.floor((seconds % (24 * 60 * 60)) / (60 * 60));
|
|
740
|
-
const minutes = Math.floor((seconds % (60 * 60)) / 60);
|
|
741
|
-
|
|
742
|
-
if (days > 0) {
|
|
743
|
-
return `${days}d ${hours}h ${minutes}m ago`;
|
|
744
|
-
} else if (hours > 0) {
|
|
745
|
-
return `${hours}h ${minutes}m ago`;
|
|
746
|
-
} else {
|
|
747
|
-
return `${minutes}m ago`;
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
// Format time limit - prefer accounting data
|
|
752
|
-
let timeLimit = 'N/A';
|
|
753
|
-
if (acc?.time?.limit?.number) {
|
|
754
|
-
timeLimit = `${acc.time.limit.number}min`;
|
|
755
|
-
} else if (typeof job.time_limit === 'string') {
|
|
756
|
-
timeLimit = job.time_limit;
|
|
757
|
-
} else if (job.time_limit?.number) {
|
|
758
|
-
timeLimit = `${job.time_limit.number}min`;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
return (
|
|
762
|
-
<Table.Row
|
|
763
|
-
key={`persisted-${jrJobId}`}
|
|
764
|
-
_hover={{ bg: 'var(--color-bg-hover)' }}
|
|
765
|
-
bg={index % 2 === 0 ? 'transparent' : 'var(--color-bg-stripe)'}
|
|
766
|
-
>
|
|
767
|
-
<Table.Cell pl={6} pr={4}>
|
|
768
|
-
<HStack gap={2}>
|
|
769
|
-
{/* first thing of the row: the important jobs stand out */}
|
|
770
|
-
<JobImportantStar jrJobId={jrJobId} important={!!persistedJobInfo.important} />
|
|
771
|
-
<Tooltip
|
|
772
|
-
positioning={{ placement: 'top', offset: { mainAxis: 8 } }}
|
|
773
|
-
content={formatDuration(persistedJobInfo.freshness)}
|
|
774
|
-
>
|
|
775
|
-
<Box
|
|
776
|
-
width="12px"
|
|
777
|
-
height="12px"
|
|
778
|
-
backgroundColor={getFreshnessColor(freshnessRatio)}
|
|
779
|
-
borderRadius="2px"
|
|
780
|
-
cursor="pointer"
|
|
781
|
-
border="1px solid"
|
|
782
|
-
borderColor="var(--color-border)"
|
|
783
|
-
/>
|
|
784
|
-
</Tooltip>
|
|
785
|
-
<Text fontWeight="semibold" color="var(--color-text)">{jobId}</Text>
|
|
786
|
-
</HStack>
|
|
787
|
-
</Table.Cell>
|
|
788
|
-
<Table.Cell>
|
|
789
|
-
<Text fontFamily="mono" fontSize="sm" color="var(--color-text-muted)">
|
|
790
|
-
{jrJobId}
|
|
791
|
-
</Text>
|
|
792
|
-
</Table.Cell>
|
|
793
|
-
<Table.Cell>
|
|
794
|
-
<HStack gap={2} flexWrap="wrap">
|
|
795
|
-
<Text color="var(--color-text)">{jobName}<AgentBadge tag={persistedJobInfo.agent} /></Text>
|
|
796
|
-
{(persistedJobInfo.groups || []).map((g) => (
|
|
797
|
-
<Badge
|
|
798
|
-
key={g}
|
|
799
|
-
size="sm"
|
|
800
|
-
variant="subtle"
|
|
801
|
-
colorPalette="purple"
|
|
802
|
-
cursor="pointer"
|
|
803
|
-
title={`Only the jobs of the group ${g}`}
|
|
804
|
-
onClick={() => setFilter('groups', g)}
|
|
805
|
-
>
|
|
806
|
-
{g}
|
|
807
|
-
</Badge>
|
|
808
|
-
))}
|
|
809
|
-
</HStack>
|
|
810
|
-
</Table.Cell>
|
|
811
|
-
<Table.Cell>
|
|
812
|
-
<HStack gap={2}>
|
|
813
|
-
{getStatusIcon(jobStatus)}
|
|
814
|
-
<Badge colorScheme={getStatusColor(jobStatus)}>
|
|
815
|
-
{jobStatus}
|
|
816
|
-
</Badge>
|
|
817
|
-
</HStack>
|
|
818
|
-
</Table.Cell>
|
|
819
|
-
<Table.Cell>
|
|
820
|
-
<Text color="var(--color-text)" fontSize="sm">{persistedJobInfo.cluster || 'mila'}</Text>
|
|
821
|
-
</Table.Cell>
|
|
822
|
-
<Table.Cell>
|
|
823
|
-
<Text color="var(--color-text)">{partition}</Text>
|
|
824
|
-
</Table.Cell>
|
|
825
|
-
<Table.Cell>
|
|
826
|
-
<Text color="var(--color-text)">{user}</Text>
|
|
827
|
-
</Table.Cell>
|
|
828
|
-
<Table.Cell>
|
|
829
|
-
<Text color="var(--color-text)">{timeLimit}</Text>
|
|
830
|
-
</Table.Cell>
|
|
831
|
-
<Table.Cell>
|
|
832
|
-
<HStack gap={2}>
|
|
833
|
-
<Tooltip
|
|
834
|
-
positioning={{ placement: 'top', offset: { mainAxis: 8 } }}
|
|
835
|
-
content="View Logs"
|
|
836
|
-
>
|
|
837
|
-
<Link
|
|
838
|
-
to={paths.jobLogs(jobId, jrJobId)}
|
|
839
|
-
>
|
|
840
|
-
<IconButton
|
|
841
|
-
aria-label="View job logs"
|
|
842
|
-
size="xs"
|
|
843
|
-
variant="ghost"
|
|
844
|
-
>
|
|
845
|
-
<LuEye />
|
|
846
|
-
</IconButton>
|
|
847
|
-
</Link>
|
|
848
|
-
</Tooltip>
|
|
849
|
-
<Tooltip
|
|
850
|
-
positioning={{ placement: 'top', offset: { mainAxis: 8 } }}
|
|
851
|
-
content="Rerun Job"
|
|
852
|
-
>
|
|
853
|
-
<IconButton
|
|
854
|
-
aria-label="Rerun job"
|
|
855
|
-
size="xs"
|
|
856
|
-
variant="ghost"
|
|
857
|
-
colorScheme="blue"
|
|
858
|
-
onClick={() => handleRerunJob(jrJobId)}
|
|
859
|
-
>
|
|
860
|
-
<LuRefreshCw />
|
|
861
|
-
</IconButton>
|
|
862
|
-
</Tooltip>
|
|
863
|
-
</HStack>
|
|
864
|
-
</Table.Cell>
|
|
865
|
-
</Table.Row>
|
|
866
|
-
);
|
|
867
|
-
})}
|
|
868
|
-
</Table.Body>
|
|
869
|
-
</Table.Root>
|
|
870
|
-
)}
|
|
871
|
-
</>
|
|
872
|
-
)}
|
|
873
|
-
</Card.Body>
|
|
874
|
-
</Card.Root>
|
|
432
|
+
{merged ? (
|
|
433
|
+
<JobsTable
|
|
434
|
+
title="Jobs"
|
|
435
|
+
rows={allRows}
|
|
436
|
+
total={allActiveJobs.length + allPersistedJobs.length - duplicates}
|
|
437
|
+
loading={activeJobsLoading || persistedJobsLoading}
|
|
438
|
+
error={activeJobsError || persistedJobsError}
|
|
439
|
+
empty="No jobs found"
|
|
440
|
+
emptyHint="Submit a new job to get started"
|
|
441
|
+
maxH="75vh"
|
|
442
|
+
cardProps={{ flex: '1', minH: '300px', display: 'flex', flexDirection: 'column' }}
|
|
443
|
+
{...tableActions}
|
|
444
|
+
/>
|
|
445
|
+
) : (
|
|
446
|
+
<>
|
|
447
|
+
<JobsTable
|
|
448
|
+
title="Active Jobs"
|
|
449
|
+
rows={activeRows}
|
|
450
|
+
total={allActiveJobs.length}
|
|
451
|
+
loading={activeJobsLoading}
|
|
452
|
+
error={activeJobsError}
|
|
453
|
+
empty="No active jobs found"
|
|
454
|
+
emptyHint="Submit a new job to get started"
|
|
455
|
+
maxH="35vh"
|
|
456
|
+
{...tableActions}
|
|
457
|
+
/>
|
|
458
|
+
<JobsTable
|
|
459
|
+
title="Persisted Jobs"
|
|
460
|
+
rows={persistedRows}
|
|
461
|
+
total={allPersistedJobs.length}
|
|
462
|
+
loading={persistedJobsLoading}
|
|
463
|
+
error={persistedJobsError}
|
|
464
|
+
empty="No persisted jobs found"
|
|
465
|
+
emptyHint="Completed jobs will appear here"
|
|
466
|
+
maxH="70vh"
|
|
467
|
+
cardProps={{ flex: '1', minH: '300px', display: 'flex', flexDirection: 'column' }}
|
|
468
|
+
{...tableActions}
|
|
469
|
+
/>
|
|
470
|
+
</>
|
|
471
|
+
)}
|
|
875
472
|
|
|
876
473
|
|
|
877
474
|
</VStack>
|