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
+23 -1
View File
@@ -27,7 +27,7 @@ from fluksio.core.config import settings
from fluksio.core.db import writing
from fluksio.flow.events import event_bus
from fluksio.flow.messages import requalify
from fluksio.flow.runs import RunRejected, RunService, new_run_id
from fluksio.flow.runs import OUTPUT_CAP, RunRejected, RunService, new_run_id
from fluksio.flow.store import FlowNotFound
from fluksio.models import Message, Run, RunArtifact, RunMetric, RunNode
@@ -800,6 +800,28 @@ def read_run(run_id: str, session: SessionDep) -> Any:
return detail
@router.get("/{run_id}/nodes/{node}/outputs", response_model=dict[str, Any] | None)
def read_node_outputs(run_id: str, node: str, session: SessionDep) -> Any:
"""What one node returned, by message, as the stage cache stored it.
Kept only for a node that succeeded and may be reused, and only up to
256 kB of JSON. Null when the node published nothing.
"""
row = session.get(RunNode, {"run_id": run_id, "node": node})
if row is None:
raise HTTPException(status_code=404, detail=f"No node '{node}' in this run")
if row.outputs is None:
raise HTTPException(
status_code=404,
detail=(
f"Node '{node}' kept no outputs. It failed, may not be cached, "
f"or returned more than {OUTPUT_CAP // 1000} kB or a value JSON "
"cannot carry."
),
)
return json.loads(row.outputs)
@router.post("/{run_id}/cancel", response_model=RunRow)
async def cancel_run(run_id: str, request: Request, session: SessionDep) -> Any:
"""Stop a run. One already past its last node is left as it finished."""