@milabench/bujang 0.0.0-stage → 0.1.2
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 +108 -2
- package/dist/api.d.ts +151 -0
- package/dist/components/AutocompleteInput.d.ts +15 -0
- package/dist/components/MonacoEditor.d.ts +11 -0
- package/dist/components/toaster.d.ts +2 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/constants.d.ts +3 -0
- package/dist/context.d.ts +44 -0
- package/dist/hooks/useColorMode.d.ts +4 -0
- package/dist/hooks/usePageTitle.d.ts +2 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +5036 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +26 -0
- package/dist/routes.d.ts +22 -0
- package/dist/theme.css +72 -0
- package/dist/toast.d.ts +18 -0
- package/dist/types.d.ts +474 -0
- package/dist/views/AgentActivityView.d.ts +8 -0
- package/dist/views/JobDetails.d.ts +2 -0
- package/dist/views/JobLogs.d.ts +4 -0
- package/dist/views/JobSubmit.d.ts +22 -0
- package/dist/views/JobSubmitView.d.ts +2 -0
- package/dist/views/JobsView.d.ts +4 -0
- package/dist/views/LogDisplay.d.ts +11 -0
- package/dist/views/PipelinesView.d.ts +2 -0
- package/dist/views/ScheduledJobsView.d.ts +2 -0
- package/package.json +70 -4
- package/src/api.ts +602 -0
- package/src/components/AutocompleteInput.tsx +253 -0
- package/src/components/MonacoEditor.tsx +163 -0
- package/src/components/toaster.tsx +38 -0
- package/src/components/tooltip.tsx +52 -0
- package/src/constants.ts +3 -0
- package/src/context.tsx +106 -0
- package/src/hooks/useColorMode.ts +31 -0
- package/src/hooks/usePageTitle.ts +21 -0
- package/src/index.ts +33 -0
- package/src/paths.ts +71 -0
- package/src/routes.tsx +55 -0
- package/src/theme.css +72 -0
- package/src/toast.ts +35 -0
- package/src/types.ts +542 -0
- package/src/views/AgentActivityView.tsx +262 -0
- package/src/views/JobDetails.tsx +675 -0
- package/src/views/JobLogs.tsx +987 -0
- package/src/views/JobSubmit.tsx +1272 -0
- package/src/views/JobSubmitView.tsx +69 -0
- package/src/views/JobsView.tsx +736 -0
- package/src/views/LogDisplay.tsx +171 -0
- package/src/views/PipelinesView.tsx +1318 -0
- package/src/views/ScheduledJobsView.tsx +735 -0
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milabench/bujang",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "React views for bujang: Slurm job submission, logs, pipelines, scheduled jobs and agent activity",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"development": "./src/index.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./theme.css": {
|
|
20
|
+
"development": "./src/theme.css",
|
|
21
|
+
"default": "./dist/theme.css"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"src",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"*.css"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "vite --config vite.app.config.ts",
|
|
35
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
36
|
+
"build:app": "vite build --config vite.app.config.ts",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"prepare": "npm run build"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@chakra-ui/react": "^3",
|
|
42
|
+
"@monaco-editor/react": "^4",
|
|
43
|
+
"@tanstack/react-query": "^5",
|
|
44
|
+
"axios": ">=1.6",
|
|
45
|
+
"react": ">=18",
|
|
46
|
+
"react-dom": ">=18",
|
|
47
|
+
"react-icons": "^5",
|
|
48
|
+
"react-router-dom": ">=6.22"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@chakra-ui/react": "^3.30.0",
|
|
52
|
+
"@emotion/react": "^11.14.0",
|
|
53
|
+
"@monaco-editor/react": "^4.7.0",
|
|
54
|
+
"@tanstack/react-query": "^5.17.19",
|
|
55
|
+
"@types/node": "^22.0.0",
|
|
56
|
+
"@types/react": "^18.2.55",
|
|
57
|
+
"@types/react-dom": "^18.2.19",
|
|
58
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
59
|
+
"axios": "^1.6.7",
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0",
|
|
62
|
+
"react-icons": "^5.5.0",
|
|
63
|
+
"react-router-dom": "^6.22.1",
|
|
64
|
+
"typescript": "^5.3.3",
|
|
65
|
+
"vite": "^6.0.0"
|
|
66
|
+
},
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "git+https://github.com/milabench/bujang.git",
|
|
70
|
+
"directory": "ui"
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
// HTTP client for the bujang /api/slurm/* routes.
|
|
2
|
+
//
|
|
3
|
+
// Every request goes through the axios instance and apiBase configured with
|
|
4
|
+
// `configureBujangApi` (BujangProvider calls it for you). Paths below are
|
|
5
|
+
// relative to apiBase (default "/api/slurm").
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import type { AxiosError, AxiosRequestConfig } from 'axios';
|
|
8
|
+
import type {
|
|
9
|
+
ApiError,
|
|
10
|
+
SlurmJob,
|
|
11
|
+
SlurmJobSubmitResponse,
|
|
12
|
+
SlurmJobLogResponse,
|
|
13
|
+
SlurmJobAccounting,
|
|
14
|
+
SlurmJobDetail,
|
|
15
|
+
SlurmClusterInfo,
|
|
16
|
+
SlurmProfile,
|
|
17
|
+
SlurmClusterStatus,
|
|
18
|
+
PersitedJobInfo,
|
|
19
|
+
SlurmJobStatusResponse,
|
|
20
|
+
EarlySyncResponse,
|
|
21
|
+
PipelineTemplatePayload,
|
|
22
|
+
PipelineRunResponse,
|
|
23
|
+
PipelineRunSummary,
|
|
24
|
+
PipelineRunStatus,
|
|
25
|
+
ScheduledJob,
|
|
26
|
+
ScheduledJobRun,
|
|
27
|
+
ScheduledJobTemplateDiff,
|
|
28
|
+
AgentEvent,
|
|
29
|
+
AgentSession,
|
|
30
|
+
} from './types';
|
|
31
|
+
|
|
32
|
+
export const DEFAULT_API_BASE = '/api/slurm';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* What bujang needs from an axios instance. Typed structurally so the host's instance fits even
|
|
36
|
+
* when its axios version differs from the one bujang was built with.
|
|
37
|
+
*/
|
|
38
|
+
export interface BujangHttpClient {
|
|
39
|
+
get<T = any>(url: string, config?: any): Promise<{ data: T }>;
|
|
40
|
+
post<T = any>(url: string, data?: any, config?: any): Promise<{ data: T }>;
|
|
41
|
+
put<T = any>(url: string, data?: any, config?: any): Promise<{ data: T }>;
|
|
42
|
+
delete<T = any>(url: string, config?: any): Promise<{ data: T }>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface BujangApiConfig {
|
|
46
|
+
/** Prefix of the bujang routes. Joined to the axios instance's baseURL (axios semantics). */
|
|
47
|
+
apiBase?: string;
|
|
48
|
+
/** Axios instance to send requests with (interceptors, auth headers, baseURL...). */
|
|
49
|
+
axios?: BujangHttpClient;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const defaultInstance: BujangHttpClient = axios.create({ timeout: 10000 });
|
|
53
|
+
|
|
54
|
+
let currentInstance: BujangHttpClient = defaultInstance;
|
|
55
|
+
let currentBase: string = DEFAULT_API_BASE;
|
|
56
|
+
|
|
57
|
+
const trimSlash = (s: string) => s.replace(/\/+$/, '');
|
|
58
|
+
|
|
59
|
+
/** Configure the instance and prefix used by every API function. */
|
|
60
|
+
export function configureBujangApi(config: BujangApiConfig = {}): void {
|
|
61
|
+
currentInstance = config.axios ?? defaultInstance;
|
|
62
|
+
currentBase = trimSlash(config.apiBase ?? DEFAULT_API_BASE);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Current API configuration (read-only snapshot). */
|
|
66
|
+
export function getBujangApiConfig(): { apiBase: string; axios: BujangHttpClient } {
|
|
67
|
+
return { apiBase: currentBase, axios: currentInstance };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const api = {
|
|
71
|
+
get: <T = any>(path: string, config?: AxiosRequestConfig) => currentInstance.get<T>(currentBase + path, config),
|
|
72
|
+
post: <T = any>(path: string, data?: unknown, config?: AxiosRequestConfig) => currentInstance.post<T>(currentBase + path, data, config),
|
|
73
|
+
put: <T = any>(path: string, data?: unknown, config?: AxiosRequestConfig) => currentInstance.put<T>(currentBase + path, data, config),
|
|
74
|
+
delete: <T = any>(path: string, config?: AxiosRequestConfig) => currentInstance.delete<T>(currentBase + path, config),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleError = (error: unknown): never => {
|
|
78
|
+
// Rethrow cancellations as-is so React Query can tell aborts apart from failures.
|
|
79
|
+
if (axios.isCancel(error)) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
if (axios.isAxiosError(error)) {
|
|
83
|
+
const axiosError = error as AxiosError;
|
|
84
|
+
const data = axiosError.response?.data as { error?: string; message?: string } | undefined;
|
|
85
|
+
throw {
|
|
86
|
+
message: data?.error || data?.message || axiosError.message,
|
|
87
|
+
status: axiosError.response?.status || 500,
|
|
88
|
+
} as ApiError;
|
|
89
|
+
}
|
|
90
|
+
throw {
|
|
91
|
+
message: 'An unexpected error occurred',
|
|
92
|
+
status: 500,
|
|
93
|
+
} as ApiError;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// Slurm-related API functions
|
|
98
|
+
export const getSlurmJobs = async (): Promise<SlurmJob[]> => {
|
|
99
|
+
try {
|
|
100
|
+
const response = await api.get('/jobs');
|
|
101
|
+
return response.data;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return handleError(error);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const getSlurmPersistedJobs = async (): Promise<PersitedJobInfo[]> => {
|
|
108
|
+
try {
|
|
109
|
+
const response = await api.get('/jobs/persited');
|
|
110
|
+
return response.data;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return handleError(error);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const getSlurmClusterStatus = async (): Promise<SlurmClusterStatus> => {
|
|
117
|
+
try {
|
|
118
|
+
const response = await api.get('/status');
|
|
119
|
+
return response.data;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return handleError(error);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
export const cancelSlurmJob = async (jobId: string): Promise<{ success: boolean; message?: string; error?: string }> => {
|
|
127
|
+
try {
|
|
128
|
+
const response = await api.post(`/cancel/${jobId}`);
|
|
129
|
+
return response.data;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return handleError(error);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const getSlurmJobInfo = async (jrJobId: string, jobId?: string): Promise<SlurmJobDetail> => {
|
|
136
|
+
try {
|
|
137
|
+
const url = jobId
|
|
138
|
+
? `/jobs/${jrJobId}/info/${jobId}`
|
|
139
|
+
: `/jobs/${jrJobId}/info`;
|
|
140
|
+
const response = await api.get(url);
|
|
141
|
+
return response.data;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
return handleError(error);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const getSlurmJobStdout = async (jrJobId: string): Promise<string> => {
|
|
148
|
+
try {
|
|
149
|
+
const response = await api.get(`/jobs/${jrJobId}/stdout/tail`);
|
|
150
|
+
return response.data;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
return handleError(error);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const getSlurmJobStderr = async (jrJobId: string): Promise<string> => {
|
|
157
|
+
try {
|
|
158
|
+
const response = await api.get(`/jobs/${jrJobId}/stderr/tail`);
|
|
159
|
+
return response.data;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return handleError(error);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const getSlurmJobStdoutSize = async (jrJobId: string): Promise<number> => {
|
|
166
|
+
try {
|
|
167
|
+
const response = await api.get(`/jobs/${jrJobId}/stdout/size`);
|
|
168
|
+
const size = typeof response.data === 'object' && response.data.size !== undefined
|
|
169
|
+
? response.data.size
|
|
170
|
+
: typeof response.data === 'number'
|
|
171
|
+
? response.data
|
|
172
|
+
: parseInt(response.data, 10);
|
|
173
|
+
if (isNaN(size)) {
|
|
174
|
+
throw new Error('Invalid size response from server');
|
|
175
|
+
}
|
|
176
|
+
return size;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return handleError(error);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const getSlurmJobStderrSize = async (jrJobId: string): Promise<number> => {
|
|
183
|
+
try {
|
|
184
|
+
const response = await api.get(`/jobs/${jrJobId}/stderr/size`);
|
|
185
|
+
const size = typeof response.data === 'object' && response.data.size !== undefined
|
|
186
|
+
? response.data.size
|
|
187
|
+
: typeof response.data === 'number'
|
|
188
|
+
? response.data
|
|
189
|
+
: parseInt(response.data, 10);
|
|
190
|
+
if (isNaN(size)) {
|
|
191
|
+
throw new Error('Invalid size response from server');
|
|
192
|
+
}
|
|
193
|
+
return size;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
return handleError(error);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const getSlurmJobStdoutFull = async (jrJobId: string, start?: number, end?: number): Promise<string> => {
|
|
200
|
+
try {
|
|
201
|
+
let url = `/jobs/${jrJobId}/stdout`;
|
|
202
|
+
if (start !== undefined && end !== undefined) {
|
|
203
|
+
url += `/${start}/${end}`;
|
|
204
|
+
}
|
|
205
|
+
const response = await api.get<SlurmJobLogResponse>(url);
|
|
206
|
+
|
|
207
|
+
// Handle new JSON response format
|
|
208
|
+
if (typeof response.data === 'object' && 'data' in response.data) {
|
|
209
|
+
return response.data.data;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Fallback for old string response format
|
|
213
|
+
return response.data as unknown as string;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
return handleError(error);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const getSlurmJobStderrFull = async (jrJobId: string, start?: number, end?: number): Promise<string> => {
|
|
220
|
+
try {
|
|
221
|
+
let url = `/jobs/${jrJobId}/stderr`;
|
|
222
|
+
if (start !== undefined && end !== undefined) {
|
|
223
|
+
url += `/${start}/${end}`;
|
|
224
|
+
}
|
|
225
|
+
const response = await api.get<SlurmJobLogResponse>(url);
|
|
226
|
+
|
|
227
|
+
// Handle new JSON response format
|
|
228
|
+
if (typeof response.data === 'object' && 'data' in response.data) {
|
|
229
|
+
return response.data.data;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Fallback for old string response format
|
|
233
|
+
return response.data as unknown as string;
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return handleError(error);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const getSlurmJobStatus = async (jobId: string): Promise<SlurmJob> => {
|
|
240
|
+
try {
|
|
241
|
+
const response = await api.get(`/jobs/${jobId}`);
|
|
242
|
+
return response.data;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
return handleError(error);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export const getSlurmJobAccounting = async (jrJobId: string, jobId: string): Promise<SlurmJobAccounting> => {
|
|
249
|
+
try {
|
|
250
|
+
const response = await api.get(`/jobs/${jrJobId}/acc/${jobId}`);
|
|
251
|
+
return response.data;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
return handleError(error);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export const getSlurmClusterInfo = async (): Promise<SlurmClusterInfo> => {
|
|
258
|
+
try {
|
|
259
|
+
const response = await api.get('/cluster');
|
|
260
|
+
return response.data;
|
|
261
|
+
} catch (error) {
|
|
262
|
+
return handleError(error);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
export const getSlurmTemplates = async (): Promise<string[]> => {
|
|
269
|
+
try {
|
|
270
|
+
const response = await api.get('/templates');
|
|
271
|
+
return response.data;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return handleError(error);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const getSlurmTemplateContent = async (templateName: string): Promise<string> => {
|
|
278
|
+
try {
|
|
279
|
+
const response = await api.get(`/templates/${templateName}`);
|
|
280
|
+
return response.data.content;
|
|
281
|
+
} catch (error) {
|
|
282
|
+
return handleError(error);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export const saveSlurmTemplate = async (request: {
|
|
287
|
+
name: string;
|
|
288
|
+
content: string;
|
|
289
|
+
}): Promise<{ success: boolean; message?: string; error?: string }> => {
|
|
290
|
+
try {
|
|
291
|
+
const response = await api.post('/save-template', request);
|
|
292
|
+
return response.data;
|
|
293
|
+
} catch (error) {
|
|
294
|
+
return handleError(error);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
export const getSlurmProfiles = async (): Promise<SlurmProfile[]> => {
|
|
299
|
+
try {
|
|
300
|
+
const response = await api.get('/profiles');
|
|
301
|
+
return response.data;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
return handleError(error);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export interface SlurmCluster {
|
|
308
|
+
name: string;
|
|
309
|
+
ssh: string;
|
|
310
|
+
login?: string;
|
|
311
|
+
proxy?: boolean;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export const getSlurmClusters = async (): Promise<SlurmCluster[]> => {
|
|
315
|
+
try {
|
|
316
|
+
const response = await api.get('/clusters');
|
|
317
|
+
return response.data;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
return handleError(error);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
export const saveSlurmProfile = async (request: {
|
|
326
|
+
name: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
cluster?: string;
|
|
329
|
+
sbatch_args: string[];
|
|
330
|
+
}): Promise<{ success: boolean; message?: string; error?: string }> => {
|
|
331
|
+
try {
|
|
332
|
+
const response = await api.post('/save-profile', request);
|
|
333
|
+
return response.data;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
return handleError(error);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export const submitSlurmJob = async (request: {
|
|
340
|
+
script: string;
|
|
341
|
+
job_name?: string;
|
|
342
|
+
cluster?: string;
|
|
343
|
+
sbatch_args?: string[];
|
|
344
|
+
script_args?: Record<string, string>;
|
|
345
|
+
// Individual parameters for backward compatibility
|
|
346
|
+
partition?: string;
|
|
347
|
+
nodes?: number;
|
|
348
|
+
ntasks?: number;
|
|
349
|
+
cpus_per_task?: number;
|
|
350
|
+
mem?: string;
|
|
351
|
+
time_limit?: string;
|
|
352
|
+
gpus_per_task?: string;
|
|
353
|
+
ntasks_per_node?: number;
|
|
354
|
+
exclusive?: boolean;
|
|
355
|
+
export?: string;
|
|
356
|
+
nodelist?: string;
|
|
357
|
+
dependency?: [string, string][];
|
|
358
|
+
}): Promise<SlurmJobSubmitResponse> => {
|
|
359
|
+
try {
|
|
360
|
+
const response = await api.post('/submit', request);
|
|
361
|
+
return response.data;
|
|
362
|
+
} catch (error) {
|
|
363
|
+
return handleError(error);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
export const getSlurmJobCluster = async (jrJobId: string): Promise<{ cluster: string; login?: string }> => {
|
|
368
|
+
try {
|
|
369
|
+
const response = await api.get(`/jobs/${jrJobId}/cluster`);
|
|
370
|
+
return response.data;
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return handleError(error);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const getSlurmJobScript = async (jrJobId: string): Promise<{
|
|
377
|
+
/** as written: `# {START}` / `# {END}`, without the blocks bujang inserted at submission */
|
|
378
|
+
script: string;
|
|
379
|
+
/** script.sbatch as submitted */
|
|
380
|
+
raw_script?: string;
|
|
381
|
+
sbatch_args: string[];
|
|
382
|
+
job_name: string;
|
|
383
|
+
error?: string;
|
|
384
|
+
}> => {
|
|
385
|
+
try {
|
|
386
|
+
const response = await api.get(`/jobs/${jrJobId}/script`);
|
|
387
|
+
return response.data;
|
|
388
|
+
} catch (error) {
|
|
389
|
+
return handleError(error);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export const rerunSlurmJob = async (jrJobId: string): Promise<SlurmJobSubmitResponse> => {
|
|
394
|
+
try {
|
|
395
|
+
const response = await api.get(`/rerun/${jrJobId}`);
|
|
396
|
+
return response.data;
|
|
397
|
+
} catch (error) {
|
|
398
|
+
return handleError(error);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export const saveSlurmJob = async (jrJobId: string, message: string): Promise<{ success?: boolean; error?: string }> => {
|
|
403
|
+
try {
|
|
404
|
+
const response = await api.get(`/job/save/${jrJobId}/${encodeURIComponent(message)}`);
|
|
405
|
+
return response.data;
|
|
406
|
+
} catch (error) {
|
|
407
|
+
return handleError(error);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// Secrets-related API functions
|
|
412
|
+
export const testSlurmSecret = async (name: string): Promise<{ name: string; masked: string } | null> => {
|
|
413
|
+
try {
|
|
414
|
+
const response = await api.get(`/secrets/test/${name}`);
|
|
415
|
+
return response.data;
|
|
416
|
+
} catch {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
export const listSlurmSecrets = async (): Promise<string[]> => {
|
|
422
|
+
try {
|
|
423
|
+
const response = await api.get('/secrets/list');
|
|
424
|
+
return response.data;
|
|
425
|
+
} catch {
|
|
426
|
+
return [];
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
// Pipeline template file management (matching server endpoints)
|
|
432
|
+
export const getPipelineTemplatesList = async (): Promise<string[]> => {
|
|
433
|
+
try {
|
|
434
|
+
const response = await api.get('/pipeline/template/list');
|
|
435
|
+
return response.data;
|
|
436
|
+
} catch (error) {
|
|
437
|
+
return handleError(error);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export const savePipelineToFile = async (pipelineData: PipelineTemplatePayload): Promise<{ success?: boolean; error?: string }> => {
|
|
442
|
+
try {
|
|
443
|
+
const response = await api.post('/pipeline/template/save', pipelineData);
|
|
444
|
+
return response.data;
|
|
445
|
+
} catch (error) {
|
|
446
|
+
return handleError(error);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
export const runPipelineTemplate = async (name: string): Promise<PipelineRunResponse> => {
|
|
451
|
+
try {
|
|
452
|
+
// Returns right away, the jobs are submitted in the background (see getPipelineRunStatus)
|
|
453
|
+
const response = await api.post(`/pipeline/run/${encodeURIComponent(name)}`, { context: {} });
|
|
454
|
+
return response.data;
|
|
455
|
+
} catch (error) {
|
|
456
|
+
return handleError(error);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export const getPipelineRuns = async (): Promise<PipelineRunSummary[]> => {
|
|
461
|
+
try {
|
|
462
|
+
const response = await api.get('/pipeline/runs');
|
|
463
|
+
return response.data;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
return handleError(error);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
export const getPipelineRunStatus = async (runId: string): Promise<PipelineRunStatus> => {
|
|
470
|
+
try {
|
|
471
|
+
// one ssh call per cluster of the run
|
|
472
|
+
const response = await api.get(`/pipeline/runs/${encodeURIComponent(runId)}`, { timeout: 60000 });
|
|
473
|
+
return response.data;
|
|
474
|
+
} catch (error) {
|
|
475
|
+
return handleError(error);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export const loadPipelineFromFile = async (name: string): Promise<Record<string, unknown>> => {
|
|
480
|
+
try {
|
|
481
|
+
const response = await api.get(`/pipeline/template/load/${name}`);
|
|
482
|
+
return response.data;
|
|
483
|
+
} catch (error) {
|
|
484
|
+
return handleError(error);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
/** Status of a pipeline step that runs over ssh (data mover): it has no slurm job id */
|
|
489
|
+
export const getSshJobStatus = async (jrJobId: string): Promise<SlurmJobStatusResponse> => {
|
|
490
|
+
try {
|
|
491
|
+
const response = await api.get(`/jobs/${jrJobId}/ssh/status`, { timeout: 30000 });
|
|
492
|
+
return response.data;
|
|
493
|
+
} catch (error) {
|
|
494
|
+
return handleError(error);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export const getSlurmJobStatusSimple = async (jrJobId: string, jobId: string): Promise<SlurmJobStatusResponse> => {
|
|
499
|
+
try {
|
|
500
|
+
const response = await api.get(`/jobs/${jrJobId}/status/${jobId}`);
|
|
501
|
+
return response.data;
|
|
502
|
+
} catch (error) {
|
|
503
|
+
return handleError(error);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
export const earlySyncJob = async (jrJobId: string, jobId: string): Promise<EarlySyncResponse> => {
|
|
508
|
+
try {
|
|
509
|
+
const response = await api.get(`/jobs/${jrJobId}/earlysync/${jobId}`);
|
|
510
|
+
return response.data;
|
|
511
|
+
} catch (error) {
|
|
512
|
+
return handleError(error);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
// ── Scheduled Slurm Jobs ────────────────────────────────────────────
|
|
518
|
+
|
|
519
|
+
export const getScheduledJobs = async (): Promise<ScheduledJob[]> => {
|
|
520
|
+
try {
|
|
521
|
+
const response = await api.get('/scheduled/list');
|
|
522
|
+
return response.data;
|
|
523
|
+
} catch (error) { return handleError(error); }
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
export const createScheduledJob = async (data: Partial<ScheduledJob>): Promise<ScheduledJob> => {
|
|
527
|
+
try {
|
|
528
|
+
const response = await api.post('/scheduled/create', data);
|
|
529
|
+
return response.data;
|
|
530
|
+
} catch (error) { return handleError(error); }
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
export const updateScheduledJob = async (id: number, data: Partial<ScheduledJob>): Promise<ScheduledJob> => {
|
|
534
|
+
try {
|
|
535
|
+
const response = await api.put(`/scheduled/${id}`, data);
|
|
536
|
+
return response.data;
|
|
537
|
+
} catch (error) { return handleError(error); }
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
export const deleteScheduledJob = async (id: number): Promise<{ status: string }> => {
|
|
541
|
+
try {
|
|
542
|
+
const response = await api.delete(`/scheduled/${id}`);
|
|
543
|
+
return response.data;
|
|
544
|
+
} catch (error) { return handleError(error); }
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export const toggleScheduledJob = async (id: number): Promise<ScheduledJob> => {
|
|
548
|
+
try {
|
|
549
|
+
const response = await api.post(`/scheduled/${id}/toggle`);
|
|
550
|
+
return response.data;
|
|
551
|
+
} catch (error) { return handleError(error); }
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
export const runScheduledJobNow = async (id: number): Promise<ScheduledJobRun> => {
|
|
555
|
+
try {
|
|
556
|
+
const response = await api.post(`/scheduled/${id}/run-now`);
|
|
557
|
+
return response.data;
|
|
558
|
+
} catch (error) { return handleError(error); }
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
export const getScheduledJobRuns = async (id: number): Promise<ScheduledJobRun[]> => {
|
|
562
|
+
try {
|
|
563
|
+
const response = await api.get(`/scheduled/${id}/runs`);
|
|
564
|
+
return response.data;
|
|
565
|
+
} catch (error) { return handleError(error); }
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
export const getScheduledJobTemplateDiff = async (id: number): Promise<ScheduledJobTemplateDiff> => {
|
|
569
|
+
try {
|
|
570
|
+
const response = await api.get(`/scheduled/${id}/template-diff`);
|
|
571
|
+
return response.data;
|
|
572
|
+
} catch (error) { return handleError(error); }
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
export const syncScheduledJobTemplate = async (id: number): Promise<ScheduledJob> => {
|
|
576
|
+
try {
|
|
577
|
+
const response = await api.post(`/scheduled/${id}/sync-template`);
|
|
578
|
+
return response.data;
|
|
579
|
+
} catch (error) { return handleError(error); }
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
export const getAgentSessions = async (): Promise<AgentSession[]> => {
|
|
583
|
+
try {
|
|
584
|
+
const response = await api.get('/agent/sessions');
|
|
585
|
+
return response.data;
|
|
586
|
+
} catch (error) { return handleError(error); }
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
export const getAgentActivity = async (
|
|
590
|
+
params: { session?: string; writes?: boolean; limit?: number } = {},
|
|
591
|
+
): Promise<AgentEvent[]> => {
|
|
592
|
+
try {
|
|
593
|
+
const response = await api.get('/agent/activity', {
|
|
594
|
+
params: {
|
|
595
|
+
session: params.session || undefined,
|
|
596
|
+
writes: params.writes ? 1 : undefined,
|
|
597
|
+
limit: params.limit ?? 500,
|
|
598
|
+
},
|
|
599
|
+
});
|
|
600
|
+
return response.data;
|
|
601
|
+
} catch (error) { return handleError(error); }
|
|
602
|
+
};
|