@milabench/bujang 0.1.20 → 0.1.21
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 +3602 -3532
- package/dist/index.js.map +1 -1
- package/dist/views/LogDisplay.d.ts +2 -0
- package/package.json +1 -1
- package/src/views/JobLogs.tsx +2 -1
- package/src/views/JobSubmit.tsx +65 -0
- package/src/views/LogDisplay.tsx +5 -2
- package/src/views/SetupView.tsx +39 -1
|
@@ -6,6 +6,8 @@ interface LogDisplayProps {
|
|
|
6
6
|
formatFileSize: (bytes: number) => string;
|
|
7
7
|
fetchLogData: (jrJobId: string, start?: number, end?: number) => Promise<string>;
|
|
8
8
|
getSlurmJobLogSize: (jrJobId: string) => Promise<number>;
|
|
9
|
+
/** Milliseconds between two refreshes while the job runs */
|
|
10
|
+
refreshInterval?: number;
|
|
9
11
|
}
|
|
10
12
|
export declare const LogDisplay: React.FC<LogDisplayProps>;
|
|
11
13
|
export {};
|
package/package.json
CHANGED
package/src/views/JobLogs.tsx
CHANGED
|
@@ -520,7 +520,8 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
520
520
|
description: result.error
|
|
521
521
|
|| 'Could not sync job results early. Job may not be running or compute node unavailable.',
|
|
522
522
|
type: 'warning',
|
|
523
|
-
|
|
523
|
+
// long enough to read the rsync error
|
|
524
|
+
duration: 15000,
|
|
524
525
|
});
|
|
525
526
|
}
|
|
526
527
|
} catch (error) {
|
package/src/views/JobSubmit.tsx
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
Card,
|
|
16
16
|
Spinner,
|
|
17
17
|
Icon,
|
|
18
|
+
Dialog,
|
|
19
|
+
Code,
|
|
18
20
|
} from '@chakra-ui/react';
|
|
19
21
|
import { LuCheck, LuX, LuLock, LuCalendar, LuPaperclip, LuChevronDown, LuChevronUp, LuBookOpen, LuWorkflow } from 'react-icons/lu';
|
|
20
22
|
import { toaster } from '../toast';
|
|
@@ -338,6 +340,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
338
340
|
// Sweep dialog: the arguments of the form when it was opened (null: closed)
|
|
339
341
|
const [sweepArgs, setSweepArgs] = useState<Record<string, string> | null>(null);
|
|
340
342
|
|
|
343
|
+
// Script arguments edited but not applied to the script when Submit was clicked (null: no question)
|
|
344
|
+
const [unappliedArgs, setUnappliedArgs] = useState<string[] | null>(null);
|
|
345
|
+
|
|
341
346
|
// Schedule dialog (name and cron expression)
|
|
342
347
|
const [scheduleOpen, setScheduleOpen] = useState(false);
|
|
343
348
|
|
|
@@ -658,7 +663,25 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
658
663
|
return result;
|
|
659
664
|
};
|
|
660
665
|
|
|
666
|
+
// the script arguments whose input differs from the value the script exports: only the script is
|
|
667
|
+
// submitted, so these edits would be lost
|
|
668
|
+
const _unappliedScriptArgs = (): string[] => {
|
|
669
|
+
const inScript = parseExportVariables(editorRef.current?.getValue() || '', true);
|
|
670
|
+
return Object.entries(_collectScriptArgs())
|
|
671
|
+
.filter(([name, value]) => name in inScript && inScript[name] !== value)
|
|
672
|
+
.map(([name]) => name);
|
|
673
|
+
};
|
|
674
|
+
|
|
661
675
|
const handleSubmitJob = async () => {
|
|
676
|
+
const unapplied = _unappliedScriptArgs();
|
|
677
|
+
if (unapplied.length > 0) {
|
|
678
|
+
setUnappliedArgs(unapplied);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
await doSubmitJob();
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const doSubmitJob = async () => {
|
|
662
685
|
let files;
|
|
663
686
|
try {
|
|
664
687
|
files = attachments.length
|
|
@@ -1482,6 +1505,48 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
1482
1505
|
ensureConnected={sshGate.ensure}
|
|
1483
1506
|
/>
|
|
1484
1507
|
)}
|
|
1508
|
+
{unappliedArgs && (
|
|
1509
|
+
<Dialog.Root open onOpenChange={(details) => { if (!details.open) setUnappliedArgs(null); }} size="sm">
|
|
1510
|
+
<Dialog.Backdrop />
|
|
1511
|
+
<Dialog.Positioner>
|
|
1512
|
+
<Dialog.Content className="bujang-dialog">
|
|
1513
|
+
<Dialog.Header py={3} px={4} borderBottom="1px solid" borderColor="var(--color-border)">
|
|
1514
|
+
<Dialog.Title fontSize="md" color="var(--color-text)">Apply the script arguments?</Dialog.Title>
|
|
1515
|
+
</Dialog.Header>
|
|
1516
|
+
<Dialog.Body px={4} py={4}>
|
|
1517
|
+
<VStack align="stretch" gap={2}>
|
|
1518
|
+
<Text fontSize="sm" color="var(--color-text)">
|
|
1519
|
+
These arguments were changed but not applied to the script: the job runs the
|
|
1520
|
+
script as it is in the editor.
|
|
1521
|
+
</Text>
|
|
1522
|
+
<HStack gap={2} wrap="wrap">
|
|
1523
|
+
{unappliedArgs.map(name => <Code key={name} fontSize="xs">{name}</Code>)}
|
|
1524
|
+
</HStack>
|
|
1525
|
+
</VStack>
|
|
1526
|
+
</Dialog.Body>
|
|
1527
|
+
<Dialog.Footer px={4} py={3} borderTop="1px solid" borderColor="var(--color-border)" gap={2}>
|
|
1528
|
+
<Button size="sm" variant="ghost" onClick={() => setUnappliedArgs(null)}>Cancel</Button>
|
|
1529
|
+
<Button
|
|
1530
|
+
size="sm"
|
|
1531
|
+
variant="outline"
|
|
1532
|
+
onClick={() => { setUnappliedArgs(null); void doSubmitJob(); }}
|
|
1533
|
+
>
|
|
1534
|
+
Submit without them
|
|
1535
|
+
</Button>
|
|
1536
|
+
<Button
|
|
1537
|
+
size="sm"
|
|
1538
|
+
bg="var(--color-primary)"
|
|
1539
|
+
color="var(--color-primary-text)"
|
|
1540
|
+
_hover={{ bg: 'var(--color-primary-hover)' }}
|
|
1541
|
+
onClick={() => { applyScriptArgs(); setUnappliedArgs(null); void doSubmitJob(); }}
|
|
1542
|
+
>
|
|
1543
|
+
Apply and submit
|
|
1544
|
+
</Button>
|
|
1545
|
+
</Dialog.Footer>
|
|
1546
|
+
</Dialog.Content>
|
|
1547
|
+
</Dialog.Positioner>
|
|
1548
|
+
</Dialog.Root>
|
|
1549
|
+
)}
|
|
1485
1550
|
{sshGate.dialog}
|
|
1486
1551
|
</Box>
|
|
1487
1552
|
);
|
package/src/views/LogDisplay.tsx
CHANGED
|
@@ -19,6 +19,8 @@ interface LogDisplayProps {
|
|
|
19
19
|
formatFileSize: (bytes: number) => string;
|
|
20
20
|
fetchLogData: (jrJobId: string, start?: number, end?: number) => Promise<string>;
|
|
21
21
|
getSlurmJobLogSize: (jrJobId: string) => Promise<number>;
|
|
22
|
+
/** Milliseconds between two refreshes while the job runs */
|
|
23
|
+
refreshInterval?: number;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export const LogDisplay: React.FC<LogDisplayProps> = ({
|
|
@@ -27,7 +29,8 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
|
|
|
27
29
|
isJobFinished,
|
|
28
30
|
formatFileSize,
|
|
29
31
|
fetchLogData,
|
|
30
|
-
getSlurmJobLogSize
|
|
32
|
+
getSlurmJobLogSize,
|
|
33
|
+
refreshInterval = 30000,
|
|
31
34
|
}) => {
|
|
32
35
|
// Internal state for truncation and log size
|
|
33
36
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
@@ -73,7 +76,7 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
|
|
|
73
76
|
queryKey: [`slurm-job-${logType}-full`, jrJobId],
|
|
74
77
|
queryFn: () => loadLogsChunked(jrJobId),
|
|
75
78
|
enabled: !!jrJobId,
|
|
76
|
-
refetchInterval: isJobFinished ? false :
|
|
79
|
+
refetchInterval: isJobFinished ? false : refreshInterval, // Disable refresh if job is finished
|
|
77
80
|
refetchIntervalInBackground: true,
|
|
78
81
|
});
|
|
79
82
|
|
package/src/views/SetupView.tsx
CHANGED
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
getAgentSessions,
|
|
24
24
|
getSettings,
|
|
25
25
|
getSlurmClusters,
|
|
26
|
+
getSlurmJobStderrFull,
|
|
27
|
+
getSlurmJobStderrSize,
|
|
28
|
+
getSlurmJobStdoutFull,
|
|
29
|
+
getSlurmJobStdoutSize,
|
|
26
30
|
getSlurmJobStatusSimple,
|
|
27
31
|
getSlurmPersistedJobs,
|
|
28
32
|
getSlurmProfiles,
|
|
@@ -36,6 +40,7 @@ import type { AgentSession, ApiError, PersitedJobInfo, SettingsInfo, SlurmJobSub
|
|
|
36
40
|
import { LinkableCard, Steps } from '../components/LinkableCard';
|
|
37
41
|
import { MasterBadge, SSH_CONNECTIONS_KEY, SshConnectDialog, isConnected, useSshConnectGate } from '../components/SshConnectDialog';
|
|
38
42
|
import { McpHelp } from './AgentActivityView';
|
|
43
|
+
import { LogDisplay } from './LogDisplay';
|
|
39
44
|
import { FoldersCard, SecretsCard, SETTINGS_KEY, SshCard } from './SettingsView';
|
|
40
45
|
import { useBujangPaths } from '../context';
|
|
41
46
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
@@ -209,6 +214,14 @@ const ConnectStep: React.FC<{ connections?: SshConnections; isLoading: boolean }
|
|
|
209
214
|
|
|
210
215
|
const FIRST_TEMPLATE = 'hello_world.sh';
|
|
211
216
|
const DONE_STATES = ['COMPLETED', 'FAILED', 'CANCELLED', 'TIMEOUT', 'OUT_OF_MEMORY', 'NODE_FAIL'];
|
|
217
|
+
/** How often the logs of the first job are fetched again while it runs (each fetch rsyncs the job folder) */
|
|
218
|
+
const FIRST_JOB_LOG_REFRESH = 10000;
|
|
219
|
+
|
|
220
|
+
const formatFileSize = (bytes: number): string => {
|
|
221
|
+
if (bytes === 0) return '0 B';
|
|
222
|
+
const i = Math.min(3, Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
223
|
+
return `${parseFloat((bytes / Math.pow(1024, i)).toFixed(1))} ${['B', 'KB', 'MB', 'GB'][i]}`;
|
|
224
|
+
};
|
|
212
225
|
|
|
213
226
|
const FirstJobStep: React.FC<{ info: SettingsInfo; jobCount?: number }> = ({ info, jobCount }) => {
|
|
214
227
|
const paths = useBujangPaths();
|
|
@@ -262,6 +275,8 @@ const FirstJobStep: React.FC<{ info: SettingsInfo; jobCount?: number }> = ({ inf
|
|
|
262
275
|
enabled: !!submitted?.jr_job_id && !!submitted?.job_id,
|
|
263
276
|
refetchInterval: (q) => (q.state.data && DONE_STATES.some(s => q.state.data!.status.toUpperCase().startsWith(s)) ? false : 5000),
|
|
264
277
|
});
|
|
278
|
+
const finished = !!status && DONE_STATES.some(s => status.status.toUpperCase().startsWith(s));
|
|
279
|
+
const started = !!status && !status.status.toUpperCase().startsWith('PENDING');
|
|
265
280
|
|
|
266
281
|
const go = () => {
|
|
267
282
|
const sbatch_args = choices.find(p => p.name === profile)?.sbatch_args || [];
|
|
@@ -329,11 +344,34 @@ const FirstJobStep: React.FC<{ info: SettingsInfo; jobCount?: number }> = ({ inf
|
|
|
329
344
|
{status ? <Badge colorPalette={status.status.toUpperCase().startsWith('COMPLETED') ? 'green' : 'blue'}>{status.status}</Badge> : <Spinner size="xs" />}
|
|
330
345
|
{submitted.jr_job_id && (
|
|
331
346
|
<Link asChild color="var(--color-link, var(--color-primary))">
|
|
332
|
-
<RouterLink to={paths.
|
|
347
|
+
<RouterLink to={paths.jobLogs(submitted.job_id || 0, submitted.jr_job_id)}>open the job logs</RouterLink>
|
|
333
348
|
</Link>
|
|
334
349
|
)}
|
|
335
350
|
</HStack>
|
|
336
351
|
)}
|
|
352
|
+
{submitted.success !== false && !submitted.error && submitted.jr_job_id && (
|
|
353
|
+
started ? (
|
|
354
|
+
<Grid templateColumns={{ base: '1fr', lg: '1fr 1fr' }} gap={3} mt={3}>
|
|
355
|
+
{(['stdout', 'stderr'] as const).map(kind => (
|
|
356
|
+
<Box key={kind} h="280px" display="flex" flexDirection="column">
|
|
357
|
+
<LogDisplay
|
|
358
|
+
logType={kind}
|
|
359
|
+
jrJobId={submitted.jr_job_id!}
|
|
360
|
+
isJobFinished={finished}
|
|
361
|
+
formatFileSize={formatFileSize}
|
|
362
|
+
fetchLogData={kind === 'stdout' ? getSlurmJobStdoutFull : getSlurmJobStderrFull}
|
|
363
|
+
getSlurmJobLogSize={kind === 'stdout' ? getSlurmJobStdoutSize : getSlurmJobStderrSize}
|
|
364
|
+
refreshInterval={FIRST_JOB_LOG_REFRESH}
|
|
365
|
+
/>
|
|
366
|
+
</Box>
|
|
367
|
+
))}
|
|
368
|
+
</Grid>
|
|
369
|
+
) : (
|
|
370
|
+
<Text fontSize="sm" color="var(--color-text-muted)" mt={2}>
|
|
371
|
+
The logs show up here once the job starts.
|
|
372
|
+
</Text>
|
|
373
|
+
)
|
|
374
|
+
)}
|
|
337
375
|
</Box>
|
|
338
376
|
)}
|
|
339
377
|
{!submitted && jobCount !== undefined && jobCount > 0 && (
|