Skip to content

prefect.server.api.flow_run_states

Routes for interacting with flow run state objects.

read_flow_run_state async

Get a flow run state by id.

Source code in prefect/server/api/flow_run_states.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@router.get("/{id}")
async def read_flow_run_state(
    flow_run_state_id: UUID = Path(
        ..., description="The flow run state id", alias="id"
    ),
    db: PrefectDBInterface = Depends(provide_database_interface),
) -> schemas.states.State:
    """
    Get a flow run state by id.
    """
    async with db.session_context() as session:
        flow_run_state = await models.flow_run_states.read_flow_run_state(
            session=session, flow_run_state_id=flow_run_state_id
        )
    if not flow_run_state:
        raise HTTPException(
            status.HTTP_404_NOT_FOUND, detail="Flow run state not found"
        )
    return flow_run_state

read_flow_run_states async

Get states associated with a flow run.

Source code in prefect/server/api/flow_run_states.py
40
41
42
43
44
45
46
47
48
49
50
51
@router.get("/")
async def read_flow_run_states(
    flow_run_id: UUID,
    db: PrefectDBInterface = Depends(provide_database_interface),
) -> List[schemas.states.State]:
    """
    Get states associated with a flow run.
    """
    async with db.session_context() as session:
        return await models.flow_run_states.read_flow_run_states(
            session=session, flow_run_id=flow_run_id
        )