Skip to content

Web app

The service serves a web app at /ui/, e.g. http://localhost:8000/ui/ on the local test system, or on the local service of a project, which needs no cluster. It has two modes, switched in its top bar: the Executions, the runs of people and agents live, and the Editor, in which a workflow is built or changed, estimated and run while its file stays next to the code. The app talks only to the API of the service, with the token of the user; the service serves it from the directory of its setting web (/opt/simrun/web in the service image), and without that setting there is no /ui/.

Login

The app asks for a token of the tokens file of the service (see Authentication), checks it with GET /me and keeps it in the local storage of the browser. Every request and every event stream sends it as a bearer token, never in a URL. A token the service no longer accepts (removed from the tokens file) returns the app to the login and removes the token from the browser.

Theme

The app follows the light or dark setting of the system (prefers-color-scheme) and changes with it while open. The button left of the identity in the top bar (and at the top right of the login) chooses Light, Dark or System; the choice is kept per browser, in its local storage, and applies to the other tabs of the app at once. Without a usable storage (a private window which refuses it) the choice lasts as long as the page. The logs of a task are a dark terminal in both themes. The theme needs a browser which resolves light-dark() of CSS: Chrome and Edge 123, Firefox 120, Safari 17.5 or newer.

Executions

The view has the runs on the left, the canvas of the selected run in the center with the run bar above it and the servers below it, and the inspector on the right. On a phone (narrower than 768 px) the views are one column which scrolls: the runs without a selected run, else the canvas of the run with the servers and the inspector under it (Executions in the top bar goes back to the runs); the Editor has its canvas, the inspector and the palette under each other. The top bar keeps the logo, the modes and the avatar, the minimap of a canvas is left out.

