Results in scripts
Scripts, notebooks and agents can use QA-Board's results, and add to them, from Python, the shell, or any language over HTTP. Pick the way in that fits what you have:
| You want to | Use | Where |
|---|---|---|
| Work on the runs you see in the web app: read their metrics and files, add metrics or files | qaboard.runs(url), run.log_metrics(), run.log_artifact() (Python) | below |
| The same from the shell: one folder per line, or JSON | qa runs <url> | below |
| Where the runs of a batch of your checkout save their files, before or after running them | qa batch <batch> --list-output-dirs, --list, --save-runs, qa get | Find where runs save their outputs |
| Compute metrics for a whole batch with the project's own code | postprocess() and qa batch --action-on-existing postprocess | Postprocessing |
| Run a batch on a pushed commit, as the web app does, from a script, CI job or agent | qa --label <name> batch --commit <sha> <batch>, /api/v1/commit/<sha>/batch | Start batches from a terminal, HTTP API |
| Know whether a commit regressed against its reference | qa gate --json, /api/v1/commit/<sha>/compare | Quality gate, HTTP API |
| Everything else, from any language: commits, branches, projects, a run's files, milestones | the HTTP API at /api/v1 | HTTP API |
Create runs from a training loop or a notebook, without qa run, and log while they run | qaboard.start_run() (Python, experimental) | Log from your code |
Coding agents get the same, packaged as skills.
Work on the runs you see in the web app
To post-process runs, e.g. to compute a metric on their images that the CI didn't, start from the web app: find the
commit, pick the batch, filter the runs you want, and copy the page's address. qaboard.runs() reads the project,
commit, batch and filter from it, and asks the server for those runs:
# /// script
# dependencies = ["qaboard", "imageio"]
# ///
import imageio.v3 as iio
import qaboard as qb
url = "https://qaboard.example.com/kitefin/detector/commit/7622c337?batch=ci&filter=night%20status:success"
for run in qb.runs(url):
image = iio.imread(run.output_dir / "output.png")
print(run.input, run.params, run.metrics.get("psnr"), image.mean())
Each Run has:
| Attribute | What it is |
|---|---|
input, database, input_path | The input's path relative to its database (as in batches and qa run --input), the database, and the full path. |
configs | The configurations (qa --config), strings and mappings, then the tuning parameters: like context.configs in run(). |
params | The mappings of configs merged, and the parameters the run reported: like context.params. Usually all you need. |
metrics | The run's metrics: those it returned, and those added by scripts. |
output_dir | Where its files are, as a Path: like context.output_dir. |
series(key) | What the run logged while it ran with run.log(): (step, value, time) rows, empty when it logged no such series. |
state, is_failed | pending, running or finished; whether it failed. |
id, commit, batch, project, url | Where it is in QA-Board, and its link in the web app. |
type, input_metadata, data, created_at, finished_at | The input's type and metadata, what else the server knows (who ran it, where...), when. |
extra_parameters, rel_input_path | The tuning parameters alone (they're the last of configs), and input as a Path: rarely needed, named like in run(). |
Runs are read-only: params, metrics and the other mappings are read-only views, and changing them is an error,
since it would change nothing on the server (copy them with dict(run.metrics)). run.to_dict() gives all of it as
plain data. You can also name the runs instead of giving a URL:
qb.runs(project="kitefin/detector", commit="main", batch="ci", filter="night"). commit can be a branch or a tag;
without it, you get the latest commit with results (branch= picks the branch). Keyword arguments override what a URL
says, and side="reference" gives the runs of the reference bar (?reference=) instead of the compared ones
(side="new", the default). Runs whose files were deleted, and
the iterations of automated tunings, are left out unless you ask
(include_deleted, include_hidden).
Save it as sharpness.py and run uv run sharpness.py: the # /// script header says what to install, and uv
does it in a throwaway environment. Or install the packages yourself (pip install qaboard imageio) and run
python sharpness.py. The header must list your site's package too when your QA-Board has one, next to
qaboard: it tells qa where your server and storage are. The web app's Script button writes the right header
for your server, so start from it; admins set it with QABOARD_CLI_REQUIREMENTS
(server settings).
In the web app's Visualizations and Output Files views, Script shows this snippet with the page's
address, ready to copy, and the shell version. The filter is applied like in the web app
(filter syntax), so the script works on exactly the runs you looked
at. Add status:success to the filter to skip failed and unfinished runs, which may have no files or metrics.
From the shell, qa runs <url> prints the runs' folders, one per line, and --json everything above
(--side reference for the reference bar's). It works
outside a project, without a qaboard.yaml:
qa runs "https://qaboard.example.com/kitefin/detector/commit/7622c337?batch=ci&filter=night" | while read dir; do
python compute_sharpness.py "$dir"
done
Reading needs the qaboard package (pip install qaboard) and, when the project isn't public, to be signed in:
qa auth login --server https://qaboard.example.com, or a token in QABOARD_TOKEN (see Authentication).
A token from the environment is only sent to the server qa is configured for, not to any server a pasted URL names.
When the server is behind a path prefix like https://tools.example.com/qaboard/, pass server= (--server): the
address alone can't say where the project's name starts.
Add metrics to runs
Your script can add what it computed to the runs, with run.log_metrics(): the server merges the metrics into the run's, and
remembers who added each one, when and with which script. Wrap values in Metric(...) to say their unit and which
way is better, like in run():
from qaboard import Metric
for run in qb.runs(url):
sharpness = measure(run.output_dir / "output.png")
run.log_metrics({"sharpness": Metric(sharpness, smaller_is_better=False, target=0.3)})
- Try it first with
qb.runs(url, dry_run=True)(orrun.log_metrics(..., dry_run=True)): it prints what it would add. - You need to be signed in (
qa auth login, orQABOARD_TOKENwith theingestscope) with the developer role on the project, whatever the server's policy for results sent byqa. The added metrics are recorded under the token's user, not what the script says. - The added metrics show in the web app like the others, and count in the Summary, the Metrics Diff and
quality gates. The run's
data["added_metrics"](qa runs --json) says who added each one, when and with which script. The run's own metrics.json is not changed, and nothing is written in its folder. - Values are finite numbers, booleans, short texts or
None.is_failedandcompute_timecan't be added: the run sets them. - Metrics the run itself returned are refused, unless you pass
overwrite=True: the run's value is then kept asreplacedin the provenance. Logging the same name again replaces your previous value. - If the run is run again and its code now returns a metric of the same name, the run's value wins and the addition is forgotten. The other added metrics stay, with the date they were added: they were computed from the previous run's files.
- To recompute many metrics with the project's own code instead, use your
postprocess():qa batch ci --action-on-existing postprocessredoes it on existing results (Postprocessing).
Add files to runs
A script can also add files to a run, e.g. a sharpness map next to the output it was computed from, with
run.log_artifact(name, file): name is the file's path in the run's folder (subfolders are created), file a path
to copy or bytes to write. The web app then lists it with the run's files, and opens it with the viewer its
extension picks (images side by side with the reference's, plots, text diffed...):
for run in qb.runs(url):
heatmap = sharpness_map(run.output_dir / "output.png")
run.log_artifact("sharpness/map.png", encode_png(heatmap))
run.log_artifact("sharpness/report.html", report_path)
- Nothing is overwritten: a name that exists fails, unless you pass
overwrite=True. Keep your files in a folder of their own (sharpness/), and leave what the run wrote alone: runs' folders are shared with everyone. - The file is written as you, in the shared storage, like
qa rundoes: you need write access to the run's folder. The run's manifest is then refreshed on the server, so the file shows in the web app at once. dry_run=Trueprints what would be written.- To show the file on run cards for every run, declare it in qaboard.yaml's
outputs.visualizations(visualizations); otherwise it's in Output Files.
To create runs from your own code (training loops, notebooks), with values logged at each step, use
qaboard.start_run() (experimental): see log from your code.
Find where runs save their outputs
qa batch <batch> --list-output-dirs prints where each run's results are saved now, one per line, without running
anything. In the detector's project:
qa batch ci --list-output-dirs
/home/arjun/detector/output/7622c337-20/slices-indoor
/home/arjun/detector/output/7622c337-20/slices-outdoor
...
--list prints the runs as JSON, with what each one would run. It answers "what would this batch do", with the
same --action-on-existing: a shared or CI run that would be done again is listed in the folder its new attempt
would use (reruns), and runs that would be skipped are listed where they
are, with "skipped": true.
qa batch ci --list
[
{
"type": "default",
"input_path": "inputs/slices/indoor",
"database": "inputs",
"platform": "linux",
"configurations": ["fp32", "size-320"],
"extra_parameters": {},
"batch": "ci",
"output_dir": "/home/arjun/detector/output/7622c337-20/slices-indoor",
"command": "qa --configuration fp32:size-320 run --input \"slices/indoor\"",
"rel_input_path": "slices/indoor"
}
]
To know where the runs of a batch were saved, e.g. for the next step of a pipeline, have the batch say it:
--save-runs runs.json writes the same JSON as --list once the runs are done (or started, with --no-wait).
Listing before running and reading after can disagree: someone can do a run again in between.
qa batch ci --save-runs runs.json
python compute_metrics.py runs.json
--list-inputs only prints the inputs. Runs save their files under the project's storage (see where is the data), and
qa batch ci --list-output-dirs prints those.
For other values, qa get prints the variables qa uses:
qa get commit_id
qa get --input slices/indoor output_dir
Read results over HTTP
Everything the web app shows comes from QA-Board's HTTP API, which any language can call: commits, branches, projects, a commit's batches and runs, a run's files, comparisons with a reference, milestones. For instance, the latest commits of the detector, with their CI batch:
curl "https://qaboard.example.com/api/v1/commits?project=kitefin/detector&only_ci_batches=true&limit=10" | jq
See HTTP API: authentication, the requests for everything about one commit, and the shape of the
answers. Your server also has the API's reference, to try requests, at <your-qaboard>/api/v1/docs, and its OpenAPI
document at <your-qaboard>/api/v1/openapi.json.
Authentication
Reading results doesn't need to be signed in, unless your server
requires it or the project isn't public. Adding
metrics or files does, and so do some actions, like starting batches with qa batch --commit.
qaandqaboard.runs()use your login: runqa auth login --server https://qaboard.example.comonce (see Sign in).- In CI and scripts, set
QABOARD_TOKENto a token: create one in the web app, in Settings → Access tokens (how), or use the one ofqa auth token. Give it only the scopes it needs:read,ingest(send results, add metrics),act(redo runs, start or delete batches, save milestones). - Over HTTP, send the token in an
Authorization: Bearerheader: see Authenticate, with the reasons a token can be refused.