HUB
Sign inSign up

newbe36524/hpc-console

By newbe36524

•Updated about 23 hours ago

HPC console for cluster status, Slurm jobs, workload history, and file browsing.

Image
0

1.0K

newbe36524/hpc-console repository overview

⁠HPC Console

HPC Console is a web app for viewing HPC cluster status, monitoring Slurm jobs, reviewing workload history, and browsing account folders. The web app and API run together in one container.

⁠Features

  • Cluster Status: view node hardware, partitions, and queue status.
  • Task Monitor: inspect pending, running, and recently finished jobs.
  • Workload History: review cluster load and job wait-time trends.
  • Queue Wait: a report of how long jobs wait before they start, by hour of the day and day of the week, for every partition. Choose the window, time zone, figure (median, 75th or 90th percentile, share over one hour), weekdays or weekends. Every partition is shown side by side, in its own panel on one shared scale. It reads the hourly rollups that Workload History records, so it needs no extra storage.
  • Folders: browse HPC folders and view entry sizes.
  • Run Reports: read the per-job CSV reports written by the operator skill: wait and elapsed time, CPU-hours and GPU-hours, average and peak utilization, peak memory and report status. Set HPC_CONSOLE_RUN_REPORT_DIR to the folder that holds them. See Run reports⁠.
  • Submit Task: explore the task-submission interface. Submission is currently simulated and does not send jobs to Slurm.

Without an HPC connection, the app uses sample data. With an HPC connection, it reads cluster and job information over SSH using read-only Slurm commands.

⁠Run locally with the Docker Hub image

Install and start Docker, then use the Docker Hub account newbe36524 that publishes the image:

docker run --rm -p 8000:8000 newbe36524/hpc-console:latest

Docker downloads the image if it is not already on your machine. If the repository is private, run docker login first.

Open http://localhost:8000⁠. The image starts in demo mode without HPC credentials. The API documentation is at http://localhost:8000/docs⁠.

⁠Configuration

Settings come from environment variables or from a .env file. Environment variables take precedence over the .env file. A blank value counts as unset. Create your .env from the tracked template:

cp .env.example .env

.env is git-ignored and never copied into the image. .env.example lists every setting with a comment. These are the ones to set first:

VariableDefaultPurpose
HPC_CONSOLE_HPC_HOSTblankLogin node host name. Compose requires it
HPC_CONSOLE_HPC_USERblankHPC account name. Compose requires it
HPC_CONSOLE_HPC_PORT22SSH port of the login node
HPC_CONSOLE_HOST_KEY~/.ssh/id_ed25519Host path of the unencrypted private key, mounted read-only
HPC_CONSOLE_HOST_KNOWN_HOSTS~/.ssh/known_hostsHost path of the known-hosts file, mounted read-only
HPC_CONSOLE_UID / HPC_CONSOLE_GID1000 / 1000User and group the container runs as. Set them from id -u and id -g so the key stays readable and the data folders stay writable
HPC_CONSOLE_PUBLISHED_PORT8000Host port for the console, bound to 127.0.0.1 only
HPC_CONSOLE_RUN_REPORT_DIRblankAbsolute folder of the run report CSVs. Read over SSH when an HPC is connected, otherwise from this host. Blank means no reports

Without an HPC connection, docker run starts the console in demo mode with sample data. Compose always connects to the HPC, so it stops before starting when HPC_CONSOLE_HPC_HOST or HPC_CONSOLE_HPC_USER is blank.

⁠Run with Docker Compose

The Compose file in this repository, docker-compose.yml, uses the Compose Specification. It has no top-level version: key, so do not add one. Use Docker Compose v2 (docker compose). The file was checked with Docker Compose v5.6.1.

From the repository root:

cp .env.example .env                    # then set HPC_CONSOLE_HPC_HOST and HPC_CONSOLE_HPC_USER
mkdir -p hpc-cache hpc-history          # create the data folders yourself, so your user owns them
docker compose config --quiet           # check the file and the .env values
docker compose up -d --build

Open http://127.0.0.1:8000⁠, or the port set by HPC_CONSOLE_PUBLISHED_PORT. The container always listens on port 8000 inside. The console serves only after the startup connection check to the HPC passes. Read the logs with docker compose logs -f if it does not start. The service uses restart: unless-stopped, so it starts again after a reboot or a crash, and a stop from docker compose stop is kept.

