Skip to content

prefect.orion.api.task_run_states

Routes for interacting with task run state objects.

read_task_run_state async

Get a task run state by id.

Source code in prefect/orion/api/task_run_states.py
@router.get("/{id}")
async def read_task_run_state(
    task_run_state_id: UUID = Path(
        ..., description="The task run state id", alias="id"
    ),
    db: OrionDBInterface = 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 async

Get states associated with a task run.

Source code in prefect/orion/api/task_run_states.py
@router.get("/")
async def read_task_run_states(
    task_run_id: UUID,
    db: OrionDBInterface = 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
        )