read_wandb_history

read_wandb_history(
    runs
    *
    keys=None
    x='_step'
    smoothing=0.0
    max_points=DEFAULT_MAX_POINTS
    api=None
)

Read the training curves of Weights & Biases runs.

One chart per metric, as a W&B workspace draws it: the step along the x axis, the value along the y axis, and one line per run.

Parameters

Name Type Description Default
runs str, os.PathLike, wandb.apis.public.Run, mapping, or iterable of these The runs, as for :func:load_wandb_history: a wandb/ folder or a run file in it, read with no W&B package or network; a run’s server path such as "my-team/my-project/abc123"; a fetched run; a list of these; or a mapping of run name to saved history rows. required
keys iterable of str Only these metrics, in this order, such as ["train/loss"]. None
x str What the x axis counts, such as "epoch" or "_runtime". "_step"
smoothing float A smoothing weight, from 0 up to but not including 1, applied as TensorBoard applies it. Above 0, each run is drawn twice: as logged, and smoothed, under the run’s name followed by (smoothed). 0 draws the values as logged only. 0
max_points int or None At most this many points per line, evenly spaced and always keeping the first and last, so a long run stays quick to walk. None keeps every point. 1000
api wandb.Api The API that fetches a run named by its path. None

Returns

Name Type Description
list of maidr.wandb.MetricChart One per metric. Pass one to :func:maidr.show, :func:maidr.render or :func:maidr.save_html.

Raises

Name Type Description
FileNotFoundError If a run file named does not exist.
ImportError If a run is named by its server path and wandb is not installed.
TypeError If runs is not a run, a path, a mapping or an iterable of these.
ValueError If smoothing is not in [0, 1) or max_points is below 2.

Notes

A run file is the log every run, online or offline, writes to its folder as it trains, the one wandb sync uploads; it is decoded here, so it can be read where the run trained, and read again to follow a run still training. A fetched run is read with run.scan_history(), every row it logged, not the 500 evenly sampled rows run.history() returns; max_points then thins the line. Rows are placed in order of x.

A value that is not a number – an image, a table, a histogram – is not read. A dictionary logged as a value is read as its own metrics, named with a dot, {"val": {"loss": 0.3}} as val.loss. In rows given as a pandas.DataFrame a missing value and a logged NaN look the same, so both are left out; elsewhere a logged NaN is a gap in the line.

Examples

>>> import maidr
>>> charts = maidr.read_wandb_history(
...     ["my-team/llm/abc123", "my-team/llm/def456"], keys=["train/loss"]
... )
>>> maidr.save_html(charts[0], "loss.html")