⁠Run reports

The operator skill writes one CSV report per tracked HPC job, named <job_id>.csv, into the folder set by HPC_CONSOLE_RUN_REPORT_DIR. The console reads that folder in one of four ways, and the Run Reports API shows which one applies in its source field:

SettingReports are read fromsource
Directory set, HPC connectedThe folder on the HPC, listed and read with fixed ls and cat over the existing SSH sessionhpc_directory
Directory set, no HPCA folder on this host, for example a mounted folderlocal_directory
No directory, HPC connectedNothing. The list is empty and no report is readno_directory_configured
No directory, no HPCCanned demo reports, marked simulatedsimulated
  • The directory must be an absolute path. A blank value counts as unset, and the setting never makes the HPC connection mandatory.
  • Only files named <job_id>.csv are read. Other files, subfolders and symbolic links are ignored, and a job id containing a separator or .. is refused with HTTP 422.
  • GET /api/v1/runs lists the runs submitted in the window (1d, 7d by default, 30d or 90d), newest first, with an optional exact partition. It reads at most 100 of the newest files in the window. truncated is true when more exist.
  • GET /api/v1/runs/{job_id} returns the samples in time order with a summary. GET /api/v1/runs/{job_id}/csv returns the stored file as text/csv.
  • A report is complete when its final row came from scheduler history, samples_only when it was closed from retained samples, and in_progress while the job has no final row. A report whose schema_version the console does not know is listed as unreadable.
  • Rows that cannot be read are skipped and counted in skipped_rows. A figure that cannot be computed is null, never 0.
  • If the directory cannot be read, the API returns HTTP 503 with a message that names HPC_CONSOLE_RUN_REPORT_DIR. It never returns an empty list in that case.
  • Responses hold only report columns and values derived from them. Commands, environment values and other users' reports are never returned.
  • Compose mounts no report folder. With an HPC connection none is needed. For a local folder, mount it into the container and set the variable to the path inside the container.

The column list, the value rules and the schema version are defined in the run-report contract⁠ of hpc-core. The console depends on the hpc-core package, which holds that contract and the shared metric formulas, so a change to the report format is made once, in hpc-core.

⁠Data storage

The console keeps one database, a SQLite file, and one cache file. Compose maps both folders from the repository root into the container:

Host folderContainer folderVariable (set by Compose)Holds
./hpc-history/var/lib/hpc-console/historyHPC_CONSOLE_HISTORY_DIRworkload-history.sqlite3, the workload history database. It is the long-lived record, so keep it
./hpc-cache/var/cache/hpc-consoleHPC_CONSOLE_CACHE_DIRphysical.json, the cached hardware layout. It is disposable: deleting it only causes a fetch from the HPC
  • Both folders are git-ignored and excluded from the image build.
  • Compose sets the two HPC_CONSOLE_*_DIR variables, so leave them blank in .env. To store the data elsewhere, change the host side of the volumes entries in docker-compose.yml, and keep the container side.
  • Both folders must be writable by HPC_CONSOLE_UID and HPC_CONSOLE_GID. If the history folder is not writable, or Docker creates it as root, the history stays in memory with a warning and is lost on restart.
  • A history file recorded for another HPC account or host is not mixed in. The console keeps the history in memory instead, with a warning, and leaves that file unchanged.
  • To back up the history, stop the container and copy workload-history.sqlite3. You can also copy it while the container runs with sqlite3 workload-history.sqlite3 ".backup copy.sqlite3". Copy the history file on its own, not the whole cache folder.

⁠Run from source

Requirements: Python 3.12 or newer, and Node.js 24 or newer. pnpm is not needed up front: Corepack, which ships with Node.js 24, runs the version pinned in frontend/package.json.

⁠Start the backend

From the repository root:

cd backend
uv sync --extra dev
uv run python -m app

The API listens on http://127.0.0.1:8000. The backend's Python dependencies are managed with uv⁠: uv sync --extra dev creates the environment and uv run runs a command in it, so no activation is needed. Run the backend tests with uv run pytest. To run against a local checkout of hpc-core instead of the pinned release, see Use a local hpc-core checkout⁠.

⁠Use a local hpc-core checkout

