Hi , how can i get unique id for every task that i...
# best-practices
y
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
Try:
Copy code
prefect.context.get("task_run_id", "")
y
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
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
that is great ! thanks for the prompt response !
👍 1