@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
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import { NavLink } from 'react-router-dom';
3
+ import { Box, HStack, Text, VStack } from '@chakra-ui/react';
4
+ import { useQuery } from '@tanstack/react-query';
5
+ import type { IconType } from 'react-icons';
6
+ import { LuFlaskConical, LuTags } from 'react-icons/lu';
7
+ import { getOrganizerValues } from '../api';
8
+ import type { BujangPaths } from '../paths';
9
+ import type { OrganizerValuesPage } from '../types';
10
+ import { useBujangPaths } from '../context';
11
+ import { Tooltip } from './tooltip';
12
+
13
+ /** The organizers with a page of their own: their labels, icons and links */
14
+ export interface OrganizerPage {
15
+ label: string;
16
+ /** one of them ("experiment") */
17
+ singular: string;
18
+ icon: IconType;
19
+ list: (paths: BujangPaths) => string;
20
+ detail: (paths: BujangPaths, value: string) => string;
21
+ }
22
+
23
+ export const ORGANIZER_PAGES: Record<'experiments' | 'groups', OrganizerPage> = {
24
+ experiments: {
25
+ label: 'Experiments',
26
+ singular: 'experiment',
27
+ icon: LuFlaskConical,
28
+ list: (p) => p.experiments(),
29
+ detail: (p, v) => p.experimentDetails(v),
30
+ },
31
+ groups: {
32
+ label: 'Groups',
33
+ singular: 'group',
34
+ icon: LuTags,
35
+ list: (p) => p.groups(),
36
+ detail: (p, v) => p.groupDetails(v),
37
+ },
38
+ };
39
+
40
+ export interface BujangOrganizerNavProps {
41
+ /** "experiments" or "groups" */
42
+ organizer: keyof typeof ORGANIZER_PAGES;
43
+ /** how many values to show, the most recent first (default 5) */
44
+ limit?: number;
45
+ /** icons only (a collapsed side panel) */
46
+ collapsed?: boolean;
47
+ /** called when a link is followed (close a drawer) */
48
+ onNavigate?: () => void;
49
+ }
50
+
51
+ const itemStyle = (isActive: boolean, collapsed: boolean) => ({
52
+ gap: 3,
53
+ px: collapsed ? 0 : 3,
54
+ py: 1.5,
55
+ justify: collapsed ? 'center' : 'flex-start',
56
+ borderRadius: 'md',
57
+ fontSize: 'sm',
58
+ fontWeight: isActive ? 'semibold' : 'normal',
59
+ color: isActive ? 'var(--color-primary)' : 'var(--color-text)',
60
+ bg: isActive ? 'var(--color-bg-hover)' : 'transparent',
61
+ _hover: { bg: 'var(--color-bg-hover)' },
62
+ }) as const;
63
+
64
+ /**
65
+ * A sidebar section for the experiments or the groups: its header opens the page of all of them, then
66
+ * the most recent ones (5). Shows nothing while there are none. Opt-in: bujangRoutes({ organizers: true }).
67
+ */
68
+ export const BujangOrganizerNav: React.FC<BujangOrganizerNavProps> = ({ organizer, limit = 5, collapsed = false, onNavigate }) => {
69
+ const paths = useBujangPaths();
70
+ const page = ORGANIZER_PAGES[organizer];
71
+ const { data } = useQuery<OrganizerValuesPage>({
72
+ queryKey: ['bujang-organizer-values', organizer, 'nav', limit],
73
+ queryFn: () => getOrganizerValues(organizer, { sort: 'last', limit }),
74
+ staleTime: 30_000,
75
+ refetchInterval: 60_000,
76
+ retry: false,
77
+ });
78
+ if (!data || data.total === 0) return null;
79
+ const Icon = page.icon;
80
+
81
+ return (
82
+ <Box>
83
+ {collapsed ? (
84
+ <Box borderTopWidth="1px" borderColor="var(--color-border)" mx={2} mb={1} />
85
+ ) : (
86
+ <HStack justify="space-between" px={3} mb={1}>
87
+ <NavLink to={page.list(paths)} end onClick={onNavigate}>
88
+ <Text fontSize="xs" fontWeight="semibold" letterSpacing="wide" textTransform="uppercase"
89
+ color="var(--color-text-muted)" _hover={{ color: 'var(--color-text)' }}>
90
+ {page.label}
91
+ </Text>
92
+ </NavLink>
93
+ {data.total > data.values.length && (
94
+ <NavLink to={page.list(paths)} end onClick={onNavigate}>
95
+ <Text fontSize="xs" color="var(--color-text-muted)" _hover={{ color: 'var(--color-text)' }}>
96
+ all {data.total}
97
+ </Text>
98
+ </NavLink>
99
+ )}
100
+ </HStack>
101
+ )}
102
+ <VStack as="ul" align="stretch" gap={0.5} listStyleType="none" m={0} p={0}>
103
+ {data.values.map((v) => (
104
+ <li key={v.value}>
105
+ <Tooltip content={collapsed ? `${page.singular} ${v.value}` : `${v.jobs} jobs`} positioning={{ placement: 'right' }} showArrow>
106
+ <NavLink to={page.detail(paths, v.value)} onClick={onNavigate} aria-label={collapsed ? v.value : undefined}>
107
+ {({ isActive }) => (
108
+ <HStack {...itemStyle(isActive, collapsed)}>
109
+ <Icon size={16} />
110
+ {!collapsed && <Text as="span" truncate flex={1}>{v.value}</Text>}
111
+ {!collapsed && <Text as="span" fontSize="xs" color="var(--color-text-muted)">{v.jobs}</Text>}
112
+ </HStack>
113
+ )}
114
+ </NavLink>
115
+ </Tooltip>
116
+ </li>
117
+ ))}
118
+ </VStack>
119
+ </Box>
120
+ );
121
+ };
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import { NavLink } from 'react-router-dom';
3
+ import { Box, HStack, IconButton, Text, VStack } from '@chakra-ui/react';
4
+ import { useQuery } from '@tanstack/react-query';
5
+ import { LuFolderGit2, LuPlus } from 'react-icons/lu';
6
+ import { getProjects } from '../api';
7
+ import type { ProjectsInfo } from '../types';
8
+ import { useBujangPaths } from '../context';
9
+ import { Tooltip } from './tooltip';
10
+
11
+ /** The registered projects (GET /projects), shared with the Projects pages */
12
+ export function useBujangProjects() {
13
+ return useQuery<ProjectsInfo>({ queryKey: ['bujang-projects'], queryFn: getProjects, staleTime: 30_000, retry: false });
14
+ }
15
+
16
+ export interface BujangProjectsNavProps {
17
+ /** icons only (a collapsed side panel) */
18
+ collapsed?: boolean;
19
+ /** called when a link is followed (close a drawer) */
20
+ onNavigate?: () => void;
21
+ }
22
+
23
+ const itemStyle = (isActive: boolean, collapsed: boolean) => ({
24
+ gap: 3,
25
+ px: collapsed ? 0 : 3,
26
+ py: 1.5,
27
+ justify: collapsed ? 'center' : 'flex-start',
28
+ borderRadius: 'md',
29
+ fontSize: 'sm',
30
+ fontWeight: isActive ? 'semibold' : 'normal',
31
+ color: isActive ? 'var(--color-primary)' : 'var(--color-text)',
32
+ bg: isActive ? 'var(--color-bg-hover)' : 'transparent',
33
+ _hover: { bg: 'var(--color-bg-hover)' },
34
+ }) as const;
35
+
36
+ /**
37
+ * A sidebar section of its own: "Projects" (the Projects page), a + to register a repository, and a
38
+ * quick link to each project (its jobs). Opt-in: mount it with `bujangRoutes({ projects: true })`.
39
+ */
40
+ export const BujangProjectsNav: React.FC<BujangProjectsNavProps> = ({ collapsed = false, onNavigate }) => {
41
+ const paths = useBujangPaths();
42
+ const { data } = useBujangProjects();
43
+ const projects = data?.projects ?? [];
44
+
45
+ return (
46
+ <Box>
47
+ <HStack justify={collapsed ? 'center' : 'space-between'} px={collapsed ? 0 : 3} mb={1}>
48
+ {collapsed ? (
49
+ <Box borderTopWidth="1px" borderColor="var(--color-border)" w="100%" />
50
+ ) : (
51
+ <NavLink to={paths.projects()} end onClick={onNavigate}>
52
+ <Text fontSize="xs" fontWeight="semibold" letterSpacing="wide" textTransform="uppercase"
53
+ color="var(--color-text-muted)" _hover={{ color: 'var(--color-text)' }}>
54
+ Projects
55
+ </Text>
56
+ </NavLink>
57
+ )}
58
+ {!collapsed && data?.writable !== false && (
59
+ <Tooltip content="Register a repository" positioning={{ placement: 'right' }} showArrow>
60
+ <NavLink to={paths.projects('register')} onClick={onNavigate} aria-label="Register a repository">
61
+ <IconButton as="span" aria-label="Register a repository" size="2xs" variant="ghost" color="var(--color-text-muted)">
62
+ <LuPlus />
63
+ </IconButton>
64
+ </NavLink>
65
+ </Tooltip>
66
+ )}
67
+ </HStack>
68
+ <VStack as="ul" align="stretch" gap={0.5} listStyleType="none" m={0} p={0}>
69
+ {collapsed && (
70
+ <li>
71
+ <Tooltip content="Projects" positioning={{ placement: 'right' }} showArrow>
72
+ <NavLink to={paths.projects()} end onClick={onNavigate} aria-label="Projects">
73
+ {({ isActive }) => <HStack {...itemStyle(isActive, true)}><LuPlus size={16} /></HStack>}
74
+ </NavLink>
75
+ </Tooltip>
76
+ </li>
77
+ )}
78
+ {projects.map((p) => (
79
+ <li key={p.name}>
80
+ <Tooltip content={collapsed ? p.name : p.path} positioning={{ placement: 'right' }} showArrow>
81
+ <NavLink to={paths.projectDetails(p.name)} onClick={onNavigate} aria-label={collapsed ? p.name : undefined}>
82
+ {({ isActive }) => (
83
+ <HStack {...itemStyle(isActive, collapsed)}>
84
+ <LuFolderGit2 size={16} color={p.exists ? undefined : 'var(--color-status-failed)'} />
85
+ {!collapsed && <Text as="span" truncate flex={1}>{p.name}</Text>}
86
+ {!collapsed && p.jobs > 0 && (
87
+ <Text as="span" fontSize="xs" color="var(--color-text-muted)">{p.jobs}</Text>
88
+ )}
89
+ </HStack>
90
+ )}
91
+ </NavLink>
92
+ </Tooltip>
93
+ </li>
94
+ ))}
95
+ {!collapsed && projects.length === 0 && data && (
96
+ <Text px={3} fontSize="xs" color="var(--color-text-muted)" fontStyle="italic">none yet</Text>
97
+ )}
98
+ </VStack>
99
+ </Box>
100
+ );
101
+ };
package/src/index.ts CHANGED
@@ -7,6 +7,15 @@ 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';
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';
10
19
  export { AgentActivityView, AgentBadge, McpHelp } from './views/AgentActivityView';
