Follow a record into its fields, name the metrics, name the version
Docs / docs (push) Successful in 38s
Playwright Tests / test-playwright (1, 2) (push) Successful in 2m56s
Playwright Tests / test-playwright (2, 2) (push) Successful in 2m7s
pre-commit / pre-commit (push) Failing after 2m17s
Test Backend / test-backend (push) Successful in 2m54s
Compose Smoke Test / test-compose (push) Successful in 44s
Playwright Tests / merge-reports (push) Successful in 1m17s
Docs / docs (push) Successful in 38s
Playwright Tests / test-playwright (1, 2) (push) Successful in 2m56s
Playwright Tests / test-playwright (2, 2) (push) Successful in 2m7s
pre-commit / pre-commit (push) Failing after 2m17s
Test Backend / test-backend (push) Successful in 2m54s
Compose Smoke Test / test-compose (push) Successful in 44s
Playwright Tests / merge-reports (push) Successful in 1m17s
Three things the first export pass got wrong for a real study. **Dotted paths.** A node returns a record, not a scalar — the numbers arrive inside `final_metrics` — so `--metrics final_metrics.train_loss` yielded an empty column and `--metrics final_metrics` yielded the whole record in one cell. Both sides of the wide table now take dotted paths, and the defaults reach the same depth: every number a result carries is a column named by its path, and inputs are compared leaf by leaf, so two configurations differing in one field give that field as the axis rather than two blobs that are merely not equal. Lists stay whole — a curve belongs in the long table. **`--list`.** Metric names are flow-qualified, so `--name train_loss` matched nothing and said only that. `fluksio export metrics --list` prints the names the selection carries, and an empty export made with `--name` points at it. **A version to compare.** The CLI ships ahead of the engine and a stale one answered a flat 404 with nothing anywhere in the API to tell how old it was. The engine reports `version` on `/observability/summary`, `fluksio status` prints it, and a 404 from export now names both versions — or says "older" when the field itself predates the engine. Bumped to 0.1.5, which is what makes the number worth reading. Also formats `flow/metrics.py`, which had been committed unformatted and was the last `ruff format --check` failure. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9Hdrmf2cwNABCnE5x9UJa
This commit is contained in:
@@ -654,7 +654,11 @@ def test_a_tree_that_did_not_move_is_not_written_again():
|
||||
|
||||
@pytest.fixture
|
||||
def exported():
|
||||
"""Two runs of one flow, each with two curves and one input that varies."""
|
||||
"""Two runs of one flow: two curves each, and records on both sides.
|
||||
|
||||
The numbers a node returns are usually inside a record rather than at the
|
||||
top of the result, so the fixture is shaped the way a real one is.
|
||||
"""
|
||||
made = datetime.now(UTC)
|
||||
with Session(db_engine) as session:
|
||||
for index, (lr, acc) in enumerate([(0.1, 0.5), (0.01, 0.25)]):
|
||||
@@ -664,8 +668,17 @@ def exported():
|
||||
id=run_id,
|
||||
flow="export-study",
|
||||
status="ok",
|
||||
params={"lr": lr, "epochs": 10},
|
||||
result={"acc": acc, "note": "n/a"},
|
||||
params={
|
||||
"lr": lr,
|
||||
"epochs": 10,
|
||||
"config": {"model": "mlp", "depth": index + 1},
|
||||
},
|
||||
result={
|
||||
"acc": acc,
|
||||
"note": "n/a",
|
||||
"final_metrics": {"train_loss": acc * 2},
|
||||
"test_metrics": {"known": {"perfect": 1.0}},
|
||||
},
|
||||
created_at=made + timedelta(seconds=index),
|
||||
)
|
||||
)
|
||||
@@ -727,17 +740,32 @@ def test_an_exported_run_row_carries_the_inputs_that_vary(
|
||||
rows = _lines(export(format="jsonl"))
|
||||
assert [row["id"] for row in rows] == ["exp-1", "exp-0"]
|
||||
assert {row["param.lr"] for row in rows} == {0.1, 0.01}
|
||||
# `epochs` is the same on both runs, so it is not what they differ by; a
|
||||
# string in the result is not one of the run's numbers.
|
||||
# `epochs` is the same on both runs, so it is not what they differ by, and
|
||||
# neither is the model inside the config — but the depth beside it is.
|
||||
assert "param.epochs" not in rows[0]
|
||||
assert rows[0]["metric.acc"] == 0.25
|
||||
assert "metric.note" not in rows[0]
|
||||
assert "param.config.model" not in rows[0]
|
||||
assert {row["param.config.depth"] for row in rows} == {1, 2}
|
||||
assert "param.epochs" in _lines(export(format="jsonl", params="epochs"))[0]
|
||||
|
||||
# A number inside a record is a column of its own, however deep; a string
|
||||
# is not one of the run's numbers wherever it sits.
|
||||
assert rows[0]["metric.acc"] == 0.25
|
||||
assert rows[0]["metric.final_metrics.train_loss"] == 0.5
|
||||
assert rows[0]["metric.test_metrics.known.perfect"] == 1.0
|
||||
assert "metric.note" not in rows[0]
|
||||
|
||||
named = _lines(export(format="jsonl", metrics="test_metrics.known.perfect"))
|
||||
assert list(named[0])[-1] == "metric.test_metrics.known.perfect"
|
||||
assert "metric.acc" not in named[0]
|
||||
|
||||
# csv is the default, and the columns are in the order the header names.
|
||||
header = export().text.splitlines()[0]
|
||||
assert header.startswith("id,flow,status,")
|
||||
assert header.endswith("param.lr,metric.acc")
|
||||
assert header.endswith(
|
||||
"param.config.depth,param.lr,"
|
||||
"metric.acc,metric.final_metrics.train_loss,"
|
||||
"metric.test_metrics.known.perfect"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user