Daniel Komisar

12/22/2022, 2:39 PM
Prefect v1 question: is there any way to use task looping with a function that creates tasks? I have a group of tasks that I'm using with
and what I'd really like to do is have each of those be the body of a loop. It looks like you can only loop one single task though. Am I missing something? Thanks!

James Sopkin

12/22/2022, 10:22 PM
Hi @Daniel Komisar could you clarify what you mean by using tasks as the body of a loop? Did you mean like mapping the task creation function?
I'm not sure how your apply map is being set up, but perhaps you can loop through your different functions and then pass them in as params like
with Flow("apply-map example") as flow:
    for f in [creation_task, creation_task2]:
        result = apply_map(f, range(4))