@milabench/bujang
React views for bujang's Slurm job management: jobs list, job submission, job details and
logs, pipelines, scheduled jobs and agent activity. They talk to the bujang HTTP API
(/api/slurm/* by default).
Install
// package.json of the host app
"@milabench/bujang": "^0.1.1" // release
"@milabench/bujang": "file:../bujang/ui" // local checkout, for development
The release tarball is self contained (dist/ is built, npm does not run prepare for a tarball).
A file: install uses the checkout as it is: run npm install once in bujang/ui first (it
installs the dev dependencies and builds dist/ through prepare), and npm run build there again
after you change it (or use the development condition below).
Peer dependencies the host provides: react >=18, react-dom >=18, @chakra-ui/react ^3,
@tanstack/react-query ^5, react-router-dom >=6.22 (v6 or v7), react-icons ^5,
@monaco-editor/react ^4, axios >=1.6.
Sources in development (HMR)
package.json exports src/index.ts under the development condition (and dist/ otherwise).
Vite's dev server resolves development by default, so with a file: install the host's
vite dev compiles bujang's sources and hot reloads them as you edit bujang/ui/src: no alias,
no rebuild. vite build uses dist/. Types always come from dist/*.d.ts.
A file: install is a symlink, and bujang/ui/node_modules holds its own copies of React
and the other peers for development. Tell Vite to use the host's copies, otherwise React
hooks break:
// vite.config.ts
resolve: {
dedupe: ['react', 'react-dom', 'react-router-dom', '@chakra-ui/react', '@emotion/react',
'@tanstack/react-query', '@monaco-editor/react', 'react-icons'],
},
(npm install --install-links copies the package instead of linking it, so it does not
need this.)
Setup
The host provides ChakraProvider, QueryClientProvider and a router. Put
BujangProvider inside the router and mount the routes:
import { BujangProvider, bujangRouteElements, bujangNavItems, createBujangPaths } from '@milabench/bujang';
import '@milabench/bujang/theme.css'; // default colour tokens (optional, host tokens win)
<BrowserRouter>
<BujangProvider basePath="/slurm">
<Routes>
{bujangRouteElements({ basePath: '/slurm' })}
{/* ...host routes */}
</Routes>
</BujangProvider>
</BrowserRouter>
// sidebar entries
bujangNavItems(createBujangPaths('/slurm')); // [{ view, label, path }, ...]
bujangRoutes(options) returns the same routes as plain { id, path, element } objects for
useRoutes / createBrowserRouter. Options: basePath (default "") and views (mount only
some views). Default layout under basePath:
| view |
path |
jobs |
/jobs |
submitJob |
/jobs/submit |
jobDetails |
/jobrunner/:slurmJobId/:jrJobId |
jobLogs |
/joblogs/:slurmJobId/:jrJobId |
pipelines |
/pipelines |
pipelineDetails |
/pipelines/:pipelineName (?run=<run id> shows that run) |
scheduled |
/scheduled |
agent |
/agent |
The views are also exported (JobsView, JobSubmitView, JobDetailsView, JobLogsView,
PipelinesView, PipelineDetailsView, ScheduledJobsView, AgentActivityView) if you prefer to declare the routes
yourself. If you change the URLs, pass matching paths.
BujangProvider props
| prop |
default |
|
apiBase |
"/api/slurm" |
Prefix of the bujang HTTP routes. Joined to the axios instance's baseURL, e.g. axios={api} with baseURL: '/api' takes apiBase="/slurm". |
axios |
internal instance (10 s timeout) |
Axios instance for every request (auth headers, interceptors). Typed structurally (BujangHttpClient: get / post / put / delete), so the host's instance fits whatever its axios version. |
basePath |
"" |
Where the views are mounted. Same value as bujangRoutes({ basePath }). |
paths |
built from basePath |
Partial override of the URL builders the views use to link to each other: jobs(), submitJob(), jobDetails(slurmJobId, jrJobId), jobLogs(slurmJobId, jrJobId), pipelines(), pipelineDetails(name, runId?), scheduled(), agent(session?). |
toast |
built-in Chakra toaster |
(options: { title, description, type, duration }) => void. Without it, bujang renders its own <BujangToaster/>. |
usePageTitle |
sets document.title |
Hook called by each view with its title. |
titleSuffix |
"bujang" |
Suffix of the default title: "<title> - <suffix>". |
colorMode |
follows <html class="dark"> / data-theme |
Forces the Monaco editor theme. |
pushJobData |
none |
(jrJobId) => Promise<{ status }>. When set, the job logs page shows a "Push Data" button that calls it. |
The API functions (getSlurmJobs, submitSlurmJob, ...) and types are exported too. They
use the provider's configuration, or configureBujangApi({ apiBase, axios }) outside React.
Standalone app
app/ is a minimal app built on the package.
npm run dev: runs the app and proxies /api to http://localhost:8765 (override it with BUJANG_API).
npm run build:app: builds the app into ../bujang/cli/serve/static, where the default Python server serves it.