@milabench/bujang 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api.d.ts +40 -1
- package/dist/components/LinkableCard.d.ts +27 -0
- package/dist/components/SshConnectDialog.d.ts +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4618 -3593
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +8 -3
- package/dist/routes.d.ts +1 -1
- package/dist/types.d.ts +185 -1
- package/dist/views/JanitorView.d.ts +5 -0
- package/package.json +1 -1
- package/src/api.ts +110 -0
- package/src/components/LinkableCard.tsx +120 -0
- package/src/components/SshConnectDialog.tsx +377 -0
- package/src/index.ts +2 -0
- package/src/paths.ts +13 -4
- package/src/routes.tsx +3 -1
- package/src/types.ts +197 -1
- package/src/views/JanitorView.tsx +693 -0
- package/src/views/JobLogs.tsx +2 -1
- package/src/views/JobSubmit.tsx +139 -13
- package/src/views/JobsView.tsx +5 -62
- package/src/views/PipelineGraph.tsx +33 -3
- package/src/views/SettingsView.tsx +112 -48
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
Badge,
|
|
10
10
|
Table,
|
|
11
11
|
Spinner,
|
|
12
|
-
Card,
|
|
13
12
|
Grid,
|
|
14
13
|
Code,
|
|
15
14
|
Input,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
Alert,
|
|
20
19
|
} from '@chakra-ui/react';
|
|
21
20
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
21
|
+
import { Link } from 'react-router-dom';
|
|
22
22
|
import {
|
|
23
23
|
LuDatabase,
|
|
24
24
|
LuFolder,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
} from '../api';
|
|
45
45
|
import type {
|
|
46
46
|
ApiError,
|
|
47
|
+
SettingsDatabaseTable,
|
|
47
48
|
SettingsField,
|
|
48
49
|
SettingsInfo,
|
|
49
50
|
SettingsOrigin,
|
|
@@ -56,6 +57,8 @@ import type {
|
|
|
56
57
|
} from '../types';
|
|
57
58
|
import { toaster } from '../toast';
|
|
58
59
|
import { Tooltip } from '../components/tooltip';
|
|
60
|
+
import { LinkableCard, Steps, useHashScroll } from '../components/LinkableCard';
|
|
61
|
+
import { useBujangPaths } from '../context';
|
|
59
62
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
60
63
|
|
|
61
64
|
const SETTINGS_KEY = ['bujang-settings'];
|
|
@@ -73,30 +76,48 @@ const fail = (title: string) => (error: unknown) =>
|
|
|
73
76
|
|
|
74
77
|
// ─── Layout pieces ──────────────────────────────────────────────────
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
/** A card of the page, linkable: /settings#<id> (SECTIONS) */
|
|
80
|
+
const Section = LinkableCard;
|
|
81
|
+
|
|
82
|
+
/** The cards of the page, in order: their ids are the URL hashes (/settings#ssh) */
|
|
83
|
+
const SECTIONS: { id: string; label: string }[] = [
|
|
84
|
+
{ id: 'general', label: 'General' },
|
|
85
|
+
{ id: 'ssh', label: 'SSH' },
|
|
86
|
+
{ id: 'secrets', label: 'Secrets' },
|
|
87
|
+
{ id: 'folders', label: 'Folders' },
|
|
88
|
+
{ id: 'database', label: 'Database' },
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const formatBytes = (n: number | null | undefined) => {
|
|
92
|
+
if (n == null) return '—';
|
|
93
|
+
if (n < 1024) return `${n} B`;
|
|
94
|
+
const units = ['KB', 'MB', 'GB', 'TB'];
|
|
95
|
+
let v = n / 1024;
|
|
96
|
+
let i = 0;
|
|
97
|
+
while (v >= 1024 && i < units.length - 1) { v /= 1024; i++; }
|
|
98
|
+
return `${v.toFixed(v < 10 ? 1 : 0)} ${units[i]}`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** Tables of a database and their rows */
|
|
102
|
+
const TablesTable: React.FC<{ tables: SettingsDatabaseTable[] }> = ({ tables }) => (
|
|
103
|
+
<Table.Root size="sm" variant="outline">
|
|
104
|
+
<Table.Header>
|
|
105
|
+
<Table.Row>
|
|
106
|
+
<Table.ColumnHeader>Table</Table.ColumnHeader>
|
|
107
|
+
<Table.ColumnHeader>Holds</Table.ColumnHeader>
|
|
108
|
+
<Table.ColumnHeader textAlign="end">Rows</Table.ColumnHeader>
|
|
109
|
+
</Table.Row>
|
|
110
|
+
</Table.Header>
|
|
111
|
+
<Table.Body>
|
|
112
|
+
{tables.map(t => (
|
|
113
|
+
<Table.Row key={t.name}>
|
|
114
|
+
<Table.Cell fontFamily="mono" fontSize="xs">{t.name}</Table.Cell>
|
|
115
|
+
<Table.Cell fontSize="xs" color="var(--color-text-muted)">{t.description || '—'}</Table.Cell>
|
|
116
|
+
<Table.Cell textAlign="end">{t.exists ? t.rows ?? '?' : <Badge size="sm">not created</Badge>}</Table.Cell>
|
|
117
|
+
</Table.Row>
|
|
118
|
+
))}
|
|
119
|
+
</Table.Body>
|
|
120
|
+
</Table.Root>
|
|
100
121
|
);
|
|
101
122
|
|
|
102
123
|
/** Label / value rows */
|
|
@@ -177,7 +198,7 @@ const GeneralCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
177
198
|
else if (mcp.disabled) mcpText = <Text>off (<Mono>--no-mcp</Mono>)</Text>;
|
|
178
199
|
else mcpText = <Text color="var(--color-text-muted)">not served by this app</Text>;
|
|
179
200
|
return (
|
|
180
|
-
<Section icon={<LuInfo />} title="General">
|
|
201
|
+
<Section id="general" icon={<LuInfo />} title="General">
|
|
181
202
|
<KV
|
|
182
203
|
rows={[
|
|
183
204
|
['bujang version', <Mono key="v">{g.version}</Mono>],
|
|
@@ -272,6 +293,7 @@ const FoldersCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
272
293
|
|
|
273
294
|
return (
|
|
274
295
|
<Section
|
|
296
|
+
id="folders"
|
|
275
297
|
icon={<LuFolder />}
|
|
276
298
|
title="Folders"
|
|
277
299
|
subtitle={<>Saved to the user file, like <Code fontSize="xs">bujang init</Code>.</>}
|
|
@@ -374,10 +396,16 @@ const DatabaseCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
374
396
|
|
|
375
397
|
return (
|
|
376
398
|
<Section
|
|
399
|
+
id="database"
|
|
377
400
|
icon={<LuDatabase />}
|
|
378
401
|
title="Database"
|
|
379
|
-
subtitle=
|
|
402
|
+
subtitle={<>
|
|
403
|
+
The scheduled jobs live in the database below (SQLAlchemy: <Code fontSize="xs">database_url</Code> or
|
|
404
|
+
the host's); everything else bujang keeps in the SQLite files of the job folder. The job folders do not
|
|
405
|
+
depend on either: delete <Code fontSize="xs">state.db</Code> and its index is rebuilt.
|
|
406
|
+
</>}
|
|
380
407
|
>
|
|
408
|
+
<SubHeading>Scheduled jobs database</SubHeading>
|
|
381
409
|
<KV
|
|
382
410
|
rows={[
|
|
383
411
|
['URL', db.url ? <Mono>{db.url}</Mono> : <Text color="var(--color-text-muted)">no database (scheduled jobs off)</Text>],
|
|
@@ -391,24 +419,7 @@ const DatabaseCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
391
419
|
]}
|
|
392
420
|
/>
|
|
393
421
|
{db.error && <Text fontSize="sm" color="var(--color-status-failed)">{db.error}</Text>}
|
|
394
|
-
{db.tables.length > 0 &&
|
|
395
|
-
<Table.Root size="sm" variant="outline" maxW="480px">
|
|
396
|
-
<Table.Header>
|
|
397
|
-
<Table.Row>
|
|
398
|
-
<Table.ColumnHeader>Table</Table.ColumnHeader>
|
|
399
|
-
<Table.ColumnHeader textAlign="end">Rows</Table.ColumnHeader>
|
|
400
|
-
</Table.Row>
|
|
401
|
-
</Table.Header>
|
|
402
|
-
<Table.Body>
|
|
403
|
-
{db.tables.map(t => (
|
|
404
|
-
<Table.Row key={t.name}>
|
|
405
|
-
<Table.Cell fontFamily="mono" fontSize="xs">{t.name}</Table.Cell>
|
|
406
|
-
<Table.Cell textAlign="end">{t.exists ? t.rows ?? '?' : <Badge size="sm">not created</Badge>}</Table.Cell>
|
|
407
|
-
</Table.Row>
|
|
408
|
-
))}
|
|
409
|
-
</Table.Body>
|
|
410
|
-
</Table.Root>
|
|
411
|
-
)}
|
|
422
|
+
{db.tables.length > 0 && <TablesTable tables={db.tables} />}
|
|
412
423
|
{!db.host_provided && (
|
|
413
424
|
<Field.Root>
|
|
414
425
|
<Field.Label color="var(--color-text)">database_url in the user file</Field.Label>
|
|
@@ -441,6 +452,19 @@ const DatabaseCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
441
452
|
</Field.HelperText>
|
|
442
453
|
</Field.Root>
|
|
443
454
|
)}
|
|
455
|
+
{(db.local || []).map(local => (
|
|
456
|
+
<Box key={local.name} borderTopWidth="1px" borderColor="var(--color-border)" pt={4}>
|
|
457
|
+
<HStack gap={2} wrap="wrap" mb={1}>
|
|
458
|
+
<SubHeading>{local.name}</SubHeading>
|
|
459
|
+
{local.exists ? <Badge size="sm" variant="subtle">{formatBytes(local.size)}</Badge> : <Badge size="sm">not created yet</Badge>}
|
|
460
|
+
</HStack>
|
|
461
|
+
<Text fontSize="sm" color="var(--color-text-muted)" mb={2}>
|
|
462
|
+
SQLite, <Mono>{local.path}</Mono>: {local.description}.
|
|
463
|
+
</Text>
|
|
464
|
+
{local.error && <Text fontSize="sm" color="var(--color-status-failed)">{local.error}</Text>}
|
|
465
|
+
{local.tables.length > 0 && <TablesTable tables={local.tables} />}
|
|
466
|
+
</Box>
|
|
467
|
+
))}
|
|
444
468
|
</Section>
|
|
445
469
|
);
|
|
446
470
|
};
|
|
@@ -676,10 +700,40 @@ const SshCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
676
700
|
|
|
677
701
|
return (
|
|
678
702
|
<Section
|
|
703
|
+
id="ssh"
|
|
679
704
|
icon={<LuTerminal />}
|
|
680
705
|
title="SSH"
|
|
681
706
|
subtitle={<>The ssh config entries the plugins ship, like <Code fontSize="xs">bujang ssh</Code>.</>}
|
|
682
707
|
>
|
|
708
|
+
<Steps
|
|
709
|
+
steps={[
|
|
710
|
+
{
|
|
711
|
+
title: 'Fill in your values',
|
|
712
|
+
body: <>In each plugin below, give the values it asks for (your cluster username, ...).</>,
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
title: 'Preview, then apply',
|
|
716
|
+
body: <>
|
|
717
|
+
<b>Preview install</b> shows what changes in your ssh config, <b>Apply install</b> writes
|
|
718
|
+
it (the file is backed up first).
|
|
719
|
+
</>,
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
title: 'Log in once from a terminal',
|
|
723
|
+
body: <>
|
|
724
|
+
On clusters with two-factor authentication, run <Code fontSize="xs">ssh <host></Code> once
|
|
725
|
+
and approve the prompt: bujang reuses that connection and never prompts.
|
|
726
|
+
</>,
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
title: 'Test the connections',
|
|
730
|
+
body: <>
|
|
731
|
+
<b>Test</b> at the bottom of this card checks ssh, Slurm and the remote folder of each cluster;
|
|
732
|
+
each failure comes with a hint.
|
|
733
|
+
</>,
|
|
734
|
+
},
|
|
735
|
+
]}
|
|
736
|
+
/>
|
|
683
737
|
<Field.Root>
|
|
684
738
|
<Field.Label color="var(--color-text)">ssh config file</Field.Label>
|
|
685
739
|
<HStack w="100%">
|
|
@@ -781,6 +835,7 @@ const SecretsCard: React.FC<{ writable: boolean }> = ({ writable }) => {
|
|
|
781
835
|
|
|
782
836
|
return (
|
|
783
837
|
<Section
|
|
838
|
+
id="secrets"
|
|
784
839
|
icon={<LuKeyRound />}
|
|
785
840
|
title="Secrets"
|
|
786
841
|
subtitle={<>Used in job scripts as <Code fontSize="xs">{'{{ secrets.NAME }}'}</Code>. Values are never shown.</>}
|
|
@@ -877,7 +932,9 @@ const SecretsCard: React.FC<{ writable: boolean }> = ({ writable }) => {
|
|
|
877
932
|
|
|
878
933
|
export const SettingsView: React.FC = () => {
|
|
879
934
|
usePageTitle('Settings');
|
|
935
|
+
const paths = useBujangPaths();
|
|
880
936
|
const { data: info, isLoading, error } = useQuery<SettingsInfo>({ queryKey: SETTINGS_KEY, queryFn: getSettings });
|
|
937
|
+
useHashScroll(!!info);
|
|
881
938
|
|
|
882
939
|
return (
|
|
883
940
|
<Box p={6} maxW="1100px">
|
|
@@ -888,19 +945,26 @@ export const SettingsView: React.FC = () => {
|
|
|
888
945
|
? <Badge colorPalette="green" variant="subtle">editable</Badge>
|
|
889
946
|
: <Badge variant="outline"><LuLock /> read-only</Badge>)}
|
|
890
947
|
</HStack>
|
|
891
|
-
<Text mb={
|
|
948
|
+
<Text mb={3} color="var(--color-text-muted)">
|
|
892
949
|
Where bujang keeps the jobs, its database, the ssh setup of the clusters and the secrets of the scripts.
|
|
893
950
|
</Text>
|
|
951
|
+
<HStack mb={6} gap={2} wrap="wrap" fontSize="sm">
|
|
952
|
+
{SECTIONS.map(s => (
|
|
953
|
+
<Link key={s.id} to={paths.settings(s.id)}>
|
|
954
|
+
<Badge variant="outline" cursor="pointer">{s.label}</Badge>
|
|
955
|
+
</Link>
|
|
956
|
+
))}
|
|
957
|
+
</HStack>
|
|
894
958
|
{isLoading && <Spinner />}
|
|
895
959
|
{error && <Text color="var(--color-status-failed)">{errorMessage(error)}</Text>}
|
|
896
960
|
{info && (
|
|
897
961
|
<VStack align="stretch" gap={6}>
|
|
898
962
|
{!info.writable && <ReadOnlyNote reason={info.read_only_reason} />}
|
|
899
963
|
<GeneralCard info={info} />
|
|
900
|
-
<FoldersCard info={info} />
|
|
901
|
-
<DatabaseCard info={info} />
|
|
902
964
|
<SshCard info={info} />
|
|
903
965
|
<SecretsCard writable={info.writable} />
|
|
966
|
+
<FoldersCard info={info} />
|
|
967
|
+
<DatabaseCard info={info} />
|
|
904
968
|
</VStack>
|
|
905
969
|
)}
|
|
906
970
|
</Box>
|