@milabench/bujang 0.1.12 → 0.1.13

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/src/types.ts CHANGED
@@ -121,6 +121,8 @@ export interface SlurmJobsResponse {
121
121
  export interface SlurmJobSubmitRequest {
122
122
  script: string;
123
123
  job_name?: string;
124
+ /** the template the script came from (meta/template.txt: the script of the Overview layouts) */
125
+ template?: string;
124
126
  sbatch_args?: string[];
125
127
  // Script arguments extracted from export statements
126
128
  script_args?: Record<string, string>;
@@ -139,7 +141,7 @@ export interface SlurmJobSubmitRequest {
139
141
  dependency?: [string, string][]
140
142
  }
141
143
 
142
- /** A file attached to a submission: lands in <job folder>/input/<name> ($JR_INPUT_DIR). */
144
+ /** A file attached to a submission: lands in <job folder>/input/<name> ($BUJANG_INPUT_DIR). */
143
145
  export interface JobAttachment {
144
146
  /** Relative path, sub folders allowed (data/train.csv). */
145
147
  name: string;
@@ -243,7 +245,7 @@ export interface SlurmJobAccounting {
243
245
 
244
246
  export interface PersitedJobInfo {
245
247
  name: string;
246
- /** JR_JOB_LABEL of the script (or the label given at submission), resolved: meta/label.txt */
248
+ /** BUJANG_JOB_LABEL of the script (or the label given at submission), resolved: meta/label.txt */
247
249
  label?: string | null;
248
250
  cluster?: string;
249
251
  creation_time: string;
@@ -342,7 +344,7 @@ export interface PipelineJob {
342
344
  env?: Record<string, string>;
343
345
  // slurm steps: SOCKS proxy to the login node, unset: the cluster's `proxy` setting
344
346
  proxy?: boolean;
345
- /** label template ("train lr={LR}"): names the job, wins over its group's and the script's JR_JOB_LABEL */
347
+ /** label template ("train lr={LR}"): names the job, wins over its group's and the script's BUJANG_JOB_LABEL */
346
348
  label?: string;
347
349
  job_id?: string;
348
350
  slurm_jobid?: string;
@@ -364,6 +366,9 @@ export interface PipelineRunResponse {
364
366
  /** submitting: the jobs are being submitted; failed: the submission failed (nothing runs) */
365
367
  export type PipelineSubmissionStatus = 'submitting' | 'submitted' | 'failed';
366
368
 
369
+ /** State of the jobs of a submitted run */
370
+ export type PipelineRunState = 'running' | 'failing' | 'failed' | 'completed' | 'unknown';
371
+
367
372
  /** A pipeline run in the list of runs */
368
373
  export interface PipelineRunSummary {
369
374
  run_id: string;
@@ -373,6 +378,10 @@ export interface PipelineRunSummary {
373
378
  started: number;
374
379
  status: PipelineSubmissionStatus;
375
380
  error?: string | null;
381
+ /** last known state of its jobs (saved each time its progress is read), null when never read */
382
+ state?: PipelineRunState | null;
383
+ /** when `state` was read (epoch seconds) */
384
+ checked?: number | null;
376
385
  }
377
386
 
378
387
  /** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
@@ -394,7 +403,7 @@ export interface PipelineRunStatus {
394
403
  status: PipelineSubmissionStatus;
395
404
  error?: string | null;
396
405
  // once submitted
397
- state?: 'running' | 'failing' | 'failed' | 'completed' | 'unknown';
406
+ state?: PipelineRunState;
398
407
  steps?: PipelineRunStep[];
399
408
  log?: string;
400
409
  /** the definition the run was started with (the saved pipeline may have changed since) */
@@ -596,12 +605,12 @@ export interface SettingsOrigin {
596
605
  path: string | null;
597
606
  }
598
607
 
599
- /** One editable field of the user file (local_cache, workdir, database_url). */
600
- export interface SettingsField {
608
+ /** One editable field of the user file (local_cache, workdir, database_url, show_examples). */
609
+ export interface SettingsField<T = string> {
601
610
  /** Value the running server uses (database_url: password masked). */
602
- value: string | null;
611
+ value: T | null;
603
612
  /** Value in the user file, null when absent. */
604
- file: string | null;
613
+ file: T | null;
605
614
  origin: SettingsOrigin;
606
615
  /** Name of the BUJANG_* variable when it is set (it wins over the file). */
607
616
  env: string | null;
@@ -617,6 +626,14 @@ export interface SettingsField {
617
626
 
618
627
  export type SettingsFieldName = 'local_cache' | 'workdir' | 'database_url';
619
628
 
629
+ export type SettingsFields = Record<SettingsFieldName, SettingsField> & {
630
+ show_examples: SettingsField<boolean>;
631
+ /** What the MCP server tells the agents when they connect (null: general.mcp.default_instructions). */
632
+ mcp_instructions: SettingsField;
633
+ /** The default layout of the Overview tab (null: the built-in one). */
634
+ overview_layout: SettingsField<OverviewLayout>;
635
+ };
636
+
620
637
  export interface SettingsCluster {
621
638
  name: string;
622
639
  ssh: string;
@@ -669,6 +686,8 @@ export interface SettingsMcp {
669
686
  url: string | null;
670
687
  /** Turned off (--no-mcp). */
671
688
  disabled: boolean;
689
+ /** The instructions sent to the agents when mcp_instructions is empty. */
690
+ default_instructions: string;
672
691
  }
673
692
 
674
693
  export interface SettingsGeneral {
@@ -690,7 +709,7 @@ export interface SettingsInfo {
690
709
  writable: boolean;
691
710
  read_only_reason: string | null;
692
711
  user_file: { path: string | null; exists: boolean; user_config_dir: string | null; error: string | null };
693
- fields: Record<SettingsFieldName, SettingsField>;
712
+ fields: SettingsFields;
694
713
  secrets_file: string;
695
714
  clusters: SettingsCluster[];
696
715
  sources: {
@@ -895,6 +914,55 @@ export interface JobDataField {
895
914
  values?: string[] | null;
896
915
  }
897
916
 
917
+ /** A panel of the Overview tab: the log view, or a chart of an event */
918
+ export type OverviewPanel =
919
+ | { kind: 'logs'; title?: string; levels?: string[]; files?: string }
920
+ | {
921
+ kind: 'chart';
922
+ title?: string;
923
+ event?: string;
924
+ /** comma separated paths or globs, relative to the job folder */
925
+ files?: string;
926
+ /** Vega-Lite, its data the named dataset "rows"; else the builder fields below; neither: guessed */
927
+ spec?: Record<string, unknown>;
928
+ mark?: string;
929
+ x?: string;
930
+ y?: string;
931
+ aggregate?: string;
932
+ color?: string;
933
+ column?: string;
934
+ row?: string;
935
+ log_x?: boolean;
936
+ log_y?: boolean;
937
+ zero?: boolean;
938
+ };
939
+
940
+ export interface OverviewLayout {
941
+ panels: OverviewPanel[];
942
+ }
943
+
944
+ export type OverviewScope = 'experiment' | 'script';
945
+
946
+ /** GET /jobs/<jr>/overview/layout */
947
+ export interface JobOverviewLayout {
948
+ layout: OverviewLayout;
949
+ /** where it comes from: saved for the experiment / script, a plugin, the setting, the built-in one */
950
+ source: { kind: OverviewScope | 'plugin' | 'setting' | 'default'; name: string | null };
951
+ /** what a layout can be saved for */
952
+ keys: { experiment: string | null; script: string };
953
+ }
954
+
955
+ /** GET /overview/layouts */
956
+ export interface SavedOverviewLayout {
957
+ scope: OverviewScope;
958
+ key: string;
959
+ layout: OverviewLayout;
960
+ updated: number | null;
961
+ }
962
+
963
+ /** What an event of a JSONL file is for: plotted, shown in the log view, or neither */
964
+ export type JobDataRole = 'metric' | 'log' | 'other';
965
+
898
966
  /** GET /jobs/<jr>/data: the JSONL files of the artifact folders of a job and their schema */
899
967
  export interface JobData {
900
968
  jr_job_id: string;
@@ -904,13 +972,33 @@ export interface JobData {
904
972
  size?: number;
905
973
  mtime?: number;
906
974
  rows?: number;
907
- /** per event ("" for the records without an event envelope), its row count and fields */
908
- events?: { event: string; count: number; truncated: boolean; fields: JobDataField[] }[];
975
+ /** the JSONL processor that read the file ("generic", or one of a plugin) */
976
+ processor?: string;
977
+ /** per event ("" for the records without an event envelope), its role, row count and fields */
978
+ events?: { event: string; role: JobDataRole; count: number; truncated: boolean; fields: JobDataField[] }[];
909
979
  error?: string;
910
980
  }[];
911
981
  truncated: boolean;
912
982
  }
913
983
 
984
+ /** GET /job/environment: what a job of a cluster finds in its environment */
985
+ export interface JobEnvironment {
986
+ cluster: string;
987
+ /** an example job id: the prefix is the job name, the suffix is drawn at submission */
988
+ job_id: string;
989
+ remote_folder: string;
990
+ variables: {
991
+ name: string;
992
+ /** resolved for this cluster and name; null when it does not apply (no label, not a pipeline step) */
993
+ value: string | null;
994
+ /** when the value is known: at submission, when the job runs, or for pipeline steps only */
995
+ known: 'submission' | 'run' | 'pipeline';
996
+ description: string;
997
+ }[];
998
+ /** the job folder, one line each (a text tree) */
999
+ tree: string[];
1000
+ }
1001
+
914
1002
  /** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
915
1003
  export interface SyncStatus {
916
1004
  /** unix time of the last background sync, null before the first one */
@@ -920,6 +1008,10 @@ export interface SyncStatus {
920
1008
  /** seconds between two background syncs, null when the server does not run them */
921
1009
  interval: number | null;
922
1010
  jobs: number;
1011
+ /** unix time of the soonest next round of the background sync (a cluster), null when none is planned */
1012
+ next?: number | null;
1013
+ /** the clusters being synced now */
1014
+ running?: string[];
923
1015
  /** per cluster: true synced, false failed, 'recent': not asked, a full rsync ran less than min_refresh_interval ago */
924
1016
  synced?: Record<string, boolean | 'recent'>;
925
1017
  skipped?: string;
@@ -990,12 +1082,18 @@ export interface JanitorQueueTicket {
990
1082
  expires: number;
991
1083
  }
992
1084
 
1085
+ /** A periodic task (state.db `periodic`): sync:<cluster>, book_keeping:<cluster>, reindex, ... */
993
1086
  export interface JanitorPeriodic {
994
- /** APScheduler job id, null when only its history is known */
995
- id: string | null;
1087
+ id: string;
996
1088
  name: string;
1089
+ cluster: string | null;
1090
+ /** seconds between two runs, null: runs when asked (the scheduled-job checker) */
997
1091
  interval: number | null;
1092
+ /** unix time of the next run (a request makes it sooner), null when none is planned */
998
1093
  next_run: number | null;
1094
+ /** a run was asked for (Refresh, a slow rsync) and has not started yet */
1095
+ requested: number | null;
1096
+ running: boolean;
999
1097
  last: JanitorRun | null;
1000
1098
  }
1001
1099
 
@@ -40,6 +40,7 @@ import type {
40
40
  ApiError,
41
41
  JanitorArchiveResult,
42
42
  JanitorOverview,
43
+ JanitorPeriodic,
43
44
  JanitorRun,
44
45
  JanitorSkipped,
45
46
  JanitorStaleResult,
@@ -207,45 +208,113 @@ const RunningCard: React.FC<{ data: JanitorOverview }> = ({ data }) => {
207
208
  // ─── Periodic jobs ──────────────────────────────────────────────────
208
209
 
209
210
  const PERIODIC_HELP: Record<string, string> = {
210
- 'full sync': 'pulls the job folders of the clusters that have unfinished jobs (rsync), then updates the index of the jobs page for what changed. Not a database sync.',
211
- book_keeping: 'hourly: full rsync of each cluster, accounting of the finished jobs, then removal of their folders on the cluster',
211
+ 'full sync': 'pulls the job folders of the cluster while it has unfinished jobs (rsync), then updates the index of the jobs page for what changed. A slow rsync asks for a book keeping.',
212
+ book_keeping: 'full rsync of the cluster, accounting of the finished jobs, then removal of their folders on the cluster. Also runs when a sync of the cluster is slow.',
213
+ reindex: 'every job folder against the index, then the organizer folders',
212
214
  scheduled_check: 'submits the scheduled jobs that are due',
213
215
  janitor_prune: 'removes the history older than the retention',
214
216
  index: 'every job folder against the index (after the book keeping)',
215
217
  organize: 'the organizer folders (clusters/, experiments/, groups/)',
216
218
  };
217
219
 
218
- const PeriodicCard: React.FC<{ data: JanitorOverview }> = ({ data }) => (
219
- <LinkableCard id="periodic" icon={<LuCalendarClock />} title="Periodic jobs" subtitle="What runs on its own, when it runs next and how its last run went.">
220
- {data.periodic.length === 0 ? <Muted>No periodic job (the server was started without its scheduler).</Muted> : (
221
- <Table.Root size="sm" variant="outline">
222
- <Table.Header>
223
- <Table.Row>
224
- {['Job', 'What it does', 'Every', 'Next run', 'Last run', 'Took', 'Data', 'Status'].map(h => <Table.ColumnHeader key={h}>{h}</Table.ColumnHeader>)}
225
- </Table.Row>
226
- </Table.Header>
227
- <Table.Body>
228
- {data.periodic.map(p => (
229
- <Table.Row key={p.name}>
230
- <Table.Cell>
231
- <Tooltip content={PERIODIC_HELP[p.name] || p.name} showArrow>
232
- <Text fontFamily="mono" fontSize="xs">{p.name}</Text>
233
- </Tooltip>
234
- </Table.Cell>
235
- <Table.Cell fontSize="xs" color="var(--color-text-muted)" maxW="380px">{PERIODIC_HELP[p.name] || '—'}</Table.Cell>
236
- <Table.Cell>{p.interval ? formatDuration(p.interval) : p.id ? 'when due' : '—'}</Table.Cell>
237
- <Table.Cell fontSize="xs">{p.next_run ? <Tooltip content={when(p.next_run)} showArrow><span>{ago(p.next_run)}</span></Tooltip> : '—'}</Table.Cell>
238
- <Table.Cell fontSize="xs">{p.last ? <Tooltip content={when(p.last.ended)} showArrow><span>{ago(p.last.ended)}</span></Tooltip> : 'never'}</Table.Cell>
239
- <Table.Cell>{formatDuration(p.last?.duration)}</Table.Cell>
240
- <Table.Cell fontSize="xs"><Bytes bytesIn={p.last?.bytes_in} bytesOut={p.last?.bytes_out} /></Table.Cell>
241
- <Table.Cell><StatusBadge status={p.last?.status} error={p.last?.error} /></Table.Cell>
220
+ /** The tasks of one name (full sync, book_keeping: one per cluster) as one row */
221
+ interface PeriodicGroup {
222
+ name: string;
223
+ members: JanitorPeriodic[];
224
+ }
225
+
226
+ function groupPeriodic(rows: JanitorPeriodic[]): PeriodicGroup[] {
227
+ const groups = new Map<string, JanitorPeriodic[]>();
228
+ for (const p of rows) groups.set(p.name, [...(groups.get(p.name) ?? []), p]);
229
+ return [...groups.entries()].map(([name, members]) => ({ name, members }));
230
+ }
231
+
232
+ /** The soonest next run, the latest last run, the ones running now */
233
+ function summarize(members: JanitorPeriodic[]) {
234
+ const nexts = members.map(m => m.next_run).filter((t): t is number => !!t);
235
+ const lasts = members.map(m => m.last).filter((l): l is JanitorRun => !!l);
236
+ return {
237
+ next: nexts.length ? Math.min(...nexts) : null,
238
+ requested: members.some(m => m.requested),
239
+ running: members.filter(m => m.running).map(m => m.cluster || m.name),
240
+ last: lasts.length ? lasts.reduce((a, b) => (b.ended > a.ended ? b : a)) : null,
241
+ interval: members[0]?.interval ?? null,
242
+ };
243
+ }
244
+
245
+ const PeriodicCells: React.FC<{ next: number | null; requested: boolean | number | null; running: boolean | string[]; last: JanitorRun | null; interval: number | null }> = ({ next, requested, running, last, interval }) => {
246
+ const runningText = Array.isArray(running) ? (running.length ? `running: ${running.join(', ')}` : '') : (running ? 'running now' : '');
247
+ return (
248
+ <>
249
+ <Table.Cell>{interval ? formatDuration(interval) : 'when due'}</Table.Cell>
250
+ <Table.Cell fontSize="xs">
251
+ {runningText || (next ? <Tooltip content={when(next)} showArrow><span>{requested ? 'asked, ' : ''}{ago(next)}</span></Tooltip> : '—')}
252
+ </Table.Cell>
253
+ <Table.Cell fontSize="xs">{last ? <Tooltip content={when(last.ended)} showArrow><span>{ago(last.ended)}</span></Tooltip> : 'never'}</Table.Cell>
254
+ <Table.Cell>{formatDuration(last?.duration)}</Table.Cell>
255
+ <Table.Cell fontSize="xs"><Bytes bytesIn={last?.bytes_in} bytesOut={last?.bytes_out} /></Table.Cell>
256
+ <Table.Cell><StatusBadge status={last?.status} error={last?.error} /></Table.Cell>
257
+ </>
258
+ );
259
+ };
260
+
261
+ /** One cluster of a per-cluster task: a chip colored by its last run, the details in its tooltip */
262
+ const ClusterChip: React.FC<{ p: JanitorPeriodic }> = ({ p }) => {
263
+ const status = p.running ? 'running' : p.last?.status;
264
+ const tip = [
265
+ p.cluster,
266
+ p.running ? 'running now' : p.next_run ? `next ${p.requested ? '(asked) ' : ''}${ago(p.next_run)}` : 'nothing planned',
267
+ p.last ? `last ${ago(p.last.ended)}, took ${formatDuration(p.last.duration)}: ${p.last.status}` : 'never ran (no job on it)',
268
+ p.last?.error || '',
269
+ ].filter(Boolean).join('\n');
270
+ return (
271
+ <Tooltip content={<Text whiteSpace="pre-line">{tip}</Text>} showArrow>
272
+ <Badge size="xs" variant={p.last || p.running ? 'subtle' : 'outline'}
273
+ colorPalette={status === 'running' ? 'blue' : status ? STATUS_COLORS[status as JanitorStatus] || 'gray' : 'gray'}
274
+ fontFamily="mono">
275
+ {p.cluster}
276
+ </Badge>
277
+ </Tooltip>
278
+ );
279
+ };
280
+
281
+ const PeriodicCard: React.FC<{ data: JanitorOverview }> = ({ data }) => {
282
+ const groups = useMemo(() => groupPeriodic(data.periodic), [data.periodic]);
283
+ return (
284
+ <LinkableCard id="periodic" icon={<LuCalendarClock />} title="Periodic jobs" subtitle="What runs on its own, when it runs next and how its last run went. The sync and the book keeping run per cluster: hover a cluster for its own runs.">
285
+ {groups.length === 0 ? <Muted>No periodic job (the server has not started its background tasks).</Muted> : (
286
+ <Table.Root size="sm" variant="outline">
287
+ <Table.Header>
288
+ <Table.Row>
289
+ {['Job', 'Clusters', 'What it does', 'Every', 'Next run', 'Last run', 'Took', 'Data', 'Status'].map(h => <Table.ColumnHeader key={h}>{h}</Table.ColumnHeader>)}
242
290
  </Table.Row>
243
- ))}
244
- </Table.Body>
245
- </Table.Root>
246
- )}
247
- </LinkableCard>
248
- );
291
+ </Table.Header>
292
+ <Table.Body>
293
+ {groups.map(g => {
294
+ const perCluster = g.members.some(m => m.cluster);
295
+ return (
296
+ <Table.Row key={g.name}>
297
+ <Table.Cell>
298
+ <Tooltip content={PERIODIC_HELP[g.name] || g.name} showArrow>
299
+ <Text fontFamily="mono" fontSize="xs">{g.name}</Text>
300
+ </Tooltip>
301
+ </Table.Cell>
302
+ <Table.Cell maxW="260px">
303
+ {perCluster
304
+ ? <HStack gap={1} flexWrap="wrap">{g.members.map(p => <ClusterChip key={p.id} p={p} />)}</HStack>
305
+ : <Text fontSize="xs" color="var(--color-text-muted)">—</Text>}
306
+ </Table.Cell>
307
+ <Table.Cell fontSize="xs" color="var(--color-text-muted)" maxW="380px">{PERIODIC_HELP[g.name] || '—'}</Table.Cell>
308
+ <PeriodicCells {...summarize(g.members)} />
309
+ </Table.Row>
310
+ );
311
+ })}
312
+ </Table.Body>
313
+ </Table.Root>
314
+ )}
315
+ </LinkableCard>
316
+ );
317
+ };
249
318
 
250
319
  // ─── Runs ───────────────────────────────────────────────────────────
251
320