https://prefect.io logo
#best-practices
Title
# best-practices
y

yair friedman

06/02/2022, 6:15 AM
Hi , how can i get unique id for every task that is run in parallel ? if i have task A and i run it with : runs = A.map(listOfInputs, unmapped(input2)) when i print this in A:
Copy code
task_id = prefect.context.get("task_id", "")
i have the same task_id for every task A run …..
a

Anna Geller

06/02/2022, 10:30 AM
Try:
Copy code
prefect.context.get("task_run_id", "")
y

yair friedman

06/02/2022, 11:01 AM
thanks, that is working, get the unique id, the question is why task_id is generated as A_1 for all mapped runs. i wish that each task_id for the same task runs would have a running id, meaning A_1, A-2 , etc.
a

Anna Geller

06/02/2022, 11:45 AM
You can influence task name, but not task id - task id refers to the mapped task, which then spins up many child task runs, but the task itself stays the same I think this is what you are looking for: https://docs.prefect.io/core/idioms/task-run-names.html#naming-task-runs-based-on-inputs
y

yair friedman

06/02/2022, 1:05 PM
that is great ! thanks for the prompt response !
👍 1
8 Views