runlab-client
Did my change actually help? You record each seed's metric for two arms: your change and its baseline. RunLab gives back a verdict you can quote, built from:
- a pre-registered plan;
- a paired test across seeds, with a 95 % confidence interval;
- checks that refuse a comparison that would mislead, e.g. arms tuned with unequal budgets.
This repo has the Python client (standard library only), the OpenAPI spec (rendered) and examples.
Get started
pip install runlab-client # Python 3.10+, no dependencies
runlab login # sign in with GitHub, approve this terminal
# Sign in to RunLab: open https://runlab.tools/login?code=BCDF-GHJK
# and check that the page shows the code BCDF-GHJK (it works for 10 minutes; ...)
# Logged in as ada
runlab whoami # ada (agent) at https://runlab.tools
runlab loginopens a browser when this machine has a display. On an SSH session or a headless GPU box, open the printed link on any device (your laptop or phone).- The page asks "Authorize this terminal?" and shows the code, the address and host name that asked. Approve only if the code matches the one in your terminal.
- The key is saved to
~/.config/runlab/token($XDG_CONFIG_HOMErespected): the folder is0700, the file0600. It is a personal API key namedcli <host> <date>that works until you log out.runlab logoutrevokes it and deletes the file. - After that,
RunLab()needs no settings. Its order:token=argument, envRUNLAB_TOKEN, the saved key;url=argument, envRUNLAB_URL, the URL you logged in to,https://runlab.tools. The saved key is only sent to the URL that issued it. - In CI or other non-interactive jobs, set
RUNLAB_TOKEN(andRUNLAB_URL) instead.
Quickstart
from runlab_client import RunLab
rl = RunLab() # after `runlab login` (or RUNLAB_TOKEN)
rl.me() # {'name': 'ada', 'role': 'agent', ...}
# 1. Pre-register, before any seed runs.
rl.plan("resnet-aug", "mixup", "baseline", "acc",
hypothesis="mixup raises top-1 accuracy", n_max=10, stopping="fixed")
# 2. Record each seed's metric for both arms (use the same seeds for both).
for seed in range(10):
rl.result("resnet-aug", "mixup", acc=train("mixup", seed), seed=seed)
rl.result("resnet-aug", "baseline", acc=train("baseline", seed), seed=seed)
# 3. Compare once, after the planned seeds ran.
v = rl.compare("resnet-aug", "mixup", "baseline", "acc")
print(v["verdict"], v["prereg"]["status"]) # a_better ok
print(v["text"])
# mixup vs baseline on acc (higher is better): mixup is better
# paired_t: diff +0.0178 [95% CI +0.0094, +0.0262], p=0.00098, n=10 (A 10, B 10)
# ... (relative effect, rank test, seed stability, fragility, plan, equal budget)
# 4. May a write-up quote it?
for c in rl.report("resnet-aug")["claims"]:
print(c["status"], c["quote"]) # quotable mixup − baseline on acc = ...
train is your own training run. The numbers above are an illustration. A runnable version
with a simulated train is examples/quickstart.py, and
examples/curl.sh does the same loop over plain HTTP.
The loop
| Step | Client | HTTP | What RunLab does |
|---|---|---|---|
| 1. Plan | plan(project, a, b, metric, hypothesis, n_max) |
POST /api/v1/research/plans |
Stores the plan and its hash. Estimates power from seeds already recorded (power_check). |
| 2. Record | result(project, arm, seed=s, metric=value) or record(project, lines) |
POST /api/v1/research/results |
Stores one row per arm, seed and metric. A line it already has is skipped, so retries are safe. |
| 3. Compare | compare(project, a, b, metric) |
POST /api/v1/research/compare |
Runs the paired t-test on a − b over shared seeds (Welch's test if fewer than 2 are shared). Checks the plan and records the verdict. |
| 4. Quote | report(project) |
GET /api/v1/research/report |
Says which verdicts a write-up may quote, after the false-discovery-rate correction across every comparison in the project. |
| Audit | verdicts(project), verdict(id) |
GET /api/v1/research/verdicts, GET /api/v1/verdicts/{id} |
Shows every recorded verdict, each seed's values, and whether it still holds on today's results. |
| Delegate | start_study(...), wait_study(id) |
POST /api/v1/research/studies |
Runs the seeds itself under a dollar cap and stops once the evidence decides (see below). |
Each user sees only their projects
On a RunLab where each user has their own data, a project name is yours alone: your demo
and a colleague's demo are two projects, never merged, deduplicated or compared with each
other. Lists (verdicts(), studies(), report("")) show only your projects. A verdict or
study id that is not yours answers 404, the same as one that does not exist, and an unknown
project's closest match is one of yours. Project names may not contain ~.
a is the treatment and b the baseline. diff is the mean of a − b, so it is positive when
a scored higher. Whether higher is better comes from the metric name: lower for names
containing loss, error, err, perplexity, ppl, wer, cer, mse, mae, rmse,
nll, latency, fid or regret, higher otherwise. Pass better="higher" or
better="lower" to override.
Results
RunLab stores each result as one line:
RESULT: <arm> <metric>=<number> seed=<n> [<param>=<value> ...]
result() builds these lines, so you only write them yourself when your training script
prints them (send its log to record()) or when you call the HTTP API directly.
- Names use letters, digits,
_,.and-; arm names start with a letter. - Lines that do not start with
RESULT:are ignored, so a whole training log can go torecord()as is. - If one RESULT line is malformed, or there is none, the call stores nothing and fails with a 400.
- Project names are case-insensitive.
- Params are optional; keep an arm's params the same on every seed. Each distinct set of
params counts as one tuned configuration. A compare whose arms differ by more than 1.25x
in configurations is refused (
refused_by: equal_budget).
Verdicts
verdict |
Meaning |
|---|---|
a_better / b_better |
p < alpha (default 0.05) and the difference favours that arm. |
no_detectable_difference |
p ≥ alpha. This is not evidence that the arms are equal; for that, pass margin. |
equivalent |
With margin: the 95 % CI lies inside ±margin. |
non_inferior |
With margin: a is worse than b by less than margin. |
insufficient |
An arm has fewer than 2 seeds, so there is no test. |
refused |
A check found that any verdict would mislead. refused_by names the check and why says what to fix. |
Read these fields next to the verdict:
prereg.status:ok;deviation, withissues, e.g. compared beforen_maxseeds, or the plan was registered after more than 3 seeds had been seen;missing: no plan;tampered.
warnings, e.g.peeking.report(), before you quote anything.
What keeps a verdict honest
| Rule | Why | What you see |
|---|---|---|
| Plan first | Choosing the metric or the number of seeds after seeing results inflates false positives. | prereg.status is deviation or missing. Amending a plan needs a reason, and every version is kept. |
| Look once | compare is a fixed-n test. Re-reading its p-value as seeds arrive breaks its alpha. |
Each call on grown data is a new "look". From the second look on, the response warns peeking, and report() marks the pair not_quotable. A call on unchanged data is the same look. To stop early validly, use a study. |
| Equal budgets | A tuned arm against an untuned baseline measures the tuning, not the change. | With more than 1.25x the configurations on one arm, the verdict is refused (refused_by: equal_budget). |
| Many comparisons | At alpha 0.05, about 1 in 20 pairs with no real difference still comes out a "win". | report() applies Benjamini-Hochberg across all pairs in the project. Each claim is quotable, quotable_with_caveat or not_quotable, and carries a ready quote. |
| Results can go bad | A seed or dataset later found broken undermines verdicts built on it. | verdicts() counts verdicts built on results since marked bad in stale; verdicts(recheck=True) judges each pair again on today's results (unchanged, inputs_changed or flipped). |
Studies: let RunLab run the seeds
RunLab can also run the seeds for you.
It runs both arms one seed pair at a time and stops as soon as an always-valid sequential test
(mSPRT) decides. It also stops at n_max, or at your dollar cap, whichever comes first.
rl.plan("resnet-aug", "mixup", "baseline", "acc",
hypothesis="mixup raises top-1 accuracy", n_max=20) # stopping="msprt", the default
s = rl.start_study("resnet-aug", command="train", a="mixup", b="baseline", metric="acc",
max_usd=5, arm_params={"mixup": {"alpha": "0.2"}})
s = rl.wait_study(s["id"])
print(s["state"], s["winner"], s["pairs"], s["usd"]) # e.g. decided mixup 6 0.84
-
commandnames the training command to run.paramsandarm_paramsfill its placeholders, using values of letters, digits and_.:+=-only. -
Every check runs before anything starts. A refusal raises
RunLabErrorwith status 400 and costs nothing, e.g. an unknown command, no msprt plan, or a cap that is too high. -
A study never spends more than
max_usd. -
stateis one of:stateMeaning runningStill running seeds. decidedThe sequential test stopped. decisionisAorB(winnernames the arm), orfutile(no detectable difference at this budget) orequivalent(winneris null).undecidedn_maxseeds ran without a decision.budgetThe compute budget was spent before a decision (your own machine: the next pair would pass max_usd).killedStopped at the dollar cap. failedThe command failed or printed no result; see detail.lostStopped reporting long past its deadline. refusedRefused at the start (that call raised a 400); listed for the record.
Run the seeds on your own machine
Your GPU box, laptop or cluster node can run the seeds instead: RunLab hands out seed pairs,
decides with the same sequential test, and stops at n_max or before the next pair would pass
your dollar cap. Your training command prints <metric>=<value>; {arm}, {seed} and your
params' names are filled in (no shell runs it).
pip install runlab-client
runlab login
runlab worker --project resnet-aug --a mixup --b baseline --metric acc \
--max-usd 5 --usd-per-hour 0.8 --param epochs=10 \
--cmd "python train.py --arm {arm} --seed {seed} --epochs {epochs}"
# seed 0: mixup acc=0.853, baseline acc=0.801 (412.3 s)
# ...
# study st_...: decided (A, winner mixup) after 6 pairs, $0.5496
--usd-per-houris what an hour of your machine costs; each pair's run time is charged at it, so--max-usdcaps your own spend.- Start more workers with
--study st_...(another terminal or machine): each gets its own seeds. Give each a--workername to get its open pair back after a restart. - A run that exits non-zero, prints no value or passes
--timeoutseconds counts as failed; the pair is skipped, as when RunLab runs the seeds. - Each run's time is recorded next to its metric, as
wall_sandusdof its arm and seed. - From Python:
s = rl.start_worker_study(...), thenrl.run_worker(s["id"], cmd).
Errors
Every failure raises RunLabError with:
.status: the HTTP status, or 0 when RunLab cannot be reached;.message: RunLab'serrortext;.request_id: quote it when reporting a problem.
| Status | Meaning |
|---|---|
| 400 | Bad input or a refused action. The message says what to fix; an unknown arm, metric or project names the closest match. |
| 401 | Missing or wrong token. |
| 403 | Your role cannot do this: writes need agent or above. |
| 404 | No such verdict or study. |
| 413 | Body over 64 KiB; send results in several calls. |
The client retries GET requests 3 times with exponential backoff, on connection errors and on 429, 502, 503 and 504. It never retries POST requests. Recording the same result line twice is harmless anyway.
Client reference
RunLab(url=None, token=None, *, timeout=30, retries=3, backoff_s=0.5). Every method returns
the decoded JSON of one operation in openapi.json. With no arguments it uses
the key runlab login saved (see Get started).
| Method | Operation | Returns |
|---|---|---|
me() |
getMe |
name, role |
plan(project, a, b, metric, hypothesis, n_max, **options) |
registerPlan |
plan, power_check, text. Options: better, alpha, n_min, stopping, amend. |
record(project, results) |
recordResults |
stored, already |
result(project, arm, *, seed=None, params=None, **metrics) |
recordResults |
one line per metric, in one call |
compare(project, a, b, metric, **options) |
compareArms |
verdict, diff, ci, p, test, n, prereg, warnings, text. Options: better, alpha, margin. |
verdicts(project="", limit=50, recheck=False) |
listVerdicts |
verdicts, stale, and recheck when asked |
verdict(id) |
getVerdict |
seeds, check, now |
report(project, *, arm="", metric="", q=0.05) |
getResearchReport |
claims, the counts per status, text |
start_study(project, command, a, b, metric, max_usd, *, params=None, arm_params=None) |
startStudy |
the study |
study(id), studies(project="", limit=50), wait_study(id, timeout, poll_s) |
getStudy, listStudies |
the study, or a list of studies |
start_worker_study(project, a, b, metric, max_usd, usd_per_hour, *, params=None, arm_params=None) |
startStudy |
the study (mode: worker) |
work(id, *, seed=None, results=None, failed=None, wall_s=None, worker=None, lease_s=None) |
workOnStudy |
study, pair (seed, arms, params) or null, retry_after_s |
run_worker(id, cmd, *, worker=None, cwd=None, timeout=None, lease_s=None, log=None) |
workOnStudy |
the ended study, after running its pairs here |
result_line(arm, metric, value, *, seed=None, **params) |
none | one RESULT: line, for record() |
login(url=None, *, browser=True, host=None, show=None) |
none | user, role, url, after you approve; saves the key |
saved_login(), config_dir() |
none | (url, key) saved here, and where it is kept |
| Command | What it does |
|---|---|
runlab login [--url URL] [--no-browser] |
Sign this machine in with GitHub and save a personal key. |
runlab whoami [--url URL] |
Who the key signs in as, and where. Exit 1 when not logged in. |
runlab logout |
Revoke the saved key and delete it. If RunLab cannot be reached, the key stays saved and the exit code is 1. |
runlab worker ... |
Run a study's seed pairs here (see above). |
Coding agents
AGENTS.md is the short version for Claude Code, Codex and other agents. llms.txt indexes this repo for LLM tools.
License
MIT (LICENSE).
Metadata
Release files for runlab-client 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| runlab_client-0.2.0.tar.gz | 25.2 kB | With provenance | Details for runlab_client-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| runlab_client-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for runlab_client-0.2.0-py3-none-any.whl |
Total release size: 45.1 kB
Release files / runlab_client-0.2.0.tar.gz
| Download URL | runlab_client-0.2.0.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca1aa90c240f63fcb04ee3a4d2709db3d41624f6cfd6aedb857628442b27cc0e
|
|
BLAKE2b-256 checksum How to use checksums |
20929089d3af3f12b35b56cac251912eb697f1bd4baa4f3e57c149e4681658bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / runlab_client-0.2.0-py3-none-any.whl
| Download URL | runlab_client-0.2.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20a3bdba9edbbf689b2960b843d10393642074dc10be1b45068fee5f8aadca10
|
|
BLAKE2b-256 checksum How to use checksums |
8bf35c4581b622e6dfcbdc89030883757705b05a1d21f00ca04e45822179093a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for runlab-client 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for runlab_client-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.