@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/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 +6140 -5101
- 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/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/JobSubmit.tsx +3 -0
- package/src/views/JobsTable.tsx +44 -6
- package/src/views/JobsView.tsx +26 -9
- 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/dataCharts.tsx +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
3
|
+
import { Badge, Box, Button, Code, HStack, Spinner, Text } from '@chakra-ui/react';
|
|
4
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { LuFolderGit2, LuLink, LuRefreshCw } from 'react-icons/lu';
|
|
6
|
+
import { getProjects, syncProjects } from '../api';
|
|
7
|
+
import type { ApiError, ProjectsInfo } from '../types';
|
|
8
|
+
import { toaster } from '../toast';
|
|
9
|
+
import { useBujangPaths } from '../context';
|
|
10
|
+
import { JobsView } from './JobsView';
|
|
11
|
+
import { CollectionOverview, CollectionTabs, useCollectionTab } from './CollectionView';
|
|
12
|
+
import { PROJECTS_KEY, ProjectArchive, ProjectCard } from './ProjectsView';
|
|
13
|
+
import type { Project } from '../types';
|
|
14
|
+
|
|
15
|
+
/** How many scripts / pipelines / profiles the project has (the details list them) */
|
|
16
|
+
const ProjectConfigInline: React.FC<{ project: Project }> = ({ project }) => {
|
|
17
|
+
const n = (items?: string[]) => items?.length ?? 0;
|
|
18
|
+
return (
|
|
19
|
+
<Text as="span" fontSize="xs">
|
|
20
|
+
{n(project.templates)} scripts · {n(project.pipelines)} pipelines · {n(project.profiles)} profiles
|
|
21
|
+
</Text>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The repository of a project under the heading of its jobs: where the links are, relink */
|
|
26
|
+
const ProjectStrip: React.FC<{ name: string; info: ProjectsInfo | undefined }> = ({ name, info }) => {
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const project = info?.projects.find((p) => p.name === name);
|
|
29
|
+
const sync = useMutation({
|
|
30
|
+
mutationFn: () => syncProjects(name),
|
|
31
|
+
onSuccess: (report) => {
|
|
32
|
+
const r = report[name] || {};
|
|
33
|
+
toaster.create({
|
|
34
|
+
title: r.error ? `Cannot link ${name}` : `${r.added?.length ?? 0} links added, ${r.removed?.length ?? 0} removed`,
|
|
35
|
+
description: r.error,
|
|
36
|
+
type: r.error ? 'error' : 'success',
|
|
37
|
+
});
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: PROJECTS_KEY });
|
|
39
|
+
},
|
|
40
|
+
onError: (error: ApiError) => toaster.create({ title: 'Relink failed', description: error.message, type: 'error' }),
|
|
41
|
+
});
|
|
42
|
+
if (!info) return <Spinner size="sm" />;
|
|
43
|
+
if (!project) return <Text color="var(--color-status-failed)">No project {name} is registered.</Text>;
|
|
44
|
+
return (
|
|
45
|
+
<HStack gap={3} wrap="wrap" fontSize="sm" color="var(--color-text-muted)">
|
|
46
|
+
<Code fontSize="xs">{project.target}</Code>
|
|
47
|
+
<ProjectConfigInline project={project} />
|
|
48
|
+
{!project.exists && <Badge colorPalette="red">repository missing</Badge>}
|
|
49
|
+
<Badge variant="subtle"><LuLink /> {project.links} links</Badge>
|
|
50
|
+
<Button size="xs" variant="ghost" loading={sync.isPending} onClick={() => sync.mutate()}><LuRefreshCw /> Relink</Button>
|
|
51
|
+
<ProjectArchive project={project} />
|
|
52
|
+
</HStack>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** One project: its repository, then the jobs page filtered on it */
|
|
57
|
+
export const ProjectDetailsView: React.FC = () => {
|
|
58
|
+
const { projectName = '' } = useParams();
|
|
59
|
+
const paths = useBujangPaths();
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
const { data: info } = useQuery<ProjectsInfo>({ queryKey: PROJECTS_KEY, queryFn: getProjects });
|
|
62
|
+
const project = info?.projects.find((p) => p.name === projectName);
|
|
63
|
+
const [details, setDetails] = React.useState(false);
|
|
64
|
+
const [tab, setTab] = useCollectionTab();
|
|
65
|
+
const title = <HStack gap={2} as="span"><LuFolderGit2 /> {projectName}</HStack>;
|
|
66
|
+
if (tab === 'overview') {
|
|
67
|
+
return (
|
|
68
|
+
<CollectionOverview
|
|
69
|
+
organizer="projects"
|
|
70
|
+
value={projectName}
|
|
71
|
+
title={title}
|
|
72
|
+
pageTitle={projectName}
|
|
73
|
+
header={
|
|
74
|
+
<HStack mt={-3} gap={4} wrap="wrap">
|
|
75
|
+
<CollectionTabs tab={tab} onTab={setTab} />
|
|
76
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
77
|
+
its layout is saved in the project folder: {project ? `${project.target}/layouts/overview.yaml` : 'layouts/overview.yaml'}
|
|
78
|
+
</Text>
|
|
79
|
+
</HStack>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<JobsView
|
|
87
|
+
key={projectName}
|
|
88
|
+
filters={{ projects: projectName }}
|
|
89
|
+
pageTitle={projectName}
|
|
90
|
+
title={title}
|
|
91
|
+
submitPath={`${paths.submitJob()}?project=${encodeURIComponent(projectName)}`}
|
|
92
|
+
header={
|
|
93
|
+
<Box mt={-3}>
|
|
94
|
+
<HStack gap={2} wrap="wrap">
|
|
95
|
+
<CollectionTabs tab={tab} onTab={setTab} />
|
|
96
|
+
<ProjectStrip name={projectName} info={info} />
|
|
97
|
+
{project && (
|
|
98
|
+
<Button size="xs" variant="ghost" onClick={() => setDetails(!details)}>
|
|
99
|
+
{details ? 'Hide details' : 'Details'}
|
|
100
|
+
</Button>
|
|
101
|
+
)}
|
|
102
|
+
</HStack>
|
|
103
|
+
{details && project && info && (
|
|
104
|
+
<Box mt={3}>
|
|
105
|
+
<ProjectCard project={project} writable={info.writable} onRemoved={() => navigate(paths.projects())} />
|
|
106
|
+
</Box>
|
|
107
|
+
)}
|
|
108
|
+
</Box>
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
2
|
+
import { Link, useNavigate } from 'react-router-dom';
|
|
3
3
|
import { Badge, Box, Button, Code, Heading, HStack, Input, Spinner, Text, VStack } from '@chakra-ui/react';
|
|
4
4
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { LuBot, LuFolderGit2, LuLink, LuPlus, LuRefreshCw, LuTrash2 } from 'react-icons/lu';
|
|
6
|
-
import { getProjects, registerProject, removeProject, syncProjects } from '../api';
|
|
7
|
-
import type { ApiError, Project, ProjectsInfo } from '../types';
|
|
5
|
+
import { LuArchive, LuBot, LuFolderGit2, LuLink, LuPlus, LuRefreshCw, LuTrash2 } from 'react-icons/lu';
|
|
6
|
+
import { getProjects, janitorArchive, registerProject, removeProject, syncProjects } from '../api';
|
|
7
|
+
import type { ApiError, JanitorArchiveResult, Project, ProjectsInfo } from '../types';
|
|
8
8
|
import { LinkableCard, useHashScroll } from '../components/LinkableCard';
|
|
9
9
|
import { Tooltip } from '../components/tooltip';
|
|
10
10
|
import { toaster } from '../toast';
|
|
11
11
|
import { useBujangPaths } from '../context';
|
|
12
12
|
import { usePageTitle } from '../hooks/usePageTitle';
|
|
13
13
|
|
|
14
|
-
const PROJECTS_KEY = ['bujang-projects'];
|
|
14
|
+
export const PROJECTS_KEY = ['bujang-projects'];
|
|
15
15
|
|
|
16
16
|
const inputStyle = {
|
|
17
17
|
bg: 'var(--color-input-bg)',
|
|
@@ -35,6 +35,8 @@ const Label: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
|
35
35
|
|
|
36
36
|
const RegisterCard: React.FC<{ info: ProjectsInfo }> = ({ info }) => {
|
|
37
37
|
const queryClient = useQueryClient();
|
|
38
|
+
const navigate = useNavigate();
|
|
39
|
+
const paths = useBujangPaths();
|
|
38
40
|
const [path, setPath] = useState('');
|
|
39
41
|
const [name, setName] = useState('');
|
|
40
42
|
const [folder, setFolder] = useState('');
|
|
@@ -49,6 +51,7 @@ const RegisterCard: React.FC<{ info: ProjectsInfo }> = ({ info }) => {
|
|
|
49
51
|
});
|
|
50
52
|
setPath(''); setName(''); setFolder('');
|
|
51
53
|
queryClient.invalidateQueries({ queryKey: PROJECTS_KEY });
|
|
54
|
+
navigate(paths.projectDetails(out.project.name));
|
|
52
55
|
},
|
|
53
56
|
onError: fail('Registration failed'),
|
|
54
57
|
});
|
|
@@ -98,7 +101,7 @@ const RegisterCard: React.FC<{ info: ProjectsInfo }> = ({ info }) => {
|
|
|
98
101
|
);
|
|
99
102
|
};
|
|
100
103
|
|
|
101
|
-
const ProjectCard: React.FC<{ project: Project; writable: boolean }> = ({ project, writable }) => {
|
|
104
|
+
export const ProjectCard: React.FC<{ project: Project; writable: boolean; onRemoved?: () => void }> = ({ project, writable, onRemoved }) => {
|
|
102
105
|
const paths = useBujangPaths();
|
|
103
106
|
const queryClient = useQueryClient();
|
|
104
107
|
const [confirm, setConfirm] = useState(false);
|
|
@@ -120,10 +123,11 @@ const ProjectCard: React.FC<{ project: Project; writable: boolean }> = ({ projec
|
|
|
120
123
|
onSuccess: (out) => {
|
|
121
124
|
toaster.create({ title: `Project ${project.name} removed`, description: `${out.removed.length} links removed from the repository`, type: 'success' });
|
|
122
125
|
queryClient.invalidateQueries({ queryKey: PROJECTS_KEY });
|
|
126
|
+
onRemoved?.();
|
|
123
127
|
},
|
|
124
128
|
onError: fail('Removal failed'),
|
|
125
129
|
});
|
|
126
|
-
const jobsLink =
|
|
130
|
+
const jobsLink = paths.projectDetails(project.name);
|
|
127
131
|
|
|
128
132
|
return (
|
|
129
133
|
<LinkableCard
|
|
@@ -159,8 +163,10 @@ const ProjectCard: React.FC<{ project: Project; writable: boolean }> = ({ projec
|
|
|
159
163
|
<Badge variant="subtle"><LuLink /> {project.links} links</Badge>
|
|
160
164
|
</HStack>
|
|
161
165
|
<Text color="var(--color-text-muted)">
|
|
162
|
-
|
|
166
|
+
bujang folder <Code fontSize="xs">{project.target}</Code>, jobs linked in <Code fontSize="xs">{project.jobs_dir}</Code>
|
|
163
167
|
</Text>
|
|
168
|
+
<ProjectConfig project={project} />
|
|
169
|
+
<ProjectArchive project={project} />
|
|
164
170
|
<Text color="var(--color-text-muted)">
|
|
165
171
|
Tag a job: <Code fontSize="xs">project="{project.name}"</Code> (MCP <Code fontSize="xs">submit_job</Code> /{' '}
|
|
166
172
|
<Code fontSize="xs">run_pipeline</Code>, the Submit page), or <Code fontSize="xs">export BUJANG_PROJECT={project.name}</Code> in the script.
|
|
@@ -170,6 +176,102 @@ const ProjectCard: React.FC<{ project: Project; writable: boolean }> = ({ projec
|
|
|
170
176
|
);
|
|
171
177
|
};
|
|
172
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Archive the jobs of a project: their folders move out of the local cache into the project's jobs/,
|
|
181
|
+
* where their links were (a preview first). Jobs not over or still on their cluster stay.
|
|
182
|
+
*/
|
|
183
|
+
export const ProjectArchive: React.FC<{ project: Project }> = ({ project }) => {
|
|
184
|
+
const queryClient = useQueryClient();
|
|
185
|
+
const [plan, setPlan] = useState<JanitorArchiveResult | null>(null);
|
|
186
|
+
const preview = useMutation({
|
|
187
|
+
mutationFn: () => janitorArchive({ organizer: 'projects', value: project.name, dry_run: true }),
|
|
188
|
+
onSuccess: setPlan,
|
|
189
|
+
onError: fail('Preview failed'),
|
|
190
|
+
});
|
|
191
|
+
const apply = useMutation({
|
|
192
|
+
mutationFn: () => janitorArchive({ organizer: 'projects', value: project.name, dry_run: false }),
|
|
193
|
+
onSuccess: (out) => {
|
|
194
|
+
setPlan(null);
|
|
195
|
+
toaster.create({
|
|
196
|
+
title: `Archived ${out.moved?.length ?? 0} job folders into ${project.jobs_dir}`,
|
|
197
|
+
description: out.skipped.length ? `${out.skipped.length} left where they are` : undefined,
|
|
198
|
+
type: 'success',
|
|
199
|
+
});
|
|
200
|
+
queryClient.invalidateQueries({ queryKey: PROJECTS_KEY });
|
|
201
|
+
},
|
|
202
|
+
onError: fail('Archive failed'),
|
|
203
|
+
});
|
|
204
|
+
const moving = plan?.would_move ?? [];
|
|
205
|
+
return (
|
|
206
|
+
<Box>
|
|
207
|
+
<Tooltip content="Move the job folders of the project into its repository, in place of their links" showArrow>
|
|
208
|
+
<Button size="xs" variant="ghost" loading={preview.isPending} onClick={() => preview.mutate()}>
|
|
209
|
+
<LuArchive /> Archive
|
|
210
|
+
</Button>
|
|
211
|
+
</Tooltip>
|
|
212
|
+
{plan && (
|
|
213
|
+
<VStack align="stretch" gap={2} mt={2} p={3} borderWidth="1px" borderRadius="md" borderColor="var(--color-border)" fontSize="sm">
|
|
214
|
+
{moving.length === 0
|
|
215
|
+
? <Text color="var(--color-text-muted)">Nothing to archive.</Text>
|
|
216
|
+
: (
|
|
217
|
+
<Text color="var(--color-text)">
|
|
218
|
+
{moving.length} job folders move into <Code fontSize="xs">{project.jobs_dir}</Code>: they leave the
|
|
219
|
+
local cache and live in the repository from then on (deleting them there deletes the jobs).
|
|
220
|
+
</Text>
|
|
221
|
+
)}
|
|
222
|
+
{plan.skipped.length > 0 && (
|
|
223
|
+
<Box maxH="120px" overflowY="auto" fontFamily="mono" fontSize="xs" color="var(--color-text-muted)">
|
|
224
|
+
{plan.skipped.map(s => <Box key={s.jr_job_id}>{s.jr_job_id}: {s.reason}</Box>)}
|
|
225
|
+
</Box>
|
|
226
|
+
)}
|
|
227
|
+
<HStack gap={2}>
|
|
228
|
+
{moving.length > 0 && (
|
|
229
|
+
<Button size="xs" colorPalette="blue" loading={apply.isPending} onClick={() => apply.mutate()}>
|
|
230
|
+
Move {moving.length} folders
|
|
231
|
+
</Button>
|
|
232
|
+
)}
|
|
233
|
+
<Button size="xs" variant="ghost" onClick={() => setPlan(null)}>Cancel</Button>
|
|
234
|
+
</HStack>
|
|
235
|
+
</VStack>
|
|
236
|
+
)}
|
|
237
|
+
</Box>
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/** The scripts, pipelines and profiles of a project (files of its bujang folder) */
|
|
242
|
+
export const ProjectConfig: React.FC<{ project: Project }> = ({ project }) => {
|
|
243
|
+
const paths = useBujangPaths();
|
|
244
|
+
const groups: [string, string[], (name: string) => string | null][] = [
|
|
245
|
+
['scripts', project.templates ?? [], (name) => `${paths.submitJob()}?template=${encodeURIComponent(name)}&project=${encodeURIComponent(project.name)}`],
|
|
246
|
+
['pipelines', project.pipelines ?? [], (name) => paths.pipelineDetails(name)],
|
|
247
|
+
['profiles', project.profiles ?? [], () => null],
|
|
248
|
+
];
|
|
249
|
+
const prefix = `${project.name}:`;
|
|
250
|
+
const empty = groups.every(([, items]) => items.length === 0);
|
|
251
|
+
return (
|
|
252
|
+
<VStack align="stretch" gap={1} color="var(--color-text-muted)">
|
|
253
|
+
{groups.map(([label, items, to]) => items.length > 0 && (
|
|
254
|
+
<HStack key={label} gap={2} wrap="wrap" align="baseline">
|
|
255
|
+
<Text fontSize="xs" fontWeight="semibold" w="70px">{label}</Text>
|
|
256
|
+
{items.map((item) => {
|
|
257
|
+
const short = item.startsWith(prefix) ? item.slice(prefix.length) : item;
|
|
258
|
+
const link = to(item);
|
|
259
|
+
const badge = <Badge key={item} variant="subtle" cursor={link ? 'pointer' : undefined} title={item}>{short}</Badge>;
|
|
260
|
+
return link ? <Link key={item} to={link}>{badge}</Link> : badge;
|
|
261
|
+
})}
|
|
262
|
+
</HStack>
|
|
263
|
+
))}
|
|
264
|
+
{empty && (
|
|
265
|
+
<Text fontSize="xs">
|
|
266
|
+
No scripts, pipelines or profiles yet: add <Code fontSize="xs">scripts/<cluster>/*.sh</Code>,{' '}
|
|
267
|
+
<Code fontSize="xs">scripts/<cluster>/pipeline/*.json</Code>, <Code fontSize="xs">profiles.yaml</Code> or{' '}
|
|
268
|
+
<Code fontSize="xs">clusters.yaml</Code> to the bujang folder, they are named <Code fontSize="xs">{prefix}<name></Code>.
|
|
269
|
+
</Text>
|
|
270
|
+
)}
|
|
271
|
+
</VStack>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
173
275
|
const AgentsCard: React.FC<{ argument: string }> = ({ argument }) => (
|
|
174
276
|
<LinkableCard id="agents" icon={<LuBot />} title="Coding agents" subtitle="how an agent working in a repository tags its jobs">
|
|
175
277
|
<VStack align="stretch" gap={2} fontSize="sm" color="var(--color-text-muted)">
|
|
@@ -179,6 +281,13 @@ const AgentsCard: React.FC<{ argument: string }> = ({ argument }) => (
|
|
|
179
281
|
<Code fontSize="xs">run_pipeline</Code>. The README bujang puts in the repository folder says the same, for an agent that
|
|
180
282
|
reads the repository first.
|
|
181
283
|
</Text>
|
|
284
|
+
<Text>
|
|
285
|
+
A project keeps its own scripts, pipelines and profiles in its bujang folder, named{' '}
|
|
286
|
+
<Code fontSize="xs"><project>:<name></Code>: an agent edits them as files of the repository (or with{' '}
|
|
287
|
+
<Code fontSize="xs">save_template</Code> / <Code fontSize="xs">save_pipeline</Code> / <Code fontSize="xs">save_profile</Code>{' '}
|
|
288
|
+
and <Code fontSize="xs">project=</Code>). Using one tags the job with the project; in a project pipeline a bare name finds
|
|
289
|
+
the project's first.
|
|
290
|
+
</Text>
|
|
182
291
|
<Text>
|
|
183
292
|
A job script can tag itself with <Code fontSize="xs">export {argument}=<name></Code>. A pipeline run tagged for a
|
|
184
293
|
project brings its steps (they show inside the run folder). An unknown project name is refused at submission.
|
package/src/views/dataCharts.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Charts of the
|
|
1
|
+
/** Charts of the data files of a job: the chart builder, its Vega-Lite spec, and the chart itself. */
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Alert, Box, HStack, Input, Text } from '@chakra-ui/react';
|
|
4
4
|
import type { JobData, JobDataField, JobDataRole, OverviewBlock } from '../types';
|