@milabench/bujang 0.1.19 → 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.
package/src/index.ts CHANGED
@@ -8,6 +8,14 @@ export { PipelineGraph, pipelineMermaid, pipelineSteps } from './views/PipelineG
8
8
  export type { GraphStep } from './views/PipelineGraph';
9
9
  export { ScheduledJobsView } from './views/ScheduledJobsView';
10
10
  export { ProjectsView } from './views/ProjectsView';
11
+ export { ProjectDetailsView } from './views/ProjectDetailsView';
12
+ export { BujangProjectsNav, useBujangProjects } from './components/ProjectsNav';
13
+ export { BujangOrganizerNav } from './components/OrganizerNav';
14
+ export type { BujangOrganizerNavProps } from './components/OrganizerNav';
15
+ export { OrganizerValuesView, OrganizerValueView } from './views/OrganizerValuesView';
16
+ export { CollectionOverview, CollectionTabs } from './views/CollectionView';
17
+ export { ComparePanel, CollectionJobs } from './views/OverviewPanels';
18
+ export type { BujangProjectsNavProps } from './components/ProjectsNav';
11
19
  export { AgentActivityView, AgentBadge, McpHelp } from './views/AgentActivityView';
12
20
  export { SettingsView } from './views/SettingsView';
13
21
  export { JanitorView } from './views/JanitorView';
@@ -22,8 +30,8 @@ export { JobImportantButton, JobGroupsButton, JobImportantStar } from './views/J
22
30
  // Provider, paths, routes
23
31
  export { BujangProvider, useBujang, useBujangPaths } from './context';
24
32
  export type { BujangProviderProps, BujangContextValue } from './context';
25
- export { createBujangPaths, defaultRoutePatterns, normalizeBasePath, bujangNavItems } from './paths';
26
- export type { BujangPaths, BujangView, BujangNavItem } from './paths';
33
+ export { createBujangPaths, defaultRoutePatterns, normalizeBasePath, bujangNavItems, OPTIONAL_VIEWS, PROJECT_VIEWS, ORGANIZER_VIEWS } from './paths';
34
+ export type { BujangPaths, BujangView, BujangNavItem, BujangNavOptions } from './paths';
27
35
  export { bujangRoutes, bujangRouteElements } from './routes';
28
36
  export type { BujangRoutesOptions, BujangRouteObject } from './routes';
29
37
 
