Skip to content

prefect.server.api.task_run_states

Routes for interacting with task run state objects.

read_task_run_state(task_run_state_id=Path(..., description='The task run state id', alias='id'), db=Depends(provide_database_interface)) async

Get a task run state by id.

Source code in src/prefect/server/api/task_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_task_run_state(
    task_run_state_id: UUID = Path(
        ..., description="The task run state id", alias="id"
    ),
    db: PrefectDBInterface = Depends(provide_database_interface),
) -> schemas.states.State:
    """
    Get a task run state by id.
    """
    async with db.session_context() as session:
        task_run_state = await models.task_run_states.read_task_run_state(
            session=session, task_run_state_id=task_run_state_id
        )
    if not task_run_state:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND, detail="Flow run state not found"
        )
    return task_run_state

read_task_run_states(task_run_id, db=Depends(provide_database_interface)) async

Get states associated with a task run.

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