@milabench/bujang 0.1.18 → 0.1.20

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.
Files changed (41) hide show
  1. package/README.md +16 -0
  2. package/dist/api.d.ts +46 -4
  3. package/dist/components/OrganizerNav.d.ts +28 -0
  4. package/dist/components/ProjectsNav.d.ts +15 -0
  5. package/dist/index.d.ts +11 -2
  6. package/dist/index.js +6344 -4777
  7. package/dist/index.js.map +1 -1
  8. package/dist/paths.d.ts +27 -3
  9. package/dist/routes.d.ts +7 -2
  10. package/dist/types.d.ts +118 -4
  11. package/dist/views/CollectionView.d.ts +22 -0
  12. package/dist/views/JobDataOverview.d.ts +1 -1
  13. package/dist/views/JobsTable.d.ts +1 -0
  14. package/dist/views/JobsView.d.ts +12 -1
  15. package/dist/views/OrganizerValuesView.d.ts +13 -0
  16. package/dist/views/OverviewPanels.d.ts +13 -2
  17. package/dist/views/ProjectDetailsView.d.ts +3 -0
  18. package/dist/views/ProjectsView.d.ts +20 -0
  19. package/dist/views/dataCharts.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/src/api.ts +90 -8
  22. package/src/components/OrganizerNav.tsx +121 -0
  23. package/src/components/ProjectsNav.tsx +101 -0
  24. package/src/index.ts +11 -2
  25. package/src/paths.ts +50 -3
  26. package/src/routes.tsx +21 -4
  27. package/src/types.ts +117 -5
  28. package/src/views/CollectionView.tsx +68 -0
  29. package/src/views/JanitorView.tsx +2 -1
  30. package/src/views/JobDataOverview.tsx +23 -6
  31. package/src/views/JobLogs.tsx +47 -2
  32. package/src/views/JobSubmit.tsx +25 -0
  33. package/src/views/JobsTable.tsx +81 -21
  34. package/src/views/JobsView.tsx +49 -9
  35. package/src/views/OrganizerValuesView.tsx +207 -0
  36. package/src/views/OverviewPanels.tsx +531 -7
  37. package/src/views/PipelineEditor.tsx +69 -2
  38. package/src/views/PipelinesView.tsx +145 -4
  39. package/src/views/ProjectDetailsView.tsx +112 -0
  40. package/src/views/ProjectsView.tsx +355 -0
  41. package/src/views/dataCharts.tsx +1 -1
