Skip to content

How to get task name from task_run_id? #17151

Answered by zzstoatzz
tonal asked this question in Q&A
Discussion options

You must be logged in to vote

hi @tonal - to read the run names I think you'd have to go back to the API since the run name doesn't live on state_details (which is available here is fut.state.state_details, which may not be ideal because it might take a second for the run info to propagate per #14661

for example
import asyncio
import time
from uuid import UUID

from prefect import flow, get_client, task
from prefect.client.schemas.filters import TaskRunFilter, TaskRunFilterId
from prefect.futures import wait


@task
def errors_on_odd(number: int) -> int:
    if number % 2 == 0:
        return number
    else:
        raise ValueError("This is a test error")


async def _task_run_names_from_ids(ids: tuple[UUID, ...]) -> 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tonal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants