@milabench/bujang 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/paths.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IconType } from 'react-icons';
2
2
  /** Names of the bujang views. */
3
- export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'pipelineDetails' | 'scheduled' | 'agent' | 'janitor' | 'setup' | 'settings';
3
+ export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'pipelineDetails' | 'scheduled' | 'projects' | 'agent' | 'janitor' | 'setup' | 'settings';
4
4
  /** URL builders the views use to link to each other. */
5
5
  export interface BujangPaths {
6
6
  jobs: () => string;
@@ -11,6 +11,8 @@ export interface BujangPaths {
11
11
  /** One saved pipeline: its graph and its runs, `runId` shows that run. */
12
12
  pipelineDetails: (name: string, runId?: string) => string;
13
13
  scheduled: () => string;
14
+ /** Registered code repositories and the jobs linked into them. `name` links to one project's card. */
15
+ projects: (name?: string) => string;
14
16
  /** Agent activity, optionally filtered on one session. */
15
17
  agent: (session?: string) => string;
16
18
  /** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
package/dist/routes.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface BujangRouteObject {
15
15
  /**
16
16
  * Route objects for the default bujang URL layout under `basePath`:
17
17
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
18
- * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings.
18
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /projects, /agent, /janitor, /setup, /settings.
19
19
  */
20
20
  export declare function bujangRoutes(options?: BujangRoutesOptions): BujangRouteObject[];
21
21
  /** The same routes as <Route> elements, to drop inside a host's <Routes>. */
package/dist/types.d.ts CHANGED
@@ -166,6 +166,10 @@ export interface SlurmClusterStatus {
166
166
  }
167
167
  export interface SlurmJobStatusResponse {
168
168
  status: string;
169
+ /** pending jobs: the squeue reason (JobHeldUser, Dependency, Resources, ...) */
170
+ reason?: string;
171
+ /** pending and held (--hold): waits for `scontrol release` */
172
+ held?: boolean;
169
173
  }
170
174
  export interface SlurmJobAccounting {
171
175
  job_id: number;
@@ -357,6 +361,8 @@ export interface PipelineRunSummary {
357
361
  /** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
358
362
  export interface PipelineRunStep extends PipelineJob {
359
363
  step?: string;
364
+ /** the resolved label of the job (`label` is the template) */
365
+ job_label?: string;
360
366
  /** the value of the sweep variable of its parallel group (what tells it apart from its siblings) */
361
367
  sweep?: string;
362
368
  /** the env variable `sweep` is the value of */
@@ -856,6 +862,42 @@ export interface OrganizerGroups {
856
862
  jobs: string[];
857
863
  }[];
858
864
  }
865
+ /** A code repository registered as a project: its jobs are linked into `target` (GET /projects) */
866
+ export interface Project {
867
+ name: string;
868
+ /** the repository on the machine of the bujang server */
869
+ path: string;
870
+ /** folder inside the repository, relative ("bujang") */
871
+ folder: string;
872
+ /** path/folder: where the job links are */
873
+ target: string;
874
+ created: number | null;
875
+ /** the repository folder exists */
876
+ exists: boolean;
877
+ /** it is a git repository */
878
+ git: boolean;
879
+ /** jobs tagged for the project (runs and their steps) */
880
+ jobs: number;
881
+ /** links in the repository folder */
882
+ links: number;
883
+ }
884
+ export interface ProjectsInfo {
885
+ projects: Project[];
886
+ /** folder used when a registration gives none (the `project_folder` setting) */
887
+ default_folder: string;
888
+ /** false: the `projects` organizer is not loaded (the `organizers` setting), nothing is linked */
889
+ enabled: boolean;
890
+ /** registering and removing need a server that allows edits (settings_writable) */
891
+ writable: boolean;
892
+ /** script argument that tags a job too (export BUJANG_PROJECT=<name>) */
893
+ argument: string;
894
+ }
895
+ /** POST /projects/sync: per project, the links added and removed (or the error) */
896
+ export type ProjectsSyncReport = Record<string, {
897
+ added?: string[];
898
+ removed?: string[];
899
+ error?: string;
900
+ }>;
859
901
  /** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
860
902
  export interface JobArtifacts {
861
903
  jr_job_id: string;
@@ -918,6 +960,8 @@ export type OverviewBlock = {
918
960
  files?: string;
919
961
  /** Vega-Lite, its data the named dataset "rows"; else the builder fields below; neither: guessed */
920
962
  spec?: Record<string, unknown>;
963
+ /** first x values left out, of each event of each file */
964
+ skip?: number;
921
965
  mark?: string;
922
966
  x?: string;
923
967
  y?: string;
@@ -46,6 +46,7 @@ interface JobsTableProps {
46
46
  /** caps the rows' height; without it they fill the card (give the card a height, e.g. flex: 1) */
47
47
  maxH?: string;
48
48
  onCancel: (jobId: string) => void;
49
+ onRelease: (jobId: string) => void;
49
50
  onRerun: (jrJobId: string) => void;
50
51
  onGroup: (group: string) => void;
51
52
  /** quick filters (important, organizers), in the header next to the title */
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ProjectsView: React.FC;
@@ -37,10 +37,35 @@ export declare const guessBuilder: (fields: JobDataField[], multipleFiles: boole
37
37
  /** The fields a spec reads (to fetch only those): every `field` of it */
38
38
  export declare const specFields: (spec: unknown, out?: Set<string>) => Set<string>;
39
39
  export declare const isDarkPage: () => boolean;
40
+ type Param = {
41
+ name?: string;
42
+ value?: unknown;
43
+ select?: unknown;
44
+ bind?: {
45
+ input?: string;
46
+ options?: unknown;
47
+ labels?: string[];
48
+ };
49
+ };
50
+ /** The params of a spec with an input. The options of a select can be those of a field of the rows
51
+ * (`options: {field: "epoch"}`), after "all" (null) */
52
+ export declare const boundParams: (spec: Record<string, unknown>, rows: Record<string, unknown>[], values: Map<string, unknown>) => Param[] | undefined;
53
+ /** The rows without the first `skip` x values of each event of each file. An x the spec computes: their `start`, else their `time` */
54
+ export declare const skipFirst: <T extends Record<string, unknown>>(rows: T[], spec: unknown, skip: number) => T[];
55
+ /** The number of first x values a chart leaves out */
56
+ export declare const SkipInput: React.FC<{
57
+ value: number;
58
+ onChange: (skip: number) => void;
59
+ onDone?: () => void;
60
+ }>;
61
+ /** The signals holding the zoom of a spec: those of its interval params bound to the scales (`<param>_<field>`), null: no zoom */
62
+ export declare const zoomSignals: (spec: Record<string, unknown>) => string[];
40
63
  /** A Vega-Lite spec rendered with vega-embed (loaded on first use), `rows` as the dataset "rows" */
41
64
  export declare const VegaChart: React.FC<{
42
65
  spec: Record<string, unknown>;
43
66
  rows: Record<string, unknown>[];
67
+ /** where the inputs of the params go, under the chart when absent */
68
+ controls?: HTMLElement | null;
44
69
  }>;
45
70
  /** The events of a panel (`event`: comma separated, "" for the records without event) */
46
71
  export declare const panelEvents: (event?: string) => string[];
@@ -60,3 +85,4 @@ export declare const panelOfBuilder: (b: Builder, event: string, title?: string)
60
85
  export declare const builderOfPanel: (p: Extract<OverviewBlock, {
61
86
  kind: "chart";
62
87
  }>) => Builder | null;
88
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milabench/bujang",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/api.ts CHANGED
@@ -31,6 +31,9 @@ import type {
31
31
  SettingsUpdateResponse,
32
32
  UpdateCheck,
33
33
  OrganizerGroups,
34
+ Project,
35
+ ProjectsInfo,
36
+ ProjectsSyncReport,
34
37
  SyncStatus,
35
38
  JobEnvironment,
36
39
  JobArtifacts,
@@ -166,6 +169,16 @@ export const cancelSlurmJob = async (jobId: string): Promise<{ success: boolean;
166
169
  }
167
170
  };
168
171
 
172
+ /** scontrol release of a held job (a pipeline step submitted with --hold) */
173
+ export const releaseSlurmJob = async (jobId: string): Promise<{ success: boolean; message?: string; error?: string }> => {
174
+ try {
175
+ const response = await api.post(`/release/${jobId}`);
176
+ return response.data;
177
+ } catch (error) {
178
+ return handleError(error);
179
+ }
180
+ };
181
+
169
182
  export const getSlurmJobInfo = async (jrJobId: string, jobId?: string): Promise<SlurmJobDetail> => {
170
183
  try {
171
184
  const url = jobId
@@ -401,6 +414,8 @@ export const submitSlurmJob = async (request: {
401
414
  dependency?: [string, string][];
402
415
  /** Files for the job: <job folder>/input/<name> on the cluster before it starts ($BUJANG_INPUT_DIR). */
403
416
  files?: JobAttachment[];
417
+ /** A registered project: the job folder is linked into its repository (see getProjects). */
418
+ project?: string;
404
419
  }): Promise<SlurmJobSubmitResponse> => {
405
420
  try {
406
421
  const response = await api.post('/submit', request);
@@ -636,6 +651,40 @@ export const getOrganizers = async (): Promise<OrganizerGroups[]> => {
636
651
  } catch (error) { return handleError(error); }
637
652
  };
638
653
 
654
+ /** The registered projects: code repositories the jobs tagged for them are linked into. */
655
+ export const getProjects = async (): Promise<ProjectsInfo> => {
656
+ try {
657
+ const response = await api.get('/projects');
658
+ return response.data;
659
+ } catch (error) { return handleError(error); }
660
+ };
661
+
662
+ /** Register a repository (or change its folder): makes <path>/<folder> and links the jobs already tagged. */
663
+ export const registerProject = async (
664
+ body: { name: string; path: string; folder?: string },
665
+ ): Promise<{ project: Project; sync?: ProjectsSyncReport[string] }> => {
666
+ try {
667
+ const response = await api.post('/projects', body);
668
+ return response.data;
669
+ } catch (error) { return handleError(error); }
670
+ };
671
+
672
+ /** Forget a project: its links leave the repository, the other files of the folder stay. */
673
+ export const removeProject = async (name: string): Promise<{ name: string; removed: string[] }> => {
674
+ try {
675
+ const response = await api.delete(`/projects/${encodeURIComponent(name)}`);
676
+ return response.data;
677
+ } catch (error) { return handleError(error); }
678
+ };
679
+
680
+ /** Relink the jobs into the repositories now (one project, or all). */
681
+ export const syncProjects = async (name?: string): Promise<ProjectsSyncReport> => {
682
+ try {
683
+ const response = await api.post('/projects/sync', name ? { name } : {});
684
+ return response.data;
685
+ } catch (error) { return handleError(error); }
686
+ };
687
+
639
688
  /** The running version against PyPI; the server asks PyPI once a day, `force` asks now. */
640
689
  export const getUpdateCheck = async (force = false): Promise<UpdateCheck> => {
641
690
  try {
@@ -758,10 +807,13 @@ export const savePipelineToFile = async (pipelineData: PipelineTemplatePayload):
758
807
  }
759
808
  };
760
809
 
761
- export const runPipelineTemplate = async (name: string): Promise<PipelineRunResponse> => {
810
+ export const runPipelineTemplate = async (
811
+ name: string,
812
+ options: { experiment?: string; project?: string } = {},
813
+ ): Promise<PipelineRunResponse> => {
762
814
  try {
763
815
  // Returns right away, the jobs are submitted in the background (see getPipelineRunStatus)
764
- const response = await api.post(`/pipeline/run/${encodeURIComponent(name)}`, { context: {} });
816
+ const response = await api.post(`/pipeline/run/${encodeURIComponent(name)}`, { context: {}, ...options });
765
817
  return response.data;
766
818
  } catch (error) {
767
819
  return handleError(error);
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export { PipelinesView, PipelineDetailsView } from './views/PipelinesView';
7
7
  export { PipelineGraph, pipelineMermaid, pipelineSteps } from './views/PipelineGraph';
8
8
  export type { GraphStep } from './views/PipelineGraph';
9
9
  export { ScheduledJobsView } from './views/ScheduledJobsView';
10
+ export { ProjectsView } from './views/ProjectsView';
10
11
  export { AgentActivityView, AgentBadge, McpHelp } from './views/AgentActivityView';
11
12
  export { SettingsView } from './views/SettingsView';
12
13
  export { JanitorView } from './views/JanitorView';
package/src/paths.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { IconType } from 'react-icons';
2
- import { LuBot, LuBrush, LuCalendarClock, LuList, LuRocket, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
2
+ import { LuBot, LuBrush, LuCalendarClock, LuFolderGit2, LuList, LuRocket, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
3
3
 
4
4
  /** Names of the bujang views. */
5
5
  export type BujangView =
@@ -10,6 +10,7 @@ export type BujangView =
10
10
  | 'pipelines'
11
11
  | 'pipelineDetails'
12
12
  | 'scheduled'
13
+ | 'projects'
13
14
  | 'agent'
14
15
  | 'janitor'
15
16
  | 'setup'
@@ -25,6 +26,8 @@ export interface BujangPaths {
25
26
  /** One saved pipeline: its graph and its runs, `runId` shows that run. */
26
27
  pipelineDetails: (name: string, runId?: string) => string;
27
28
  scheduled: () => string;
29
+ /** Registered code repositories and the jobs linked into them. `name` links to one project's card. */
30
+ projects: (name?: string) => string;
28
31
  /** Agent activity, optionally filtered on one session. */
29
32
  agent: (session?: string) => string;
30
33
  /** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
@@ -47,6 +50,7 @@ export const defaultRoutePatterns: Record<BujangView, string> = {
47
50
  pipelines: '/pipelines',
48
51
  pipelineDetails: '/pipelines/:pipelineName',
49
52
  scheduled: '/scheduled',
53
+ projects: '/projects',
50
54
  agent: '/agent',
51
55
  janitor: '/janitor',
52
56
  setup: '/setup',
@@ -72,6 +76,7 @@ export function createBujangPaths(basePath: string = ''): BujangPaths {
72
76
  pipelines: () => `${b}/pipelines`,
73
77
  pipelineDetails: (name, runId) => `${b}/pipelines/${seg(name)}${runId ? `?run=${encodeURIComponent(runId)}` : ''}`,
74
78
  scheduled: () => `${b}/scheduled`,
79
+ projects: (name) => `${b}/projects${name ? `#${encodeURIComponent(`project-${name}`)}` : ''}`,
75
80
  agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
76
81
  janitor: (section) => `${b}/janitor${section ? `#${encodeURIComponent(section)}` : ''}`,
77
82
  settings: (section) => `${b}/settings${section ? `#${encodeURIComponent(section)}` : ''}`,
@@ -95,6 +100,7 @@ export function bujangNavItems(paths: BujangPaths = createBujangPaths()): Bujang
95
100
  { view: 'submitJob', label: 'Submit Job', path: paths.submitJob(), icon: LuSend },
96
101
  { view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled(), icon: LuCalendarClock },
97
102
  { view: 'pipelines', label: 'Pipelines', path: paths.pipelines(), icon: LuWorkflow },
103
+ { view: 'projects', label: 'Projects', path: paths.projects(), icon: LuFolderGit2 },
98
104
  { view: 'agent', label: 'Agent Activity', path: paths.agent(), icon: LuBot },
99
105
  { view: 'janitor', label: 'Janitor', path: paths.janitor(), icon: LuBrush },
100
106
  { view: 'settings', label: 'Settings', path: paths.settings(), icon: LuSettings },
package/src/routes.tsx CHANGED
@@ -8,6 +8,7 @@ import { JobDetailsView } from './views/JobDetails';
8
8
  import { JobLogsView } from './views/JobLogs';
9
9
  import { PipelineDetailsView, PipelinesView } from './views/PipelinesView';
10
10
  import { ScheduledJobsView } from './views/ScheduledJobsView';
11
+ import { ProjectsView } from './views/ProjectsView';
11
12
  import { AgentActivityView } from './views/AgentActivityView';
12
13
  import { SettingsView } from './views/SettingsView';
13
14
  import { JanitorView } from './views/JanitorView';
@@ -35,6 +36,7 @@ const elements: Record<BujangView, () => React.ReactElement> = {
35
36
  pipelines: () => <PipelinesView />,
36
37
  pipelineDetails: () => <PipelineDetailsView />,
37
38
  scheduled: () => <ScheduledJobsView />,
39
+ projects: () => <ProjectsView />,
38
40
  agent: () => <AgentActivityView />,
39
41
  janitor: () => <JanitorView />,
40
42
  setup: () => <SetupView />,
@@ -44,7 +46,7 @@ const elements: Record<BujangView, () => React.ReactElement> = {
44
46
  /**
45
47
  * Route objects for the default bujang URL layout under `basePath`:
46
48
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
47
- * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings.
49
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /projects, /agent, /janitor, /setup, /settings.
48
50
  */
49
51
  export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
50
52
  const base = normalizeBasePath(options.basePath);
package/src/types.ts CHANGED
@@ -184,6 +184,10 @@ export interface SlurmClusterStatus {
184
184
 
185
185
  export interface SlurmJobStatusResponse {
186
186
  status: string;
187
+ /** pending jobs: the squeue reason (JobHeldUser, Dependency, Resources, ...) */
188
+ reason?: string;
189
+ /** pending and held (--hold): waits for `scontrol release` */
190
+ held?: boolean;
187
191
  }
188
192
 
189
193
  export interface SlurmJobAccounting {
@@ -395,6 +399,8 @@ export interface PipelineRunSummary {
395
399
  /** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
396
400
  export interface PipelineRunStep extends PipelineJob {
397
401
  step?: string;
402
+ /** the resolved label of the job (`label` is the template) */
403
+ job_label?: string;
398
404
  /** the value of the sweep variable of its parallel group (what tells it apart from its siblings) */
399
405
  sweep?: string;
400
406
  /** the env variable `sweep` is the value of */
@@ -917,6 +923,41 @@ export interface OrganizerGroups {
917
923
  groups: { value: string; jobs: string[] }[];
918
924
  }
919
925
 
926
+ /** A code repository registered as a project: its jobs are linked into `target` (GET /projects) */
927
+ export interface Project {
928
+ name: string;
929
+ /** the repository on the machine of the bujang server */
930
+ path: string;
931
+ /** folder inside the repository, relative ("bujang") */
932
+ folder: string;
933
+ /** path/folder: where the job links are */
934
+ target: string;
935
+ created: number | null;
936
+ /** the repository folder exists */
937
+ exists: boolean;
938
+ /** it is a git repository */
939
+ git: boolean;
940
+ /** jobs tagged for the project (runs and their steps) */
941
+ jobs: number;
942
+ /** links in the repository folder */
943
+ links: number;
944
+ }
945
+
946
+ export interface ProjectsInfo {
947
+ projects: Project[];
948
+ /** folder used when a registration gives none (the `project_folder` setting) */
949
+ default_folder: string;
950
+ /** false: the `projects` organizer is not loaded (the `organizers` setting), nothing is linked */
951
+ enabled: boolean;
952
+ /** registering and removing need a server that allows edits (settings_writable) */
953
+ writable: boolean;
954
+ /** script argument that tags a job too (export BUJANG_PROJECT=<name>) */
955
+ argument: string;
956
+ }
957
+
958
+ /** POST /projects/sync: per project, the links added and removed (or the error) */
959
+ export type ProjectsSyncReport = Record<string, { added?: string[]; removed?: string[]; error?: string }>;
960
+
920
961
  /** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
921
962
  export interface JobArtifacts {
922
963
  jr_job_id: string;
@@ -965,6 +1006,8 @@ export type OverviewBlock =
965
1006
  files?: string;
966
1007
  /** Vega-Lite, its data the named dataset "rows"; else the builder fields below; neither: guessed */
967
1008
  spec?: Record<string, unknown>;
1009
+ /** first x values left out, of each event of each file */
1010
+ skip?: number;
968
1011
  mark?: string;
969
1012
  x?: string;
970
1013
  y?: string;
@@ -35,7 +35,9 @@ import {
35
35
  MARKS,
36
36
  ROLE_ORDER,
37
37
  ROW_LIMIT,
38
+ SkipInput,
38
39
  fileRanks,
40
+ skipFirst,
39
41
  VegaChart,
40
42
  buildSpec,
41
43
  filesWithEvent,
@@ -256,10 +258,12 @@ export const JobDataOverview: React.FC<{
256
258
  const columnTargets = (layout?.panels || []).flatMap((p, i) => (
257
259
  p.kind === 'columns' ? p.columns.map((_, c) => ({ value: `${i}.${c}`, label: `row ${i + 1}, column ${c + 1}` })) : []
258
260
  ));
261
+ const [skip, setSkip] = useState(0);
262
+ const shownRows = useMemo(() => rows && skipFirst(rows, spec, skip), [rows, spec, skip]);
259
263
  const addToLayout = () => {
260
264
  const base = layout ?? { panels: [] };
261
265
  const chosen = selectedFiles === null ? {} : { files: activeFiles.map((f) => f.path).join(',') };
262
- const panel: OverviewBlock = { ...panelOfBuilder(builder, activeEvent), ...chosen };
266
+ const panel: OverviewBlock = { ...panelOfBuilder(builder, activeEvent), ...chosen, ...(skip ? { skip } : {}) };
263
267
  const [row, col] = columnTargets.some((t) => t.value === target) ? target.split('.').map(Number) : [-1, -1];
264
268
  changeLayout({
265
269
  panels: row < 0
@@ -470,6 +474,7 @@ export const JobDataOverview: React.FC<{
470
474
  <NativeSelect.Indicator />
471
475
  </NativeSelect.Root>
472
476
  )}
477
+ <SkipInput value={skip} onChange={setSkip} />
473
478
  <Button size="2xs" variant="outline" ml={columnTargets.length ? undefined : 'auto'} onClick={addToLayout} disabled={!layout}
474
479
  title="Add this chart to the layout of the job (then save the layout)">
475
480
  <LuPlus /> Add to job layout
@@ -481,7 +486,7 @@ export const JobDataOverview: React.FC<{
481
486
  <Alert.Description>{rowsError.message}</Alert.Description>
482
487
  </Alert.Root>
483
488
  )}
484
- {rows && <VegaChart spec={spec} rows={rows} />}
489
+ {shownRows && <VegaChart spec={spec} rows={shownRows} />}
485
490
  </Card.Body>
486
491
  </Card.Root>
487
492
 
@@ -10,7 +10,6 @@ import {
10
10
  VStack,
11
11
  HStack,
12
12
  Button,
13
- NativeSelect,
14
13
  Card,
15
14
  Spinner,
16
15
  Alert,
@@ -22,9 +21,9 @@ import {
22
21
  SegmentGroup,
23
22
  } from '@chakra-ui/react';
24
23
  import { toaster } from '../toast';
25
- import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil } from 'react-icons/lu';
24
+ import { LuArrowLeft, LuRefreshCw, LuX, LuInfo, LuClock, LuPencil, LuTimer, LuPlay } from 'react-icons/lu';
26
25
  import { useQuery, useQueryClient } from '@tanstack/react-query';
27
- 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';
28
27
  import { JobSubmissionForm } from './JobSubmit';
29
28
  import type { JobSubmissionInitialData } from './JobSubmit';
30
29
  import { LogDisplay } from './LogDisplay';
@@ -36,29 +35,8 @@ import type { SlurmJobDetail, ApiError } from '../types';
36
35
  type JobLogsViewProps = Record<string, never>;
37
36
  type JobLogsTab = 'logs' | 'overview';
38
37
 
39
- // Seconds between two automatic early syncs: 'x2' waits twice the time the last one took
40
- type AutoSyncEvery = 'x2' | '10' | '30' | '60';
41
- const AUTO_SYNC_EVERY: { value: AutoSyncEvery; label: string }[] = [
42
- { value: 'x2', label: '2× sync time' },
43
- { value: '10', label: '10 s' },
44
- { value: '30', label: '30 s' },
45
- { value: '60', label: '60 s' },
46
- ];
47
- const AUTO_SYNC_KEY = 'bujang-auto-early-sync';
48
- /** 'x2' does not go below: each sync starts a step in the job */
49
- const AUTO_SYNC_MIN = 5;
50
-
51
- /** Seconds to the next automatic early sync; `took`: seconds of the last one */
52
- const autoSyncDelay = (every: AutoSyncEvery, took = 0) => (every === 'x2' ? Math.max(AUTO_SYNC_MIN, 2 * took) : Number(every));
53
-
54
- const savedAutoSyncEvery = (): AutoSyncEvery => {
55
- try {
56
- const saved = localStorage.getItem(AUTO_SYNC_KEY);
57
- return AUTO_SYNC_EVERY.find((o) => o.value === saved)?.value ?? 'x2';
58
- } catch {
59
- return 'x2';
60
- }
61
- };
38
+ // Seconds before a failed automatic early sync is tried again (a failure can be immediate)
39
+ const AUTO_SYNC_RETRY = 5;
62
40
 
63
41
  const getStatusColor = (status: string) => {
64
42
  switch (status?.toLowerCase()) {
@@ -148,11 +126,6 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
148
126
  // the job synced automatically: off when the page moves to another job
149
127
  const [autoSyncJob, setAutoSyncJob] = useState<string | null>(null);
150
128
  const autoSync = !!jrJobId && autoSyncJob === jrJobId;
151
- const [autoSyncEvery, setAutoSyncEvery] = useState<AutoSyncEvery>(savedAutoSyncEvery);
152
- const changeAutoSyncEvery = (value: AutoSyncEvery) => {
153
- try { localStorage.setItem(AUTO_SYNC_KEY, value); } catch { /* this page only */ }
154
- setAutoSyncEvery(value);
155
- };
156
129
 
157
130
  // Edit & Resubmit state
158
131
  const [isEditModalOpen, setIsEditModalOpen] = useState(false);
@@ -487,6 +460,34 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
487
460
  }
488
461
  };
489
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
+
490
491
  const handleEarlySync = async () => {
491
492
  if (!jrJobId || !slurmJobId || slurmJobId === '-') {
492
493
  toaster.create({
@@ -534,8 +535,8 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
534
535
  }
535
536
  };
536
537
 
537
- // Automatic early sync, while the job runs. A failed one is tried again at the next turn (the
538
- // error is shown on the button)
538
+ // Automatic early sync, while the job runs: again after twice the time the last one took. A failed
539
+ // one is tried again (the error is shown on the button)
539
540
  const { data: autoSyncResult, error: autoSyncFailure } = useQuery({
540
541
  queryKey: ['bujang-auto-early-sync', jrJobId, slurmJobId],
541
542
  queryFn: async () => {
@@ -549,7 +550,9 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
549
550
  return { ...result, took };
550
551
  },
551
552
  enabled: autoSync && !!slurmJobId && slurmJobId !== '-' && jobStatus?.toUpperCase() === 'RUNNING',
552
- refetchInterval: (query) => 1000 * autoSyncDelay(autoSyncEvery, query.state.data?.took),
553
+ refetchInterval: ({ state }) => 1000 * (
554
+ state.data?.status === 'ok' && !state.error ? 2 * state.data.took : AUTO_SYNC_RETRY
555
+ ),
553
556
  refetchOnWindowFocus: false,
554
557
  retry: false,
555
558
  gcTime: 0,
@@ -739,6 +742,11 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
739
742
  </Button>
740
743
  <Button
741
744
  variant={autoSync && !isJobTerminal ? 'solid' : 'outline'}
745
+ {...(autoSync && !isJobTerminal && !autoSyncError ? {
746
+ bg: 'var(--color-primary)',
747
+ color: 'var(--color-primary-text)',
748
+ _hover: { bg: 'var(--color-primary-hover)' },
749
+ } : {})}
742
750
  colorPalette={autoSync && autoSyncError ? 'red' : undefined}
743
751
  onClick={() => setAutoSyncJob(autoSync ? null : jrJobId ?? null)}
744
752
  disabled={!slurmJobId || slurmJobId === '-' || isJobTerminal}
@@ -748,23 +756,26 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
748
756
  px={2}
749
757
  title={autoSync && autoSyncError
750
758
  ? `Automatic early sync failed, trying again: ${autoSyncError}`
751
- : `Early sync while the job runs (${autoSync ? `on: every ${autoSyncDelay(autoSyncEvery, autoSyncResult?.took).toFixed(0)} s` : 'off'})`}
759
+ : autoSync
760
+ ? `Automatic early sync is on${autoSyncResult ? ` (every ${(2 * autoSyncResult.took).toFixed(1)} s, 2× the last sync)` : ''}: click to stop`
761
+ : 'Early sync again and again while the job runs, every 2× the time a sync takes'}
752
762
  >
763
+ <LuTimer />
753
764
  Auto
754
765
  </Button>
755
- <NativeSelect.Root size="md" w="140px" title="Time between two automatic early syncs">
756
- <NativeSelect.Field
757
- aria-label="Time between two automatic early syncs"
758
- value={autoSyncEvery}
759
- onChange={(e) => changeAutoSyncEvery(e.target.value as AutoSyncEvery)}
760
- borderLeftRadius={0}
761
- borderLeft="none"
762
- >
763
- {AUTO_SYNC_EVERY.map((o) => <option key={o.value} value={o.value}>{o.label}</option>)}
764
- </NativeSelect.Field>
765
- <NativeSelect.Indicator />
766
- </NativeSelect.Root>
767
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
+ )}
768
779
  {canCancelJob(jobStatus) && (
769
780
  <Button
770
781
  variant="outline"
@@ -866,6 +877,11 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
866
877
  <Badge colorScheme={getStatusColor(jobStatus)}>
867
878
  {jobStatus}
868
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
+ )}
869
885
  </WrapItem>
870
886
  )}
871
887
  {statusLoading && (