@milabench/bujang 0.1.19 → 0.1.21
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/README.md +16 -0
- package/dist/api.d.ts +16 -3
- package/dist/components/OrganizerNav.d.ts +28 -0
- package/dist/components/ProjectsNav.d.ts +15 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +6132 -5023
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +25 -3
- package/dist/routes.d.ts +7 -2
- package/dist/types.d.ts +77 -5
- package/dist/views/CollectionView.d.ts +22 -0
- package/dist/views/JobDataOverview.d.ts +1 -1
- package/dist/views/JobsView.d.ts +12 -1
- package/dist/views/LogDisplay.d.ts +2 -0
- package/dist/views/OrganizerValuesView.d.ts +13 -0
- package/dist/views/OverviewPanels.d.ts +13 -2
- package/dist/views/ProjectDetailsView.d.ts +3 -0
- package/dist/views/ProjectsView.d.ts +18 -0
- package/dist/views/dataCharts.d.ts +1 -1
- package/package.json +1 -1
- package/src/api.ts +36 -6
- package/src/components/OrganizerNav.tsx +121 -0
- package/src/components/ProjectsNav.tsx +101 -0
- package/src/index.ts +10 -2
- package/src/paths.ts +47 -6
- package/src/routes.tsx +19 -4
- package/src/types.ts +77 -6
- package/src/views/CollectionView.tsx +68 -0
- package/src/views/JanitorView.tsx +2 -1
- package/src/views/JobDataOverview.tsx +23 -6
- package/src/views/JobLogs.tsx +2 -1
- package/src/views/JobSubmit.tsx +68 -0
- package/src/views/JobsTable.tsx +44 -6
- package/src/views/JobsView.tsx +26 -9
- package/src/views/LogDisplay.tsx +5 -2
- package/src/views/OrganizerValuesView.tsx +207 -0
- package/src/views/OverviewPanels.tsx +531 -7
- package/src/views/ProjectDetailsView.tsx +112 -0
- package/src/views/ProjectsView.tsx +117 -8
- package/src/views/SetupView.tsx +39 -1
- package/src/views/dataCharts.tsx +1 -1
|
@@ -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
|
@@ -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,
|
|
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: (
|
|
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
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
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, /
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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"><organizer>/<value>/</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"><repo>/<folder>/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
|
|
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'
|
|
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
|
|
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
|
};
|
package/src/views/JobLogs.tsx
CHANGED
|
@@ -520,7 +520,8 @@ export const JobLogsView: React.FC<JobLogsViewProps> = () => {
|
|
|
520
520
|
description: result.error
|
|
521
521
|
|| 'Could not sync job results early. Job may not be running or compute node unavailable.',
|
|
522
522
|
type: 'warning',
|
|
523
|
-
|
|
523
|
+
// long enough to read the rsync error
|
|
524
|
+
duration: 15000,
|
|
524
525
|
});
|
|
525
526
|
}
|
|
526
527
|
} catch (error) {
|