The backend depends on a pinned release of hpc-core (hpc-core==... in backend/pyproject.toml, locked in uv.lock). To develop against a checkout at repos/hpc-core, beside repos/hpc-console in the monorepo, run the sync script from backend/:

cd backend
python3 scripts/sync_core.py
uv run --no-sync pytest

HPC_CONSOLE_CORE_SOURCE chooses the source. auto (the default) uses the checkout when it is there and the pinned release otherwise. local requires the checkout and fails without it. release always uses the pinned release, even when the checkout is there. The script installs the checkout editable, without dependencies, and prints the source and version in use. It never edits pyproject.toml or uv.lock.

uv sync and a plain uv run both sync the environment back to the pinned release, so run commands after the script with uv run --no-sync, for example uv run --no-sync python -m app. The Docker image and release builds install the pinned release from uv.lock and do not use the script.

⁠Start the frontend

In a second terminal, from the repository root:

cd frontend
corepack enable
pnpm install --frozen-lockfile
pnpm run dev

Open http://localhost:5173⁠. Vite forwards API requests to the backend on port 8000. Interactive API documentation is available at http://127.0.0.1:8000/docs⁠.

⁠Preview the frontend with node-dev-host

To preview the frontend without a Vite server on the host, run it in the node-dev-host⁠ container. The container builds frontend/ in a private copy and rebuilds on every save. It never writes to the project folder. Requests to /api and /health go to the hpc-console service on the same Compose network.

docker compose --profile dev-host up -d --build

Open http://127.0.0.1:43100⁠, or the port set by HPC_CONSOLE_DEV_HOST_PORT. Check the last build with docker compose exec frontend-dev-host dev-host status, or read docker compose logs -f frontend-dev-host. The preview is for development only and is not a production server.

The preview uses the Caddy configuration in dev-host/Caddyfile. Its listen port must match HTTP_PORT in docker-compose.yml.

Both services use simulated data by default. To connect the backend to Slurm, create backend/.env with HPC_CONSOLE_HPC_HOST, HPC_CONSOLE_HPC_USER, and HPC_CONSOLE_HPC_KEY_PATH. Set all three together and provide a trusted host key with HPC_CONSOLE_HPC_KNOWN_HOSTS_PATH if it is not in the system known-hosts files. The key must be unencrypted. The backend checks the SSH connection at startup.

⁠Team coordination

The Team page lists the profiles and nodes that share one team folder: which nodes are online, stale or offline, and how much of each profile's concurrency limit is in use. The page refreshes at the team's heartbeat interval and stops when you leave it. Run check inspects the shared folder and lists each result with its code and a hint. Activity shows the most recent team events, newest first.

The page is read-only. To join a team, set the HPC_CONSOLE_CLUSTER_* variables for the team's shared folder. Without them the page says that team coordination is not set up, and the rest of the console is unchanged.

⁠Team settings
VariableDefaultPurpose
HPC_CONSOLE_CLUSTER_ROOTblank (off)Absolute path of the team's shared area. The _cluster/ folder is created inside it. For the command store this is a path on the HPC; for the local store, a path on this host
HPC_CONSOLE_CLUSTER_PROFILEthe HPC accountThe profile this console belongs to: one person's HPC identity and its concurrency limit
HPC_CONSOLE_CLUSTER_NODE_IDgenerated at each startFixed node id. A generated id is the profile, console and eight random hex digits
HPC_CONSOLE_CLUSTER_HEARTBEAT_SECONDS60Heartbeat interval, from 30 to 86400. A node is online within three intervals and stale within twenty
HPC_CONSOLE_CLUSTER_CONCURRENCY_LIMIT1The profile's limit when the profile is first created, from 1 to 1024. An existing limit is kept
HPC_CONSOLE_CLUSTER_STOREcommandcommand reaches the folder through the console's own HPC connection, so it needs the HPC settings. local reads a folder on this host and needs no HPC connection
HPC_CONSOLE_CLUSTER_SHARE_QUEUEblank (the account default)This node's per-accelerator quota as type=number pairs, such as h200=1,h100=0. Setting it pins the node's profile and the Team page shows it as locked. A value above the account quota stops the console at startup. In multi mode it pins the first entry only
HPC_CONSOLE_CLUSTER_ADVERTISED_URLblank (none)The page address this node advertises, such as http://127.0.0.1:43121. Each node writes it to _cluster/endpoints/ in the team folder, and the Team page lists every node's address as a link. The address is taken as written; reachability is not checked.
HPC_CONSOLE_CLUSTER_PROFILE_MODEblank (the saved choice, else single)single or multi. Setting it locks the mode: the Team page and the API cannot change it, and a change answers 409. multi needs entries from HPC_CONSOLE_CLUSTER_PROFILES_FILE or from a saved choice
HPC_CONSOLE_CLUSTER_PROFILES_FILEblankAbsolute path of a JSON profile set: a mode and a profiles list. Setting it locks the mode and the entries. A mode setting that disagrees with the file stops startup

