Skip to main content

Experiment Tracker

A local-first experiment tracker. Metrics land in a JSONL file you own, stay queryable while the run is live, and can trigger alerts from an expression language. wandb and trackio are optional mirrors, not requirements.

📖 Documentation: https://hspk.github.io/expr_tracker/

import expr_tracker as et

et.init(project="demo", name="run-1", alert_rules=["zscore(loss[50]) > 3 => error: spike"])
for step in range(1000):
    et.log({"loss": loss, "lr": lr})
et.finish()

et.history(50)                    # the last 50 steps, as dicts
et.history(-1, output_type="pd")  # everything, as a DataFrame

Why

  • The file is the source of truth. One JSON object per step, appended to metrics.jsonl. No server, no database, no vendor.
  • History is queryable during the run. et.history(n) answers from an in-memory cache and touches the file only for what it evicted — 227 µs for history(50) whether the run has 1,000 steps or 100,000.
  • Alerts are expressions, not callbacks. zscore(loss[50]) > 3 or isnan(loss) is parsed, validated, and evaluated against a rolling window. Rules can be replayed over a finished run to tune thresholds before you trust them.
  • It stays out of the way. log() costs ~26 µs. A failed disk, a dead webhook or an unserialisable value degrades with a warning; none can stop training.

Install

uv add expr_tracker                 # local-first: click, loguru, pydantic only
uv add "expr_tracker[wandb]"        # mirror to Weights & Biases
uv add "expr_tracker[trackio]"      # mirror to trackio
uv add "expr_tracker[lark]"         # Feishu/Lark alert channel
uv add "expr_tracker[pandas]"       # history(output_type="pandas")
uv add "expr_tracker[all]"          # everything

Only the JSONL history is built in. A missing extra is reported with the exact install command; it never crashes a run.

Features

Logging One line per step. Several log() calls for one step merge into one row, wandb-compatible step/commit semantics, numpy and pydantic values handled.
History et.history(n) during or after the run, offline reads of any run directory, dict/pandas/polars output, bounded in-memory cache with observable hit rate.
Alerts An expression DSL with rolling windows, three-valued logic (no false alarms during warm-up), a rule state machine, and a watchdog that catches a hung run.
Channels Lark, Slack, DingTalk, WeCom, generic webhook, email — with rate limiting, dedup, retries and per-channel routing.
Artifacts Versioned file sets, deduplicated by content, shared across a project's runs, with lineage.
Distributed Per-rank shards so concurrent appends cannot corrupt step order; only rank 0 alerts by default.
CLI et history, et rules explain, et rules test, et alert.

wandb compatibility

Migrating an existing script is usually one line:

# import wandb as et
import expr_tracker as et

init, log, finish, alert, log_artifact, use_artifact, Artifact, define_metric, run.summary, run.step, run.dir and run.url keep their wandb names and signatures. See the compatibility table.

Development

uv sync --all-extras
uv run pytest                                   # everything
uv run pytest -m "not slow and not benchmark"   # the fast suite
uv run pytest -m benchmark -s                   # timing and memory report
uv run pytest --cov=expr_tracker                # coverage
uv run ruff check src tests
uv run ruff format src tests

Test layout

File Covers
test_history, test_expr_*, test_alert_*, test_writer_durability, … per-module unit tests
test_correctness.py value and type round trips, randomised commit sequences, ordering invariants
test_cache.py that the cache really serves reads: zero-IO assertions, eviction boundaries, warm/cold parity
test_failure_modes.py degradation: write failures, read-only dirs, encoder blow-ups, dead alert backends
test_e2e.py full runs, resume, crash recovery, offline reads, CLI
test_scenarios.py live cross-process reads, alerts during eviction, out-of-order resume
test_hot_paths.py contracts and defaults of et.log / et.history / summary / alerts
test_value_encoding.py numpy, pydantic, datetime, Path, Enum round trips; output types; query bounds
test_expr_properties.py DSL properties: render round-trip stability, precedence, the whole M builder
test_distributed.py rank shards, alert_on_rank, real multi-process runs
test_wandb.py real wandb in offline mode: parameter mapping, step alignment, artifacts
test_trackio.py trackio contract, resume mapping, real end-to-end
test_lark_live.py Lark channel; real delivery when ET_LARK_TEST_WEBHOOK is set
test_stress.py (slow) 100k-row writes, concurrency, cache thrash, write-failure recovery
test_benchmark.py (benchmark) throughput, tail latency, query cost, memory stability

Docs

uv run --group docs mkdocs serve    # preview at localhost:8000
uv run --group docs mkdocs build    # build into site/

Published to GitHub Pages by .github/workflows/docs.yaml on every push to main. Internals: docs/design.md (data model and key invariants) and docs/architecture.md (module map, read/write paths, concurrency model).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

expr_tracker-0.2.0.tar.gz (337.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

expr_tracker-0.2.0-py3-none-any.whl (76.3 kB view details)

Uploaded Python 3

File details

Details for the file expr_tracker-0.2.0.tar.gz.

File metadata

  • Download URL: expr_tracker-0.2.0.tar.gz
  • Upload date:
  • Size: 337.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for expr_tracker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d55f6f5f6577b71d348bcbaa108edada8a632658255ea06328976de177de7d5f
MD5 9fa4860d18fc3beb6df55c46a6395340
BLAKE2b-256 ac4ecfeaf9e20b65f51e3159a2a8fa7f7b45094d6a26fdd24955c7505aca7989

See more details on using hashes here.

Provenance

The following attestation bundles were made for expr_tracker-0.2.0.tar.gz:

Publisher: release.yaml on HSPK/expr_tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file expr_tracker-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: expr_tracker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 76.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for expr_tracker-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 defcd0f92d81eb10acb41aeee1c464ec79cfc546a2e0297f2547e0700d7fe842
MD5 ec857f9a8d85501d97b63f6dce788b74
BLAKE2b-256 9f35b30b67d7fe1f4deda9e87dc12f508bcc554b04a72a96c4423d824f21a10a

See more details on using hashes here.

Provenance

The following attestation bundles were made for expr_tracker-0.2.0-py3-none-any.whl:

Publisher: release.yaml on HSPK/expr_tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page