GET /runs/{id}/nodes/{node}/outputs serves what a node returned

The stage cache's stored outputs, as kept (up to 256 kB of JSON). A node
that kept none answers 404 saying why. Listed in the API docs.
This commit is contained in:
2026-10-15 10:23:39 +02:00
parent e75b0297fd
commit 21cfed7d39
5 changed files with 95 additions and 2 deletions
+31
View File
@@ -1115,6 +1115,37 @@ def test_a_curve_whose_run_is_gone_is_empty_rather_than_an_error(
assert node["curve_lost"] is True
def test_a_node_answers_with_what_it_returned(client, superuser_token_headers):
"""What the stage cache stored, and a 404 that says why for a node without."""
run_id = new_run_id()
with Session(db_engine) as session:
session.add(
Run(id=run_id, flow="study", status="ok", created_at=datetime.now(UTC))
)
session.add(RunNode(run_id=run_id, node="fit", outputs='{"study.loss":0.5}'))
session.add(RunNode(run_id=run_id, node="plot", status="error"))
session.commit()
url = f"{settings.API_V1_STR}/runs/{run_id}/nodes"
try:
kept = client.get(f"{url}/fit/outputs", headers=superuser_token_headers)
assert kept.json() == {"study.loss": 0.5}
none = client.get(f"{url}/plot/outputs", headers=superuser_token_headers)
assert none.status_code == 404
assert "kept no outputs" in none.json()["detail"]
absent = client.get(f"{url}/nope/outputs", headers=superuser_token_headers)
assert absent.status_code == 404
finally:
with Session(db_engine) as session:
for row in session.exec(
select(RunNode).where(col(RunNode.run_id) == run_id)
).all():
session.delete(row)
session.delete(session.get(Run, run_id))
session.commit()
def _metric(run_id: str, name: str, step: int, value: float, ts: float) -> RunMetric:
return RunMetric(run_id=run_id, name=name, step=step, value=value, ts=ts)