@milabench/bujang 0.1.14 → 0.1.16
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 +1 -0
- package/dist/index.js +7828 -7044
- package/dist/index.js.map +1 -1
- package/dist/theme.css +26 -0
- package/dist/types.d.ts +63 -10
- package/dist/views/AgentActivityView.d.ts +2 -1
- package/dist/views/JobArtifacts.d.ts +1 -0
- package/dist/views/JobDataOverview.d.ts +4 -3
- package/dist/views/JobSubmit.d.ts +1 -0
- package/dist/views/JobsTable.d.ts +57 -0
- package/dist/views/OverviewPanels.d.ts +38 -9
- package/dist/views/SettingsView.d.ts +4 -0
- package/dist/views/dataCharts.d.ts +11 -7
- package/package.json +1 -1
- package/src/api.ts +9 -2
- package/src/components/SshConnectDialog.tsx +1 -1
- package/src/theme.css +26 -0
- package/src/types.ts +48 -6
- package/src/views/AgentActivityView.tsx +14 -5
- package/src/views/JobArtifacts.tsx +1 -1
- package/src/views/JobDataOverview.tsx +125 -138
- package/src/views/JobLogs.tsx +18 -8
- package/src/views/JobMarks.tsx +1 -1
- package/src/views/JobSubmit.tsx +27 -21
- package/src/views/JobsTable.tsx +746 -0
- package/src/views/JobsView.tsx +83 -518
- package/src/views/OverviewPanels.tsx +940 -88
- 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/SettingsView.tsx +80 -18
- package/src/views/SweepDialog.tsx +1 -1
- package/src/views/dataCharts.tsx +21 -11
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 } from 'react-icons/lu';
|
|
34
16
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
35
17
|
import {
|
|
36
18
|
getSlurmJobs,
|
|
@@ -40,60 +22,18 @@ import {
|
|
|
40
22
|
getOrganizers,
|
|
41
23
|
getSyncStatus,
|
|
42
24
|
syncNow,
|
|
25
|
+
getSettings,
|
|
43
26
|
} from '../api';
|
|
44
|
-
import {
|
|
45
|
-
import type { SlurmJob, PersitedJobInfo, ApiError, OrganizerGroups, SyncStatus } from '../types';
|
|
27
|
+
import type { SlurmJob, PersitedJobInfo, ApiError, OrganizerGroups, SyncStatus, SettingsInfo } from '../types';
|
|
46
28
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
47
|
-
import { AgentBadge } from './AgentActivityView';
|
|
48
29
|
import { SshConnectButton } from '../components/SshConnectDialog';
|
|
49
|
-
import {
|
|
30
|
+
import { JobsTable, fromActive, fromPersisted, mergeRows } from './JobsTable';
|
|
31
|
+
import { SETTINGS_KEY } from './SettingsView';
|
|
50
32
|
|
|
51
33
|
type JobsViewProps = Record<string, never>;
|
|
52
34
|
|
|
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
35
|
const AUTO_REFRESH_KEY = 'bujang-jobs-auto-refresh';
|
|
95
36
|
const AUTO_REFRESH_MS = 30_000;
|
|
96
|
-
|
|
97
37
|
/** On unless turned off on this browser: the page follows the background sync of the server */
|
|
98
38
|
function readAutoRefresh(): boolean {
|
|
99
39
|
try {
|
|
@@ -132,11 +72,11 @@ const OrganizerFilters: React.FC<{
|
|
|
132
72
|
const shown = organizers.filter((o) => o.groups.length > 0 || selected[o.name]);
|
|
133
73
|
if (shown.length === 0) return null;
|
|
134
74
|
return (
|
|
135
|
-
<HStack gap={
|
|
75
|
+
<HStack gap={3} flexWrap="wrap">
|
|
136
76
|
{shown.map((o) => (
|
|
137
77
|
<HStack key={o.name} gap={2}>
|
|
138
78
|
<Text fontSize="sm" color="var(--color-text-muted)">{filterLabel(o.name)}:</Text>
|
|
139
|
-
<NativeSelect.Root size="
|
|
79
|
+
<NativeSelect.Root size="xs" w="auto" minW="120px">
|
|
140
80
|
<NativeSelect.Field
|
|
141
81
|
value={selected[o.name] ?? ''}
|
|
142
82
|
onChange={(e) => onChange(o.name, e.target.value)}
|
|
@@ -169,18 +109,6 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
169
109
|
const navigate = useNavigate();
|
|
170
110
|
const paths = useBujangPaths();
|
|
171
111
|
|
|
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
112
|
const [autoRefresh, setAutoRefresh] = React.useState(readAutoRefresh);
|
|
185
113
|
const toggleAutoRefresh = (on: boolean) => {
|
|
186
114
|
try {
|
|
@@ -190,6 +118,9 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
190
118
|
}
|
|
191
119
|
setAutoRefresh(on);
|
|
192
120
|
};
|
|
121
|
+
// jobs_merged setting (Settings page, Display card): one table, or one for the active and one for the persisted jobs
|
|
122
|
+
const { data: settings } = useQuery<SettingsInfo>({ queryKey: SETTINGS_KEY, queryFn: getSettings, staleTime: 60_000 });
|
|
123
|
+
const merged = settings?.fields.jobs_merged?.value !== false;
|
|
193
124
|
// Queries
|
|
194
125
|
const { data: sync } = useQuery<SyncStatus>({
|
|
195
126
|
queryKey: ['bujang-sync'],
|
|
@@ -288,8 +219,18 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
288
219
|
const persistedJobs = allPersistedJobs.filter(
|
|
289
220
|
(job) => (!allowed || allowed.has(job.name)) && (!importantOnly || job.important),
|
|
290
221
|
);
|
|
291
|
-
const
|
|
292
|
-
|
|
222
|
+
const activeRows = React.useMemo(() => activeJobs.map(fromActive), [activeJobs]);
|
|
223
|
+
const persistedRows = React.useMemo(() => persistedJobs.map(fromPersisted), [persistedJobs]);
|
|
224
|
+
// the important filter only knows the job folders: a job only in squeue is not marked
|
|
225
|
+
const allRows = React.useMemo(
|
|
226
|
+
() => mergeRows(activeJobs, persistedJobs).filter((r) => !importantOnly || r.important),
|
|
227
|
+
[activeJobs, persistedJobs, importantOnly],
|
|
228
|
+
);
|
|
229
|
+
// a job in squeue and in the job folders is one row
|
|
230
|
+
const duplicates = React.useMemo(() => {
|
|
231
|
+
const names = new Set(allPersistedJobs.map((p) => p.name));
|
|
232
|
+
return allActiveJobs.filter((j: SlurmJob) => j.jr_job_id && names.has(j.jr_job_id)).length;
|
|
233
|
+
}, [allActiveJobs, allPersistedJobs]);
|
|
293
234
|
|
|
294
235
|
|
|
295
236
|
|
|
@@ -350,6 +291,26 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
350
291
|
rerunJobMutation.mutate(jrJobId);
|
|
351
292
|
}
|
|
352
293
|
};
|
|
294
|
+
const tableActions = {
|
|
295
|
+
onCancel: handleCancelJob,
|
|
296
|
+
onRerun: handleRerunJob,
|
|
297
|
+
onGroup: (g: string) => setFilter('groups', g),
|
|
298
|
+
};
|
|
299
|
+
// quick filters, in the header of the (first) table; they apply to both tables when split
|
|
300
|
+
const quickFilters = (
|
|
301
|
+
<>
|
|
302
|
+
<Button
|
|
303
|
+
size="xs"
|
|
304
|
+
variant={importantOnly ? 'solid' : 'outline'}
|
|
305
|
+
colorPalette="yellow"
|
|
306
|
+
onClick={() => setFilter('important', importantOnly ? '' : '1')}
|
|
307
|
+
title="Only the jobs marked important"
|
|
308
|
+
>
|
|
309
|
+
<LuStar fill={importantOnly ? 'currentColor' : 'none'} /> Important
|
|
310
|
+
</Button>
|
|
311
|
+
<OrganizerFilters organizers={organizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
|
|
312
|
+
</>
|
|
313
|
+
);
|
|
353
314
|
|
|
354
315
|
|
|
355
316
|
|
|
@@ -435,443 +396,47 @@ export const JobsView: React.FC<JobsViewProps> = () => {
|
|
|
435
396
|
</HStack>
|
|
436
397
|
</Box>
|
|
437
398
|
|
|
438
|
-
<HStack gap={4} flexWrap="wrap">
|
|
439
|
-
<Button
|
|
440
|
-
size="sm"
|
|
441
|
-
variant={importantOnly ? 'solid' : 'outline'}
|
|
442
|
-
colorPalette="yellow"
|
|
443
|
-
onClick={() => setFilter('important', importantOnly ? '' : '1')}
|
|
444
|
-
title="Only the jobs marked important"
|
|
445
|
-
>
|
|
446
|
-
<LuStar fill={importantOnly ? 'currentColor' : 'none'} /> Important
|
|
447
|
-
</Button>
|
|
448
|
-
<OrganizerFilters organizers={organizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
|
|
449
|
-
</HStack>
|
|
450
399
|
|
|
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>
|
|
400
|
+
{merged ? (
|
|
401
|
+
<JobsTable
|
|
402
|
+
title=""
|
|
403
|
+
rows={allRows}
|
|
404
|
+
total={allActiveJobs.length + allPersistedJobs.length - duplicates}
|
|
405
|
+
loading={activeJobsLoading || persistedJobsLoading}
|
|
406
|
+
error={activeJobsError || persistedJobsError}
|
|
407
|
+
empty="No jobs found"
|
|
408
|
+
emptyHint="Submit a new job to get started"
|
|
409
|
+
cardProps={{ flex: '1', minH: '300px', display: 'flex', flexDirection: 'column' }}
|
|
410
|
+
quickFilters={quickFilters}
|
|
411
|
+
{...tableActions}
|
|
412
|
+
/>
|
|
413
|
+
) : (
|
|
414
|
+
<>
|
|
415
|
+
<JobsTable
|
|
416
|
+
title="Active Jobs"
|
|
417
|
+
rows={activeRows}
|
|
418
|
+
total={allActiveJobs.length}
|
|
419
|
+
loading={activeJobsLoading}
|
|
420
|
+
error={activeJobsError}
|
|
421
|
+
empty="No active jobs found"
|
|
422
|
+
emptyHint="Submit a new job to get started"
|
|
423
|
+
maxH="35vh"
|
|
424
|
+
quickFilters={quickFilters}
|
|
425
|
+
{...tableActions}
|
|
426
|
+
/>
|
|
427
|
+
<JobsTable
|
|
428
|
+
title="Persisted Jobs"
|
|
429
|
+
rows={persistedRows}
|
|
430
|
+
total={allPersistedJobs.length}
|
|
431
|
+
loading={persistedJobsLoading}
|
|
432
|
+
error={persistedJobsError}
|
|
433
|
+
empty="No persisted jobs found"
|
|
434
|
+
emptyHint="Completed jobs will appear here"
|
|
435
|
+
cardProps={{ flex: '1', minH: '300px', display: 'flex', flexDirection: 'column' }}
|
|
436
|
+
{...tableActions}
|
|
437
|
+
/>
|
|
438
|
+
</>
|
|
439
|
+
)}
|
|
875
440
|
|
|
876
441
|
|
|
877
442
|
</VStack>
|