on this page ▾
[ GUIDES ] PYTHON SDK

Python SDK (import researchvc as rvc)#

import researchvc as rvc

with rvc.start_run(name="multilingual-rl", config={"learning_rate": 1e-5, "epochs": 3, "seed": 42},
                   group="rl", hypothesis="hypothesis:2c1c189c0e") as run:
    for step in range(100):
        run.log_metric("loss", 1 / (step + 1), step=step)
    run.log_metric("accuracy", 0.782)
    run.log_artifact("results.json")            # tracked and linked to the run
    run.log_dataset("datasets/train.jsonl")     # dataset name, entity id or tracked path
    run.log_note("Warm-up of 500 steps")
    run.log_claim("Reward normalization improves Bengali accuracy", evidence=["accuracy"])
API Behaviour
start_run(name, config=None, *, tags, group, hypothesis, repo_path) returns a Run; use as a context manager
Run.log_metric(name, value, step=None) / log_metrics(dict, step) numeric only (NumPy/torch scalars converted); NaN/Inf recorded as invalid, not as metrics
log_config(dict) / log_params merged into the run config; *seed* integer keys become recorded seeds
log_seed(value, name) explicit seed
log_artifact(path, kind) output file captured (stored if under the size threshold)
log_dataset(ref) creates a USES edge pinned to the current dataset version
log_claim(text, evidence=[metric names], category) registers a claim with SUPPORTS edges from this run (an assertion, not a verification)
cancel() / finish(status) explicit completion; context exit sets succeeded, failed (exception recorded, traceback redacted) or interrupted
rvc.active_run(), rvc.log_metric(...) module-level helpers for the innermost active run

Modes#

  • Wrapped (rvc run -- python train.py): the SDK writes to the wrapper's buffer (RVC_RUN_DIR); the wrapper owns command, stdout/stderr, environment and finalization.
  • Standalone (inside a repository): the SDK creates and finalizes its own run.
  • Offline (no repository, e.g. a cluster node, or RVC_OFFLINE_DIR set): events are buffered to ~/.rvc-offline/<run>/; import later with rvc experiments import <dir>.

All logging is thread-safe (one lock per run buffer). Buffers are append-only JSON lines; if a process dies, rvc experiments recover finalizes the run as interrupted. Runs are staged; rvc commit makes them part of history.

docs/sdk.md