@milabench/bujang 0.1.3 → 0.1.4
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/dist/api.d.ts +24 -1
- package/dist/context.d.ts +1 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3364 -2835
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +45 -1
- package/dist/views/JobDataOverview.d.ts +9 -0
- package/dist/views/JobMarks.d.ts +17 -0
- package/package.json +5 -2
- package/src/api.ts +59 -0
- package/src/context.tsx +1 -15
- package/src/index.ts +2 -1
- package/src/types.ts +43 -1
- package/src/views/JobDataOverview.tsx +594 -0
- package/src/views/JobLogs.tsx +47 -162
- package/src/views/JobMarks.tsx +233 -0
- package/src/views/JobsView.tsx +36 -35
package/dist/types.d.ts
CHANGED
|
@@ -225,6 +225,20 @@ export interface PersitedJobInfo {
|
|
|
225
225
|
acc: SlurmJobAccounting;
|
|
226
226
|
/** Submitted by an agent through the MCP server */
|
|
227
227
|
agent?: AgentTag | null;
|
|
228
|
+
/** Marked important by the user */
|
|
229
|
+
important?: boolean;
|
|
230
|
+
/** The manual groups of the job (groups/<group>/<job id>) */
|
|
231
|
+
groups?: string[];
|
|
232
|
+
}
|
|
233
|
+
/** GET/POST /jobs/<jr>/marks: whether a job is important, its groups, every group, git */
|
|
234
|
+
export interface JobMarks {
|
|
235
|
+
jr_job_id: string;
|
|
236
|
+
important: boolean;
|
|
237
|
+
groups: string[];
|
|
238
|
+
/** every group known, with its number of jobs */
|
|
239
|
+
all_groups: Record<string, number>;
|
|
240
|
+
/** the local cache is in a git repository: the job folder can be committed */
|
|
241
|
+
git: boolean;
|
|
228
242
|
}
|
|
229
243
|
export interface SlurmPartition {
|
|
230
244
|
partition: string;
|
|
@@ -733,7 +747,7 @@ export interface OrganizerGroups {
|
|
|
733
747
|
jobs: string[];
|
|
734
748
|
}[];
|
|
735
749
|
}
|
|
736
|
-
/** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (
|
|
750
|
+
/** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
|
|
737
751
|
export interface JobArtifacts {
|
|
738
752
|
jr_job_id: string;
|
|
739
753
|
folders: string[];
|
|
@@ -748,6 +762,36 @@ export interface JobArtifacts {
|
|
|
748
762
|
/** HTML reports run sandboxed: their scripts cannot reach the bujang API */
|
|
749
763
|
sandboxed: boolean;
|
|
750
764
|
}
|
|
765
|
+
/** A field of the rows of an event of a JSONL file (dotted name for nested values: gpudata.0.power) */
|
|
766
|
+
export interface JobDataField {
|
|
767
|
+
name: string;
|
|
768
|
+
type: 'number' | 'string' | 'boolean' | 'mixed';
|
|
769
|
+
count: number;
|
|
770
|
+
min?: number;
|
|
771
|
+
max?: number;
|
|
772
|
+
/** distinct values of a string field, null when there are too many */
|
|
773
|
+
values?: string[] | null;
|
|
774
|
+
}
|
|
775
|
+
/** GET /jobs/<jr>/data: the JSONL files of the artifact folders of a job and their schema */
|
|
776
|
+
export interface JobData {
|
|
777
|
+
jr_job_id: string;
|
|
778
|
+
folders: string[];
|
|
779
|
+
files: {
|
|
780
|
+
path: string;
|
|
781
|
+
size?: number;
|
|
782
|
+
mtime?: number;
|
|
783
|
+
rows?: number;
|
|
784
|
+
/** per event ("" for the records without an event envelope), its row count and fields */
|
|
785
|
+
events?: {
|
|
786
|
+
event: string;
|
|
787
|
+
count: number;
|
|
788
|
+
truncated: boolean;
|
|
789
|
+
fields: JobDataField[];
|
|
790
|
+
}[];
|
|
791
|
+
error?: string;
|
|
792
|
+
}[];
|
|
793
|
+
truncated: boolean;
|
|
794
|
+
}
|
|
751
795
|
/** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
|
|
752
796
|
export interface SyncStatus {
|
|
753
797
|
/** unix time of the last background sync, null before the first one */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The Overview tab of a job: the JSONL files of its artifact folders (output/, runs/, results/)
|
|
4
|
+
* plotted with Vega-Lite. A builder writes the spec; the spec can be edited by hand, and is shown
|
|
5
|
+
* with the rows URL as an Altair snippet.
|
|
6
|
+
*/
|
|
7
|
+
export declare const JobDataOverview: React.FC<{
|
|
8
|
+
jrJobId: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Star toggle: mark the job important (kept in its meta folder, shown on the jobs page) */
|
|
3
|
+
export declare const JobImportantButton: React.FC<{
|
|
4
|
+
jrJobId: string;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* "Groups" button and its dialog: add the job to existing groups or a new one
|
|
8
|
+
* (groups/<group>/<job id>), and commit the job folder when the local cache is a git repository.
|
|
9
|
+
*/
|
|
10
|
+
export declare const JobGroupsButton: React.FC<{
|
|
11
|
+
jrJobId: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Star of a job in a list: click to toggle */
|
|
14
|
+
export declare const JobImportantStar: React.FC<{
|
|
15
|
+
jrJobId: string;
|
|
16
|
+
important: boolean;
|
|
17
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milabench/bujang",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
"directory": "ui"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"mermaid": "^11.17.2"
|
|
73
|
+
"mermaid": "^11.17.2",
|
|
74
|
+
"vega": "^5.33.1",
|
|
75
|
+
"vega-embed": "^6.29.0",
|
|
76
|
+
"vega-lite": "^5.23.0"
|
|
74
77
|
}
|
|
75
78
|
}
|
package/src/api.ts
CHANGED
|
@@ -33,6 +33,8 @@ import type {
|
|
|
33
33
|
OrganizerGroups,
|
|
34
34
|
SyncStatus,
|
|
35
35
|
JobArtifacts,
|
|
36
|
+
JobData,
|
|
37
|
+
JobMarks,
|
|
36
38
|
UpdateResult,
|
|
37
39
|
SettingsSecrets,
|
|
38
40
|
SshSettings,
|
|
@@ -411,6 +413,23 @@ export const rerunSlurmJob = async (jrJobId: string): Promise<SlurmJobSubmitResp
|
|
|
411
413
|
}
|
|
412
414
|
};
|
|
413
415
|
|
|
416
|
+
/** Whether a job is important, its groups, every group known, and whether it can be committed. */
|
|
417
|
+
export const getJobMarks = async (jrJobId: string): Promise<JobMarks> => {
|
|
418
|
+
try {
|
|
419
|
+
const response = await api.get(`/jobs/${encodeURIComponent(jrJobId)}/marks`);
|
|
420
|
+
return response.data;
|
|
421
|
+
} catch (error) { return handleError(error); }
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
/** Mark a job important, set its groups (existing or new names); a field left out is kept. */
|
|
425
|
+
export const setJobMarks = async (jrJobId: string, marks: { important?: boolean; groups?: string[] }): Promise<JobMarks> => {
|
|
426
|
+
try {
|
|
427
|
+
const response = await api.post(`/jobs/${encodeURIComponent(jrJobId)}/marks`, marks);
|
|
428
|
+
return response.data;
|
|
429
|
+
} catch (error) { return handleError(error); }
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/** Commit the job folder to the git repository of the local cache (only when there is one). */
|
|
414
433
|
export const saveSlurmJob = async (jrJobId: string, message: string): Promise<{ success?: boolean; error?: string }> => {
|
|
415
434
|
try {
|
|
416
435
|
const response = await api.get(`/job/save/${jrJobId}/${encodeURIComponent(message)}`);
|
|
@@ -486,6 +505,46 @@ export const getJobArtifacts = async (jrJobId: string): Promise<JobArtifacts> =>
|
|
|
486
505
|
export const jobArtifactUrl = (jrJobId: string, path: string): string =>
|
|
487
506
|
`${currentBase}/jobs/${encodeURIComponent(jrJobId)}/artifacts/${path.split('/').map(encodeURIComponent).join('/')}`;
|
|
488
507
|
|
|
508
|
+
/** The JSONL files of the artifact folders of a job, with their events and fields (cached server side). */
|
|
509
|
+
export const getJobData = async (jrJobId: string): Promise<JobData> => {
|
|
510
|
+
try {
|
|
511
|
+
const response = await api.get(`/jobs/${encodeURIComponent(jrJobId)}/data`, { timeout: 60000 });
|
|
512
|
+
return response.data;
|
|
513
|
+
} catch (error) { return handleError(error); }
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/** Query of GET /jobs/<jr>/data/rows: comma separated files (or globs), events, dotted fields. */
|
|
517
|
+
export interface JobDataRowsQuery {
|
|
518
|
+
files?: string[];
|
|
519
|
+
events?: string[];
|
|
520
|
+
fields?: string[];
|
|
521
|
+
/** only the rows having these fields */
|
|
522
|
+
require?: string[];
|
|
523
|
+
limit?: number;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const rowsParams = (query: JobDataRowsQuery): URLSearchParams => {
|
|
527
|
+
const params = new URLSearchParams();
|
|
528
|
+
if (query.files?.length) params.set('files', query.files.join(','));
|
|
529
|
+
if (query.events?.length) params.set('event', query.events.join(','));
|
|
530
|
+
if (query.fields?.length) params.set('fields', query.fields.join(','));
|
|
531
|
+
if (query.require?.length) params.set('require', query.require.join(','));
|
|
532
|
+
if (query.limit) params.set('limit', String(query.limit));
|
|
533
|
+
return params;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
/** The rows of the JSONL files of a job (each with `_file` and `_name`), for plots. */
|
|
537
|
+
export const getJobDataRows = async (jrJobId: string, query: JobDataRowsQuery): Promise<Record<string, unknown>[]> => {
|
|
538
|
+
try {
|
|
539
|
+
const response = await api.get(`/jobs/${encodeURIComponent(jrJobId)}/data/rows?${rowsParams(query)}`, { timeout: 120000 });
|
|
540
|
+
return response.data;
|
|
541
|
+
} catch (error) { return handleError(error); }
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
/** URL of the rows of a job: a Vega-Lite / Altair data url (relative to the page when apiBase is). */
|
|
545
|
+
export const jobDataRowsUrl = (jrJobId: string, query: JobDataRowsQuery): string =>
|
|
546
|
+
`${currentBase}/jobs/${encodeURIComponent(jrJobId)}/data/rows?${rowsParams(query)}`;
|
|
547
|
+
|
|
489
548
|
/** When the job index was last synced with the clusters. */
|
|
490
549
|
export const getSyncStatus = async (): Promise<SyncStatus> => {
|
|
491
550
|
try {
|
package/src/context.tsx
CHANGED
|
@@ -7,12 +7,6 @@ import { setBujangToastHandler } from './toast';
|
|
|
7
7
|
import type { BujangToastHandler } from './toast';
|
|
8
8
|
import { BujangToaster } from './components/toaster';
|
|
9
9
|
|
|
10
|
-
/** Result of the optional host "push job data" action shown on the job logs page. */
|
|
11
|
-
export interface PushJobDataResult {
|
|
12
|
-
status: string;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
export interface BujangProviderProps {
|
|
17
11
|
/** Prefix of the bujang HTTP routes. Default "/api/slurm". */
|
|
18
12
|
apiBase?: string;
|
|
@@ -30,11 +24,6 @@ export interface BujangProviderProps {
|
|
|
30
24
|
titleSuffix?: string;
|
|
31
25
|
/** Force the Monaco editor theme. Default follows the `dark` class / data-theme on <html>. */
|
|
32
26
|
colorMode?: 'light' | 'dark';
|
|
33
|
-
/**
|
|
34
|
-
* Optional host action rendered as a "Push Data" button on the job logs page
|
|
35
|
-
* (e.g. to push job results to a database).
|
|
36
|
-
*/
|
|
37
|
-
pushJobData?: (jrJobId: string) => Promise<PushJobDataResult>;
|
|
38
27
|
/**
|
|
39
28
|
* URL of the MCP endpoint shown on the Agent Activity page (e.g. when the host serves it on
|
|
40
29
|
* its own port). Default: what the server reports, else `<origin>/mcp` when it mounts it.
|
|
@@ -49,7 +38,6 @@ export interface BujangContextValue {
|
|
|
49
38
|
usePageTitle?: (title: string) => void;
|
|
50
39
|
titleSuffix: string;
|
|
51
40
|
colorMode?: 'light' | 'dark';
|
|
52
|
-
pushJobData?: (jrJobId: string) => Promise<PushJobDataResult>;
|
|
53
41
|
mcpUrl?: string;
|
|
54
42
|
}
|
|
55
43
|
|
|
@@ -70,7 +58,6 @@ export function BujangProvider({
|
|
|
70
58
|
usePageTitle,
|
|
71
59
|
titleSuffix = 'bujang',
|
|
72
60
|
colorMode,
|
|
73
|
-
pushJobData,
|
|
74
61
|
mcpUrl,
|
|
75
62
|
children,
|
|
76
63
|
}: BujangProviderProps): React.ReactElement {
|
|
@@ -93,9 +80,8 @@ export function BujangProvider({
|
|
|
93
80
|
usePageTitle,
|
|
94
81
|
titleSuffix,
|
|
95
82
|
colorMode,
|
|
96
|
-
pushJobData,
|
|
97
83
|
mcpUrl,
|
|
98
|
-
}), [apiBase, basePath, paths, usePageTitle, titleSuffix, colorMode,
|
|
84
|
+
}), [apiBase, basePath, paths, usePageTitle, titleSuffix, colorMode, mcpUrl]);
|
|
99
85
|
|
|
100
86
|
return (
|
|
101
87
|
<BujangContext.Provider value={value}>
|
package/src/index.ts
CHANGED
|
@@ -13,10 +13,11 @@ export { JobSubmissionForm } from './views/JobSubmit';
|
|
|
13
13
|
export type { JobSubmissionInitialData } from './views/JobSubmit';
|
|
14
14
|
export { LogDisplay } from './views/LogDisplay';
|
|
15
15
|
export { JobArtifactsCard } from './views/JobArtifacts';
|
|
16
|
+
export { JobImportantButton, JobGroupsButton, JobImportantStar } from './views/JobMarks';
|
|
16
17
|
|
|
17
18
|
// Provider, paths, routes
|
|
18
19
|
export { BujangProvider, useBujang, useBujangPaths } from './context';
|
|
19
|
-
export type { BujangProviderProps, BujangContextValue
|
|
20
|
+
export type { BujangProviderProps, BujangContextValue } from './context';
|
|
20
21
|
export { createBujangPaths, defaultRoutePatterns, normalizeBasePath, bujangNavItems } from './paths';
|
|
21
22
|
export type { BujangPaths, BujangView, BujangNavItem } from './paths';
|
|
22
23
|
export { bujangRoutes, bujangRouteElements } from './routes';
|
package/src/types.ts
CHANGED
|
@@ -244,6 +244,21 @@ export interface PersitedJobInfo {
|
|
|
244
244
|
acc: SlurmJobAccounting;
|
|
245
245
|
/** Submitted by an agent through the MCP server */
|
|
246
246
|
agent?: AgentTag | null;
|
|
247
|
+
/** Marked important by the user */
|
|
248
|
+
important?: boolean;
|
|
249
|
+
/** The manual groups of the job (groups/<group>/<job id>) */
|
|
250
|
+
groups?: string[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** GET/POST /jobs/<jr>/marks: whether a job is important, its groups, every group, git */
|
|
254
|
+
export interface JobMarks {
|
|
255
|
+
jr_job_id: string;
|
|
256
|
+
important: boolean;
|
|
257
|
+
groups: string[];
|
|
258
|
+
/** every group known, with its number of jobs */
|
|
259
|
+
all_groups: Record<string, number>;
|
|
260
|
+
/** the local cache is in a git repository: the job folder can be committed */
|
|
261
|
+
git: boolean;
|
|
247
262
|
}
|
|
248
263
|
|
|
249
264
|
export interface SlurmPartition {
|
|
@@ -783,7 +798,7 @@ export interface OrganizerGroups {
|
|
|
783
798
|
groups: { value: string; jobs: string[] }[];
|
|
784
799
|
}
|
|
785
800
|
|
|
786
|
-
/** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (
|
|
801
|
+
/** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
|
|
787
802
|
export interface JobArtifacts {
|
|
788
803
|
jr_job_id: string;
|
|
789
804
|
folders: string[];
|
|
@@ -793,6 +808,33 @@ export interface JobArtifacts {
|
|
|
793
808
|
sandboxed: boolean;
|
|
794
809
|
}
|
|
795
810
|
|
|
811
|
+
/** A field of the rows of an event of a JSONL file (dotted name for nested values: gpudata.0.power) */
|
|
812
|
+
export interface JobDataField {
|
|
813
|
+
name: string;
|
|
814
|
+
type: 'number' | 'string' | 'boolean' | 'mixed';
|
|
815
|
+
count: number;
|
|
816
|
+
min?: number;
|
|
817
|
+
max?: number;
|
|
818
|
+
/** distinct values of a string field, null when there are too many */
|
|
819
|
+
values?: string[] | null;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** GET /jobs/<jr>/data: the JSONL files of the artifact folders of a job and their schema */
|
|
823
|
+
export interface JobData {
|
|
824
|
+
jr_job_id: string;
|
|
825
|
+
folders: string[];
|
|
826
|
+
files: {
|
|
827
|
+
path: string;
|
|
828
|
+
size?: number;
|
|
829
|
+
mtime?: number;
|
|
830
|
+
rows?: number;
|
|
831
|
+
/** per event ("" for the records without an event envelope), its row count and fields */
|
|
832
|
+
events?: { event: string; count: number; truncated: boolean; fields: JobDataField[] }[];
|
|
833
|
+
error?: string;
|
|
834
|
+
}[];
|
|
835
|
+
truncated: boolean;
|
|
836
|
+
}
|
|
837
|
+
|
|
796
838
|
/** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
|
|
797
839
|
export interface SyncStatus {
|
|
798
840
|
/** unix time of the last background sync, null before the first one */
|