The console refuses to start on an invalid value, and the error names the setting. A blank value counts as unset.

⁠Node profile

A node's profile is its share of the account's accelerator quota. The account quota is set by the team's operator. This node can ask for less: one row per accelerator type on the Team page sets its explicit quota, and the effective limit is the smaller of the node's quota and the account quota. A type the node does not list takes the account value.

  • PUT /api/v1/team/profile takes a JSON object such as {"h200": 1}. A value above the account quota is refused with status 422, and the error names the type. A refused request changes nothing.
  • DELETE /api/v1/team/profile resets the node to the account default.
  • A change is saved in HPC_CONSOLE_HISTORY_DIR, so it survives a restart. The first node keeps team-profile.json, and each other node keeps team-profile-<node id>.json. Without that directory it is kept in memory only. The file is never written to the team folder.
  • A change is published to the team folder through the node's own record. When the folder cannot be reached, the response reports pending, and the next heartbeat publishes it.
  • Lowering the account quota keeps the node's explicit values, and they apply again when the account quota is raised.
  • HPC_CONSOLE_CLUSTER_SHARE_QUEUE pins the profile. A pinned profile is read-only in the API and the Team page, and PUT and DELETE return status 409.
  • In multi mode, GET, PUT and DELETE on /api/v1/team/profile take ?node_id= to choose one of the console's nodes. Without it the request addresses the first enabled node. A node this console does not run is answered with 404, and nothing changes.
⁠Profile modes

A console runs one team node in single mode, the default and the behaviour before profile sets existed. In multi mode it runs one node for each enabled entry of its profile set, up to 16 entries. An entry is one profile: its node id, display name, explicit node quota (share_queue), concurrency limit and an enabled flag. The nodes share one connection to the team folder, one lock and one heartbeat round. Each node registers and leaves on its own, and a failure in one node is reported in that node's state only.

  • GET /api/v1/team/profile-mode answers enabled, mode, locked, locked_by and profiles, one row per entry with profile_id, node_id, display_name, enabled, concurrency_limit, node_quota, source (default or explicit), state and locked. The state is starting, ok, unreachable, conflict, or disabled for an entry that runs no node. With team coordination off it answers 200 with enabled false.
  • PUT /api/v1/team/profile-mode takes {"mode": "single"} or {"mode": "multi", "profiles": [...]}. An entry has a profile_id and may have node_id, display_name, share_queue (h200=1), concurrency_limit and enabled. An entry without a node_id gets a generated one, so send the ids back on later changes: a new id is a new node with no saved adjustment. single without a list keeps the first entry as the console's one node, and removes the other nodes.
  • PUT /api/v1/team/profile-mode/entries/{node_id} takes {"enabled": true} or {"enabled": false} and goes through the same change path. A disabled entry keeps its quota and saved adjustment, its record leaves the team, and enabling it again registers it again. Disabling the last enabled entry is refused with 409, the switch is refused with 409 in single mode, and an unknown node id is 404.
  • Status codes: 409 when a setting locks the mode, when team coordination is off, or for the refusals above. 422, in the standard error shape with the entry and the field named, when the hpc-core rules or the account quota refuse the set. 404 for an unknown node. A refused request changes nothing.
  • GET /api/v1/team/nodes adds self_node_ids, every node the console runs, and profile_mode. self_node_id stays the first node, and is_self is true for every node in self_node_ids.
  • The chosen mode is saved in team-profile-mode.json in HPC_CONSOLE_HISTORY_DIR, never in the team folder, and is read back on restart. An unreadable file is ignored with a warning, and the console starts in single mode.
  • A setting takes precedence over the saved choice. The precedence is: the profiles file, then the mode setting, then the saved choice, then single.
  • Startup stops, naming the setting, for multi with no entries, a profiles file that cannot be read or is refused, a mode setting that disagrees with the file, and an entry above the account quota when the account can be read.