11
20
  export { SettingsView } from './views/SettingsView';
12
21
  export { JanitorView } from './views/JanitorView';
@@ -21,8 +30,8 @@ export { JobImportantButton, JobGroupsButton, JobImportantStar } from './views/J
21
30
  // Provider, paths, routes
22
31
  export { BujangProvider, useBujang, useBujangPaths } from './context';
23
32
  export type { BujangProviderProps, BujangContextValue } from './context';
24
- export { createBujangPaths, defaultRoutePatterns, normalizeBasePath, bujangNavItems } from './paths';
25
- 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';
26
35
  export { bujangRoutes, bujangRouteElements } from './routes';
27
36
  export type { BujangRoutesOptions, BujangRouteObject } from './routes';
28
37
 
package/src/paths.ts CHANGED
@@ -10,6 +10,12 @@ export type BujangView =
10
10
  | 'pipelines'
11
11
  | 'pipelineDetails'
12
12
  | 'scheduled'
13
+ | 'projects'
14
+ | 'projectDetails'
15
+ | 'experiments'
16
+ | 'experimentDetails'
17
+ | 'groups'
18
+ | 'groupDetails'
13
19
  | 'agent'
14
20
  | 'janitor'
15
21
  | 'setup'
@@ -25,6 +31,18 @@ export interface BujangPaths {
25
31
  /** One saved pipeline: its graph and its runs, `runId` shows that run. */
26
32
  pipelineDetails: (name: string, runId?: string) => string;
27
33
  scheduled: () => string;
34
+ /** Registered code repositories and the jobs linked into them. `name` links to one project's card. */
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;
28
46
  /** Agent activity, optionally filtered on one session. */
29
47
  agent: (session?: string) => string;
30
48
  /** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
@@ -47,6 +65,12 @@ export const defaultRoutePatterns: Record<BujangView, string> = {
47
65
  pipelines: '/pipelines',
48
66
  pipelineDetails: '/pipelines/:pipelineName',
49
67
  scheduled: '/scheduled',
68
+ projects: '/projects',
69
+ projectDetails: '/projects/:projectName',
70
+ experiments: '/experiments',
71
+ experimentDetails: '/experiments/:value',
72
+ groups: '/groups',
73
+ groupDetails: '/groups/:value',
50
74
  agent: '/agent',
51
75
  janitor: '/janitor',
52
76
  setup: '/setup',
@@ -72,6 +96,12 @@ export function createBujangPaths(basePath: string = ''): BujangPaths {
72
96
  pipelines: () => `${b}/pipelines`,
73
97
  pipelineDetails: (name, runId) => `${b}/pipelines/${seg(name)}${runId ? `?run=${encodeURIComponent(runId)}` : ''}`,
74
98
  scheduled: () => `${b}/scheduled`,
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)}`,
75
105
  agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
76
106
  janitor: (section) => `${b}/janitor${section ? `#${encodeURIComponent(section)}` : ''}`,
77
107
  settings: (section) => `${b}/settings${section ? `#${encodeURIComponent(section)}` : ''}`,
@@ -87,9 +117,25 @@ export interface BujangNavItem {
87
117
  icon?: IconType;
88
118
  }
89
119
 
90
- /** Sidebar entries for the top-level bujang views. */
91
- export function bujangNavItems(paths: BujangPaths = createBujangPaths()): BujangNavItem[] {
92
- 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[] = [
93
139
  { view: 'setup', label: 'Setup Guide', path: paths.setup(), icon: LuRocket },
94
140
  { view: 'jobs', label: 'Jobs', path: paths.jobs(), icon: LuList },
95
141
  { view: 'submitJob', label: 'Submit Job', path: paths.submitJob(), icon: LuSend },
@@ -99,4 +145,5 @@ export function bujangNavItems(paths: BujangPaths = createBujangPaths()): Bujang
99
145
  { view: 'janitor', label: 'Janitor', path: paths.janitor(), icon: LuBrush },
100
146
  { view: 'settings', label: 'Settings', path: paths.settings(), icon: LuSettings },
101
147
  ];
148
+ return items.filter((item) => item.view !== 'setup' || options.setup !== false);
102
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';
@@ -8,6 +8,9 @@ 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';
12
+ import { ProjectDetailsView } from './views/ProjectDetailsView';
13
+ import { OrganizerValueView, OrganizerValuesView } from './views/OrganizerValuesView';
11
14
  import { AgentActivityView } from './views/AgentActivityView';
12
15
  import { SettingsView } from './views/SettingsView';
13
16
  import { JanitorView } from './views/JanitorView';
@@ -16,8 +19,12 @@ import { SetupView } from './views/SetupView';
16
19
  export interface BujangRoutesOptions {
17
20
  /** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
18
21
  basePath?: string;
19
- /** Only mount these views (default: all). */
22
+ /** Only mount these views (default: all but the optional ones). */
20
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;
21
28
  }
22
29
 
23
30
  /** A plain route object, usable with <Route>, useRoutes() or createBrowserRouter(). */
@@ -35,6 +42,12 @@ const elements: Record<BujangView, () => React.ReactElement> = {
35
42
  pipelines: () => <PipelinesView />,
36
43
  pipelineDetails: () => <PipelineDetailsView />,
37
44
  scheduled: () => <ScheduledJobsView />,
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" />,
38
51
  agent: () => <AgentActivityView />,
39
52
  janitor: () => <JanitorView />,
40
53
  setup: () => <SetupView />,
@@ -44,11 +57,15 @@ const elements: Record<BujangView, () => React.ReactElement> = {
44
57
  /**
45
58
  * Route objects for the default bujang URL layout under `basePath`:
46
59
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
47
- * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings.
60
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings; with `projects`,
61
+ * /projects and /projects/:projectName.
48
62
  */
49
63
  export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
50
64
  const base = normalizeBasePath(options.basePath);
51
- 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
+ );
52
69
  return views.map((id) => ({
53
70
  id,
54
71
  path: `${base}${defaultRoutePatterns[id]}`,
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,67 @@ export interface OrganizerGroups {
917
923
  groups: { value: string; jobs: string[] }[];
918
924
  }
919
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
+
946
+ /** A code repository registered as a project: its jobs are linked into `target` (GET /projects) */
947
+ export interface Project {
948
+ name: string;
949
+ /** the repository on the machine of the bujang server */
950
+ path: string;
951
+ /** folder inside the repository, relative ("bujang") */
952
+ folder: string;
953
+ /** path/folder: the bujang folder of the project (its config, jobs/) */
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[];
961
+ created: number | null;
962
+ /** the repository folder exists */
963
+ exists: boolean;
964
+ /** it is a git repository */
965
+ git: boolean;
966
+ /** jobs tagged for the project (runs and their steps) */
967
+ jobs: number;
968
+ /** links in the repository folder */
969
+ links: number;
970
+ }
971
+
972
+ export interface ProjectsInfo {
973
+ projects: Project[];
974
+ /** folder used when a registration gives none (the `project_folder` setting) */
975
+ default_folder: string;
976
+ /** false: the `projects` organizer is not loaded (the `organizers` setting), nothing is linked */
977
+ enabled: boolean;
978
+ /** registering and removing need a server that allows edits (settings_writable) */
979
+ writable: boolean;
980
+ /** script argument that tags a job too (export BUJANG_PROJECT=<name>) */
981
+ argument: string;
982
+ }
983
+
984
+ /** POST /projects/sync: per project, the links added and removed (or the error) */
985
+ export type ProjectsSyncReport = Record<string, { added?: string[]; removed?: string[]; error?: string }>;
986
+
920
987
  /** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
921
988
  export interface JobArtifacts {
922
989
  jr_job_id: string;
@@ -955,6 +1022,8 @@ export type OverviewBlock =
955
1022
  | { kind: 'artifacts'; title?: string; files?: string }
956
1023
  | { kind: 'files'; title?: string }
957
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[] }
958
1027
  | { kind: 'logs'; title?: string; levels?: string[]; files?: string }
959
1028
  | {
960
1029
  kind: 'chart';
@@ -993,7 +1062,48 @@ export interface OverviewLayout {
993
1062
  panels: OverviewPanel[];
994
1063
  }
995
1064
 
996
- 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
+ }
997
1107
 
998
1108
  /** GET /jobs/<jr>/overview/layout */
999
1109
  export interface JobOverviewLayout {
@@ -1006,8 +1116,8 @@ export interface JobOverviewLayout {
1006
1116
  source: { kind: OverviewScope | 'file' | 'plugin' | 'setting' | 'default'; name: string | null };
1007
1117
  /** the charts of the built-in layout, to add to this one */
1008
1118
  blocks: OverviewBlock[];
1009
- /** what a layout can be saved for */
1010
- 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 } };
1011
1121
  }
1012
1122
 
1013
1123
  /** GET /overview/layouts */
@@ -1021,16 +1131,18 @@ export interface SavedOverviewLayout {
1021
1131
  /** What an event of a JSONL file is for: plotted, shown in the log view, or neither */
1022
1132
  export type JobDataRole = 'metric' | 'log' | 'other';
1023
1133
 
1024
- /** 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 */
1025
1135
  export interface JobData {
1026
1136
  jr_job_id: string;
1027
1137
  folders: string[];
1138
+ /** the Overview of a collection: its jobs (their files are under "<job id>/") */
1139
+ jobs?: CollectionJob[];
1028
1140
  files: {
1029
1141
  path: string;
1030
1142
  size?: number;
1031
1143
  mtime?: number;
1032
1144
  rows?: number;
1033
- /** 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", ...) */
1034
1146
  processor?: string;
1035
1147
  /** per event ("" for the records without an event envelope), its role, row count and fields */
1036
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
+ };