@milabench/bujang 0.1.6 → 0.1.8
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 +29 -1
- package/dist/components/LinkableCard.d.ts +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3813 -3006
- 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 +150 -0
- package/dist/views/JanitorView.d.ts +5 -0
- package/package.json +1 -1
- package/src/api.ts +70 -0
- package/src/components/LinkableCard.tsx +120 -0
- package/src/index.ts +2 -0
- package/src/paths.ts +13 -4
- package/src/routes.tsx +3 -1
- package/src/types.ts +158 -0
- package/src/views/JanitorView.tsx +690 -0
- package/src/views/JobLogs.tsx +2 -1
- package/src/views/JobSubmit.tsx +132 -11
- package/src/views/PipelineGraph.tsx +33 -3
- package/src/views/SettingsView.tsx +112 -48
package/src/views/JobLogs.tsx
CHANGED
|
@@ -481,7 +481,8 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
481
481
|
} else {
|
|
482
482
|
toaster.create({
|
|
483
483
|
title: 'Early Sync Failed',
|
|
484
|
-
description:
|
|
484
|
+
description: result.error
|
|
485
|
+
|| 'Could not sync job results early. Job may not be running or compute node unavailable.',
|
|
485
486
|
type: 'warning',
|
|
486
487
|
duration: 5000,
|
|
487
488
|
});
|
package/src/views/JobSubmit.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Spinner,
|
|
17
17
|
Icon,
|
|
18
18
|
} from '@chakra-ui/react';
|
|
19
|
-
import { LuCheck, LuX, LuLock, LuCalendar } from 'react-icons/lu';
|
|
19
|
+
import { LuCheck, LuX, LuLock, LuCalendar, LuPaperclip } from 'react-icons/lu';
|
|
20
20
|
import { toaster } from '../toast';
|
|
21
21
|
import { MonacoEditor } from '../components/MonacoEditor';
|
|
22
22
|
import type { MonacoCodeEditor } from '../components/MonacoEditor';
|
|
@@ -30,9 +30,77 @@ import {
|
|
|
30
30
|
saveSlurmTemplate,
|
|
31
31
|
testSlurmSecret,
|
|
32
32
|
createScheduledJob,
|
|
33
|
+
fileToAttachment,
|
|
33
34
|
} from '../api';
|
|
34
35
|
import type { SlurmProfile, SlurmJob, ApiError, ScheduledJob } from '../types';
|
|
35
36
|
|
|
37
|
+
const formatSize = (n: number) =>
|
|
38
|
+
n < 1024 ? `${n} B` : n < 1024 ** 2 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1024 ** 2).toFixed(1)} MB`;
|
|
39
|
+
|
|
40
|
+
/** Name of an attached file in input/: its path inside a picked folder, else its name */
|
|
41
|
+
const attachmentName = (file: File) => (file as File & { webkitRelativePath?: string }).webkitRelativePath || file.name;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Files sent with the job: copied to <job folder>/input/ on the cluster before the job starts,
|
|
45
|
+
* the script finds them in $JR_INPUT_DIR.
|
|
46
|
+
*/
|
|
47
|
+
const AttachmentsCard: React.FC<{ files: File[]; onChange: (files: File[]) => void }> = ({ files, onChange }) => {
|
|
48
|
+
const fileInput = useRef<HTMLInputElement>(null);
|
|
49
|
+
const folderInput = useRef<HTMLInputElement>(null);
|
|
50
|
+
const add = (list: FileList | null) => {
|
|
51
|
+
if (!list) return;
|
|
52
|
+
const byName = new Map(files.map(f => [attachmentName(f), f]));
|
|
53
|
+
Array.from(list).forEach(f => byName.set(attachmentName(f), f));
|
|
54
|
+
onChange(Array.from(byName.values()));
|
|
55
|
+
};
|
|
56
|
+
const total = files.reduce((n, f) => n + f.size, 0);
|
|
57
|
+
return (
|
|
58
|
+
<Card.Root bg="var(--color-bg-card)" borderWidth="1px" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm" p={4}>
|
|
59
|
+
<VStack align="stretch" gap={3}>
|
|
60
|
+
<HStack justify="space-between" wrap="wrap" gap={2}>
|
|
61
|
+
<Heading size="sm" fontWeight="semibold" color="var(--color-text)">
|
|
62
|
+
<HStack gap={2}><LuPaperclip /> Attached files</HStack>
|
|
63
|
+
</Heading>
|
|
64
|
+
<HStack gap={2}>
|
|
65
|
+
<Button size="xs" variant="outline" onClick={() => fileInput.current?.click()}>Add files</Button>
|
|
66
|
+
<Button size="xs" variant="outline" onClick={() => folderInput.current?.click()}>Add a folder</Button>
|
|
67
|
+
</HStack>
|
|
68
|
+
</HStack>
|
|
69
|
+
<input ref={fileInput} type="file" multiple hidden onChange={(e) => { add(e.target.files); e.target.value = ''; }} />
|
|
70
|
+
<input
|
|
71
|
+
ref={folderInput}
|
|
72
|
+
type="file"
|
|
73
|
+
multiple
|
|
74
|
+
hidden
|
|
75
|
+
{...({ webkitdirectory: '', directory: '' } as Record<string, string>)}
|
|
76
|
+
onChange={(e) => { add(e.target.files); e.target.value = ''; }}
|
|
77
|
+
/>
|
|
78
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
79
|
+
Copied to <code>input/</code> of the job folder on the cluster before the job starts: the script reads
|
|
80
|
+
them from <code>$JR_INPUT_DIR</code> and writes its results to <code>$JR_OUTPUT_DIR</code>.
|
|
81
|
+
</Text>
|
|
82
|
+
{files.length > 0 && (
|
|
83
|
+
<VStack align="stretch" gap={1}>
|
|
84
|
+
{files.map(f => (
|
|
85
|
+
<HStack key={attachmentName(f)} justify="space-between" fontSize="sm">
|
|
86
|
+
<Text fontFamily="mono" fontSize="xs" color="var(--color-text)" truncate>input/{attachmentName(f)}</Text>
|
|
87
|
+
<HStack gap={2} flexShrink={0}>
|
|
88
|
+
<Text fontSize="xs" color="var(--color-text-muted)">{formatSize(f.size)}</Text>
|
|
89
|
+
<Button size="2xs" variant="ghost" aria-label={`Remove ${attachmentName(f)}`}
|
|
90
|
+
onClick={() => onChange(files.filter(x => x !== f))}>
|
|
91
|
+
<LuX />
|
|
92
|
+
</Button>
|
|
93
|
+
</HStack>
|
|
94
|
+
</HStack>
|
|
95
|
+
))}
|
|
96
|
+
<Text fontSize="xs" color="var(--color-text-muted)">{files.length} files, {formatSize(total)} in all</Text>
|
|
97
|
+
</VStack>
|
|
98
|
+
)}
|
|
99
|
+
</VStack>
|
|
100
|
+
</Card.Root>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
36
104
|
const CRON_PRESETS: { label: string; cron: string }[] = [
|
|
37
105
|
{ label: 'Daily at midnight', cron: '0 0 * * *' },
|
|
38
106
|
{ label: 'Weekly on Sunday at 2am', cron: '0 2 * * 0' },
|
|
@@ -111,6 +179,33 @@ interface ClusterOption {
|
|
|
111
179
|
ssh: string;
|
|
112
180
|
}
|
|
113
181
|
|
|
182
|
+
/** The last cluster / profile / template picked on the submit page, restored on the next visit */
|
|
183
|
+
const SUBMIT_SELECTION_KEY = 'bujang-submit-selection';
|
|
184
|
+
|
|
185
|
+
interface SavedSelection {
|
|
186
|
+
cluster?: string;
|
|
187
|
+
profile?: string;
|
|
188
|
+
template?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function loadSavedSelection(): SavedSelection {
|
|
192
|
+
try {
|
|
193
|
+
const raw = localStorage.getItem(SUBMIT_SELECTION_KEY);
|
|
194
|
+
const parsed = raw ? JSON.parse(raw) : null;
|
|
195
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
196
|
+
} catch {
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function saveSelection(selection: SavedSelection): void {
|
|
202
|
+
try {
|
|
203
|
+
localStorage.setItem(SUBMIT_SELECTION_KEY, JSON.stringify(selection));
|
|
204
|
+
} catch {
|
|
205
|
+
// storage unavailable (private window, blocked site data): the URL still keeps the selection
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
114
209
|
interface JobSubmissionFormProps {
|
|
115
210
|
templates?: string[];
|
|
116
211
|
profiles: SlurmProfile[];
|
|
@@ -135,12 +230,15 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
135
230
|
const queryClient = useQueryClient();
|
|
136
231
|
|
|
137
232
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
138
|
-
// read once: the URL is then written from the selection
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
233
|
+
// read once: the URL is then written from the selection.
|
|
234
|
+
// URL first, then the last selection saved in localStorage, then the defaults.
|
|
235
|
+
const [urlSelection] = useState(() => {
|
|
236
|
+
if (!syncUrl) return { cluster: null, profile: null, template: null };
|
|
237
|
+
const saved = loadSavedSelection();
|
|
238
|
+
const fromUrl = searchParams.has('cluster') || searchParams.has('profile') || searchParams.has('template');
|
|
239
|
+
const pick = (key: keyof SavedSelection) => (fromUrl ? searchParams.get(key) : saved[key] ?? null);
|
|
240
|
+
return { cluster: pick('cluster'), profile: pick('profile'), template: pick('template') };
|
|
241
|
+
});
|
|
144
242
|
|
|
145
243
|
// No form state needed - we'll build the data on-demand from refs
|
|
146
244
|
|
|
@@ -157,6 +255,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
157
255
|
// sbatch arguments without a form field (--gpus, --tmp, ...), space separated
|
|
158
256
|
const [extraArgs, setExtraArgs] = useState<string>('');
|
|
159
257
|
|
|
258
|
+
// Files sent with the job (input/ of the job folder)
|
|
259
|
+
const [attachments, setAttachments] = useState<File[]>([]);
|
|
260
|
+
|
|
160
261
|
// Schedule state
|
|
161
262
|
const [scheduleName, setScheduleName] = useState<string>('');
|
|
162
263
|
const [cronPreset, setCronPreset] = useState<string>(CRON_PRESETS[0].cron);
|
|
@@ -176,6 +277,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
176
277
|
});
|
|
177
278
|
queryClient.invalidateQueries({ queryKey: ['slurm-jobs'] });
|
|
178
279
|
queryClient.invalidateQueries({ queryKey: ['slurm-persisted-jobs'] });
|
|
280
|
+
setAttachments([]);
|
|
179
281
|
if (onClose) onClose();
|
|
180
282
|
},
|
|
181
283
|
onError: (error: ApiError) => {
|
|
@@ -470,13 +572,23 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
470
572
|
return result;
|
|
471
573
|
};
|
|
472
574
|
|
|
473
|
-
const handleSubmitJob = () => {
|
|
575
|
+
const handleSubmitJob = async () => {
|
|
576
|
+
let files;
|
|
577
|
+
try {
|
|
578
|
+
files = attachments.length
|
|
579
|
+
? await Promise.all(attachments.map(f => fileToAttachment(f, attachmentName(f))))
|
|
580
|
+
: undefined;
|
|
581
|
+
} catch (error) {
|
|
582
|
+
toaster.create({ title: 'Cannot read the attached files', description: String(error), type: 'error', duration: 5000 });
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
474
585
|
submitJobMutation.mutate({
|
|
475
586
|
script: editorRef.current?.getValue() || '',
|
|
476
587
|
job_name: jobNameRef.current?.value || 'bujang_job',
|
|
477
588
|
cluster: selectedCluster,
|
|
478
589
|
sbatch_args: _collectSbatchArgs(),
|
|
479
590
|
script_args: _collectScriptArgs(),
|
|
591
|
+
files,
|
|
480
592
|
});
|
|
481
593
|
};
|
|
482
594
|
|
|
@@ -575,8 +687,8 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
575
687
|
return;
|
|
576
688
|
}
|
|
577
689
|
|
|
578
|
-
// No initialData: apply the profile / template the URL
|
|
579
|
-
//
|
|
690
|
+
// No initialData: apply the profile / template the URL (or the saved selection) picks,
|
|
691
|
+
// once they are loaded. Neither: nothing is preselected.
|
|
580
692
|
const defaultProfile = urlSelection.profile ?? '';
|
|
581
693
|
const defaultTemplate = urlSelection.template ?? '';
|
|
582
694
|
|
|
@@ -591,7 +703,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
591
703
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- handleProfileSelect/handleTemplateSelect/selectedProfile/selectedTemplate intentionally excluded: this is a run-once (per initialData/profiles/templates arrival) effect guarded by ref flags; the handlers are recreated every render and adding them (or the state they set) as deps would just cause redundant re-invocations, not additional side effects, but wrapping them in useCallback risks changing their identity semantics elsewhere in this large form -- not worth the risk for a mount-time-only effect.
|
|
592
704
|
}, [initialData, profiles, templates]);
|
|
593
705
|
|
|
594
|
-
// Selection -> URL (replace: no history entry per click)
|
|
706
|
+
// Selection -> URL (replace: no history entry per click) and localStorage
|
|
595
707
|
useEffect(() => {
|
|
596
708
|
if (!syncUrl) return;
|
|
597
709
|
setSearchParams((prev) => {
|
|
@@ -602,6 +714,12 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
602
714
|
set('template', selectedTemplate);
|
|
603
715
|
return next;
|
|
604
716
|
}, { replace: true });
|
|
717
|
+
// don't save while a restored profile / template waits for its list to load: it is still
|
|
718
|
+
// empty, and saving it would wipe the saved selection if the page is left before that
|
|
719
|
+
const profilePending = !selectedProfile && !!urlSelection.profile && !defaultProfileApplied.current;
|
|
720
|
+
const templatePending = !selectedTemplate && !!urlSelection.template && !defaultTemplateApplied.current;
|
|
721
|
+
if (profilePending || templatePending) return;
|
|
722
|
+
saveSelection({ cluster: selectedCluster, profile: selectedProfile, template: selectedTemplate });
|
|
605
723
|
}, [syncUrl, selectedCluster, selectedProfile, selectedTemplate, setSearchParams]);
|
|
606
724
|
|
|
607
725
|
// Minimal state only for displaying script args section (not for values)
|
|
@@ -1157,6 +1275,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
|
|
|
1157
1275
|
|
|
1158
1276
|
</VStack>
|
|
1159
1277
|
</Card.Root>
|
|
1278
|
+
|
|
1279
|
+
{/* Files sent with the job */}
|
|
1280
|
+
<AttachmentsCard files={attachments} onChange={setAttachments} />
|
|
1160
1281
|
</VStack>
|
|
1161
1282
|
|
|
1162
1283
|
{/* Right Column - Script Editor */}
|
|
@@ -160,6 +160,34 @@ export function pipelineMermaid(root: PipelineNode, states: Record<string, strin
|
|
|
160
160
|
|
|
161
161
|
let mermaidCounter = 0;
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Run `fn` with the global AMD `define` hidden.
|
|
165
|
+
*
|
|
166
|
+
* @monaco-editor/react loads Monaco's AMD loader (vs/loader.js), which installs `window.define`.
|
|
167
|
+
* Mermaid bundles fastdom / fastdom-promised, whose UMD wrappers test `typeof define` before
|
|
168
|
+
* `module` and so call an anonymous `define(...)` when it exists. Monaco's loader then throws
|
|
169
|
+
* "Can only have one anonymous define call per script file". It happens only after an editor
|
|
170
|
+
* was opened. Hiding `define` makes them take the CommonJS branch the bundler wrapped them in.
|
|
171
|
+
* Mermaid loads its diagram chunks lazily during render, so render goes inside too.
|
|
172
|
+
*/
|
|
173
|
+
let amdHidden = 0;
|
|
174
|
+
let savedDefine: unknown;
|
|
175
|
+
async function withoutAmdDefine<T>(fn: () => Promise<T>): Promise<T> {
|
|
176
|
+
const w = window as unknown as { define?: unknown };
|
|
177
|
+
if (amdHidden++ === 0) {
|
|
178
|
+
savedDefine = w.define;
|
|
179
|
+
w.define = undefined;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
return await fn();
|
|
183
|
+
} finally {
|
|
184
|
+
if (--amdHidden === 0 && savedDefine !== undefined) {
|
|
185
|
+
w.define = savedDefine;
|
|
186
|
+
savedDefine = undefined;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
163
191
|
/** The pipeline graph, rendered by mermaid (loaded on first use) */
|
|
164
192
|
export const PipelineGraph: React.FC<{ definition: PipelineNode; states?: Record<string, string> }> = ({ definition, states }) => {
|
|
165
193
|
const { colorMode } = useColorMode();
|
|
@@ -173,9 +201,11 @@ export const PipelineGraph: React.FC<{ definition: PipelineNode; states?: Record
|
|
|
173
201
|
let cancelled = false;
|
|
174
202
|
(async () => {
|
|
175
203
|
try {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
204
|
+
const { svg: out } = await withoutAmdDefine(async () => {
|
|
205
|
+
const mermaid = (await import('mermaid')).default;
|
|
206
|
+
mermaid.initialize({ startOnLoad: false, theme: dark ? 'dark' : 'default', securityLevel: 'strict', flowchart: { htmlLabels: true } });
|
|
207
|
+
return mermaid.render(`bujang-pipeline-${baseId}-${mermaidCounter++}`, source);
|
|
208
|
+
});
|
|
179
209
|
if (!cancelled) { setSvg(out); setError(null); }
|
|
180
210
|
} catch (e) {
|
|
181
211
|
if (!cancelled) setError((e as Error).message || String(e));
|
|
@@ -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>
|