⁠Team protocol limits
  • Slot limits are advisory. Slurm remains the authority on what runs.
  • The folder's permissions are the trust boundary. There is no confidentiality and no authentication: a sender's id is a claim.
  • Do not put secrets in messages or node names. Team nodes read them as data and never run them.
  • The console writes its own node record only, and it leaves the team on a normal shutdown.

⁠Local three-profile simulation

For testing team behaviour on one machine: three console nodes (hpc-console-a, hpc-console-b, hpc-console-c) run as three profiles (sim-a, sim-b, sim-c) on one HPC account. Each profile has its own data and its own share of the accelerator quota. The default single instance is unchanged, and docker compose up never starts the simulation.

Turn it on. Set HPC_CONSOLE_LOCAL_SIMULATION=three-profile in .env, or in the environment, which wins. A blank value or any other value keeps the simulation off, and every command then refuses without changing anything.

Commands. Run them from backend/, for example uv run python scripts/local_sim.py plan.

CommandWhat it does
planReads the account quota and prints each profile's node quota. Writes nothing, to the team folder or to disk
prepareReads the account quota, sets each profile's account record to it (only when it differs), copies the data for each profile and writes local-sim/pins.env
upRefuses while the default hpc-console service runs or a port is taken. Otherwise prepares and starts the three services
downStops the three services and keeps every data copy
statusOne row per profile: node id, port, container state and node quota

Data layout. prepare copies ./hpc-cache into local-sim/<profile>/cache, and workload-history.sqlite3 into local-sim/<profile>/history with SQLite's online backup from a read-only connection, so changes still in the write-ahead log are included. An existing copy is never replaced, and the originals are only read. local-sim/ is git-ignored and is not sent to the image build.

Quota rule. For h100 and h200 that the account holds, with quota N, sim-a and sim-b each pin floor(N/2) and sim-c pins the remainder N - 2*floor(N/2). For l40s, sim-c pins the whole quota and sim-a and sim-b pin none. A type the account lacks is not listed, and smaller types keep the account default. The pins go to HPC_CONSOLE_CLUSTER_SHARE_QUEUE of each service.

Ports and labels. HPC_CONSOLE_SIM_PORT_BASE (default 43121) gives three loopback ports, 43121 to 43123 by default. They must stay inside 43100-43299. Each service carries the node-dev-host.port and node-dev-host.name labels, so the ND Console control node lists three console nodes. HPC_CONSOLE_SIM_PREFIX (default sim) changes the profile id prefix.

Return to the single instance. Run local_sim.py down, unset the flag, then docker compose up -d. The local-sim/ copies stay on disk until you delete them.

Account records. The console checks a pin against its own profile's account quota at startup, so each simulated profile's record must hold the account quota. prepare sets sim-a, sim-b and sim-c to the account's quota with hpc-core's own record writer, and leaves a record alone when it already holds that quota. The record keeps its concurrency limit. A record that cannot be read is not overwritten, and nothing is started.

Reading the quota. The account quota is read with the console's own connection settings (HPC_CONSOLE_HPC_*, HPC_CONSOLE_HOST_KEY, HPC_CONSOLE_HOST_KNOWN_HOSTS) and the team folder named by HPC_CONSOLE_CLUSTER_ROOT. Reading never registers a node. With HPC_CONSOLE_CLUSTER_STORE=local the folder is read from this host.

Current limits.

  • Team coordination must be configured, so HPC_CONSOLE_CLUSTER_ROOT must be set. Setting it in .env also turns it on for the default single console, so pass it on the command line for the simulation when the default console should stay off.
  • A failed read stops the command before anything is written.

⁠Design notes

  • Cluster and node support⁠: design for running consoles as nodes of a research team. Team coordination and profile modes are implemented as described above; the work-sharing design in it (sections 4 to 6) is still a draft.

Tag summary

Content type

Image

Digest

sha256:0158332de…

Size

56.8 MB

Last updated

27 days ago

docker pull newbe36524/hpc-console