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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user