package/src/paths.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { IconType } from 'react-icons';
2
- import { LuBot, LuBrush, LuCalendarClock, LuFolderGit2, LuList, LuRocket, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
2
+ import { LuBot, LuBrush, LuCalendarClock, LuList, LuRocket, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
3
3
 
4
4
  /** Names of the bujang views. */
5
5
  export type BujangView =
@@ -11,6 +11,11 @@ export type BujangView =
11
11
  | 'pipelineDetails'
12
12
  | 'scheduled'
13
13
  | 'projects'
14
+ | 'projectDetails'
15
+ | 'experiments'
16
+ | 'experimentDetails'
17
+ | 'groups'
18
+ | 'groupDetails'
14
19
  | 'agent'
15
20
  | 'janitor'
16
21
  | 'setup'
@@ -28,6 +33,16 @@ export interface BujangPaths {
28
33
  scheduled: () => string;
29
34
  /** Registered code repositories and the jobs linked into them. `name` links to one project's card. */
30
35
  projects: (name?: string) => string;
36
+ /** One project: its repository and its jobs. */
37
+ projectDetails: (name: string) => string;
38
+ /** Every experiment: a searchable, paginated table. */
39
+ experiments: () => string;
40
+ /** The jobs of one experiment. */
41
+ experimentDetails: (value: string) => string;
42
+ /** Every group: a searchable, paginated table. */
43
+ groups: () => string;
44
+ /** The jobs of one group. */
45
+ groupDetails: (value: string) => string;
31
46
  /** Agent activity, optionally filtered on one session. */
32
47
  agent: (session?: string) => string;
33
48
  /** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
@@ -51,6 +66,11 @@ export const defaultRoutePatterns: Record<BujangView, string> = {
51
66
  pipelineDetails: '/pipelines/:pipelineName',
52
67
  scheduled: '/scheduled',
53
68
  projects: '/projects',
69
+ projectDetails: '/projects/:projectName',
70
+ experiments: '/experiments',
71
+ experimentDetails: '/experiments/:value',
72
+ groups: '/groups',
73
+ groupDetails: '/groups/:value',
54
74
  agent: '/agent',
55
75
  janitor: '/janitor',
56
76
  setup: '/setup',
@@ -76,7 +96,12 @@ export function createBujangPaths(basePath: string = ''): BujangPaths {
76
96
  pipelines: () => `${b}/pipelines`,
77
97
  pipelineDetails: (name, runId) => `${b}/pipelines/${seg(name)}${runId ? `?run=${encodeURIComponent(runId)}` : ''}`,
78
98
  scheduled: () => `${b}/scheduled`,
79
- projects: (name) => `${b}/projects${name ? `#${encodeURIComponent(`project-${name}`)}` : ''}`,
99
+ projects: (section) => `${b}/projects${section ? `#${encodeURIComponent(section)}` : ''}`,
100
+ projectDetails: (name) => `${b}/projects/${seg(name)}`,
101
+ experiments: () => `${b}/experiments`,
102
+ experimentDetails: (value) => `${b}/experiments/${seg(value)}`,
103
+ groups: () => `${b}/groups`,
104
+ groupDetails: (value) => `${b}/groups/${seg(value)}`,
80
105
  agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
81
106
  janitor: (section) => `${b}/janitor${section ? `#${encodeURIComponent(section)}` : ''}`,
82
107
  settings: (section) => `${b}/settings${section ? `#${encodeURIComponent(section)}` : ''}`,
@@ -92,17 +117,33 @@ export interface BujangNavItem {
92
117
  icon?: IconType;
93
118
  }
94
119
 
95
- /** Sidebar entries for the top-level bujang views. */
96
- export function bujangNavItems(paths: BujangPaths = createBujangPaths()): BujangNavItem[] {
97
- return [
120
+ /**
121
+ * Views a host opts into (bujangRoutes({ projects: true }), BujangProjectsNav): the Projects section links
122
+ * the jobs into local code repositories, which only makes sense where the server runs on the user's machine.
123
+ */
124
+ export const PROJECT_VIEWS: BujangView[] = ['projects', 'projectDetails'];
125
+
126
+ /** The experiments / groups pages (BujangOrganizerNav): opt-in too, bujangRoutes({ organizers: true }). */
127
+ export const ORGANIZER_VIEWS: BujangView[] = ['experiments', 'experimentDetails', 'groups', 'groupDetails'];
128
+
129
+ export const OPTIONAL_VIEWS: BujangView[] = [...PROJECT_VIEWS, ...ORGANIZER_VIEWS];
130
+
131
+ /** Sidebar entries for the top-level bujang views (the projects have their own section: BujangProjectsNav). */
132
+ export interface BujangNavOptions {
133
+ /** the Setup Guide entry (default true): a host that sets bujang up itself leaves it out */
134
+ setup?: boolean;
135
+ }
136
+
137
+ export function bujangNavItems(paths: BujangPaths = createBujangPaths(), options: BujangNavOptions = {}): BujangNavItem[] {
138
+ const items: BujangNavItem[] = [
98
139
  { view: 'setup', label: 'Setup Guide', path: paths.setup(), icon: LuRocket },
99
140
  { view: 'jobs', label: 'Jobs', path: paths.jobs(), icon: LuList },
100
141
  { view: 'submitJob', label: 'Submit Job', path: paths.submitJob(), icon: LuSend },
101
142
  { view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled(), icon: LuCalendarClock },
102
143
  { view: 'pipelines', label: 'Pipelines', path: paths.pipelines(), icon: LuWorkflow },
103
- { view: 'projects', label: 'Projects', path: paths.projects(), icon: LuFolderGit2 },
104
144
  { view: 'agent', label: 'Agent Activity', path: paths.agent(), icon: LuBot },
105
145
  { view: 'janitor', label: 'Janitor', path: paths.janitor(), icon: LuBrush },
106
146
  { view: 'settings', label: 'Settings', path: paths.settings(), icon: LuSettings },
107
147
  ];
148
+ return items.filter((item) => item.view !== 'setup' || options.setup !== false);
108
149
  }
package/src/routes.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Route } from 'react-router-dom';
3
- import { defaultRoutePatterns, normalizeBasePath } from './paths';
3
+ import { ORGANIZER_VIEWS, PROJECT_VIEWS, defaultRoutePatterns, normalizeBasePath } from './paths';
4
4
  import type { BujangView } from './paths';
5
5
  import { JobsView } from './views/JobsView';
6
6
  import { JobSubmitView } from './views/JobSubmitView';
@@ -9,6 +9,8 @@ import { JobLogsView } from './views/JobLogs';
9
9
  import { PipelineDetailsView, PipelinesView } from './views/PipelinesView';
10
10
  import { ScheduledJobsView } from './views/ScheduledJobsView';
11
11
  import { ProjectsView } from './views/ProjectsView';
12
+ import { ProjectDetailsView } from './views/ProjectDetailsView';
13
+ import { OrganizerValueView, OrganizerValuesView } from './views/OrganizerValuesView';
12
14
  import { AgentActivityView } from './views/AgentActivityView';
13
15
  import { SettingsView } from './views/SettingsView';
14
16
  import { JanitorView } from './views/JanitorView';
@@ -17,8 +19,12 @@ import { SetupView } from './views/SetupView';
17
19
  export interface BujangRoutesOptions {
18
20
  /** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
19
21
  basePath?: string;
20
- /** Only mount these views (default: all). */
22
+ /** Only mount these views (default: all but the optional ones). */
21
23
  views?: BujangView[];
24
+ /** Mount the Projects views too (/projects, /projects/:projectName), see BujangProjectsNav. Default false. */
25
+ projects?: boolean;
26
+ /** Mount the experiments and groups pages too (/experiments[/:value], /groups[/:value]), see BujangOrganizerNav. */
27
+ organizers?: boolean;
22
28
  }
23
29
 
24
30
  /** A plain route object, usable with <Route>, useRoutes() or createBrowserRouter(). */
@@ -37,6 +43,11 @@ const elements: Record<BujangView, () => React.ReactElement> = {
37
43
  pipelineDetails: () => <PipelineDetailsView />,
38
44
  scheduled: () => <ScheduledJobsView />,
39
45
  projects: () => <ProjectsView />,
46
+ projectDetails: () => <ProjectDetailsView />,
47
+ experiments: () => <OrganizerValuesView organizer="experiments" />,
48
+ experimentDetails: () => <OrganizerValueView organizer="experiments" />,
49
+ groups: () => <OrganizerValuesView organizer="groups" />,
50
+ groupDetails: () => <OrganizerValueView organizer="groups" />,
40
51
  agent: () => <AgentActivityView />,
41
52
  janitor: () => <JanitorView />,
42
53
  setup: () => <SetupView />,
@@ -46,11 +57,15 @@ const elements: Record<BujangView, () => React.ReactElement> = {
46
57
  /**
47
58
  * Route objects for the default bujang URL layout under `basePath`:
48
59
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
49
- * /pipelines, /pipelines/:pipelineName, /scheduled, /projects, /agent, /janitor, /setup, /settings.
60
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings; with `projects`,
61
+ * /projects and /projects/:projectName.
50
62
  */
51
63
  export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
52
64
  const base = normalizeBasePath(options.basePath);
53
- const views = options.views ?? (Object.keys(defaultRoutePatterns) as BujangView[]);
65
+ const views = options.views
66
+ ?? (Object.keys(defaultRoutePatterns) as BujangView[]).filter(
67
+ (v) => (options.projects || !PROJECT_VIEWS.includes(v)) && (options.organizers || !ORGANIZER_VIEWS.includes(v)),
68
+ );
54
69
  return views.map((id) => ({
55
70
  id,
56
71
  path: `${base}${defaultRoutePatterns[id]}`,
package/src/types.ts CHANGED
@@ -923,6 +923,26 @@ export interface OrganizerGroups {
923
923
  groups: { value: string; jobs: string[] }[];
924
924
  }
925
925
 
926
+ /** One value of an organizer (an experiment, a group): its jobs and when they ran */
927
+ export interface OrganizerValue {
928
+ value: string;
929
+ /** how many jobs (pipeline runs and their steps count) */
930
+ jobs: number;
931
+ /** the oldest job folder (seconds) */
932
+ first: number | null;
933
+ /** the last change of one of its job folders (seconds) */
934
+ last: number | null;
935
+ }
936
+
937
+ /** GET /organizers/<name>/values: a page of the values */
938
+ export interface OrganizerValuesPage {
939
+ organizer: string;
940
+ total: number;
941
+ offset: number;
942
+ limit: number;
943
+ values: OrganizerValue[];
944
+ }
945
+
926
946
  /** A code repository registered as a project: its jobs are linked into `target` (GET /projects) */
927
947
  export interface Project {
928
948
  name: string;
@@ -930,8 +950,14 @@ export interface Project {
930
950
  path: string;
931
951
  /** folder inside the repository, relative ("bujang") */
932
952
  folder: string;
933
- /** path/folder: where the job links are */
953
+ /** path/folder: the bujang folder of the project (its config, jobs/) */
934
954
  target: string;
955
+ /** target/jobs: where the job links are */
956
+ jobs_dir: string;
957
+ /** its own scripts, pipelines and profiles, named "<project>:<name>" */
958
+ templates: string[];
959
+ pipelines: string[];
960
+ profiles: string[];
935
961
  created: number | null;
936
962
  /** the repository folder exists */
937
963
  exists: boolean;
@@ -996,6 +1022,8 @@ export type OverviewBlock =
996
1022
  | { kind: 'artifacts'; title?: string; files?: string }
997
1023
  | { kind: 'files'; title?: string }
998
1024
  | { kind: 'stats'; title?: string; metrics?: StatsMetric[]; show?: StatName[] }
1025
+ /** a row per job: its arguments (`args`: their names; absent: the ones that differ), its state, the `metrics` */
1026
+ | { kind: 'compare'; title?: string; metrics?: CompareMetric[]; args?: string[] }
999
1027
  | { kind: 'logs'; title?: string; levels?: string[]; files?: string }
1000
1028
  | {
1001
1029
  kind: 'chart';
@@ -1034,7 +1062,48 @@ export interface OverviewLayout {
1034
1062
  panels: OverviewPanel[];
1035
1063
  }
1036
1064
 
1037
- export type OverviewScope = 'experiment' | 'script';
1065
+ /** A collection of jobs with an Overview of its own (the jobs compared): its organizer */
1066
+ export type CollectionScope = 'experiments' | 'groups' | 'projects';
1067
+
1068
+ export type OverviewScope = 'experiment' | 'script' | CollectionScope;
1069
+
1070
+ /** A job of a collection (GET /collections/<organizer>/<value>/data) */
1071
+ export interface CollectionJob {
1072
+ jr_job_id: string;
1073
+ label: string | null;
1074
+ state: string;
1075
+ settled: boolean;
1076
+ cluster: string | null;
1077
+ created: number | null;
1078
+ /** the arguments of its script (arguments.json) */
1079
+ args: Record<string, unknown>;
1080
+ }
1081
+
1082
+ /** What a compare block shows of a field, per job */
1083
+ export type CompareStat = 'last' | 'first' | 'min' | 'max' | 'mean' | 'count';
1084
+
1085
+ /** A column of a compare block: a statistic of a number field of an event */
1086
+ export interface CompareMetric {
1087
+ event: string;
1088
+ field: string;
1089
+ stat?: CompareStat;
1090
+ title?: string;
1091
+ /** conditional formatting: a color scale over the column, its better end green */
1092
+ scale?: CompareScale;
1093
+ /** conditional formatting: the first rule a value matches colors its cell (before the scale) */
1094
+ rules?: CompareRule[];
1095
+ }
1096
+
1097
+ export type CompareScale = 'higher' | 'lower';
1098
+ export type CompareRuleOp = '<' | '<=' | '>' | '>=' | '==' | '!=';
1099
+ export type CompareRuleColor = 'good' | 'bad' | 'warn' | 'info';
1100
+
1101
+ /** A conditional format of a compare column: `value <op> <value>` colors the cell */
1102
+ export interface CompareRule {
1103
+ op: CompareRuleOp;
1104
+ value: number;
1105
+ color: CompareRuleColor;
1106
+ }
1038
1107
 
1039
1108
  /** GET /jobs/<jr>/overview/layout */
1040
1109
  export interface JobOverviewLayout {
@@ -1047,8 +1116,8 @@ export interface JobOverviewLayout {
1047
1116
  source: { kind: OverviewScope | 'file' | 'plugin' | 'setting' | 'default'; name: string | null };
1048
1117
  /** the charts of the built-in layout, to add to this one */
1049
1118
  blocks: OverviewBlock[];
1050
- /** what a layout can be saved for */
1051
- keys: { experiment: string | null; script: string };
1119
+ /** what a layout can be saved for; `collection`: the Overview of an experiment / group / project */
1120
+ keys: { experiment: string | null; script: string; collection?: { scope: CollectionScope; key: string } };
1052
1121
  }
1053
1122
 
1054
1123
  /** GET /overview/layouts */
@@ -1062,16 +1131,18 @@ export interface SavedOverviewLayout {
1062
1131
  /** What an event of a JSONL file is for: plotted, shown in the log view, or neither */
1063
1132
  export type JobDataRole = 'metric' | 'log' | 'other';
1064
1133
 
1065
- /** GET /jobs/<jr>/data: the JSONL files of the artifact folders of a job and their schema */
1134
+ /** GET /jobs/<jr>/data: the data files of the artifact folders of a job and their schema */
1066
1135
  export interface JobData {
1067
1136
  jr_job_id: string;
1068
1137
  folders: string[];
1138
+ /** the Overview of a collection: its jobs (their files are under "<job id>/") */
1139
+ jobs?: CollectionJob[];
1069
1140
  files: {
1070
1141
  path: string;
1071
1142
  size?: number;
1072
1143
  mtime?: number;
1073
1144
  rows?: number;
1074
- /** the JSONL processor that read the file ("generic", or one of a plugin) */
1145
+ /** the data processor that read the file ("jsonl", or one of a plugin: "csv", ...) */
1075
1146
  processor?: string;
1076
1147
  /** per event ("" for the records without an event envelope), its role, row count and fields */
1077
1148
  events?: { event: string; role: JobDataRole; count: number; truncated: boolean; fields: JobDataField[] }[];
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { useSearchParams } from 'react-router-dom';
3
+ import { Box, Button, Group, Heading, HStack, VStack } from '@chakra-ui/react';
4
+ import { LuChartLine, LuList } from 'react-icons/lu';
5
+ import { collectionId } from '../api';
6
+ import type { CollectionScope } from '../types';
7
+ import { usePageTitle } from '../hooks/usePageTitle';
8
+ import { JobDataOverview } from './JobDataOverview';
9
+
10
+ export type CollectionTab = 'jobs' | 'overview';
11
+
12
+ /** The tab of a collection page (experiment, group, project), in the URL: the Overview, else ?view=jobs */
13
+ export function useCollectionTab(): [CollectionTab, (tab: CollectionTab) => void] {
14
+ const [params, setParams] = useSearchParams();
15
+ const tab: CollectionTab = params.get('view') === 'jobs' ? 'jobs' : 'overview';
16
+ const setTab = (next: CollectionTab) => {
17
+ const out = new URLSearchParams(params);
18
+ if (next === 'jobs') out.set('view', 'jobs');
19
+ else out.delete('view');
20
+ setParams(out, { replace: true });
21
+ };
22
+ return [tab, setTab];
23
+ }
24
+
25
+ /** Overview | Jobs */
26
+ export const CollectionTabs: React.FC<{ tab: CollectionTab; onTab: (tab: CollectionTab) => void }> = ({ tab, onTab }) => (
27
+ <Group attached>
28
+ {([['overview', 'Overview', LuChartLine], ['jobs', 'Jobs', LuList]] as const).map(([key, label, Icon]) => (
29
+ <Button
30
+ key={key}
31
+ size="xs"
32
+ variant={tab === key ? 'solid' : 'outline'}
33
+ bg={tab === key ? 'var(--color-primary)' : undefined}
34
+ color={tab === key ? 'var(--color-primary-text)' : 'var(--color-text)'}
35
+ onClick={() => onTab(key)}
36
+ aria-pressed={tab === key}
37
+ >
38
+ <Icon /> {label}
39
+ </Button>
40
+ ))}
41
+ </Group>
42
+ );
43
+
44
+ /**
45
+ * The Overview of a collection: the panels of a job's Overview over the data of all its jobs (a line per
46
+ * job, the jobs compared in a table), with a layout of its own (a project's in its repository).
47
+ */
48
+ export const CollectionOverview: React.FC<{
49
+ organizer: CollectionScope;
50
+ value: string;
51
+ title: React.ReactNode;
52
+ pageTitle: string;
53
+ /** under the heading: the tabs, links */
54
+ header?: React.ReactNode;
55
+ }> = ({ organizer, value, title, pageTitle, header }) => {
56
+ usePageTitle(`${pageTitle} · Overview`);
57
+ return (
58
+ <Box p={6} h="100%" bg="var(--color-bg-page)" overflowY="auto">
59
+ <VStack align="stretch" gap={4}>
60
+ <HStack gap={3}>
61
+ <Heading size="xl" fontWeight="bold" color="var(--color-text)">{title}</Heading>
62
+ </HStack>
63
+ {header}
64
+ <JobDataOverview key={`${organizer}/${value}`} jrJobId={collectionId(organizer, value)} />
65
+ </VStack>
66
+ </Box>
67
+ );
68
+ };
@@ -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
  };
@@ -522,6 +522,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
522
522
 
523
523
  const handleTemplateSelect = (templateName: string) => {
524
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);
525
528
  if (templateName && templates?.includes(templateName)) {
526
529
  loadTemplateMutation.mutate(templateName);
527
530
  }
@@ -245,11 +245,26 @@ interface Column {
245
245
  label: string;
246
246
  /** 'values': tick any of the values in the rows; 'text': a substring */
247
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[];
248
250
  /** what the filter looks at */
249
251
  text: (r: JobRow) => string;
250
252
  sort: (r: JobRow) => string | number | null;
251
253
  }
252
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
+
253
268
  const COLUMNS: Column[] = [
254
269
  { id: 'jobId', label: 'Job ID', filter: 'text', text: (r) => r.jobId, sort: (r) => (Number.isFinite(+r.jobId) ? +r.jobId : r.jobId) },
255
270
  { id: 'jrJobId', label: 'JR Job ID', filter: 'text', text: (r) => r.jrJobId ?? '', sort: (r) => r.jrJobId },
@@ -268,7 +283,14 @@ const COLUMNS: Column[] = [
268
283
  // the jobs outside a pipeline last
269
284
  sort: (r) => r.pipeline?.run_id ?? null,
270
285
  },
271
- { 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
+ },
272
294
  { id: 'cluster', label: 'Cluster', filter: 'values', text: (r) => r.cluster, sort: (r) => r.cluster },
273
295
  { id: 'partition', label: 'Partition', filter: 'values', text: (r) => r.partition, sort: (r) => r.partition },
274
296
  { id: 'user', label: 'User', filter: 'text', text: (r) => r.user, sort: (r) => r.user },
@@ -454,10 +476,16 @@ export const JobsTable: React.FC<JobsTableProps & { cardProps?: React.ComponentP
454
476
  const options = React.useMemo(() => {
455
477
  const out: Partial<Record<ColumnId, string[]>> = {};
456
478
  for (const c of COLUMNS) {
457
- 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)];
458
486
  }
459
487
  return out;
460
- }, [rows]);
488
+ }, [rows, filters]);
461
489
 
462
490
  const shown = React.useMemo(() => {
463
491
  const active = COLUMNS.filter((c) => isSet(filters[c.id]));
@@ -671,14 +699,24 @@ const JobRowView: React.FC<{
671
699
  />
672
700
  </Tooltip>
673
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>
674
706
  <Text fontWeight="semibold" color="var(--color-text)">
675
707
  {row.jobId}
676
708
  </Text>
677
- <AgentBadge tag={row.agent} />
678
709
  </HStack>
679
710
  </Table.Cell>
680
- <Table.Cell>
681
- <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
+ >
682
720
  {row.jrJobId}
683
721
  </Text>
684
722
  </Table.Cell>