Unified export tooling for Weights & Biases.
uv tool install dr-wandbOr as a library:
uv add dr-wandbwandb login- Export W&B runs into a durable local layout that downstream repos can load without talking to the W&B API directly.
- Keep export behavior deterministic so repeated syncs and diffs stay readable.
- Separate current run snapshots from optional history rows while letting both live under one named export.
- Hide raw W&B SDK object quirks behind JSON-safe stored models.
There is one public command:
wandb-export ENTITY PROJECT --name EXPORT_NAME [OPTIONS]The command always writes into data_root / name, where name identifies one
logical export. That directory is self-contained and can hold:
manifest.json: what was exported and where its artifacts livestate.json: incremental tracking state used for future syncsruns.jsonl: the current latest snapshot for each runhistory.jsonl: optional history rows when--mode historyis used
Example metadata-only export:
wandb-export ml-moe moe --name moe_runs --data-root dataThis writes:
data/moe_runs/
manifest.json
state.json
runs.jsonl
Metadata mode writes one current snapshot per run. It does not export history rows.
Example history export:
wandb-export ml-moe moe \
--name moe_history \
--data-root data \
--mode historyThis writes:
data/moe_history/
manifest.json
state.json
runs.jsonl
history.jsonl
History mode writes the same current snapshots plus normalized history rows
selected from scan_history.
History export can be limited with selection flags:
wandb-export ml-moe moe \
--name moe_eval_tail \
--data-root data \
--mode history \
--history-key eval/loss \
--history-key eval/accuracy \
--max-records 100History selection rules to rely on:
- history selection flags only apply in
--mode history --history-keynarrows the metric keys requested from W&B--min-stepand--max-stepconstrain the scan window when supported by the underlying W&B API call--max-recordstrims the final result to the most recent rows after scanning
The CLI logs progress to stderr by default. Set DR_WANDB_LOG_LEVEL to a
standard Python logging level such as DEBUG, INFO, WARNING, ERROR, or
CRITICAL to override that behavior for batch runs or CI. Invalid values fall
back to INFO.
dr-wandb supports two sync modes:
SyncMode.INCREMENTAL- fetches newly created runs since the export's tracked
max_created_at - refreshes previously seen runs that are not yet terminal
- reuses prior snapshots and history rows where possible
- fetches newly created runs since the export's tracked
SyncMode.FULL_RECONCILE- ignores prior incremental state
- rebuilds the named export from scratch using the current W&B project state
Terminal run states are treated as complete enough to stop refreshing unless a full reconcile is requested.
runs.jsonl stores RunSnapshot records, each of which contains:
- one normalized
WandbRun - the
exported_attimestamp for that snapshot
Raw W&B SDK objects are normalized into JSON-safe data before being written.
That includes nested config-like payloads and object-valued fields such as
user.
history.jsonl stores HistoryRow records. Each row keeps:
run_id- step, timestamp, and runtime when available
wandb_metadatafrom_wandbmetricsfor non-underscore keysextrafor underscore-prefixed fields that are not promoted into the typed top-level columns
History rows are merged by a stable deduplication key so repeated incremental exports do not blindly append duplicates.
from pathlib import Path
from dr_wandb import ExportEngine, ExportMode, ExportRequest
summary = ExportEngine(
ExportRequest(
entity="ml-moe",
project="moe",
name="moe_runs",
data_root=Path("data"),
mode=ExportMode.METADATA,
)
).export()
print(summary.run_count)ExportEngine.export() is the high-level entrypoint when you want the same
workflow the CLI runs and a typed ExportSummary describing the artifacts it
wrote.
Read an existing export back in with the top-level helper functions:
from pathlib import Path
from dr_wandb import load_manifest, load_run_snapshots
manifest = load_manifest("moe_runs", Path("data"))
snapshots = load_run_snapshots("moe_runs", Path("data"))
print(manifest.mode, len(snapshots))If the export includes history rows:
from pathlib import Path
from dr_wandb import iter_history_rows
rows = list(iter_history_rows("moe_history", Path("data")))
print(len(rows))ExportStore is also available if you want direct access to the per-export
directory layout and I/O. The top-level helpers are the better default when you
just want to read a completed export.
ExportMode.METADATAexports current run snapshots only.ExportMode.HISTORYexports current run snapshots plus history rows.SyncMode.INCREMENTALfetches newly created runs and refreshes tracked non-terminal runs.SyncMode.FULL_RECONCILErebuilds the export from scratch.- Each named export is self-contained inside
data_root / name.
For local iteration, run the smallest targeted test command that covers the code you changed.
Before committing:
uv run ruff format .
uv run ruff check .
uv run ty check
uv run pytestBefore publishing:
uv buildMIT