@milabench/bujang 0.1.12 → 0.1.14

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.
@@ -16,13 +16,15 @@ import {
16
16
  Spinner,
17
17
  Icon,
18
18
  } from '@chakra-ui/react';
19
- import { LuCheck, LuX, LuLock, LuCalendar, LuPaperclip } from 'react-icons/lu';
19
+ import { LuCheck, LuX, LuLock, LuCalendar, LuPaperclip, LuChevronDown, LuChevronUp, LuBookOpen, LuWorkflow } 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';
23
23
  import AutocompleteInput from '../components/AutocompleteInput';
24
+ import SweepDialog from './SweepDialog';
25
+ import ScheduleDialog from './ScheduleDialog';
24
26
  import { useSshConnectGate } from '../components/SshConnectDialog';
25
- import { useMutation, useQueryClient } from '@tanstack/react-query';
27
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
26
28
  import { useSearchParams } from 'react-router-dom';
27
29
  import {
28
30
  submitSlurmJob,
@@ -32,8 +34,9 @@ import {
32
34
  testSlurmSecret,
33
35
  createScheduledJob,
34
36
  fileToAttachment,
37
+ getJobEnvironment,
35
38
  } from '../api';
36
- import type { SlurmProfile, SlurmJob, ApiError, ScheduledJob } from '../types';
39
+ import type { SlurmProfile, SlurmJob, ApiError, ScheduledJob, JobEnvironment } from '../types';
37
40
 
38
41
  const formatSize = (n: number) =>
39
42
  n < 1024 ? `${n} B` : n < 1024 ** 2 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1024 ** 2).toFixed(1)} MB`;
@@ -41,74 +44,134 @@ const formatSize = (n: number) =>
41
44
  /** Name of an attached file in input/: its path inside a picked folder, else its name */
42
45
  const attachmentName = (file: File) => (file as File & { webkitRelativePath?: string }).webkitRelativePath || file.name;
43
46
 
47
+ const ENV_VIEW_KEY = 'bujang-submit-env-view';
48
+
44
49
  /**
45
- * Files sent with the job: copied to <job folder>/input/ on the cluster before the job starts,
46
- * the script finds them in $JR_INPUT_DIR.
50
+ * What the job finds in its environment: the BUJANG_* variables resolved for the cluster and the job's
51
+ * label (or job name), as a table, or the job folder as a tree.
47
52
  */
48
- const AttachmentsCard: React.FC<{ files: File[]; onChange: (files: File[]) => void }> = ({ files, onChange }) => {
49
- const fileInput = useRef<HTMLInputElement>(null);
50
- const folderInput = useRef<HTMLInputElement>(null);
51
- const add = (list: FileList | null) => {
52
- if (!list) return;
53
- const byName = new Map(files.map(f => [attachmentName(f), f]));
54
- Array.from(list).forEach(f => byName.set(attachmentName(f), f));
55
- onChange(Array.from(byName.values()));
53
+ const EnvironmentCard: React.FC<{ cluster: string; name: string }> = ({ cluster, name }) => {
54
+ const [view, setView] = useState<'table' | 'tree'>(() => {
55
+ try { return localStorage.getItem(ENV_VIEW_KEY) === 'tree' ? 'tree' : 'table'; } catch { return 'table'; }
56
+ });
57
+ const choose = (v: 'table' | 'tree') => {
58
+ try { localStorage.setItem(ENV_VIEW_KEY, v); } catch { /* this page only */ }
59
+ setView(v);
56
60
  };
57
- const total = files.reduce((n, f) => n + f.size, 0);
61
+ const { data, error } = useQuery<JobEnvironment, ApiError>({
62
+ queryKey: ['bujang-job-environment', cluster, name],
63
+ queryFn: () => getJobEnvironment(cluster, name),
64
+ enabled: !!cluster,
65
+ staleTime: 60_000,
66
+ placeholderData: (previous) => previous,
67
+ retry: false,
68
+ });
69
+ const known = { submission: 'at submission', run: 'when the job runs', pipeline: 'pipeline steps' } as const;
58
70
  return (
59
71
  <Card.Root bg="var(--color-bg-card)" borderWidth="1px" borderColor="var(--color-border)" borderRadius="lg" boxShadow="sm" p={4}>
60
72
  <VStack align="stretch" gap={3}>
61
- <HStack justify="space-between" wrap="wrap" gap={2}>
62
- <Heading size="sm" fontWeight="semibold" color="var(--color-text)">
63
- <HStack gap={2}><LuPaperclip /> Attached files</HStack>
64
- </Heading>
73
+ <HStack justify="space-between" align="center">
65
74
  <HStack gap={2}>
66
- <Button size="xs" variant="outline" onClick={() => fileInput.current?.click()}>Add files</Button>
67
- <Button size="xs" variant="outline" onClick={() => folderInput.current?.click()}>Add a folder</Button>
75
+ <Icon color="var(--color-text-muted)"><LuBookOpen /></Icon>
76
+ <Heading size="sm" fontWeight="semibold" color="var(--color-text)">Job environment</Heading>
77
+ </HStack>
78
+ <HStack gap={0} borderWidth="1px" borderColor="var(--color-border)" borderRadius="md" overflow="hidden">
79
+ {(['table', 'tree'] as const).map(v => (
80
+ <Button key={v} size="xs" variant={view === v ? 'solid' : 'ghost'} borderRadius={0}
81
+ bg={view === v ? 'var(--color-primary)' : undefined}
82
+ color={view === v ? 'var(--color-primary-text)' : 'var(--color-text-muted)'}
83
+ onClick={() => choose(v)} aria-pressed={view === v}>
84
+ {v === 'table' ? 'Variables' : 'Folder'}
85
+ </Button>
86
+ ))}
68
87
  </HStack>
69
88
  </HStack>
70
- <input ref={fileInput} type="file" multiple hidden onChange={(e) => { add(e.target.files); e.target.value = ''; }} />
71
- <input
72
- ref={folderInput}
73
- type="file"
74
- multiple
75
- hidden
76
- {...({ webkitdirectory: '', directory: '' } as Record<string, string>)}
77
- onChange={(e) => { add(e.target.files); e.target.value = ''; }}
78
- />
79
89
  <Text fontSize="xs" color="var(--color-text-muted)">
80
- Copied to <code>input/</code> of the job folder on the cluster before the job starts: the script reads
81
- them from <code>$JR_INPUT_DIR</code> and writes its results to <code>$JR_OUTPUT_DIR</code>.
90
+ Set by bujang in the <code># {'{START}'}</code> block. Values for a job of <b>{cluster}</b>
91
+ {data ? <> named <code>{data.job_id}</code> (its last 8 characters are drawn at submission)</> : null}.
82
92
  </Text>
83
- {files.length > 0 && (
84
- <VStack align="stretch" gap={1}>
85
- {files.map(f => (
86
- <HStack key={attachmentName(f)} justify="space-between" fontSize="sm">
87
- <Text fontFamily="mono" fontSize="xs" color="var(--color-text)" truncate>input/{attachmentName(f)}</Text>
88
- <HStack gap={2} flexShrink={0}>
89
- <Text fontSize="xs" color="var(--color-text-muted)">{formatSize(f.size)}</Text>
90
- <Button size="2xs" variant="ghost" aria-label={`Remove ${attachmentName(f)}`}
91
- onClick={() => onChange(files.filter(x => x !== f))}>
92
- <LuX />
93
- </Button>
94
- </HStack>
95
- </HStack>
96
- ))}
97
- <Text fontSize="xs" color="var(--color-text-muted)">{files.length} files, {formatSize(total)} in all</Text>
98
- </VStack>
93
+ {error ? <Text fontSize="sm" color="var(--color-status-failed)">{error.message}</Text> : !data ? <Spinner size="sm" /> : view === 'table' ? (
94
+ <Box as="table" width="100%" fontSize="xs" css={{ '& td': { padding: '4px 8px 4px 0', verticalAlign: 'top' } }}>
95
+ <tbody>
96
+ {data.variables.map(v => (
97
+ <tr key={v.name} title={v.description}>
98
+ <td><Text as="span" fontFamily="mono" fontWeight="semibold" color="var(--color-text)">${v.name}</Text></td>
99
+ <td>
100
+ <Text fontFamily="mono" color="var(--color-text)" wordBreak="break-all">{v.value ?? '—'}</Text>
101
+ <Text color="var(--color-text-muted)">{v.description} · {known[v.known]}</Text>
102
+ </td>
103
+ </tr>
104
+ ))}
105
+ </tbody>
106
+ </Box>
107
+ ) : (
108
+ <Box as="pre" fontFamily="mono" fontSize="xs" p={3} borderRadius="md" bg="var(--color-bg-stripe)" color="var(--color-text)" overflowX="auto" m={0}>
109
+ {data.tree.join('\n')}
110
+ </Box>
99
111
  )}
100
112
  </VStack>
101
113
  </Card.Root>
102
114
  );
103
115
  };
104
116
 
105
- const CRON_PRESETS: { label: string; cron: string }[] = [
106
- { label: 'Daily at midnight', cron: '0 0 * * *' },
107
- { label: 'Weekly on Sunday at 2am', cron: '0 2 * * 0' },
108
- { label: 'Monthly on the 1st', cron: '0 0 1 * *' },
109
- { label: 'Weekdays at midnight', cron: '0 0 * * 1-5' },
110
- { label: 'Custom', cron: '' },
111
- ];
117
+ /**
118
+ * Files sent with the job: copied to <job folder>/input/ on the cluster before the job starts,
119
+ * the script finds them in $BUJANG_INPUT_DIR. A section of the Script Arguments card.
120
+ */
121
+ const AttachmentsSection: React.FC<{ files: File[]; onChange: (files: File[]) => void }> = ({ files, onChange }) => {
122
+ const fileInput = useRef<HTMLInputElement>(null);
123
+ const folderInput = useRef<HTMLInputElement>(null);
124
+ const add = (list: FileList | null) => {
125
+ if (!list) return;
126
+ const byName = new Map(files.map(f => [attachmentName(f), f]));
127
+ Array.from(list).forEach(f => byName.set(attachmentName(f), f));
128
+ onChange(Array.from(byName.values()));
129
+ };
130
+ const total = files.reduce((n, f) => n + f.size, 0);
131
+ return (
132
+ <VStack align="stretch" gap={3} borderTop="1px solid" borderColor="var(--color-border)" pt={4}>
133
+ <HStack justify="space-between" wrap="wrap" gap={2}>
134
+ <Heading size="sm" fontWeight="semibold" color="var(--color-text)">
135
+ <HStack gap={2}><LuPaperclip /> Attached files</HStack>
136
+ </Heading>
137
+ <HStack gap={2}>
138
+ <Button size="xs" variant="outline" onClick={() => fileInput.current?.click()}>Add files</Button>
139
+ <Button size="xs" variant="outline" onClick={() => folderInput.current?.click()}>Add a folder</Button>
140
+ </HStack>
141
+ </HStack>
142
+ <input ref={fileInput} type="file" multiple hidden onChange={(e) => { add(e.target.files); e.target.value = ''; }} />
143
+ <input
144
+ ref={folderInput}
145
+ type="file"
146
+ multiple
147
+ hidden
148
+ {...({ webkitdirectory: '', directory: '' } as Record<string, string>)}
149
+ onChange={(e) => { add(e.target.files); e.target.value = ''; }}
150
+ />
151
+ <Text fontSize="xs" color="var(--color-text-muted)">
152
+ Copied to <code>input/</code> of the job folder on the cluster before the job starts: the script reads
153
+ them from <code>$BUJANG_INPUT_DIR</code> and writes its results to <code>$BUJANG_OUTPUT_DIR</code>.
154
+ </Text>
155
+ {files.length > 0 && (
156
+ <VStack align="stretch" gap={1}>
157
+ {files.map(f => (
158
+ <HStack key={attachmentName(f)} justify="space-between" fontSize="sm">
159
+ <Text fontFamily="mono" fontSize="xs" color="var(--color-text)" truncate>input/{attachmentName(f)}</Text>
160
+ <HStack gap={2} flexShrink={0}>
161
+ <Text fontSize="xs" color="var(--color-text-muted)">{formatSize(f.size)}</Text>
162
+ <Button size="2xs" variant="ghost" aria-label={`Remove ${attachmentName(f)}`}
163
+ onClick={() => onChange(files.filter(x => x !== f))}>
164
+ <LuX />
165
+ </Button>
166
+ </HStack>
167
+ </HStack>
168
+ ))}
169
+ <Text fontSize="xs" color="var(--color-text-muted)">{files.length} files, {formatSize(total)} in all</Text>
170
+ </VStack>
171
+ )}
172
+ </VStack>
173
+ );
174
+ };
112
175
 
113
176
  // Utility function to parse export variables from script content
114
177
  // if only_constant=true then ignores exported variables that are derived
@@ -199,6 +262,8 @@ function loadSavedSelection(): SavedSelection {
199
262
  }
200
263
  }
201
264
 
265
+ const SLURM_OPEN_KEY = 'bujang-submit-slurm-open';
266
+
202
267
  function saveSelection(selection: SavedSelection): void {
203
268
  try {
204
269
  localStorage.setItem(SUBMIT_SELECTION_KEY, JSON.stringify(selection));
@@ -253,18 +318,26 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
253
318
  const [cpusPerTask, setCpusPerTask] = useState<string>('');
254
319
  const [ntasksPerNode, setNtasksPerNode] = useState<string>('');
255
320
  const [exclusive, setExclusive] = useState<boolean>(false);
321
+ // the job name as last left (the job environment card names its example job after it)
322
+ const [jobNameValue, setJobNameValue] = useState<string>(initialData?.job_name || 'bujang_job');
323
+ // the Slurm card: open (arguments and dependency shown) or only the cluster and the profile
324
+ const [slurmOpen, setSlurmOpen] = useState<boolean>(() => {
325
+ try { return localStorage.getItem(SLURM_OPEN_KEY) !== '0'; } catch { return true; }
326
+ });
327
+ const toggleSlurmOpen = (on: boolean) => {
328
+ try { localStorage.setItem(SLURM_OPEN_KEY, on ? '1' : '0'); } catch { /* this page only */ }
329
+ setSlurmOpen(on);
330
+ };
256
331
  // sbatch arguments without a form field (--gpus, --tmp, ...), space separated
257
332
  const [extraArgs, setExtraArgs] = useState<string>('');
258
333
 
259
334
  // Files sent with the job (input/ of the job folder)
260
335
  const [attachments, setAttachments] = useState<File[]>([]);
336
+ // Sweep dialog: the arguments of the form when it was opened (null: closed)
337
+ const [sweepArgs, setSweepArgs] = useState<Record<string, string> | null>(null);
261
338
 
262
- // Schedule state
263
- const [scheduleName, setScheduleName] = useState<string>('');
264
- const [cronPreset, setCronPreset] = useState<string>(CRON_PRESETS[0].cron);
265
- const [cronCustom, setCronCustom] = useState<string>(CRON_PRESETS[0].cron);
266
- const isCustomCron = cronPreset === '';
267
- const effectiveCron = isCustomCron ? cronCustom : cronPreset;
339
+ // Schedule dialog (name and cron expression)
340
+ const [scheduleOpen, setScheduleOpen] = useState(false);
268
341
 
269
342
  // Mutations
270
343
  const sshGate = useSshConnectGate();
@@ -365,6 +438,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
365
438
  duration: 5000,
366
439
  });
367
440
  queryClient.invalidateQueries({ queryKey: ['scheduled-jobs'] });
441
+ setScheduleOpen(false);
368
442
  },
369
443
  onError: (error: ApiError) => {
370
444
  toaster.create({
@@ -587,6 +661,8 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
587
661
  const request = {
588
662
  script: editorRef.current?.getValue() || '',
589
663
  job_name: jobNameRef.current?.value || 'bujang_job',
664
+ // the template the script came from: the Overview layout saved for it applies to the job
665
+ template: selectedTemplate.trim() || undefined,
590
666
  cluster: selectedCluster,
591
667
  sbatch_args: _collectSbatchArgs(),
592
668
  script_args: _collectScriptArgs(),
@@ -596,16 +672,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
596
672
  await sshGate.ensure(selectedCluster, () => submitJobMutation.mutate(request));
597
673
  };
598
674
 
599
- const handleSaveScheduled = () => {
600
- const name = scheduleName.trim();
601
- if (!name) {
602
- toaster.create({ title: 'Schedule name required', type: 'warning', duration: 3000 });
603
- return;
604
- }
605
- if (!effectiveCron.trim()) {
606
- toaster.create({ title: 'Cron expression required', type: 'warning', duration: 3000 });
607
- return;
608
- }
675
+ const handleSaveScheduled = (name: string, cron: string) => {
609
676
  const script = editorRef.current?.getValue() || '';
610
677
  if (!script.trim()) {
611
678
  toaster.create({ title: 'Script content required', type: 'warning', duration: 3000 });
@@ -614,7 +681,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
614
681
  const templateName = selectedTemplate.trim();
615
682
  saveScheduledMutation.mutate({
616
683
  name,
617
- cron_expression: effectiveCron,
684
+ cron_expression: cron,
618
685
  cluster: selectedCluster,
619
686
  script,
620
687
  sbatch_args: _collectSbatchArgs(),
@@ -846,46 +913,25 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
846
913
  </Heading>
847
914
 
848
915
  <HStack gap={2} flex={1} justify="flex-end" minW={0} flexWrap="wrap">
849
- <Input
850
- value={scheduleName}
851
- onChange={(e) => setScheduleName(e.target.value)}
852
- placeholder="Schedule name"
853
- size="sm"
854
- w="150px"
855
- flexShrink={1}
856
- />
857
- <NativeSelect.Root size="sm" w="170px" flexShrink={1}>
858
- <NativeSelect.Field
859
- value={cronPreset}
860
- onChange={(e) => {
861
- setCronPreset(e.target.value);
862
- if (e.target.value !== '') setCronCustom(e.target.value);
863
- }}
864
- >
865
- {CRON_PRESETS.map(p => (
866
- <option key={p.cron || '__custom'} value={p.cron}>{p.label}</option>
867
- ))}
868
- </NativeSelect.Field>
869
- </NativeSelect.Root>
870
- <Input
871
- value={isCustomCron ? cronCustom : cronPreset}
872
- onChange={(e) => { setCronCustom(e.target.value); setCronPreset(''); }}
873
- fontFamily="mono"
874
- placeholder="* * * * *"
875
- size="sm"
876
- w="120px"
877
- flexShrink={1}
878
- />
879
916
  <Button
880
917
  variant="outline"
881
- onClick={handleSaveScheduled}
882
- loading={saveScheduledMutation.isPending}
918
+ onClick={() => setScheduleOpen(true)}
883
919
  fontWeight="medium"
884
920
  size="sm"
885
921
  flexShrink={0}
886
922
  >
887
923
  <LuCalendar /> Schedule
888
924
  </Button>
925
+ <Button
926
+ variant="outline"
927
+ onClick={() => setSweepArgs(_collectScriptArgs())}
928
+ fontWeight="medium"
929
+ size="sm"
930
+ flexShrink={0}
931
+ title="Make a pipeline out of this job: one job per combination of argument values"
932
+ >
933
+ <LuWorkflow /> Sweep
934
+ </Button>
889
935
  <Button
890
936
  onClick={handleSubmitJob}
891
937
  loading={submitJobMutation.isPending}
@@ -904,7 +950,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
904
950
  <Grid templateColumns="repeat(2, 1fr)" gap={6} width="100%" flex="1" overflow="hidden">
905
951
  {/* Left Column - Slurm Options */}
906
952
  <VStack align="stretch" gap={4} overflowY="auto" pr={2}>
907
- {/* Profile Section */}
953
+ {/* Slurm: profile (always shown), then arguments and dependency (collapsible) */}
908
954
  <Card.Root
909
955
  bg="var(--color-bg-card)"
910
956
  borderWidth="1px"
@@ -914,9 +960,22 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
914
960
  p={4}
915
961
  >
916
962
  <VStack align="stretch" gap={3}>
917
- <Heading size="sm" fontWeight="semibold" color="var(--color-text)">
918
- Slurm Profile
919
- </Heading>
963
+ <HStack justify="space-between" align="center">
964
+ <Heading size="sm" fontWeight="semibold" color="var(--color-text)">
965
+ Slurm
966
+ </Heading>
967
+ <Button
968
+ variant="ghost"
969
+ size="xs"
970
+ onClick={() => toggleSlurmOpen(!slurmOpen)}
971
+ aria-expanded={slurmOpen}
972
+ color="var(--color-text-muted)"
973
+ title={slurmOpen ? 'Show only the cluster and the profile' : 'Show the Slurm arguments and the dependency'}
974
+ >
975
+ {slurmOpen ? <LuChevronUp /> : <LuChevronDown />}
976
+ {slurmOpen ? 'Less' : 'Arguments'}
977
+ </Button>
978
+ </HStack>
920
979
  <HStack gap={4} align="center">
921
980
  <HStack gap={2} align="center" flex={3} minW={0}>
922
981
  <Text fontSize="sm" fontWeight="medium" color="var(--color-text)" whiteSpace="nowrap">Cluster:</Text>
@@ -972,236 +1031,213 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
972
1031
  </Button>
973
1032
  </HStack>
974
1033
  </HStack>
975
- </VStack>
976
- </Card.Root>
977
-
978
- {/* Slurm Arguments Section */}
979
- <Card.Root
980
- bg="var(--color-bg-card)"
981
- borderWidth="1px"
982
- borderColor="var(--color-border)"
983
- borderRadius="lg"
984
- boxShadow="sm"
985
- p={4}
986
- >
987
- <VStack align="stretch" gap={4}>
988
- <Heading size="sm" fontWeight="semibold" color="var(--color-text)">
989
- Slurm Arguments
990
- </Heading>
991
-
992
- <Field.Root>
993
- <HStack gap={3} align="center">
994
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Job Name</Field.Label>
995
- <Input
996
- ref={jobNameRef}
997
- defaultValue={initialData?.job_name || "bujang_job"}
998
- placeholder="bujang_job"
999
- flex={1}
1000
- />
1001
- </HStack>
1002
- </Field.Root>
1034
+ {/* hidden, not unmounted: the fields keep what was typed */}
1035
+ <VStack align="stretch" gap={4} display={slurmOpen ? 'flex' : 'none'} pt={3} borderTopWidth="1px" borderColor="var(--color-border)">
1036
+ <Text fontSize="xs" fontWeight="semibold" textTransform="uppercase" letterSpacing="wider" color="var(--color-text-muted)">Arguments</Text>
1003
1037
 
1004
- <Grid templateColumns="repeat(2, 1fr)" gap={4}>
1005
1038
  <Field.Root>
1006
1039
  <HStack gap={3} align="center">
1007
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Partition</Field.Label>
1040
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Job Name</Field.Label>
1008
1041
  <Input
1009
- ref={partitionRef}
1010
- defaultValue=""
1011
- placeholder="Leave empty for default"
1042
+ ref={jobNameRef}
1043
+ defaultValue={initialData?.job_name || "bujang_job"}
1044
+ onBlur={(e) => setJobNameValue(e.target.value)}
1045
+ placeholder="bujang_job"
1012
1046
  flex={1}
1013
1047
  />
1014
1048
  </HStack>
1015
1049
  </Field.Root>
1016
1050
 
1051
+ <Grid templateColumns="repeat(2, 1fr)" gap={4}>
1052
+ <Field.Root>
1053
+ <HStack gap={3} align="center">
1054
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Partition</Field.Label>
1055
+ <Input
1056
+ ref={partitionRef}
1057
+ defaultValue=""
1058
+ placeholder="Leave empty for default"
1059
+ flex={1}
1060
+ />
1061
+ </HStack>
1062
+ </Field.Root>
1063
+
1064
+ <Field.Root>
1065
+ <HStack gap={3} align="center">
1066
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Nodes</Field.Label>
1067
+ <NumberInput.Root
1068
+ value={nodes}
1069
+ onValueChange={(details) => setNodes(details.value)}
1070
+ min={1}
1071
+ max={100}
1072
+ flex={1}
1073
+ >
1074
+ <NumberInput.Input />
1075
+ </NumberInput.Root>
1076
+ </HStack>
1077
+ </Field.Root>
1078
+
1079
+ <Field.Root>
1080
+ <HStack gap={3} align="center">
1081
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Tasks</Field.Label>
1082
+ <NumberInput.Root
1083
+ value={ntasks}
1084
+ onValueChange={(details) => setNtasks(details.value)}
1085
+ min={1}
1086
+ max={100}
1087
+ flex={1}
1088
+ >
1089
+ <NumberInput.Input />
1090
+ </NumberInput.Root>
1091
+ </HStack>
1092
+ </Field.Root>
1093
+
1094
+ <Field.Root>
1095
+ <HStack gap={3} align="center">
1096
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">CPUs per Task</Field.Label>
1097
+ <NumberInput.Root
1098
+ value={cpusPerTask}
1099
+ onValueChange={(details) => setCpusPerTask(details.value)}
1100
+ min={1}
1101
+ max={1024}
1102
+ flex={1}
1103
+ >
1104
+ <NumberInput.Input />
1105
+ </NumberInput.Root>
1106
+ </HStack>
1107
+ </Field.Root>
1108
+
1109
+ <Field.Root>
1110
+ <HStack gap={3} align="center">
1111
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">GPUs per Task</Field.Label>
1112
+ <Input
1113
+ ref={gpusPerTaskRef}
1114
+ placeholder="e.g. 1, 2"
1115
+ flex={1}
1116
+ />
1117
+ </HStack>
1118
+ </Field.Root>
1119
+
1120
+ <Field.Root>
1121
+ <HStack gap={3} align="center">
1122
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Tasks per Node</Field.Label>
1123
+ <NumberInput.Root
1124
+ value={ntasksPerNode}
1125
+ onValueChange={(details) => setNtasksPerNode(details.value)}
1126
+ min={1}
1127
+ max={100}
1128
+ flex={1}
1129
+ >
1130
+ <NumberInput.Input />
1131
+ </NumberInput.Root>
1132
+ </HStack>
1133
+ </Field.Root>
1134
+
1135
+ <Field.Root>
1136
+ <HStack gap={3} align="center">
1137
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Memory</Field.Label>
1138
+ <Input
1139
+ ref={memRef}
1140
+ placeholder="e.g. 8G, 16GB"
1141
+ flex={1}
1142
+ />
1143
+ </HStack>
1144
+ </Field.Root>
1145
+
1146
+ <Field.Root>
1147
+ <HStack gap={3} align="center">
1148
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Time Limit</Field.Label>
1149
+ <Input
1150
+ ref={timeLimitRef}
1151
+ placeholder="e.g. 02:00:00, 1-12:00:00"
1152
+ flex={1}
1153
+ />
1154
+ </HStack>
1155
+ </Field.Root>
1156
+
1157
+ <Field.Root>
1158
+ <HStack gap={3} align="center">
1159
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Export</Field.Label>
1160
+ <Input
1161
+ ref={exportVarsRef}
1162
+ placeholder="e.g. ALL, NONE, VAR1,VAR2"
1163
+ flex={1}
1164
+ />
1165
+ </HStack>
1166
+ </Field.Root>
1167
+
1168
+ <Field.Root>
1169
+ <HStack gap={3} align="center">
1170
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Node List</Field.Label>
1171
+ <Input
1172
+ ref={nodelistRef}
1173
+ defaultValue=""
1174
+ placeholder="e.g., cn-d[003-004]"
1175
+ flex={1}
1176
+ />
1177
+ </HStack>
1178
+ </Field.Root>
1179
+
1180
+ <Field.Root gridColumn="1 / -1">
1181
+ <HStack gap={3} align="center">
1182
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Other Args</Field.Label>
1183
+ <Input
1184
+ value={extraArgs}
1185
+ onChange={(e) => setExtraArgs(e.target.value)}
1186
+ placeholder="e.g., --gpus=h100:4 --tmp=1000G"
1187
+ flex={1}
1188
+ />
1189
+ </HStack>
1190
+ </Field.Root>
1191
+ </Grid>
1192
+ <Text fontSize="xs" fontWeight="semibold" textTransform="uppercase" letterSpacing="wider" color="var(--color-text-muted)">Options and dependency</Text>
1017
1193
  <Field.Root>
1018
1194
  <HStack gap={3} align="center">
1019
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Nodes</Field.Label>
1020
- <NumberInput.Root
1021
- value={nodes}
1022
- onValueChange={(details) => setNodes(details.value)}
1023
- min={1}
1024
- max={100}
1025
- flex={1}
1026
- >
1027
- <NumberInput.Input />
1028
- </NumberInput.Root>
1029
- </HStack>
1030
- </Field.Root>
1031
-
1032
- <Field.Root>
1033
- <HStack gap={3} align="center">
1034
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Tasks</Field.Label>
1035
- <NumberInput.Root
1036
- value={ntasks}
1037
- onValueChange={(details) => setNtasks(details.value)}
1038
- min={1}
1039
- max={100}
1040
- flex={1}
1041
- >
1042
- <NumberInput.Input />
1043
- </NumberInput.Root>
1044
- </HStack>
1045
- </Field.Root>
1046
-
1047
- <Field.Root>
1048
- <HStack gap={3} align="center">
1049
- <Field.Label minW="120px" mb={0} color="var(--color-text)">CPUs per Task</Field.Label>
1050
- <NumberInput.Root
1051
- value={cpusPerTask}
1052
- onValueChange={(details) => setCpusPerTask(details.value)}
1053
- min={1}
1054
- max={1024}
1055
- flex={1}
1056
- >
1057
- <NumberInput.Input />
1058
- </NumberInput.Root>
1059
- </HStack>
1060
- </Field.Root>
1061
-
1062
- <Field.Root>
1063
- <HStack gap={3} align="center">
1064
- <Field.Label minW="120px" mb={0} color="var(--color-text)">GPUs per Task</Field.Label>
1065
- <Input
1066
- ref={gpusPerTaskRef}
1067
- placeholder="e.g. 1, 2"
1068
- flex={1}
1069
- />
1070
- </HStack>
1071
- </Field.Root>
1072
-
1073
- <Field.Root>
1074
- <HStack gap={3} align="center">
1075
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Tasks per Node</Field.Label>
1076
- <NumberInput.Root
1077
- value={ntasksPerNode}
1078
- onValueChange={(details) => setNtasksPerNode(details.value)}
1079
- min={1}
1080
- max={100}
1081
- flex={1}
1082
- >
1083
- <NumberInput.Input />
1084
- </NumberInput.Root>
1085
- </HStack>
1086
- </Field.Root>
1087
-
1088
- <Field.Root>
1089
- <HStack gap={3} align="center">
1090
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Memory</Field.Label>
1091
- <Input
1092
- ref={memRef}
1093
- placeholder="e.g. 8G, 16GB"
1094
- flex={1}
1095
- />
1096
- </HStack>
1097
- </Field.Root>
1098
-
1099
- <Field.Root>
1100
- <HStack gap={3} align="center">
1101
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Time Limit</Field.Label>
1102
- <Input
1103
- ref={timeLimitRef}
1104
- placeholder="e.g. 02:00:00, 1-12:00:00"
1105
- flex={1}
1106
- />
1107
- </HStack>
1108
- </Field.Root>
1109
-
1110
- <Field.Root>
1111
- <HStack gap={3} align="center">
1112
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Export</Field.Label>
1113
- <Input
1114
- ref={exportVarsRef}
1115
- placeholder="e.g. ALL, NONE, VAR1,VAR2"
1116
- flex={1}
1117
- />
1195
+ <Field.Label minW="120px" mb={0} color="var(--color-text)">Exclusive</Field.Label>
1196
+ <Checkbox.Root checked={exclusive} onCheckedChange={(e) => setExclusive(!!e.checked)}>
1197
+ <Checkbox.HiddenInput />
1198
+ <Checkbox.Control />
1199
+ <Checkbox.Label color="var(--color-text)">Request exclusive access to nodes</Checkbox.Label>
1200
+ </Checkbox.Root>
1118
1201
  </HStack>
1119
1202
  </Field.Root>
1120
1203
 
1121
1204
  <Field.Root>
1122
1205
  <HStack gap={3} align="center">
1123
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Node List</Field.Label>
1124
- <Input
1125
- ref={nodelistRef}
1126
- defaultValue=""
1127
- placeholder="e.g., cn-d[003-004]"
1128
- flex={1}
1129
- />
1130
- </HStack>
1131
- </Field.Root>
1132
-
1133
- <Field.Root gridColumn="1 / -1">
1134
- <HStack gap={3} align="center">
1135
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Other Args</Field.Label>
1136
- <Input
1137
- value={extraArgs}
1138
- onChange={(e) => setExtraArgs(e.target.value)}
1139
- placeholder="e.g., --gpus=h100:4 --tmp=1000G"
1140
- flex={1}
1141
- />
1206
+ <Field.Label minW="120px" fontWeight="semibold" mb={0} color="var(--color-text)">Dependency</Field.Label>
1207
+ <NativeSelect.Root flex={1}>
1208
+ <NativeSelect.Field ref={dependencyEventRef}
1209
+ defaultValue=""
1210
+ placeholder="Select event"
1211
+ >
1212
+ <option value="after">After</option>
1213
+ <option value="afterok">After Ok</option>
1214
+ <option value="afterany">After Any</option>
1215
+ <option value="afterburstbuffer">After Burst Buffer</option>
1216
+ <option value="aftercorr">After Corr</option>
1217
+ <option value="afternotok">After Not Ok</option>
1218
+ <option value="singleton">Singleton</option>
1219
+ </NativeSelect.Field>
1220
+ </NativeSelect.Root>
1221
+ <NativeSelect.Root flex={1}>
1222
+ <NativeSelect.Field
1223
+ ref={dependencyJobRef}
1224
+ defaultValue=""
1225
+ placeholder="Select job"
1226
+ >
1227
+ {dependencyJobs.map((job) => (
1228
+ <option key={job.job_id} value={job.job_id || ''}>
1229
+ {job.job_id} - {job.name || job.job_name || 'Unnamed'} ({job.job_state?.[0] || 'Unknown'})
1230
+ </option>
1231
+ ))}
1232
+ </NativeSelect.Field>
1233
+ </NativeSelect.Root>
1142
1234
  </HStack>
1143
1235
  </Field.Root>
1144
- </Grid>
1145
- </VStack>
1146
- </Card.Root>
1147
-
1148
- {/* Exclusive and Dependency Section */}
1149
- <Card.Root
1150
- bg="var(--color-bg-card)"
1151
- borderWidth="1px"
1152
- borderColor="var(--color-border)"
1153
- borderRadius="lg"
1154
- boxShadow="sm"
1155
- p={4}
1156
- >
1157
- <VStack align="stretch" gap={4}>
1158
- <Field.Root>
1159
- <HStack gap={3} align="center">
1160
- <Field.Label minW="120px" mb={0} color="var(--color-text)">Exclusive</Field.Label>
1161
- <Checkbox.Root checked={exclusive} onCheckedChange={(e) => setExclusive(!!e.checked)}>
1162
- <Checkbox.HiddenInput />
1163
- <Checkbox.Control />
1164
- <Checkbox.Label color="var(--color-text)">Request exclusive access to nodes</Checkbox.Label>
1165
- </Checkbox.Root>
1166
- </HStack>
1167
- </Field.Root>
1168
-
1169
- <Field.Root>
1170
- <HStack gap={3} align="center">
1171
- <Field.Label minW="120px" fontWeight="semibold" mb={0} color="var(--color-text)">Dependency</Field.Label>
1172
- <NativeSelect.Root flex={1}>
1173
- <NativeSelect.Field ref={dependencyEventRef}
1174
- defaultValue=""
1175
- placeholder="Select event"
1176
- >
1177
- <option value="after">After</option>
1178
- <option value="afterok">After Ok</option>
1179
- <option value="afterany">After Any</option>
1180
- <option value="afterburstbuffer">After Burst Buffer</option>
1181
- <option value="aftercorr">After Corr</option>
1182
- <option value="afternotok">After Not Ok</option>
1183
- <option value="singleton">Singleton</option>
1184
- </NativeSelect.Field>
1185
- </NativeSelect.Root>
1186
- <NativeSelect.Root flex={1}>
1187
- <NativeSelect.Field
1188
- ref={dependencyJobRef}
1189
- defaultValue=""
1190
- placeholder="Select job"
1191
- >
1192
- {dependencyJobs.map((job) => (
1193
- <option key={job.job_id} value={job.job_id || ''}>
1194
- {job.job_id} - {job.name || job.job_name || 'Unnamed'} ({job.job_state?.[0] || 'Unknown'})
1195
- </option>
1196
- ))}
1197
- </NativeSelect.Field>
1198
- </NativeSelect.Root>
1199
- </HStack>
1200
- </Field.Root>
1236
+ </VStack>
1201
1237
  </VStack>
1202
1238
  </Card.Root>
1203
1239
 
1204
- {/* Script Arguments Section */}
1240
+ {/* Script Arguments and Attached files: one card, two sections */}
1205
1241
  <Card.Root
1206
1242
  bg="var(--color-bg-card)"
1207
1243
  borderWidth="1px"
@@ -1277,11 +1313,12 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
1277
1313
  </Box>
1278
1314
  )}
1279
1315
 
1316
+ {/* Files sent with the job */}
1317
+ <AttachmentsSection files={attachments} onChange={setAttachments} />
1280
1318
  </VStack>
1281
1319
  </Card.Root>
1282
1320
 
1283
- {/* Files sent with the job */}
1284
- <AttachmentsCard files={attachments} onChange={setAttachments} />
1321
+ <EnvironmentCard cluster={selectedCluster} name={jobNameValue} />
1285
1322
  </VStack>
1286
1323
 
1287
1324
  {/* Right Column - Script Editor */}
@@ -1392,6 +1429,28 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
1392
1429
  </Grid>
1393
1430
 
1394
1431
  </VStack>
1432
+ {scheduleOpen && (
1433
+ <ScheduleDialog
1434
+ onClose={() => setScheduleOpen(false)}
1435
+ onSave={handleSaveScheduled}
1436
+ isSaving={saveScheduledMutation.isPending}
1437
+ baseName={selectedTemplate.trim() || jobNameRef.current?.value || ''}
1438
+ />
1439
+ )}
1440
+ {sweepArgs && (
1441
+ <SweepDialog
1442
+ isOpen
1443
+ onClose={() => setSweepArgs(null)}
1444
+ cluster={selectedCluster}
1445
+ getScript={() => editorRef.current?.getValue() || ''}
1446
+ getSbatchArgs={_collectSbatchArgs}
1447
+ profile={clusterProfiles.find(p => p.name === selectedProfile.trim())}
1448
+ args={sweepArgs}
1449
+ baseName={selectedTemplate.trim() || jobNameRef.current?.value || ''}
1450
+ attachmentCount={attachments.length}
1451
+ ensureConnected={sshGate.ensure}
1452
+ />
1453
+ )}
1395
1454
  {sshGate.dialog}
1396
1455
  </Box>
1397
1456
  );