@@ -595,12 +595,13 @@ const ArchiveTool: React.FC = () => {
595
595
 
596
596
  return (
597
597
  <Box>
598
- <HStack gap={2} mb={1}><LuArchive /><SubHeading>Archive an experiment or a group</SubHeading></HStack>
598
+ <HStack gap={2} mb={1}><LuArchive /><SubHeading>Archive an experiment, a group or a project</SubHeading></HStack>
599
599
  <Text fontSize="sm" color="var(--color-text-muted)" mb={3}>
600
600
  Moves the job folders out of <Code fontSize="xs">jobs/</Code> into <Code fontSize="xs">&lt;organizer&gt;/&lt;value&gt;/</Code>:
601
601
  the link there becomes the folder itself, so <Code fontSize="xs">jobs/</Code> keeps only what is still moving.
602
602
  The jobs stay on every page. A pipeline run moves with its steps: the run folder, its steps inside it.
603
603
  Jobs not over or still on their cluster are left where they are (a run with such a step too).
604
+ A registered project's jobs go into its repository (<Code fontSize="xs">&lt;repo&gt;/&lt;folder&gt;/jobs/</Code>).
604
605
  </Text>
605
606
  <HStack gap={2} wrap="wrap">
606
607
  <Select value={organizer} onChange={(v) => { setOrganizer(v); setValue(''); setPlan(null); }}
@@ -46,7 +46,7 @@ import {
46
46
  panelOfBuilder,
47
47
  specFields,
48
48
  } from './dataCharts';
49
- import { LayoutBar, LayoutPanels, layoutKeyOf, type OverviewView } from './OverviewPanels';
49
+ import { CollectionJobs, LayoutBar, LayoutPanels, layoutKeyOf, type OverviewView } from './OverviewPanels';
50
50
 
51
51
  const FieldSelect: React.FC<{
52
52
  label: string;
@@ -85,15 +85,18 @@ const SETTLE = 100_000;
85
85
 
86
86
  /**
87
87
  * The Overview tab of a job: the panels of its layout (the log view, charts: GET
88
- * /jobs/<jr>/overview/layout), or the "explore data" layout: the JSONL files of its artifact folders
88
+ * /jobs/<jr>/overview/layout), or the "explore data" layout: the data files of its artifact folders
89
89
  * (output/, runs/, results/) plotted with a chart builder, whose charts can be added to the layout of the job.
90
90
  */
91
91
  export const JobDataOverview: React.FC<{
92
92
  jrJobId: string;
93
93
  /** the job is running (or waiting): its data is followed */
94
94
  live?: boolean;
95
- }> = ({ jrJobId, live = false }) => {
95
+ }> = ({ jrJobId, live: liveProp = false }) => {
96
96
  const queryClient = useQueryClient();
97
+ // a collection (experiment, group, project) is followed while one of its jobs is not over
98
+ const [jobsLive, setJobsLive] = useState(false);
99
+ const live = liveProp || jobsLive;
97
100
  // the last files come back with the syncs after the end of the job: followed a little longer
98
101
  const [settling, setSettling] = useState(false);
99
102
  const wasLive = useRef(live);
@@ -126,6 +129,7 @@ export const JobDataOverview: React.FC<{
126
129
  known.current = version;
127
130
  }, [data, dataUpdatedAt, version, jrJobId, queryClient]);
128
131
 
132
+ useEffect(() => setJobsLive(!!data?.jobs?.some((j) => !j.settled)), [data]);
129
133
  const files = useMemo(() => (data?.files || []).filter((f) => !f.error), [data]);
130
134
  // a job of several processes, each with its files: the panels show one of them, the first by default
131
135
  const ranks = useMemo(() => fileRanks(files), [files]);
@@ -237,9 +241,13 @@ export const JobDataOverview: React.FC<{
237
241
  setDraft(next);
238
242
  setEditing(true);
239
243
  };
240
- const saveLayout = useMutation<unknown, ApiError, { target: 'experiment' | 'script' | 'default'; layout: OverviewLayout | null }>({
244
+ const saveLayout = useMutation<unknown, ApiError, { target: 'experiment' | 'script' | 'default' | 'collection'; layout: OverviewLayout | null }>({
241
245
  mutationFn: ({ target, layout: value }) => {
242
246
  if (target === 'default') return updateSettings({ overview_layout: value });
247
+ if (target === 'collection') {
248
+ if (!found?.keys.collection) throw new Error('not the Overview of a collection');
249
+ return saveOverviewLayout(found.keys.collection.scope, found.keys.collection.key, value);
250
+ }
243
251
  const key = target === 'experiment' ? found?.keys.experiment : found?.keys.script;
244
252
  return saveOverviewLayout(target, key || '', value);
245
253
  },
@@ -248,7 +256,11 @@ export const JobDataOverview: React.FC<{
248
256
  setEditing(false);
249
257
  setPicked(null);
250
258
  queryClient.invalidateQueries({ queryKey: ['bujang-overview-layout'] });
251
- const what = target === 'default' ? 'the default layout' : `the ${target} ${target === 'experiment' ? found?.keys.experiment : found?.keys.script}`;
259
+ const what = target === 'default'
260
+ ? 'the default layout'
261
+ : target === 'collection'
262
+ ? `${found?.keys.collection?.scope} ${found?.keys.collection?.key}`
263
+ : `the ${target} ${target === 'experiment' ? found?.keys.experiment : found?.keys.script}`;
252
264
  toaster.create({ title: value ? `Layout saved for ${what}` : `Layout of ${what} removed`, type: 'success', duration: 3000 });
253
265
  },
254
266
  onError: (err) => toaster.create({ title: 'Could not save the layout', description: err.message, type: 'error' }),
@@ -296,12 +308,13 @@ export const JobDataOverview: React.FC<{
296
308
  const cardProps = { bg: 'var(--color-bg-card)', border: '1px solid', borderColor: 'var(--color-border)' } as const;
297
309
 
298
310
  return (
311
+ <CollectionJobs.Provider value={data?.jobs ?? null}>
299
312
  <VStack align="stretch" gap={4} pb={6}>
300
313
  {!files.length && (
301
314
  <Card.Root {...cardProps}>
302
315
  <Card.Body p={3}>
303
316
  <Text color="var(--color-text-muted)">
304
- No JSONL data (*.jsonl, *.ndjson, *.data) in {(data?.folders || ['output']).map((f) => `${f}/`).join(', ')} of this job.
317
+ No data files (*.jsonl, *.ndjson, *.data, or a format of a plugin) in {(data?.folders || ['output']).map((f) => `${f}/`).join(', ')} of this job.
305
318
  A job writes its results in <Code>output/</Code>.
306
319
  </Text>
307
320
  <Button mt={3} size="sm" variant="outline" onClick={() => refetch()} loading={isFetching} alignSelf="start">
@@ -335,6 +348,9 @@ export const JobDataOverview: React.FC<{
335
348
  const { kind, name } = shown.source;
336
349
  if ((kind === 'experiment' || kind === 'script') && window.confirm(`Remove the layout saved for the ${kind} ${name}?`)) {
337
350
  saveLayout.mutate({ target: kind, layout: null });
351
+ } else if (found?.keys.collection && kind === found.keys.collection.scope
352
+ && window.confirm(`Remove the layout saved for ${kind} ${name}?`)) {
353
+ saveLayout.mutate({ target: 'collection', layout: null });
338
354
  }
339
355
  }}
340
356
  />
@@ -527,5 +543,6 @@ export const JobDataOverview: React.FC<{
527
543
  </Card.Root>
528
544
  </>)}
529
545
  </VStack>
546
+ </CollectionJobs.Provider>
530
547
  );
531
548
  };
@@ -21,9 +21,9 @@ import {
21
21
  SegmentGroup,
22
22
  } from '@chakra-ui/react';
23
23
  import { toaster } from '../toast';
24
- import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil, LuTimer } from 'react-icons/lu';
24
+ import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil, LuTimer, LuPlay } from 'react-icons/lu';
25
25
  import { useQuery, useQueryClient } from '@tanstack/react-query';
26
- import { getSlurmJobStdoutFull, getSlurmJobStderrFull, getSlurmJobStdoutSize, getSlurmJobStderrSize, getSlurmJobStatusSimple, getSshJobStatus, getSlurmJobAccounting, rerunSlurmJob, cancelSlurmJob, getSlurmJobInfo, getSlurmJobCluster, getSlurmClusterStatus, earlySyncJob, getSlurmJobScript, getSlurmTemplates, getSlurmProfiles, getSlurmClusters } from '../api';
26
+ import { getSlurmJobStdoutFull, getSlurmJobStderrFull, getSlurmJobStdoutSize, getSlurmJobStderrSize, getSlurmJobStatusSimple, getSshJobStatus, getSlurmJobAccounting, rerunSlurmJob, cancelSlurmJob, releaseSlurmJob, getSlurmJobInfo, getSlurmJobCluster, getSlurmClusterStatus, earlySyncJob, getSlurmJobScript, getSlurmTemplates, getSlurmProfiles, getSlurmClusters } from '../api';
27
27
  import { JobSubmissionForm } from './JobSubmit';
28
28
  import type { JobSubmissionInitialData } from './JobSubmit';
29
29
  import { LogDisplay } from './LogDisplay';
@@ -460,6 +460,34 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
460
460
  }
461
461
  };
462
462
 
463
+ // Release state: a held job (pipeline step submitted with --hold)
464
+ const [isReleasing, setIsReleasing] = useState(false);
465
+ const isHeld = !!jobStatusData?.held && jobStatus?.toUpperCase() === 'PENDING';
466
+
467
+ const handleRelease = async () => {
468
+ if (!slurmJobId || slurmJobId === '-') return;
469
+ setIsReleasing(true);
470
+ try {
471
+ const result = await releaseSlurmJob(slurmJobId);
472
+ toaster.create({
473
+ title: result.success ? 'Job Released' : 'Release Failed',
474
+ description: result.success ? (result.message || `Job ${slurmJobId} released`) : (result.error || 'Failed to release job'),
475
+ type: result.success ? 'success' : 'error',
476
+ duration: 5000,
477
+ });
478
+ if (result.success) refetchStatus();
479
+ } catch (error) {
480
+ toaster.create({
481
+ title: 'Release Failed',
482
+ description: (error as ApiError).message || 'An unexpected error occurred',
483
+ type: 'error',
484
+ duration: 5000,
485
+ });
486
+ } finally {
487
+ setIsReleasing(false);
488
+ }
489
+ };
490
+
463
491
  const handleEarlySync = async () => {
464
492
  if (!jrJobId || !slurmJobId || slurmJobId === '-') {
465
493
  toaster.create({
@@ -736,6 +764,18 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
736
764
  Auto
737
765
  </Button>
738
766
  </HStack>
767
+ {isHeld && (
768
+ <Button
769
+ variant="outline"
770
+ colorScheme="orange"
771
+ onClick={handleRelease}
772
+ loading={isReleasing}
773
+ title={`Held (${jobStatusData?.reason}): scontrol release lets slurm schedule it`}
774
+ >
775
+ <LuPlay />
776
+ Release Job
777
+ </Button>
778
+ )}
739
779
  {canCancelJob(jobStatus) && (
740
780
  <Button
741
781
  variant="outline"
@@ -837,6 +877,11 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
837
877
  <Badge colorScheme={getStatusColor(jobStatus)}>
838
878
  {jobStatus}
839
879
  </Badge>
880
+ {jobStatusData?.reason && jobStatus.toUpperCase() === 'PENDING' && (
881
+ <Badge ml={1} colorPalette={isHeld ? 'orange' : 'gray'} title="squeue pending reason">
882
+ {isHeld ? `HELD (${jobStatusData.reason})` : jobStatusData.reason}
883
+ </Badge>
884
+ )}
840
885
  </WrapItem>
841
886
  )}
842
887
  {statusLoading && (
@@ -35,6 +35,7 @@ import {
35
35
  createScheduledJob,
36
36
  fileToAttachment,
37
37
  getJobEnvironment,
38
+ getProjects,
38
39
  } from '../api';
39
40
  import type { SlurmProfile, SlurmJob, ApiError, ScheduledJob, JobEnvironment } from '../types';
40
41
 
@@ -340,6 +341,11 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
340
341
  // Schedule dialog (name and cron expression)
341
342
  const [scheduleOpen, setScheduleOpen] = useState(false);
342
343
 
344
+ // a registered project: the job folder is linked into its repository (?project=<name> picks one)
345
+ const { data: projectsInfo } = useQuery({ queryKey: ['bujang-projects'], queryFn: getProjects, staleTime: 60_000, retry: false });
346
+ const projectNames = useMemo(() => (projectsInfo?.projects ?? []).map(p => p.name), [projectsInfo]);
347
+ const [project, setProject] = useState<string>(() => (syncUrl ? searchParams.get('project') : null) || '');
348
+
343
349
  // Mutations
344
350
  const sshGate = useSshConnectGate();
345
351
  const submitJobMutation = useMutation({
@@ -516,6 +522,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
516
522
 
517
523
  const handleTemplateSelect = (templateName: string) => {
518
524
  setSelectedTemplate(templateName);
525
+ // a script of a project ("<project>:<name>"): the job goes with that project
526
+ const owner = templateName.includes(':') ? templateName.split(':')[0] : '';
527
+ if (owner && projectNames.includes(owner)) setProject(owner);
519
528
  if (templateName && templates?.includes(templateName)) {
520
529
  loadTemplateMutation.mutate(templateName);
521
530
  }
@@ -668,6 +677,7 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
668
677
  sbatch_args: _collectSbatchArgs(),
669
678
  script_args: _collectScriptArgs(),
670
679
  files,
680
+ project: project || undefined,
671
681
  };
672
682
  // a cluster without an open ssh connection (MFA): log in first, then submit
673
683
  await sshGate.ensure(selectedCluster, () => submitJobMutation.mutate(request));
@@ -938,6 +948,21 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
938
948
  </Button>
939
949
  </>
940
950
  )}
951
+ {projectNames.length > 0 && (
952
+ <NativeSelect.Root size="sm" w="200px" flexShrink={0} title="Link the job folder into the repository of a project">
953
+ <NativeSelect.Field
954
+ value={project}
955
+ onChange={(e) => setProject(e.target.value)}
956
+ bg="var(--color-input-bg)"
957
+ borderColor="var(--color-input-border)"
958
+ color="var(--color-text)"
959
+ >
960
+ <option value="">no project</option>
961
+ {projectNames.map(name => <option key={name} value={name}>project: {name}</option>)}
962
+ </NativeSelect.Field>
963
+ <NativeSelect.Indicator />
964
+ </NativeSelect.Root>
965
+ )}
941
966
  <Button
942
967
  onClick={handleSubmitJob}
943
968
  loading={submitJobMutation.isPending}
@@ -24,9 +24,10 @@ import {
24
24
  LuArrowUpDown,
25
25
  LuCircleCheck,
26
26
  LuClock,
27
- LuEye,
28
27
  LuFilter,
29
28
  LuInfo,
29
+ LuPause,
30
+ LuPlay,
30
31
  LuRefreshCw,
31
32
  LuTrash2,
32
33
  LuTriangleAlert,
@@ -65,8 +66,17 @@ export interface JobRow {
65
66
  freshness: number | null;
66
67
  }
67
68
 
69
+ /** squeue reasons of a held job (submitted with --hold, waits for `scontrol release`) */
70
+ const HELD_REASONS = ['JobHeldUser', 'JobHeldAdmin'];
71
+
72
+ /** PENDING shown as HELD when the job waits for a release, not for resources */
73
+ const withHeld = (status: string, job: Partial<SlurmJob> & { hold?: boolean }): string =>
74
+ status.toUpperCase() === 'PENDING' && (job.hold || HELD_REASONS.includes(job.state_reason ?? ''))
75
+ ? 'HELD'
76
+ : status;
77
+
68
78
  export const fromActive = (job: SlurmJob): JobRow => {
69
- const status = job.job_state?.[0] || NO_JOB_STATE;
79
+ const status = withHeld(job.job_state?.[0] || NO_JOB_STATE, job);
70
80
  const limit = typeof job.time_limit === 'string' ? null : job.time_limit?.number ?? null;
71
81
  return {
72
82
  key: `active-${job.cluster ?? ''}-${job.job_id}`,
@@ -111,7 +121,7 @@ export const fromPersisted = (p: PersitedJobInfo): JobRow => {
111
121
  jobId: acc?.job_id?.toString() || job.job_id || '-',
112
122
  jrJobId: p.name,
113
123
  name: p.label || acc?.name || job.name || job.job_name || 'Persisted Job',
114
- status: acc?.state?.current?.[0] || job.job_state?.[0] || 'PENDING',
124
+ status: acc?.state?.current?.[0] || withHeld(job.job_state?.[0] || 'PENDING', job),
115
125
  cluster: p.cluster || 'mila',
116
126
  partition: acc?.partition || job.partition || 'N/A',
117
127
  user: acc?.user || job.user_name || job.user || 'N/A',
@@ -159,6 +169,8 @@ const getStatusColor = (status: string) => {
159
169
  case 'pending':
160
170
  case 'pd':
161
171
  return 'yellow';
172
+ case 'held':
173
+ return 'orange';
162
174
  case 'completed':
163
175
  case 'cd':
164
176
  return 'blue';
@@ -178,6 +190,8 @@ const getStatusIcon = (status: string) => {
178
190
  case 'pending':
179
191
  case 'pd':
180
192
  return <LuClock color="var(--color-status-pending)" />;
193
+ case 'held':
194
+ return <LuPause color="var(--color-status-pending)" />;
181
195
  case 'completed':
182
196
  case 'cd':
183
197
  return <LuCircleCheck color="var(--color-status-completed)" />;
@@ -189,9 +203,9 @@ const getStatusIcon = (status: string) => {
189
203
  }
190
204
  };
191
205
 
192
- const isLive = (status: string) => ['running', 'pending', 'r', 'pd'].includes(status.toLowerCase());
206
+ const isLive = (status: string) => ['running', 'pending', 'held', 'r', 'pd'].includes(status.toLowerCase());
193
207
  /** still in slurm's hands (not only running/pending): rerunning it now would duplicate it */
194
- const UNFINISHED = ['running', 'pending', 'r', 'pd', 'configuring', 'cf', 'completing', 'cg', 'suspended', 's',
208
+ const UNFINISHED = ['running', 'pending', 'held', 'r', 'pd', 'configuring', 'cf', 'completing', 'cg', 'suspended', 's',
195
209
  'requeued', 'rq', 'requeue_hold', 'rh', 'requeue_fed', 'rf', 'resizing', 'rs', 'stage_out', 'so', 'signaling', 'si'];
196
210
  const isFinal = (status: string) => !UNFINISHED.includes(status.toLowerCase());
197
211
 
@@ -231,11 +245,26 @@ interface Column {
231
245
  label: string;
232
246
  /** 'values': tick any of the values in the rows; 'text': a substring */
233
247
  filter: 'text' | 'values' | null;
248
+ /** 'values' filter: a fixed list of choices, in this order, shown even when no row has them */
249
+ choices?: string[];
234
250
  /** what the filter looks at */
235
251
  text: (r: JobRow) => string;
236
252
  sort: (r: JobRow) => string | number | null;
237
253
  }
238
254
 
255
+ /**
256
+ * every state a job can show: slurm's job states (squeue/sacct), plus HELD (a PENDING job on hold),
257
+ * the most common first so they are found without scrolling
258
+ */
259
+ const JOB_STATES = [
260
+ // common
261
+ 'RUNNING', 'PENDING', 'COMPLETED', 'FAILED', 'CANCELLED', 'TIMEOUT', 'HELD', 'OUT_OF_MEMORY',
262
+ // occasional
263
+ 'COMPLETING', 'CONFIGURING', 'PREEMPTED', 'NODE_FAIL', 'REQUEUED', 'SUSPENDED',
264
+ // rare
265
+ 'BOOT_FAIL', 'DEADLINE', 'STOPPED', 'SIGNALING', 'STAGE_OUT', 'RESIZING', 'REVOKED', 'SPECIAL_EXIT',
266
+ ];
267
+
239
268
  const COLUMNS: Column[] = [
240
269
  { id: 'jobId', label: 'Job ID', filter: 'text', text: (r) => r.jobId, sort: (r) => (Number.isFinite(+r.jobId) ? +r.jobId : r.jobId) },
241
270
  { id: 'jrJobId', label: 'JR Job ID', filter: 'text', text: (r) => r.jrJobId ?? '', sort: (r) => r.jrJobId },
@@ -254,7 +283,14 @@ const COLUMNS: Column[] = [
254
283
  // the jobs outside a pipeline last
255
284
  sort: (r) => r.pipeline?.run_id ?? null,
256
285
  },
257
- { id: 'status', label: 'Status', filter: 'values', text: (r) => r.status, sort: (r) => r.status },
286
+ {
287
+ id: 'status',
288
+ label: 'Status',
289
+ filter: 'values',
290
+ choices: JOB_STATES,
291
+ text: (r) => r.status,
292
+ sort: (r) => r.status,
293
+ },
258
294
  { id: 'cluster', label: 'Cluster', filter: 'values', text: (r) => r.cluster, sort: (r) => r.cluster },
259
295
  { id: 'partition', label: 'Partition', filter: 'values', text: (r) => r.partition, sort: (r) => r.partition },
260
296
  { id: 'user', label: 'User', filter: 'text', text: (r) => r.user, sort: (r) => r.user },
@@ -398,6 +434,7 @@ interface JobsTableProps {
398
434
  /** caps the rows' height; without it they fill the card (give the card a height, e.g. flex: 1) */
399
435
  maxH?: string;
400
436
  onCancel: (jobId: string) => void;
437
+ onRelease: (jobId: string) => void;
401
438
  onRerun: (jrJobId: string) => void;
402
439
  onGroup: (group: string) => void;
403
440
  /** quick filters (important, organizers), in the header next to the title */
@@ -414,6 +451,7 @@ export const JobsTable: React.FC<JobsTableProps & { cardProps?: React.ComponentP
414
451
  emptyHint,
415
452
  maxH,
416
453
  onCancel,
454
+ onRelease,
417
455
  onRerun,
418
456
  onGroup,
419
457
  quickFilters,
@@ -438,10 +476,16 @@ export const JobsTable: React.FC<JobsTableProps & { cardProps?: React.ComponentP
438
476
  const options = React.useMemo(() => {
439
477
  const out: Partial<Record<ColumnId, string[]>> = {};
440
478
  for (const c of COLUMNS) {
441
- if (c.filter === 'values') out[c.id] = [...new Set(rows.map(c.text))].sort(compare);
479
+ if (c.filter !== 'values') continue;
480
+ // the ticked values too: a filter from the URL that matches no row can still be unticked
481
+ const ticked = filters[c.id];
482
+ const seen = [...new Set([...rows.map(c.text), ...(Array.isArray(ticked) ? ticked : [])])];
483
+ const fixed = c.choices ?? [];
484
+ // a value outside the fixed list (a state slurm added, '-') still shows, after it
485
+ out[c.id] = [...fixed, ...seen.filter((v) => !fixed.includes(v)).sort(compare)];
442
486
  }
443
487
  return out;
444
- }, [rows]);
488
+ }, [rows, filters]);
445
489
 
446
490
  const shown = React.useMemo(() => {
447
491
  const active = COLUMNS.filter((c) => isSet(filters[c.id]));
@@ -613,6 +657,7 @@ export const JobsTable: React.FC<JobsTableProps & { cardProps?: React.ComponentP
613
657
  logsPath={paths.jobLogs(row.jobId, row.jrJobId || NO_JR_JOB_ID)}
614
658
  pipelinePath={row.pipeline ? paths.pipelineDetails(row.pipeline.name, row.pipeline.run_id) : null}
615
659
  onCancel={onCancel}
660
+ onRelease={onRelease}
616
661
  onRerun={onRerun}
617
662
  onGroup={onGroup}
618
663
  />
@@ -632,9 +677,10 @@ const JobRowView: React.FC<{
632
677
  logsPath: string;
633
678
  pipelinePath: string | null;
634
679
  onCancel: (jobId: string) => void;
680
+ onRelease: (jobId: string) => void;
635
681
  onRerun: (jrJobId: string) => void;
636
682
  onGroup: (group: string) => void;
637
- }> = ({ row, striped, logsPath, pipelinePath, onCancel, onRerun, onGroup }) => (
683
+ }> = ({ row, striped, logsPath, pipelinePath, onCancel, onRelease, onRerun, onGroup }) => (
638
684
  <Table.Row _hover={{ bg: 'var(--color-bg-hover)' }} bg={striped ? 'var(--color-bg-stripe)' : 'transparent'}>
639
685
  <Table.Cell pl={6} pr={4}>
640
686
  <HStack gap={2}>
@@ -653,28 +699,35 @@ const JobRowView: React.FC<{
653
699
  />
654
700
  </Tooltip>
655
701
  )}
702
+ {/* the slot is kept without an agent: the job ids stay aligned */}
703
+ <Box as="span" display="inline-flex" w="1em" flexShrink={0}>
704
+ <AgentBadge tag={row.agent} />
705
+ </Box>
656
706
  <Text fontWeight="semibold" color="var(--color-text)">
657
707
  {row.jobId}
658
708
  </Text>
659
- <AgentBadge tag={row.agent} />
660
709
  </HStack>
661
710
  </Table.Cell>
662
- <Table.Cell>
663
- <Text fontFamily="mono" fontSize="sm" color="var(--color-text-muted)">
711
+ {/* the id shrinks with the window, then is clipped (the full id in the tooltip) */}
712
+ <Table.Cell maxW="clamp(6ch, 14vw, 36ch)">
713
+ <Text
714
+ fontFamily="mono"
715
+ fontSize="clamp(0.65rem, 0.8vw, 0.875rem)"
716
+ color="var(--color-text-muted)"
717
+ truncate
718
+ title={row.jrJobId ?? undefined}
719
+ >
664
720
  {row.jrJobId}
665
721
  </Text>
666
722
  </Table.Cell>
667
723
  <Table.Cell>
668
724
  <HStack gap={2} flexWrap="wrap">
669
- {/* the view before the name, away from cancel at the end of the row: no misclick */}
670
- <Tooltip positioning={{ placement: 'top', offset: { mainAxis: 8 } }} content="View Logs">
671
- <Link to={logsPath}>
672
- <IconButton aria-label="View job logs" size="xs" variant="ghost">
673
- <LuEye />
674
- </IconButton>
675
- </Link>
676
- </Tooltip>
677
- <Text color="var(--color-text)">{row.name}</Text>
725
+ {/* the name opens the logs (away from cancel at the end of the row: no misclick) */}
726
+ <Link to={logsPath} title="View Logs">
727
+ <Text color="var(--color-text)" _hover={{ textDecoration: 'underline', color: 'var(--color-link, var(--color-primary))' }}>
728
+ {row.name}
729
+ </Text>
730
+ </Link>
678
731
  {row.groups.map((g) => (
679
732
  <Badge
680
733
  key={g}
@@ -733,6 +786,13 @@ const JobRowView: React.FC<{
733
786
  </IconButton>
734
787
  </Tooltip>
735
788
  )}
789
+ {row.active && row.status.toUpperCase() === 'HELD' && row.jobId !== NO_JOB_ID && (
790
+ <Tooltip positioning={{ placement: 'top', offset: { mainAxis: 8 } }} content="Release Job (scontrol release)">
791
+ <IconButton aria-label="Release job" size="xs" variant="ghost" colorScheme="orange" onClick={() => onRelease(row.jobId)}>
792
+ <LuPlay />
793
+ </IconButton>
794
+ </Tooltip>
795
+ )}
736
796
  {row.active && isLive(row.status) && row.jobId !== NO_JOB_ID && (
737
797
  <Tooltip positioning={{ placement: 'top', offset: { mainAxis: 8 } }} content="Cancel Job">
738
798
  <IconButton aria-label="Cancel job" size="xs" variant="ghost" colorScheme="red" onClick={() => onCancel(row.jobId)}>
@@ -19,6 +19,7 @@ import {
19
19
  getSlurmPersistedJobs,
20
20
  cancelSlurmJob,
21
21
  rerunSlurmJob,
22
+ releaseSlurmJob,
22
23
  getOrganizers,
23
24
  getSyncStatus,
24
25
  syncNow,
@@ -30,7 +31,18 @@ import { SshConnectButton } from '../components/SshConnectDialog';
30
31
  import { JobsTable, fromActive, fromPersisted, mergeRows } from './JobsTable';
31
32
  import { SETTINGS_KEY } from './SettingsView';
32
33
 
33
- type JobsViewProps = Record<string, never>;
34
+ interface JobsViewProps {
35
+ /** organizer filters always applied, not shown in the filter bar ({ projects: 'my-repo' }) */
36
+ filters?: Record<string, string>;
37
+ /** the heading (default "Jobs") */
38
+ title?: React.ReactNode;
39
+ /** the browser tab title (default "Jobs") */
40
+ pageTitle?: string;
41
+ /** shown under the heading */
42
+ header?: React.ReactNode;
43
+ /** where "Submit New Job" goes (default the Submit page) */
44
+ submitPath?: string;
45
+ }
34
46
 
35
47
  const AUTO_REFRESH_KEY = 'bujang-jobs-auto-refresh';
36
48
  const AUTO_REFRESH_MS = 30_000;
@@ -102,8 +114,8 @@ const OrganizerFilters: React.FC<{
102
114
  );
103
115
  };
104
116
 
105
- export const JobsView: React.FC<JobsViewProps> = () => {
106
- usePageTitle('Jobs');
117
+ export const JobsView: React.FC<JobsViewProps> = ({ filters, title, pageTitle, header, submitPath }) => {
118
+ usePageTitle(pageTitle ?? 'Jobs');
107
119
 
108
120
  const queryClient = useQueryClient();
109
121
  const navigate = useNavigate();
@@ -180,7 +192,12 @@ export const JobsView: React.FC<JobsViewProps> = () => {
180
192
 
181
193
  // ?clusters=mila&experiments=lr-sweep: the jobs under every chosen value
182
194
  const [params, setParams] = useSearchParams();
183
- const organizerNames = React.useMemo(() => organizers.map((o) => o.name), [organizers]);
195
+ // the fixed filters are not offered in the filter bar
196
+ const shownOrganizers = React.useMemo(
197
+ () => organizers.filter((o) => !filters?.[o.name]),
198
+ [organizers, filters],
199
+ );
200
+ const organizerNames = React.useMemo(() => shownOrganizers.map((o) => o.name), [shownOrganizers]);
184
201
  const selected = React.useMemo(() => {
185
202
  const out: Record<string, string> = {};
186
203
  for (const name of organizerNames) {
@@ -190,14 +207,14 @@ export const JobsView: React.FC<JobsViewProps> = () => {
190
207
  return out;
191
208
  }, [params, organizerNames]);
192
209
  const allowed = React.useMemo(() => {
193
- const sets = Object.entries(selected).map(([name, value]) => {
210
+ const sets = Object.entries({ ...selected, ...filters }).map(([name, value]) => {
194
211
  const group = organizers.find((o) => o.name === name)?.groups.find((g) => g.value === value);
195
212
  return new Set<string>(group?.jobs ?? []);
196
213
  });
197
214
  if (sets.length === 0) return null;
198
215
  const [first, ...rest] = sets;
199
216
  return new Set<string>([...first].filter((id) => rest.every((set) => set.has(id))));
200
- }, [selected, organizers]);
217
+ }, [selected, filters, organizers]);
201
218
  const setFilter = (name: string, value: string) => {
202
219
  const next = new URLSearchParams(params);
203
220
  if (value) next.set(name, value);
@@ -256,6 +273,27 @@ export const JobsView: React.FC<JobsViewProps> = () => {
256
273
  },
257
274
  });
258
275
 
276
+ const releaseJobMutation = useMutation({
277
+ mutationFn: releaseSlurmJob,
278
+ onSuccess: (data) => {
279
+ toaster.create({
280
+ title: 'Job Released',
281
+ description: data.message || 'Job released',
282
+ type: 'success',
283
+ duration: 5000,
284
+ });
285
+ queryClient.invalidateQueries({ queryKey: ['slurm-jobs'] });
286
+ },
287
+ onError: (error: ApiError) => {
288
+ toaster.create({
289
+ title: 'Release Failed',
290
+ description: error.message || 'Failed to release job',
291
+ type: 'error',
292
+ duration: 5000,
293
+ });
294
+ },
295
+ });
296
+
259
297
  const rerunJobMutation = useMutation({
260
298
  mutationFn: rerunSlurmJob,
261
299
  onSuccess: (data) => {
@@ -293,6 +331,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
293
331
  };
294
332
  const tableActions = {
295
333
  onCancel: handleCancelJob,
334
+ onRelease: (jobId: string) => releaseJobMutation.mutate(jobId),
296
335
  onRerun: handleRerunJob,
297
336
  onGroup: (g: string) => setFilter('groups', g),
298
337
  };
@@ -308,7 +347,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
308
347
  >
309
348
  <LuStar fill={importantOnly ? 'currentColor' : 'none'} /> Important
310
349
  </Button>
311
- <OrganizerFilters organizers={organizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
350
+ <OrganizerFilters organizers={shownOrganizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
312
351
  </>
313
352
  );
314
353
 
@@ -323,14 +362,14 @@ export const JobsView: React.FC<JobsViewProps> = () => {
323
362
  <HStack justify="space-between" align="center">
324
363
  <HStack gap={3} align="center">
325
364
  <Heading size="xl" fontWeight="bold" color="var(--color-text)">
326
- Jobs
365
+ {title ?? 'Jobs'}
327
366
  </Heading>
328
367
  <SshConnectButton />
329
368
  </HStack>
330
369
 
331
370
  <HStack gap={3}>
332
371
  <Button
333
- onClick={() => navigate(paths.submitJob())}
372
+ onClick={() => navigate(submitPath ?? paths.submitJob())}
334
373
  size="sm"
335
374
  fontWeight="medium"
336
375
  bg="var(--color-primary)"
@@ -395,6 +434,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
395
434
  </HStack>
396
435
  </HStack>
397
436
  </Box>
437
+ {header}
398
438
 
399
439
 
400
440
  {merged ? (