The Executions: a running run with its task selected Everything is live: the app reads the event streams GET /events (the runs and the servers) and GET /runs/{run}/events (the record, the progress and the workers of the selected run). When a stream drops, e.g. while the service restarts, the top bar shows reconnecting and the app connects again, waiting 1 s, doubling up to 10 s, and keeps the selected run.

  • Top bar: where you are (the workflow of the selected run), the capacity of the cluster (the cores the pods of all servers request out of all cores, and the number of queued runs) and the identity of the token.
  • Runs: a card per run, the 200 most recent, with the workflow, the run, who submitted it (an agent with its owner), its state, its progress and, for a failed run, its message. The chips All, Mine (the runs of the person of the token and of the person's agents), Agents and Active (submitting, queued or running) filter them, a menu selects a group. A click selects the run; the address /ui/#/runs/<run> keeps it on a reload.
  • Run bar: the run, who submitted it and when, its state and its progress (tasks done, units done of all units), and Stop, which cancels a run that is not over after a confirmation in the bar.
  • Canvas: a card per task, in columns by the depth of the task in the graph of its inputs, with the edges of the inputs. A card shows the type, the task, its state, its settings, the units of its ledger with a progress bar and the workers of a split task on their servers; a task split over several workers is drawn as a stack. A task without a ledger shows its state without a progress bar.
  • Servers: a tile per server of the cluster with the cores and memory the pods of runs on it request, out of what the scheduler gives them (the allocatable cores and memory less the requests of other pods, e.g. of DaemonSets), a segment per pod, those of the selected run in blue; a reserved server says by which run.
  • Inspector: without a selected task, the run: its message, who submitted it with which priority and when, its kills for memory and its sources (the snapshots with branch, commit and changed files). With a task selected on the canvas, the tabs Overview (why a failed task failed, the exit of its last pod; the units, the elapsed and the remaining time, or the phase, starting or merging; the numeric fields of the last progress line, the workers with their servers, processes and memory, and the resources its plan requested), Outputs (the output files of the task) and Logs (the last lines of every pod, read again every 5 s while the task runs; tracebacks and errors in red, the lines of the Argo executor hidden unless asked for, long lines scrolled sideways or, with wrap lines, wrapped at the width of the inspector). A server is named by the last two parts of its host name everywhere, agent-0 for k3d-simrun-test-agent-0, the full name in a tooltip.

A failed task: the message names the pod and its exit

The outputs of a task

The Editor

The Editor edits a workflow file which stays on the machine with the code: the browser never reads or writes that machine, a command running there does. The browser can be on any machine which reaches the service.

The command

On the machine with the working trees, with SIMRUN_URL, SIMRUN_TOKEN and SIMRUN_STORE set as for every command and the store mounted:

simrun edit fit.yaml --source model=~/git/pkdb_models --source sbmlsim=~/git/sbmlsim

It reads the file (a file which does not exist yet is a new workflow named by the file stem, without tasks), snapshots the sources, opens an edit session in the service and prints the link of the Editor, e.g. http://localhost:8000/ui/#/edit/<id>. It keeps running: it answers the saves and runs of the browser, and every 2 s it sends the file and the state of the working trees (branch, commit, uncommitted files) to the session when they changed. While a run is being submitted (plans, snapshots) it keeps telling the service that it is alive, and when the service is not reachable or a proxy answers 502, 503 or 504 (e.g. during a redeploy), it retries with a backoff of 1 s doubling to 10 s; a request is done once, also when its answer had to be sent again. Ctrl-C (or SIGTERM) closes the session and ends the command with exit code 0; when the service does not answer the close within 5 s, the command ends anyway and the session shows not connected after 30 s. A second Ctrl-C ends the command at once. --group is the group of the runs started from the Editor which name none.

The session

A session lives in the store under edits/<id>/, so a restart of the service keeps it. The page #/edit (the Editor switch of the top bar) lists the sessions of your token by file name, with the directory, the machine, the workflow and whether the session is connected; the sessions which are no longer connected are listed under Closed, the ones not seen for a day behind Show older. A click opens one; the breadcrumb of the top bar then names the file. Saves and runs of a session are allowed only to the person whose token opened it. A session is connected while its command runs and asked the service for requests within the last 30 s.

Editing

The Editor has the palette of the task types of the service on the left, the canvas in the middle with the bar floating above it, and the inspector on the right.

The Editor: the palette, the canvas with the estimate on the cards, and the settings and resources of the selected task

  • Palette: the task types installed in the service, grouped by the part of their name before the first . (demo.squares under "Demo", command under "General"), with the description of the type (see Plugins) and a search; its footer says which file a save writes on which machine. A click adds a task right of the right-most one and pans the canvas to show it, a drag drops it where it is let go. A new task is named by the last part of its type, with -2, -3 for further ones.
  • Canvas: a card per task with a handle per output port on the right and per input port of its type on the left; a command has a handle per input it reads and a +, where a connection adds an input named after the task it reads. Dragging from an output to an input connects them; a connection which closes a cycle or reaches a port which is already connected is refused with a note under the bar. Delete or Backspace removes the selected task (and the inputs which read it) or edge. The tasks are laid out when the session opens and when the workflow comes from disk; afterwards they stay where they are dragged. Positions are not saved in the file.
  • Inspector: with a task selected, its type and id, its settings as a form of the JSON Schema of the settings of its type, without the fields the schema marks readOnly, which the plan of the type sets (numbers, choices and switches in two columns; an empty field is not written, so the default of the type applies; what the form cannot edit is edited as JSON), its inputs and the ports staged to local scratch, its resources (workers and memory per worker overriding the learned ones, its split; a command has the resources of its settings and stages nothing) and the estimate: memory per worker of the plan, duration and placement (the pods, the worker processes of a pod and the memory of a pod). Without a selected task, the workflow: its name, its split, the reservation of a server, the group of the run and the sources.
  • Validation and estimate: every change is validated at once in the browser, by the code of the service compiled to WebAssembly (simrun-core) with the manifests of the task types of the service (GET /task-types/manifests): the same messages as the service, without a request and without a connection. The errors of a task show on its card and in the inspector, an error of a setting under its field, the others in the inspector of the workflow. A valid workflow is estimated in the browser as well, with what the service plans with besides the workflow, its nodes, their reservations and the resources learned for the model of the sources (POST /estimate/context, asked again when it is older than 30 s or the sources change), and the cards show the chips of the estimate (workers, memory per worker, duration, pods); without an estimate the inspector of a task says why, e.g. that one worker needs more memory than any server has. A task type which counts its units with python (count_units) is estimated by the service 400 ms after the last change. The service stays the authority: it validates the draft again at a save and at a run, and its answer replaces the one of the browser. When the module cannot be loaded, the service validates and estimates every change 400 ms after the last one. The estimate is of the workflow as edited: a task type which plans its settings does so only when the workflow runs.

A command task in the Editor: its args one per line, the inputs it reads and a + handle for another

Save and Run

The bar shows the branch, the commit and the uncommitted files of the model source, the machine of the session and the state of the draft: valid, saved, unsaved changes, the number of errors, or changed on disk.

  • Save sends the draft to the command, which writes it into the file atomically, in the form simrun writes a workflow (the fields which differ from the defaults, a list indented below its key): comments and the formatting of a hand-written file are not kept. Save is enabled only with unsaved changes (or a file changed on disk), so opening a hand-written file and looking at it never rewrites it. A save or a run waits up to 60 s for the command; it fails at once when the command stops meanwhile.
  • Run workflow sends the draft, saved or not, to the command, which snapshots the working trees again, plans the tasks with the task types installed there and submits the run, as simrun submit does with the same sources. The file is not written by a run. The Editor then shows the run in the Executions.

Conflicts

A change of the file on disk (by another editor, or by git checkout) reaches the Editor within a few seconds. Without unsaved changes the Editor takes the new workflow and lays it out again. With unsaved changes the bar says changed on disk and offers Reload (drop the draft for the file on disk) and Save anyway (overwrite the file on disk with the draft, whatever changed there). A plain Save is never written over a file which changed since the draft started from it: the command refuses it and the bar offers the same two choices. A file which appears on disk after the session opened on a missing file is such a change as well.

Without a connected machine

When the command stopped, or its machine has not asked for 30 s (asleep, off the network), the bar says that the machine is not connected. Save becomes Download YAML, which downloads the draft as <workflow name>.yaml in the form a save writes, and the state says unsaved changes, download to keep them once the draft was changed. Run workflow submits the draft from the browser with the last snapshots of the session, as edited: the plans of the task types run in the page first, as the command line runs them before a submission, for the types whose plan is a module of the page (a wasm implementation with the operation plan); a draft with a task whose plan runs only where its type is installed (a python plugin) is refused with that task named, so it runs through simrun edit. Starting the command again opens a new session.

Rerun with changes in the run bar of the Executions opens the workflow and the sources of a run in the Editor (#/runs/<run>/edit). There is no machine behind it, the bar says from run #: Download YAML keeps the changes, and Run workflow submits the changed workflow with the snapshots, the group and the reservation of the run (the reservation shows in the inspector of the workflow and can be changed there).

Running in the browser

A workflow whose tasks have a WebAssembly implementation runs in the page itself, without the service computing anything: the browser backend. The Editor's Run button has a menu of where the workflow runs: In this browser, or the backend of the service, On this machine (the local service) or On the cluster (GET /backends). The choice is kept in the browser. A workflow runs in the browser when every task has an implementation the page can run: a wasm module of the unit ABI (Unit ABI) whose host services the page provides, or a native entry of which the page has a module (demo.squares, the example module bundled with the app). Its plans run in the page before the run, as for a submission to the service. Otherwise the menu and a note under the bar name every task which does not, and the inspector of a task says why for each of its implementations (python: runs where its python plugin is installed, wasm: requires sbmlsim.simulation/1, which the browser does not provide, runs the image of its settings for a command).

How a run in the browser works:

  • Workers. The units of a task run in web workers, one instance of its module per worker, as many workers as the plan of the core gives a node of the browser's cores (navigator.hardwareConcurrency) and a memory budget (16 GB, or the navigator.deviceMemory of a smaller device), the cores of the tasks which already run taken off. The page is the coordinator: it keeps the ledger of a split task, hands a worker a batch of units (as many as take about 50 ms by the units done so far, one before the first is done), counts the units, runs the merge in a worker once every unit is done, and runs the tasks whose inputs are done side by side. The module of a wasm implementation is fetched from the service (GET /task-types/{name}/modules/{file}), its sha256 checked, compiled once and capped at the memory per worker of the plan; a module beyond it is tried once more with the memory of a retry, as a pod killed for its memory.
  • Files. A run is kept in the store of the browser, the origin private file system (OPFS) of the page's origin, with the layout and the files of the local service: runs/<id>/run.json and per task settings.json, provenance.json, out/ with the outputs, summary.json and the marker of the merge, units/size and units/done/<i>, the report of the worker workers/<task>-w0-0.json (without a peak of the memory, see below), logs/ and progress.jsonl. The outputs are those of the local service byte for byte. A unit's files are written before its mark in units/done/. A browser without OPFS (some private windows) keeps the runs in memory, until the page closes.
  • Host services. Every page provides simrun.echo/1; another script of the page registers more with services.register("<name>/<version>", (requests) => answers) of simrun-core/browser/services (the package simrun-core), which a module asks with an ask of the ABI.
  • Sleeping. The service serves the app cross-origin isolated (Cross-Origin-Opener-Policy: same-origin, Cross-Origin-Embedder-Policy: require-corp), so that a unit which sleeps blocks its worker with Atomics.wait; without isolation it waits busily.

In the Executions the runs of this browser are listed with those of the service, newest first, marked browser, with a chip Browser of their own; a run of the browser which was uploaded is listed once. The canvas, the inspector, the outputs and the logs of a browser run come from the store of the browser, live while it runs. A browser run is described in the terms of the browser, not of pods and servers: its card names this browser and the number of its web workers, the inspector of a task lists the worker with its web workers and says what its plan gave it (the web workers on the cores of this browser, the memory a module may grow to, at most 4 GB, and the memory of a retry), and below the canvas the strip shows This browser instead of the servers: its cores (navigator.hardwareConcurrency) and the web workers of the tasks which run in the page, one core each, those of the selected run in blue. The memory of a web worker is not measured: the browser gives no peak of the memory of a worker (performance.measureUserAgentSpecificMemory() measures the page with all its workers at its next garbage collection, no peak of one task), so the report of the worker has no peak (peak_memory_bytes is null, as a report without a measurement of the service). Its run bar has Stop, Download (a zip of the directory of the run), Upload (once it ended: the run becomes a run of the service, POST /runs/import, with its outputs and logs, under the identity of the token), and Remove (from the store of the browser). A run whose page was closed while it ran is interrupted: Resume continues it in this page from the units it has done, Stop ends it as cancelled. Another tab of the app sees the runs of the browser as well, and follows their changes.

The record of a run names the backend which ran it (backend: browser, or local, argo for a run of the service), and an upload keeps it, so an uploaded browser run is described in the terms of the browser wherever it is viewed, also in another browser or after it was removed from the store of this one: its card names a browser and its web workers, the inspector names the browser as where it ran (no time of a build, no image), lists the web workers with the memory not measured and says what the plan gave without the cores, which only the browser that ran it knew, and the legend of the servers strip says that the run ran in a browser, on none of the servers. The list of the runs marks it browser as well, from the backend in the summary of the run (backend of GET /runs and of the event streams), with the title "Ran in a browser, uploaded to the service with its outputs and logs"; the chip Browser filters the runs of the store of this browser.

Development

The app is a Vite project in frontend/ (Vue 3, TypeScript, Vue Flow, Tailwind CSS) with node 24 and the versions of frontend/package-lock.json. Its core and the browser backend are the npm package simrun-core of the workspace frontend/packages/simrun-core (below), which the app uses from its sources. It bundles the WebAssembly module of crates/simrun-wasm, which npm run wasm builds with the Rust toolchain of rust-toolchain.toml and the wasm-bindgen of Cargo.lock (cargo install wasm-bindgen-cli --version <version> --locked), see the Rust workspace:

cd frontend
npm ci                 # the dependencies of the lock
npm run wasm           # the module into packages/simrun-core/src/pkg; dev, build, test and typecheck run it first
npm run dev            # the dev server at http://localhost:5173/ui/, with reload on every change
npm test               # the tests of the app and of the package (Vitest, jsdom)
npm run typecheck      # vue-tsc of the app, tsc of the package
npm run build          # into frontend/dist, which the service serves with `web: frontend/dist`

The dev server proxies the API to the service of SIMRUN_URL, else http://localhost:8000, so it runs against the service of the local test system: start the service as described there, submit a run or start simrun edit, and open http://localhost:5173/ui/ with the token t-mk. The service of the local test system also serves the built app at http://localhost:8000/ui/ once npm run build made frontend/dist.

The types of the API in frontend/packages/simrun-core/src/schema.d.ts are generated from the OpenAPI document of the service, frontend/src/api/openapi.json, which is maintained by hand and against which the contract tests of the service check its routes and answers. After a change of the API, edit the document, then:

cd frontend && npm run types       # frontend/packages/simrun-core/src/schema.d.ts

The wheel simrun carries the built app (frontend/dist, which the job frontend builds) as data, installed into <prefix>/share/simrun/web, where the local service finds it; the image of the service has it at /opt/simrun/web.

Every colour of the app is a token of frontend/src/theme.css, a pair light-dark(<light>, <dark>) as in sbmlsim-web, used as a class of Tailwind (bg-surface, text-fg-muted, ring-danger-line) or as var(--color-<token>); the default palette of Tailwind is removed, so a class of it draws nothing. src/theme.test.ts fails on a colour written anywhere else (a hexadecimal colour, rgb() and the other colour functions, a class of the palette of Tailwind, a named colour), on a class or a var() of a token which does not exist, and on a colour of text with less than 4.5:1 or a mark (a bar, an edge, the focus ring) with less than 3:1 against the surfaces it is drawn on, in either scheme (WCAG 1.4.3 and 1.4.11). The canvas of Vue Flow takes the tokens through src/flow.css.

frontend/mockup/ is the approved mockup the app is built from, a single page with data in memory.

The package simrun-core

The core of the Editor and the browser backend are the npm package simrun-core, released with simrun at its version, so that other web pages can validate, estimate and run workflows as the app does:

  • simrun-core: createCore(manifests) (the task types of GET /task-types/manifests of a service), whose validate, validateYaml, estimate, workflowYaml, planText and browserTasks answer as the service does; the module simrun_wasm_bg.wasm is loaded from beside the module (loadModule), or from bytes (loadModuleSync); the types of the API (Workflow, RunRecord, ValidationResult, ...).
  • simrun-core/browser: the browser backend, BrowserBackend with OpfsStore or MemoryStore, the host services services, createUnitWorker and the plans of the types which run in the page; each module also as simrun-core/browser/<module>, so a page loads the backend with its first run, as the app does.
  • simrun-core/demo_squares.wasm: the example unit module, the native entry demo.squares.
import { createCore } from "simrun-core";

const core = await createCore(manifests);
core.validateYaml(text); // { ok: true, errors: [] }

A page which runs workflows is cross-origin isolated, so that a unit which sleeps blocks its worker, and serves the worker of the package from its own origin: a bundler emits it, unbundled the files of the package are served by the page. The README of the package (frontend/packages/simrun-core/README.md) has an example of the backend; Development describes the build, the check of its tarball and its release.