@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
package/dist/paths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IconType } from 'react-icons';
|
|
2
2
|
/** Names of the bujang views. */
|
|
3
|
-
export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'pipelineDetails' | 'scheduled' | 'projects' | 'agent' | 'janitor' | 'setup' | 'settings';
|
|
3
|
+
export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'pipelineDetails' | 'scheduled' | 'projects' | 'projectDetails' | 'experiments' | 'experimentDetails' | 'groups' | 'groupDetails' | 'agent' | 'janitor' | 'setup' | 'settings';
|
|
4
4
|
/** URL builders the views use to link to each other. */
|
|
5
5
|
export interface BujangPaths {
|
|
6
6
|
jobs: () => string;
|
|
@@ -13,6 +13,16 @@ export interface BujangPaths {
|
|
|
13
13
|
scheduled: () => string;
|
|
14
14
|
/** Registered code repositories and the jobs linked into them. `name` links to one project's card. */
|
|
15
15
|
projects: (name?: string) => string;
|
|
16
|
+
/** One project: its repository and its jobs. */
|
|
17
|
+
projectDetails: (name: string) => string;
|
|
18
|
+
/** Every experiment: a searchable, paginated table. */
|
|
19
|
+
experiments: () => string;
|
|
20
|
+
/** The jobs of one experiment. */
|
|
21
|
+
experimentDetails: (value: string) => string;
|
|
22
|
+
/** Every group: a searchable, paginated table. */
|
|
23
|
+
groups: () => string;
|
|
24
|
+
/** The jobs of one group. */
|
|
25
|
+
groupDetails: (value: string) => string;
|
|
16
26
|
/** Agent activity, optionally filtered on one session. */
|
|
17
27
|
agent: (session?: string) => string;
|
|
18
28
|
/** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
|
|
@@ -38,5 +48,17 @@ export interface BujangNavItem {
|
|
|
38
48
|
/** Icon of the entry (a react-icons component); optional, hosts can ignore it. */
|
|
39
49
|
icon?: IconType;
|
|
40
50
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Views a host opts into (bujangRoutes({ projects: true }), BujangProjectsNav): the Projects section links
|
|
53
|
+
* the jobs into local code repositories, which only makes sense where the server runs on the user's machine.
|
|
54
|
+
*/
|
|
55
|
+
export declare const PROJECT_VIEWS: BujangView[];
|
|
56
|
+
/** The experiments / groups pages (BujangOrganizerNav): opt-in too, bujangRoutes({ organizers: true }). */
|
|
57
|
+
export declare const ORGANIZER_VIEWS: BujangView[];
|
|
58
|
+
export declare const OPTIONAL_VIEWS: BujangView[];
|
|
59
|
+
/** Sidebar entries for the top-level bujang views (the projects have their own section: BujangProjectsNav). */
|
|
60
|
+
export interface BujangNavOptions {
|
|
61
|
+
/** the Setup Guide entry (default true): a host that sets bujang up itself leaves it out */
|
|
62
|
+
setup?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare function bujangNavItems(paths?: BujangPaths, options?: BujangNavOptions): BujangNavItem[];
|
package/dist/routes.d.ts
CHANGED
|
@@ -3,8 +3,12 @@ import type { BujangView } from './paths';
|
|
|
3
3
|
export interface BujangRoutesOptions {
|
|
4
4
|
/** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
|
|
5
5
|
basePath?: string;
|
|
6
|
-
/** Only mount these views (default: all). */
|
|
6
|
+
/** Only mount these views (default: all but the optional ones). */
|
|
7
7
|
views?: BujangView[];
|
|
8
|
+
/** Mount the Projects views too (/projects, /projects/:projectName), see BujangProjectsNav. Default false. */
|
|
9
|
+
projects?: boolean;
|
|
10
|
+
/** Mount the experiments and groups pages too (/experiments[/:value], /groups[/:value]), see BujangOrganizerNav. */
|
|
11
|
+
organizers?: boolean;
|
|
8
12
|
}
|
|
9
13
|
/** A plain route object, usable with <Route>, useRoutes() or createBrowserRouter(). */
|
|
10
14
|
export interface BujangRouteObject {
|
|
@@ -15,7 +19,8 @@ export interface BujangRouteObject {
|
|
|
15
19
|
/**
|
|
16
20
|
* Route objects for the default bujang URL layout under `basePath`:
|
|
17
21
|
* /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
|
|
18
|
-
* /pipelines, /pipelines/:pipelineName, /scheduled, /
|
|
22
|
+
* /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /setup, /settings; with `projects`,
|
|
23
|
+
* /projects and /projects/:projectName.
|
|
19
24
|
*/
|
|
20
25
|
export declare function bujangRoutes(options?: BujangRoutesOptions): BujangRouteObject[];
|
|
21
26
|
/** The same routes as <Route> elements, to drop inside a host's <Routes>. */
|
package/dist/types.d.ts
CHANGED
|
@@ -862,6 +862,24 @@ export interface OrganizerGroups {
|
|
|
862
862
|
jobs: string[];
|
|
863
863
|
}[];
|
|
864
864
|
}
|
|
865
|
+
/** One value of an organizer (an experiment, a group): its jobs and when they ran */
|
|
866
|
+
export interface OrganizerValue {
|
|
867
|
+
value: string;
|
|
868
|
+
/** how many jobs (pipeline runs and their steps count) */
|
|
869
|
+
jobs: number;
|
|
870
|
+
/** the oldest job folder (seconds) */
|
|
871
|
+
first: number | null;
|
|
872
|
+
/** the last change of one of its job folders (seconds) */
|
|
873
|
+
last: number | null;
|
|
874
|
+
}
|
|
875
|
+
/** GET /organizers/<name>/values: a page of the values */
|
|
876
|
+
export interface OrganizerValuesPage {
|
|
877
|
+
organizer: string;
|
|
878
|
+
total: number;
|
|
879
|
+
offset: number;
|
|
880
|
+
limit: number;
|
|
881
|
+
values: OrganizerValue[];
|
|
882
|
+
}
|
|
865
883
|
/** A code repository registered as a project: its jobs are linked into `target` (GET /projects) */
|
|
866
884
|
export interface Project {
|
|
867
885
|
name: string;
|
|
@@ -869,8 +887,14 @@ export interface Project {
|
|
|
869
887
|
path: string;
|
|
870
888
|
/** folder inside the repository, relative ("bujang") */
|
|
871
889
|
folder: string;
|
|
872
|
-
/** path/folder:
|
|
890
|
+
/** path/folder: the bujang folder of the project (its config, jobs/) */
|
|
873
891
|
target: string;
|
|
892
|
+
/** target/jobs: where the job links are */
|
|
893
|
+
jobs_dir: string;
|
|
894
|
+
/** its own scripts, pipelines and profiles, named "<project>:<name>" */
|
|
895
|
+
templates: string[];
|
|
896
|
+
pipelines: string[];
|
|
897
|
+
profiles: string[];
|
|
874
898
|
created: number | null;
|
|
875
899
|
/** the repository folder exists */
|
|
876
900
|
exists: boolean;
|
|
@@ -946,6 +970,13 @@ export type OverviewBlock = {
|
|
|
946
970
|
title?: string;
|
|
947
971
|
metrics?: StatsMetric[];
|
|
948
972
|
show?: StatName[];
|
|
973
|
+
}
|
|
974
|
+
/** a row per job: its arguments (`args`: their names; absent: the ones that differ), its state, the `metrics` */
|
|
975
|
+
| {
|
|
976
|
+
kind: 'compare';
|
|
977
|
+
title?: string;
|
|
978
|
+
metrics?: CompareMetric[];
|
|
979
|
+
args?: string[];
|
|
949
980
|
} | {
|
|
950
981
|
kind: 'logs';
|
|
951
982
|
title?: string;
|
|
@@ -984,7 +1015,42 @@ export type OverviewPanel = OverviewBlock | ColumnsPanel;
|
|
|
984
1015
|
export interface OverviewLayout {
|
|
985
1016
|
panels: OverviewPanel[];
|
|
986
1017
|
}
|
|
987
|
-
|
|
1018
|
+
/** A collection of jobs with an Overview of its own (the jobs compared): its organizer */
|
|
1019
|
+
export type CollectionScope = 'experiments' | 'groups' | 'projects';
|
|
1020
|
+
export type OverviewScope = 'experiment' | 'script' | CollectionScope;
|
|
1021
|
+
/** A job of a collection (GET /collections/<organizer>/<value>/data) */
|
|
1022
|
+
export interface CollectionJob {
|
|
1023
|
+
jr_job_id: string;
|
|
1024
|
+
label: string | null;
|
|
1025
|
+
state: string;
|
|
1026
|
+
settled: boolean;
|
|
1027
|
+
cluster: string | null;
|
|
1028
|
+
created: number | null;
|
|
1029
|
+
/** the arguments of its script (arguments.json) */
|
|
1030
|
+
args: Record<string, unknown>;
|
|
1031
|
+
}
|
|
1032
|
+
/** What a compare block shows of a field, per job */
|
|
1033
|
+
export type CompareStat = 'last' | 'first' | 'min' | 'max' | 'mean' | 'count';
|
|
1034
|
+
/** A column of a compare block: a statistic of a number field of an event */
|
|
1035
|
+
export interface CompareMetric {
|
|
1036
|
+
event: string;
|
|
1037
|
+
field: string;
|
|
1038
|
+
stat?: CompareStat;
|
|
1039
|
+
title?: string;
|
|
1040
|
+
/** conditional formatting: a color scale over the column, its better end green */
|
|
1041
|
+
scale?: CompareScale;
|
|
1042
|
+
/** conditional formatting: the first rule a value matches colors its cell (before the scale) */
|
|
1043
|
+
rules?: CompareRule[];
|
|
1044
|
+
}
|
|
1045
|
+
export type CompareScale = 'higher' | 'lower';
|
|
1046
|
+
export type CompareRuleOp = '<' | '<=' | '>' | '>=' | '==' | '!=';
|
|
1047
|
+
export type CompareRuleColor = 'good' | 'bad' | 'warn' | 'info';
|
|
1048
|
+
/** A conditional format of a compare column: `value <op> <value>` colors the cell */
|
|
1049
|
+
export interface CompareRule {
|
|
1050
|
+
op: CompareRuleOp;
|
|
1051
|
+
value: number;
|
|
1052
|
+
color: CompareRuleColor;
|
|
1053
|
+
}
|
|
988
1054
|
/** GET /jobs/<jr>/overview/layout */
|
|
989
1055
|
export interface JobOverviewLayout {
|
|
990
1056
|
layout: OverviewLayout;
|
|
@@ -1003,10 +1069,14 @@ export interface JobOverviewLayout {
|
|
|
1003
1069
|
};
|
|
1004
1070
|
/** the charts of the built-in layout, to add to this one */
|
|
1005
1071
|
blocks: OverviewBlock[];
|
|
1006
|
-
/** what a layout can be saved for */
|
|
1072
|
+
/** what a layout can be saved for; `collection`: the Overview of an experiment / group / project */
|
|
1007
1073
|
keys: {
|
|
1008
1074
|
experiment: string | null;
|
|
1009
1075
|
script: string;
|
|
1076
|
+
collection?: {
|
|
1077
|
+
scope: CollectionScope;
|
|
1078
|
+
key: string;
|
|
1079
|
+
};
|
|
1010
1080
|
};
|
|
1011
1081
|
}
|
|
1012
1082
|
/** GET /overview/layouts */
|
|
@@ -1018,16 +1088,18 @@ export interface SavedOverviewLayout {
|
|
|
1018
1088
|
}
|
|
1019
1089
|
/** What an event of a JSONL file is for: plotted, shown in the log view, or neither */
|
|
1020
1090
|
export type JobDataRole = 'metric' | 'log' | 'other';
|
|
1021
|
-
/** GET /jobs/<jr>/data: the
|
|
1091
|
+
/** GET /jobs/<jr>/data: the data files of the artifact folders of a job and their schema */
|
|
1022
1092
|
export interface JobData {
|
|
1023
1093
|
jr_job_id: string;
|
|
1024
1094
|
folders: string[];
|
|
1095
|
+
/** the Overview of a collection: its jobs (their files are under "<job id>/") */
|
|
1096
|
+
jobs?: CollectionJob[];
|
|
1025
1097
|
files: {
|
|
1026
1098
|
path: string;
|
|
1027
1099
|
size?: number;
|
|
1028
1100
|
mtime?: number;
|
|
1029
1101
|
rows?: number;
|
|
1030
|
-
/** the
|
|
1102
|
+
/** the data processor that read the file ("jsonl", or one of a plugin: "csv", ...) */
|
|
1031
1103
|
processor?: string;
|
|
1032
1104
|
/** per event ("" for the records without an event envelope), its role, row count and fields */
|
|
1033
1105
|
events?: {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CollectionScope } from '../types';
|
|
3
|
+
export type CollectionTab = 'jobs' | 'overview';
|
|
4
|
+
/** The tab of a collection page (experiment, group, project), in the URL: the Overview, else ?view=jobs */
|
|
5
|
+
export declare function useCollectionTab(): [CollectionTab, (tab: CollectionTab) => void];
|
|
6
|
+
/** Overview | Jobs */
|
|
7
|
+
export declare const CollectionTabs: React.FC<{
|
|
8
|
+
tab: CollectionTab;
|
|
9
|
+
onTab: (tab: CollectionTab) => void;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* The Overview of a collection: the panels of a job's Overview over the data of all its jobs (a line per
|
|
13
|
+
* job, the jobs compared in a table), with a layout of its own (a project's in its repository).
|
|
14
|
+
*/
|
|
15
|
+
export declare const CollectionOverview: React.FC<{
|
|
16
|
+
organizer: CollectionScope;
|
|
17
|
+
value: string;
|
|
18
|
+
title: React.ReactNode;
|
|
19
|
+
pageTitle: string;
|
|
20
|
+
/** under the heading: the tabs, links */
|
|
21
|
+
header?: React.ReactNode;
|
|
22
|
+
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* The Overview tab of a job: the panels of its layout (the log view, charts: GET
|
|
4
|
-
* /jobs/<jr>/overview/layout), or the "explore data" layout: the
|
|
4
|
+
* /jobs/<jr>/overview/layout), or the "explore data" layout: the data files of its artifact folders
|
|
5
5
|
* (output/, runs/, results/) plotted with a chart builder, whose charts can be added to the layout of the job.
|
|
6
6
|
*/
|
|
7
7
|
export declare const JobDataOverview: React.FC<{
|
package/dist/views/JobsView.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface JobsViewProps {
|
|
3
|
+
/** organizer filters always applied, not shown in the filter bar ({ projects: 'my-repo' }) */
|
|
4
|
+
filters?: Record<string, string>;
|
|
5
|
+
/** the heading (default "Jobs") */
|
|
6
|
+
title?: React.ReactNode;
|
|
7
|
+
/** the browser tab title (default "Jobs") */
|
|
8
|
+
pageTitle?: string;
|
|
9
|
+
/** shown under the heading */
|
|
10
|
+
header?: React.ReactNode;
|
|
11
|
+
/** where "Submit New Job" goes (default the Submit page) */
|
|
12
|
+
submitPath?: string;
|
|
13
|
+
}
|
|
3
14
|
export declare const JobsView: React.FC<JobsViewProps>;
|
|
4
15
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ORGANIZER_PAGES } from '../components/OrganizerNav';
|
|
3
|
+
/**
|
|
4
|
+
* Every experiment (or group): a table with their job count and last activity, searched by name and
|
|
5
|
+
* paginated on the server. The search, sort, page and page size are in the URL.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OrganizerValuesView: React.FC<{
|
|
8
|
+
organizer: keyof typeof ORGANIZER_PAGES;
|
|
9
|
+
}>;
|
|
10
|
+
/** One experiment (or group): its jobs (the jobs page filtered on it), or their Overview (compared) */
|
|
11
|
+
export declare const OrganizerValueView: React.FC<{
|
|
12
|
+
organizer: keyof typeof ORGANIZER_PAGES;
|
|
13
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The panels of a job's Overview layout: the log view and the charts, and the bar saying where the layout comes from. */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { JobData, JobOverviewLayout, OverviewBlock, OverviewLayout } from '../types';
|
|
3
|
+
import type { CollectionJob, CompareRuleColor, CompareRuleOp, CompareStat, JobData, JobOverviewLayout, OverviewBlock, OverviewLayout } from '../types';
|
|
4
4
|
/** What can be done with a block of the layout; the moves are absent where they lead nowhere */
|
|
5
5
|
interface BlockActions {
|
|
6
6
|
editing: boolean;
|
|
@@ -48,7 +48,7 @@ export declare const LayoutBar: React.FC<{
|
|
|
48
48
|
editing: boolean;
|
|
49
49
|
saving: boolean;
|
|
50
50
|
onEdit: (on: boolean) => void;
|
|
51
|
-
onSave: (target: 'experiment' | 'script' | 'default') => void;
|
|
51
|
+
onSave: (target: 'experiment' | 'script' | 'default' | 'collection') => void;
|
|
52
52
|
onDiscard: () => void;
|
|
53
53
|
onReset: () => void;
|
|
54
54
|
}>;
|
|
@@ -65,4 +65,15 @@ export declare const LayoutPanels: React.FC<{
|
|
|
65
65
|
onChange: (layout: OverviewLayout) => void;
|
|
66
66
|
onEditor: (open: boolean) => void;
|
|
67
67
|
}>;
|
|
68
|
+
/** The jobs of a collection Overview (experiment, group, project), given by its page to the compare blocks */
|
|
69
|
+
export declare const CollectionJobs: React.Context<CollectionJob[] | null>;
|
|
70
|
+
export declare const COMPARE_STATS: CompareStat[];
|
|
71
|
+
export declare const COMPARE_OPS: CompareRuleOp[];
|
|
72
|
+
export declare const COMPARE_COLORS: CompareRuleColor[];
|
|
73
|
+
/**
|
|
74
|
+
* A row per job (`_job` of the rows; per file in a job's Overview): its short id, label, state and pipeline
|
|
75
|
+
* step, the arguments of its script, then a statistic of each metric (the last loss, the best one, ...)
|
|
76
|
+
* with its conditional formatting. Sorted by a click on a column, filtered by the inputs under the header.
|
|
77
|
+
*/
|
|
78
|
+
export declare const ComparePanel: React.FC<PanelProps<'compare'>>;
|
|
68
79
|
export {};
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { Project } from '../types';
|
|
3
|
+
export declare const PROJECTS_KEY: string[];
|
|
4
|
+
export declare const ProjectCard: React.FC<{
|
|
5
|
+
project: Project;
|
|
6
|
+
writable: boolean;
|
|
7
|
+
onRemoved?: () => void;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Archive the jobs of a project: their folders move out of the local cache into the project's jobs/,
|
|
11
|
+
* where their links were (a preview first). Jobs not over or still on their cluster stay.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ProjectArchive: React.FC<{
|
|
14
|
+
project: Project;
|
|
15
|
+
}>;
|
|
16
|
+
/** The scripts, pipelines and profiles of a project (files of its bujang folder) */
|
|
17
|
+
export declare const ProjectConfig: React.FC<{
|
|
18
|
+
project: Project;
|
|
19
|
+
}>;
|
|
2
20
|
export declare const ProjectsView: React.FC;
|
|
@@ -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 from 'react';
|
|
3
3
|
import type { JobData, JobDataField, JobDataRole, OverviewBlock } from '../types';
|
|
4
4
|
/** Rows fetched for a chart (the server caps at 500k) */
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -31,6 +31,7 @@ import type {
|
|
|
31
31
|
SettingsUpdateResponse,
|
|
32
32
|
UpdateCheck,
|
|
33
33
|
OrganizerGroups,
|
|
34
|
+
OrganizerValuesPage,
|
|
34
35
|
Project,
|
|
35
36
|
ProjectsInfo,
|
|
36
37
|
ProjectsSyncReport,
|
|
@@ -561,11 +562,27 @@ export const jobArtifactUrl = (jrJobId: string, path: string): string =>
|
|
|
561
562
|
/** The layout of a job's Overview tab and where it comes from. */
|
|
562
563
|
export const getJobOverviewLayout = async (jrJobId: string): Promise<JobOverviewLayout> => {
|
|
563
564
|
try {
|
|
564
|
-
const response = await api.get(
|
|
565
|
+
const response = await api.get(`${dataBase(jrJobId)}/overview/layout`, { timeout: 60000 });
|
|
565
566
|
return response.data;
|
|
566
567
|
} catch (error) { return handleError(error); }
|
|
567
568
|
};
|
|
568
569
|
|
|
570
|
+
/**
|
|
571
|
+
* The id the Overview of a collection goes by: "@<organizer>/<value>" ("@experiments/lr-sweep"). The data and
|
|
572
|
+
* layout calls below take it in place of a job id: the panels of a job's Overview work on the jobs of the
|
|
573
|
+
* collection (each file under "<job id>/", each row with `_job`, `_label`, `args`).
|
|
574
|
+
*/
|
|
575
|
+
export const collectionId = (organizer: string, value: string): string => `@${organizer}/${value}`;
|
|
576
|
+
|
|
577
|
+
/** /jobs/<id>, or /collections/<organizer>/<value> for a collection id */
|
|
578
|
+
const dataBase = (id: string): string => {
|
|
579
|
+
if (id.startsWith('@')) {
|
|
580
|
+
const [organizer, ...rest] = id.slice(1).split('/');
|
|
581
|
+
return `/collections/${encodeURIComponent(organizer)}/${encodeURIComponent(rest.join('/'))}`;
|
|
582
|
+
}
|
|
583
|
+
return `/jobs/${encodeURIComponent(id)}`;
|
|
584
|
+
};
|
|
585
|
+
|
|
569
586
|
/** The Overview layouts saved for an experiment or a script. */
|
|
570
587
|
export const getOverviewLayouts = async (): Promise<SavedOverviewLayout[]> => {
|
|
571
588
|
try {
|
|
@@ -584,10 +601,10 @@ export const saveOverviewLayout = async (
|
|
|
584
601
|
} catch (error) { return handleError(error); }
|
|
585
602
|
};
|
|
586
603
|
|
|
587
|
-
/** The
|
|
604
|
+
/** The data files of the artifact folders of a job, with their events and fields (cached server side). */
|
|
588
605
|
export const getJobData = async (jrJobId: string): Promise<JobData> => {
|
|
589
606
|
try {
|
|
590
|
-
const response = await api.get(
|
|
607
|
+
const response = await api.get(`${dataBase(jrJobId)}/data`, { timeout: 60000 });
|
|
591
608
|
return response.data;
|
|
592
609
|
} catch (error) { return handleError(error); }
|
|
593
610
|
};
|
|
@@ -615,17 +632,17 @@ const rowsParams = (query: JobDataRowsQuery): URLSearchParams => {
|
|
|
615
632
|
return params;
|
|
616
633
|
};
|
|
617
634
|
|
|
618
|
-
/** The rows of the
|
|
635
|
+
/** The rows of the data files of a job (each with `_file` and `_name`), for plots. */
|
|
619
636
|
export const getJobDataRows = async (jrJobId: string, query: JobDataRowsQuery): Promise<Record<string, unknown>[]> => {
|
|
620
637
|
try {
|
|
621
|
-
const response = await api.get(
|
|
638
|
+
const response = await api.get(`${dataBase(jrJobId)}/data/rows?${rowsParams(query)}`, { timeout: 120000 });
|
|
622
639
|
return response.data;
|
|
623
640
|
} catch (error) { return handleError(error); }
|
|
624
641
|
};
|
|
625
642
|
|
|
626
643
|
/** URL of the rows of a job: a Vega-Lite / Altair data url (relative to the page when apiBase is). */
|
|
627
644
|
export const jobDataRowsUrl = (jrJobId: string, query: JobDataRowsQuery): string =>
|
|
628
|
-
`${urlBase()}
|
|
645
|
+
`${urlBase()}${dataBase(jrJobId)}/data/rows?${rowsParams(query)}`;
|
|
629
646
|
|
|
630
647
|
/** When the job index was last synced with the clusters. */
|
|
631
648
|
export const getSyncStatus = async (): Promise<SyncStatus> => {
|
|
@@ -651,6 +668,19 @@ export const getOrganizers = async (): Promise<OrganizerGroups[]> => {
|
|
|
651
668
|
} catch (error) { return handleError(error); }
|
|
652
669
|
};
|
|
653
670
|
|
|
671
|
+
/** A page of the values of an organizer (experiments, groups): job count, last activity; `search` in the name. */
|
|
672
|
+
export const getOrganizerValues = async (
|
|
673
|
+
name: string,
|
|
674
|
+
params: { search?: string; sort?: 'last' | 'name' | 'jobs'; offset?: number; limit?: number } = {},
|
|
675
|
+
): Promise<OrganizerValuesPage> => {
|
|
676
|
+
try {
|
|
677
|
+
const response = await api.get(`/organizers/${encodeURIComponent(name)}/values`, {
|
|
678
|
+
params: { ...params, search: params.search || undefined },
|
|
679
|
+
});
|
|
680
|
+
return response.data;
|
|
681
|
+
} catch (error) { return handleError(error); }
|
|
682
|
+
};
|
|
683
|
+
|
|
654
684
|
/** The registered projects: code repositories the jobs tagged for them are linked into. */
|
|
655
685
|
export const getProjects = async (): Promise<ProjectsInfo> => {
|
|
656
686
|
try {
|
|
@@ -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
|
+
};
|