Runprint (qr)
Production-Grade, Local-First Experiment & Reproducibility Platform for AI & Scientific Research
"Run anything. Capture everything needed to reproduce it."
Runprint (qr) is a lightweight, framework-agnostic execution wrapper and reproducibility tracker for machine learning, deep learning, and computational science. It operates seamlessly both outside your code (as an invisible process supervisor via qr run -- ...) and inside your code (via an intuitive, IDE-friendly Python SDK).
All manifests, code diffs, logs, metrics, and environment locks are preserved in a clean .qr/ directory inside your project. Zero cloud accounts, zero telemetry, zero external database servers.
📑 Table of Contents
- Key Capabilities
- Installation
- Quickstart in 60 Seconds
- Interactive Web UI Hub (
qr ui) - Complete Python SDK Reference
- Three Execution Paradigms
- 1. Universal & Semantic Logging (
qr.log,qr.log_*) - 2. Hyperparameter Tracking (
qr.log_config,qr.params) - 3. Streaming Metrics & Block Timing (
qr.log_metric,qr.timer) - 4. Dataset Declarations & Checksumming (
qr.log_dataset) - 5. Artifact Registration (
qr.log_artifact) - 6. In-Code Activation for IDEs (
qr.activate(),qr.init(),qr.finish()) - 7. Hyperparameter Sweeps & GridSearch (
with qr.run()) - Complete SDK Method & Alias Cheatsheet
- Exhaustive CLI Command Guide
- Core Architectural Concepts
- Storage Layout & Manifest Schema
- License
⚡ Key Capabilities
- Zero-Instrumentation Wrapper: Wrap any command (
qr run -- python train.py, Bash scripts, C++ binaries) without modifying a single line of training code. - 100% Local-First & Self-Contained: Stored directly in
.qr/within your workspace. No third-party cloud, no SaaS subscriptions, no data exfiltration. - Complete Git & Untracked File Snapshotting: Preserves exact Git commit SHA, branch name, uncommitted working tree diffs (
git.diff), and new untracked source files without touching your Git index. - Multi-Dimensional Provenance Audit: Computes deterministic SHA-256 execution fingerprints across Code, Parameters, Datasets, and Runtime Environment. Automatically detects Identical Runs (with linear versioning
v2), Sister Runs (parameter sweeps with delta diffs), and Code Drift. - AST Core Dependency Isolator: Analyzes script imports via Python's Abstract Syntax Tree, filters out standard library packages, and isolates direct application dependencies (
direct-packages.txt) while preserving the full environment freeze (pip-freeze.txt) for 100% byte-for-byte reproducibility. - Deep Hardware & OS Diagnostics: Captures CPU driver version, physical cores & logical threads, max clock, L3 cache, RAM bus speed (MHz/MTs), per-slot RAM module topology, GPU compute capabilities, GPU driver, and dedicated VRAM.
- Interactive Web UI Hub (
qr ui): Zero-dependency local server with real-time log streaming via Server-Sent Events (SSE), Tree View by Script & Commit DAG, interactive parameter auto-forms, and side-by-side run comparisons. - 1-Click Exact Reproduction (
qr rerun --reproduce): Recreates past experiments in an isolated temporary Git worktree with an isolated reconstructed virtual environment. - 0–100 Restorability Scoring: Granular 3-pillar audit scoring (Source Code 35 pts, Environment 35 pts, Data & Inputs 30 pts) with actionable checklists in
qr show.
📦 Installation
From PyPI (Recommended)
pip install runprint
(Both qr and runprint commands are registered globally. You can also run python -m qr or python -m runprint).
From GitHub
pip install git+https://github.com/minhquang0407/Runprint.git
Local Development
git clone https://github.com/minhquang0407/Runprint.git
cd Runprint
pip install -e ".[dev]"
🚀 Quickstart in 60 Seconds
1. Initialize Runprint in your Repository
qr init
Creates .qr/, project.json, and local SQLite cache.
2. Run your First Experiment
qr run --tag baseline -- python train.py --epochs 10 --batch-size 32 --lr 0.001
If your code has uncommitted modifications, qr automatically captures the patch into git.diff:
[!] Working tree contains uncommitted changes. Snapshotting diff:
- train.py
- configs/model.yaml
Run QR-20260918-E90F-v1 [baseline] started (13:30:15)
... live stdout & stderr logged in real-time ...
Run completed: exit=0, duration=12.4s (QR-20260918-E90F-v1)
3. Launch the Web UI Hub
qr ui
Open http://127.0.0.1:8765 to explore your experiment DAG, view live logs, inspect hardware diagnostics, and compare runs.
🌐 Interactive Web UI Hub (qr ui)
Launch the built-in local dashboard anytime:
# Default (port 8765, opens browser automatically)
qr ui
# Custom port or headless mode
qr ui --port 9000 --no-browser
Key UI Features:
- Master Column Navigation:
[ ≡ Flat View ]: Chronological run list with status badges, tags, and instantaneous search.[ 🌳 Tree View by Script & Commit ]: Hierarchical DAG grouping:- Script Entrypoint (e.g.
📄 train.py (12 runs)) - Git Commit & Dirty state (e.g.
🌱 Commit #b02ad01 (dirty)) - Run Cards with nested version lineage (
v1➔v2).
- Script Entrypoint (e.g.
- 8 Dedicated Detail Tabs:
- Overview: Metadata, Git commit, restorability score gauge, execution command, duration, and exit code.
- Output Logs: Real-time streaming terminal output (
stdout&stderr) via Server-Sent Events (SSE) with search filter and download. - Metrics: Extrema summary cards (Min, Max, Latest) and interactive SVG line plots with metric selection.
- Artifacts: Registered models, weights, evaluation plots with file size and SHA-256 checksums.
- Parameters: Structured table of command-line arguments and in-code hyperparameters.
- Packages & Environment: Dual-view toggle:
[ ⭐ Direct Packages ]: Core packages directly imported by the script.[ 🔗 Full Lockfile ]: Complete 190+ package freeze of the virtual environment.
- Notes & Tags: Live editable markdown notes and experiment tags.
- Lineage & Sister Runs: Visual DAG provenance chain and Sister Runs comparison table with 1-click
[ Compare ]action.
- Launch New Run Modal (
+ New Run):- Auto-discovers runnable scripts in your project.
- AST Auto-Form: Automatically parses script arguments and generates input fields that merge into the command line.
- Multi-Dimensional Provenance Warnings: Instantly displays alert cards for 100% duplicate runs (with options to View Existing or Rerun as v2), Sister Runs with hyperparameter deltas, or Code Drift.
- Deep Hardware & OS Diagnostics Modal (
(i)):- Displays real CPU driver version, physical cores, logical threads, L3 cache, RAM bus speed (MHz/MTs), per-slot memory modules, GPU driver, and VRAM.
- 1-Click Markdown Specs Exporter: Formats full hardware specifications for research paper supplementary materials.
- Side-by-Side Run Diff Modal:
- Compares parameters, Git diffs, and metric extrema between any two runs.
- Rerun Preflight Modal:
- Pre-flight audit checklist with toggles to reconstruct virtual environments or bypass mismatches.
🐍 Complete Python SDK Reference
The runprint Python SDK (import qr) provides rich, framework-agnostic utilities for deep experiment tracking.
Three Execution Paradigms
- CLI Wrapper (
qr run -- python train.py): Zero code changes required. Ifimport qris used in the script, calls toqr.log(),qr.log_metric(), etc. automatically attach to the active CLI run via environment variables. - In-Code Activation (
qr.activate()/qr.init()): Ideal for IDE users who execute scripts by clicking Run or Debug in VS Code or PyCharm. - Context Managers (
with qr.run() as run:): Designed for multi-run loops (GridSearch, Optuna, K-Fold cross-validation) where each iteration produces an independent, linked run in the lineage DAG.
1. Universal & Semantic Logging (qr.log, qr.log_*)
The SDK provides both explicit log_* functions (for strict typing and IDE autocomplete) and a universal qr.log() dispatcher with an optional type parameter ("metric" | "config" | "dataset" | "artifact" | "note"):
import qr
# 1. Automatic Type Inference (type parameter is optional):
# If type is omitted: dict is logged as "metric", str is logged as "note"
qr.log({"loss": 0.24, "val_acc": 0.942}, step=100, epoch=5) # Auto-infers type="metric"
qr.log("Model convergence achieved at epoch 5") # Auto-infers type="note"
# 2. Explicit Type Dispatching (pass type="..."):
qr.log({"learning_rate": 0.001, "batch_size": 32}, type="config")
qr.log({"val_loss": 0.18, "f1_score": 0.92}, type="metric", epoch=10)
qr.log("checkpoints/best_model.pt", type="artifact", kind="model")
qr.log("cifar10", type="dataset", uri="data/cifar10")
qr.log("Learning rate decayed by factor of 0.1", type="note")
2. Hyperparameter Tracking (qr.log_config, qr.params)
Records training configuration into manifest.json and writes config.json:
import qr
qr.log_config({
"learning_rate": 0.001,
"batch_size": 32,
"optimizer": "AdamW",
"weight_decay": 1e-4,
"backbone": "resnet50",
})
# Or using the shorthand alias:
qr.params({"dropout": 0.2, "seed": 42})
3. Streaming Metrics & Block Timing (qr.log_metric, qr.timer)
Appends metric records to metrics.jsonl with immediate disk flushing and fsync:
import qr
for epoch in range(1, 11):
# Measure duration of a specific training phase
with qr.timer("epoch_duration_seconds"):
train_loss = train_one_epoch()
val_loss, val_acc = evaluate()
# Log metrics with step/epoch tracking
qr.log_metric(
{"train_loss": train_loss, "val_loss": val_loss, "val_accuracy": val_acc},
epoch=epoch,
step=epoch * 100,
)
4. Dataset Declarations & Checksumming (qr.log_dataset)
Declares dataset references. For local files or directories, qr automatically calculates a streaming SHA-256 fingerprint:
import qr
# Auto-calculates SHA-256 hash across file or directory contents
qr.log_dataset(
name="cifar10_train",
uri="data/cifar10/train",
version="1.0",
)
# Or declare with explicit checksum
qr.log_dataset(
name="imagenet_val",
uri="s3://my-bucket/imagenet/val.tar",
fingerprint="sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
)
# Shorthand alias:
qr.input_dataset("processed_features", "data/features.parquet")
5. Artifact Registration (qr.log_artifact)
Registers model checkpoints, evaluation charts, or exported weights. Runprint tracks the file size and SHA-256 hash without duplicating heavy files on disk:
import qr
# Register model checkpoint
qr.log_artifact(
path="checkpoints/best_model.pt",
kind="weights",
metadata={"val_accuracy": 0.952, "epoch": 8},
)
# Shorthand alias:
qr.artifact("reports/confusion_matrix.png", kind="plot")
6. In-Code Activation for IDEs (qr.init(), qr.activate(), qr.finish())
When running experiments directly via your IDE's Run / Debug buttons (VS Code, PyCharm, Jupyter) without opening a terminal, place qr.init() (or qr.activate()) at the very start of your training script:
import qr
def main():
# 🚀 1. Initialize at the VERY START:
# Immediately creates the run in .qr/runs/, records hardware and git state,
# marks status as 'running', and begins real-time stdout/stderr streaming to the Web UI!
qr.init(tag=["baseline", "cifar10"], params={"lr": 0.001, "batch_size": 32})
# 2. Declare datasets and hyperparameters
qr.input_dataset("cifar10", "data/cifar10")
# 3. Real-time metric tracking during training (fsynced immediately)
for epoch in range(10):
# ... training loop ...
qr.log({"loss": 0.25, "accuracy": 0.942}, epoch=epoch)
# 4. Register outputs
qr.artifact("checkpoints/model.pt", kind="model")
# 5. Automatic finalization: Python atexit automatically finalizes upon script exit!
# (or call qr.finish() if you wish to conclude the run early)
if __name__ == "__main__":
main()
Why qr.init() / qr.activate() Must Be Placed at the Start:
- Instant Web UI Visibility: The run appears immediately on the Web UI dashboard with a live green
runningindicator from second 0. - Live Terminal Log Streaming: Stdout and stderr are teed and streamed in real-time over Server-Sent Events (SSE) to the Web UI as log lines are printed.
- Zero Data Loss on Crash or OOM: Every call to
qr.log()flushes andfsyncs metrics directly to disk. If training crashes or is terminated midway (e.g. CUDA OOM orCtrl+C), all preceding epochs and stack traces are safely preserved. - Accurate Environmental Snapshots: Captures the exact Git working tree state, hardware metrics, and environment packages at the moment training begins.
- Automatic Lifecycle Management: Runprint automatically registers
atexitandsys.excepthookhandlers. When the script exits cleanly, the run is finalized ascompleted; if an unhandled exception occurs, it is recorded asfailedwith exit code1. - CLI Compatibility: If executed later via
qr run -- python train.py,qr.init()/qr.activate()automatically recognizes the active CLI wrapper session and transparently integrates without creating duplicate runs.
7. Hyperparameter Sweeps & GridSearch (with qr.run())
For hyperparameter search (GridSearch, Optuna, K-Fold cross-validation), isolate each trial into its own linked run in the lineage DAG:
import qr
from sklearn.ensemble import RandomForestClassifier
param_grid = [
{"n_estimators": 50, "max_depth": 3},
{"n_estimators": 100, "max_depth": 3},
{"n_estimators": 50, "max_depth": 6},
{"n_estimators": 100, "max_depth": 6},
]
# Parent Session: Represents the overarching sweep
with qr.run(tag="rf_gridsearch", params={"total_trials": len(param_grid)}) as session:
qr.input_dataset("cancer_data", "data/cancer.csv")
for i, p in enumerate(param_grid, start=1):
# Child Run: Automatically linked as a child of `session`
with qr.run(tag="trial", params=p) as trial:
model = RandomForestClassifier(**p)
model.fit(X_train, y_train)
acc = model.score(X_test, y_test)
trial.log({"trial": i, "accuracy": acc})
trial.artifact(f"models/rf_{i}.pkl", kind="model")
# Exiting trial context automatically finalizes that trial run!
Complete SDK Method & Alias Cheatsheet
| Primary Method | Shorthand Aliases | Description |
|---|---|---|
qr.log(data, type=...) |
— | Universal smart logging dispatcher |
qr.log_metric(dict, step, epoch) |
qr.metric_log |
Appends numerical metrics to metrics.jsonl |
qr.log_config(dict) |
qr.config_log, qr.params |
Logs hyperparameters to manifest and config.json |
qr.log_dataset(name, uri, ...) |
qr.input_dataset, qr.dataset_log, qr.data_log |
Declares dataset inputs with streaming SHA-256 |
qr.log_artifact(path, kind, ...) |
qr.artifact, qr.artifact_log |
Registers outputs with checksum and size tracking |
qr.log_note(text) |
qr.note |
Appends timestamped annotations to notes.jsonl |
qr.timer(name) |
— | Context manager measuring execution duration |
qr.activate(tag, params, ...) |
— | In-code runner for IDE Run/Debug executions |
qr.init(tag, params, ...) |
— | Explicit run initializer at script start |
qr.finish(status, exit_code) |
— | Explicit run finalizer |
qr.run(tag, params, parent) |
— | Context manager for multi-run sweeps / trials |
🛠️ Exhaustive CLI Command Guide
1. qr run — Execute & Snapshot
Wraps any arbitrary command, logs stdout/stderr, snapshots code, and records environment:
# Basic usage
qr run -- python train.py
# With tags and research notes
qr run --tag baseline --tag vision --notes "Batch size 32 with CosineAnnealing" -- python train.py
# Force new run (bypasses duplicate detection and linear versioning)
qr run --force -- python train.py
# Explicit parent linkage for manual lineage chaining
qr run --parent QR-20260918-E90F-v1 -- python train.py
# Override run ID
qr run --run-id MY-CUSTOM-EXPERIMENT-01 -- python train.py
2. qr ui — Local Web Hub
Starts the local dashboard server:
# Start on default port 8765
qr ui
# Specify custom port
qr ui --port 9000
# Headless mode (do not auto-open browser)
qr ui --no-browser
3. qr list — Search & Filter History
Lists historical experiment runs:
# List recent runs
qr list
# Filter by tag
qr list --tag baseline
# Limit output count
qr list --limit 15
4. qr show — Inspect Provenance & Score
Prints complete run provenance, code state, hardware, logs, and restorability audit:
qr show QR-20260918-E90F-v1
Includes the Restorability Audit Checklist:
[✓] Git Commit Recorded (+10 pts)[✓] Working Tree Clean or Complete Diff Stored (+15 pts)[✓] All Untracked Source Files Archived (+10 pts)[✓] Pinned Python Environment (+10 pts)[✓] Package Lockfile Recorded (+15 pts)[✓] Verified Dataset Fingerprints (+30 pts)
5. qr rerun — 1-Click Reproduction Engine
Rerun any historical experiment with preflight reproducibility audits:
# 1-Click full reproduction (isolated git worktree + isolated virtualenv)
qr rerun QR-20260918-E90F-v1 --reproduce
# Restore exact virtualenv from recorded lockfile into .qr/envs/
qr rerun QR-20260918-E90F-v1 --restore-env
# Execute in an isolated temporary Git worktree
qr rerun QR-20260918-E90F-v1 --isolated
# Bypass dataset fingerprint validation if data was updated intentionally
qr rerun QR-20260918-E90F-v1 --allow-dataset-mismatch
# Bypass environment package drift check
qr rerun QR-20260918-E90F-v1 --allow-env-mismatch
Reruns create a linear version child linked in the experiment lineage DAG (QR-...-v1 ➔ QR-...-v2).
6. qr diff — Side-by-Side Run Comparison
Compare code, parameters, duration, and numerical metrics between any two runs:
qr diff QR-20260918-E90F-v1 QR-20260918-1A96-v2
Outputs side-by-side comparison tables highlighting parameter deltas and numerical metric changes (e.g. accuracy: 0.9250 vs 0.9480 (+0.0230)).
7. qr env — Package Drift & Cache Management
Inspect environment drift and manage reconstructed virtualenvs:
# Compare recorded run packages against current active Python environment
qr env diff QR-20260918-E90F-v1
# List all reconstructed virtual environments in .qr/envs/
qr env list
# Clean virtual environments to reclaim disk space
qr env clean --run-id QR-20260918-E90F-v1
qr env clean --all
8. qr doctor — Integrity Diagnostics & Auto-Repair
Scans repository health, reconciles interrupted runs, backfills restorability scores, and rebuilds the SQLite index:
# Scan repository health
qr doctor
# Automatically repair orphaned runs and rebuild index
qr doctor --fix
🔬 Core Architectural Concepts
1. Multi-Dimensional Execution Fingerprint
Runprint computes a deterministic SHA-256 hash across four essential dimensions: $$\text{Fingerprint} = \text{SHA256}(\text{Command} \parallel \text{Git Commit} \parallel \text{Git Dirty} \parallel \text{Parameters} \parallel \text{Datasets})$$
- Identical Run (100% Match): Same code, same hyperparameters, same data. Warns in UI and CLI; allows re-running as
v2or viewing existing results. - Sister Run (Parameter Sweep): Same code and commit, but hyperparameters changed (e.g.
lr: 0.001 ➔ 0.01). Runprint recognizes it as a sibling in the lineage DAG. - Code Drift: Same script entrypoint, but the code has changed since the last execution. Runprint alerts and archives a fresh code snapshot.
2. Experiment Lineage DAG & Sister Runs
Experiments are organized as a Directed Acyclic Graph (DAG):
- Linear Versions: Re-running a run creates
v2,v3, etc. linked to its parent. - Tree View: Groups runs by
Script Entrypoint➔Git Commit➔Run Versions.
3. AST Core Dependencies vs. Full Lockfile
Modern Python environments often contain 150–300 packages. When reviewing an experiment, you want to know what the script actually imports.
- AST Direct Package Detection: Parses script source code using
ast.parse, discards standard library modules (sys.stdlib_module_names), and maps top-level imports to PyPI distribution names (direct-packages.txt). - Complete Lockfile: Stores
pip-freeze.txtalongside direct packages for deterministic environment restoration.
4. Deep Hardware & OS Diagnostics
Captures bare-metal hardware configuration using zero-dependency platform queries:
- CPU: Model, driver version (
Win32_PnPSignedDriver), physical cores, logical threads, max clock, L3 cache, socket designation. - RAM: Total capacity, configured bus speed (MHz/MTs), module count, and per-slot topology (capacity, speed, manufacturer, part number).
- GPU: Device names, driver version, dedicated VRAM (MB), CUDA compute capability, VBIOS version.
5. Restorability Scoring Rubric (0 – 100)
| Pillar | Max Pts | Criteria |
|---|---|---|
| Source Code | 35 pts | Valid Git commit (+10), clean tree or complete git.diff (+15), untracked source files captured (+10) |
| Environment | 35 pts | Pinned Python version (+10), package lockfile recorded (+15), zero non-standard local dependencies (+10) |
| Data & Inputs | 30 pts | Pure compute with no external data (+30), OR all datasets declared (+10) with verified SHA-256 fingerprints (+20) |
90 - 100: HIGHLY_RESTORABLE (Green)70 - 89: PARTIALLY_RESTORABLE (Yellow)< 70: LOW_RESTORABILITY (Red)
📂 Storage Layout & Manifest Schema
All data is self-contained inside your repository under .qr/:
my-project/
├── train.py
├── configs/
├── .git/
└── .qr/
├── project.json # Project configuration
├── index.sqlite # Fast local index cache (auto-rebuildable)
├── envs/ # Cached virtual environments for reproduction
├── worktrees/ # Temporary checkouts for isolated reruns
└── runs/
└── QR-20260918-E90F-v1/
├── manifest.json # Machine-readable provenance manifest (Schema v0.1)
├── config.json # Parsed hyperparameters & config
├── git.diff # Uncommitted diff patch (binary & untracked files)
├── stdout.log # Full captured stdout stream
├── stderr.log # Full captured stderr stream
├── metrics.jsonl # Streaming metric records with timestamps
├── artifacts.json # Registered artifact references & checksums
├── notes.jsonl # Timestamped experiment notes
└── environment/
├── direct-packages.txt # Core packages imported by script
├── direct-packages.json # AST-resolved distribution mapping
└── pip-freeze.txt # Full environment freeze
📄 License
Licensed under the Apache License, Version 2.0.
Metadata
Release files for runprint 0.1.7
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 |
|---|---|---|---|---|
| runprint-0.1.7.tar.gz | 112.4 kB | Without provenance | Details for runprint-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| runprint-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for runprint-0.1.7-py3-none-any.whl |
Total release size: 221.9 kB
Release files / runprint-0.1.7.tar.gz
| Download URL | runprint-0.1.7.tar.gz |
|---|---|
| Size | 112.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
249e4dde6eff7e54ffb4d233d019b3fe73c3a67dd3f824af0811310a5fe4cec0
|
|
BLAKE2b-256 checksum How to use checksums |
93f5565fa545f9a704e04f315990291e36825ac72397103eb55a50945fff3251
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / runprint-0.1.7-py3-none-any.whl
| Download URL | runprint-0.1.7-py3-none-any.whl |
|---|---|
| Size | 109.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b38eca3158e8e5c9f9a627d93f647ba795aa0b2244e7af62ddc623c8246cd08b
|
|
BLAKE2b-256 checksum How to use checksums |
a651b43aef164d3007543ddb9bdfd757e66d6456535d5c653757b5576eb1c5c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for runprint 0.1.7
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.