Skip to content

analysis

Offline, dependency-free views of a sweep directory. Each reads the per-cell status and metrics sidecars directly (no Hydra composition or xarray), so they load instantly and work mid-sweep; show also reads the sweep's multirun.yaml for the latest run's progress. See the exploration → paper guide for how they fit an exploration workflow.

show

show(root, *, metrics=None, sort=None, jobs=False)

Read the sweep under root and return a status/metrics table.

A cell's status is completed, failed, skipped (left out by sample=, or by a max_total_seconds budget that ran out), running (started; also a cell whose process was killed), or, on mushin's submitit launchers, queued: its job was submitted and has not started. A cell sent to a job again (by a resume) is queued in place of its earlier record until the job starts. Without a submitit launcher, a cell that has not started has no row.

queued comes from the launch files under root/mushin_jobs/, which a driver removes once it has waited on the jobs. A driver killed before then leaves its file, and the cells of a SLURM job that never started stay queued until a later run records them (a local one's, until its processes have exited). A launch of cells whose dirs nest below root (a hydra.sweep.subdir of several levels) lists none.

After the table, show prints the latest run's progress (its SweepProgress, also returned as .progress), for example::

run 3f2a9c1e, started 2026-11-29 10:02 UTC: 12 of 24 cells done
(11 completed, 1 failed), 2 running, 10 not started; 4 rows are
from earlier runs; not finished

(one line). The latest run is the one root/multirun.yaml names, which each run(), a resume included, rewrites when it launches. Only its own cells are counted: rows an earlier run left in a reused working_dir stay in the table, as earlier. finished says whether the run ended and wrote its manifest. A directory whose multirun.yaml names no run (missing, or from before runs were named) prints no progress line.

Parameters:

Name Type Description Default
root

A sweep working_dir (the parent of the numeric per-cell job dirs).

required
metrics list[str] | None

Restrict the metric columns to these names, in this order (default: every metric found, discovery order). An unknown name raises ValueError (like sort=); repeats are deduplicated.

None
sort str | None

Column to sort rows by (a swept param, "status", a job column, or a metric). Defaults to the swept params in grid order. "status" is always the cell status: a swept param named status is shown (and sorted) as "status (param)", and a metric that shares a swept param's name, or status, as "<name> (metric)".

None
jobs bool

Add the columns job (the submitit job id), host (the node the job ran on) and logs (the folder of its logs) after status, from the job a cell's record names; a queued row has only its job, and a cell not run by a submitit launcher has none. A swept param or a metric of one of these names is then "<name> (param)" or "<name> (metric)".

False

Returns:

Type Description
ShowResult

.rows (one dict per cell), .table (the rendered string) and .progress (the latest run's SweepProgress, or None); the table and the progress line are also printed. .progress holds run_id, started (UTC), cells (the grid's, None when unknown), the run's completed, failed, skipped, running and queued cells, earlier (rows other runs wrote), finished, and done and not_started.

best

best(root, metric, *, mode='max', over=None)

Return the completed cell that optimizes metric across the sweep, or, with over=, the configuration whose mean metric over the named swept params is best.

Parameters:

Name Type Description Default
root

A sweep working_dir.

required
metric str

The metric to optimize; it must be a finite scalar in each cell.

required
mode str

"max" (default) or "min".

'max'
over str | Sequence[str] | None

Swept params to average over, typically "seed". The default picks the single best cell, which is one seed; over="seed" groups the cells that share every other param, averages metric within each group and returns the best group, so a lucky seed cannot win. Means are comparable only over the same seeds, so only a complete group counts: one with a result (a completed cell with a finite metric) at every seed where any group has one. The others (a failed cell, a sample= sweep's holes, a configuration whose seeds have not all run) are skipped with a warning; a seed that failed for every configuration drops out instead. On a sweep still running the seeds reached so far set the bar, and the warning says so; the definitive answer comes once the sweep has finished. One value of over has nothing to average, and raises.

None

Returns:

Type Description
BestResult

With over=, its combo omits the averaged params, value and metrics are means, n counts the cells, dirs lists their job dirs and dir is None.

Raises:

Type Description
ValueError

If mode is invalid, no completed cell has metric as a finite scalar (the error lists the scalar metrics that are available), over is not a swept-param name or a sequence of them, names a param the sweep does not vary, no group is complete, or one value of over has a result.

FileNotFoundError

If root is not a directory.

diff

diff(a, b, *, metrics=None)

Compare two sweep directories a and b.

Cells are aligned by their swept-param combination. For each shared cell the delta b - a is computed for every metric that is a finite scalar in both, and only when the cell is completed on BOTH sides (a failed/skipped cell may carry a stale sidecar from a prior attempt; its row appears with empty deltas). Cells present in only one sweep are reported separately, along with a diff of the two runs' environment provenance (git/packages/python, and the accelerator when both runs recorded one).

Returns:

Type Description
DiffResult

.rows (one per shared cell: its swept params and a deltas dict of (a, b, b - a) per metric; a swept param named deltas is "deltas (param)"), .only_in_a / .only_in_b (combos), .provenance ({field: (a, b)}), and .table; the table prints.

table

table(root, *, path=None, metrics=None)

Export a sweep's cells as CSV: one row per cell with its swept params, status, and metrics.

Parameters:

Name Type Description Default
root

A sweep working_dir.

required
path

If given, write the CSV there, in UTF-8 on every platform, and return the Path. Otherwise return the CSV as a string.

None
metrics list[str] | None

Restrict the metric columns to these names, in this order (default: every metric found, discovery order); repeats are deduplicated. A metric sharing a swept param's name, or status, is emitted as "<name> (metric)", and a swept param named status as "status (param)" (status is the cell status).

None

Raises:

Type Description
FileNotFoundError

If root is not a directory.

ValueError

If metrics contains a name that is not a metric of this sweep.