Thread
#prefect-community
    s

    Sumant Agnihotri

    4 months ago
    Hi, I wrote this code:
    @task
    def slicer():
        time.sleep(2)
        op = []
        for each in range(0, random.randint(1, 10)):
            op.append(each)
        return op
    
    @task
    def model_slide():
        logger = prefect.context.get("logger")
        time.sleep(2)
        <http://logger.info|logger.info>(f'model c: {datetime.now().strftime("%H:%M:%S")}')
    
    
    if __name__ == "__main__":
        with Flow("processing-flow", executor=LocalDaskExecutor()) as flow:
            list_of_slices = slicer()
            for each in list_of_slices:
                create_flow_run(flow_name="other-processing-flow", project_name="poc")
            model_slide(upstream_task=[create_flow_run])
    I'm getting the following error:
    for each in list_of_slices:
    TypeError: Task is not iterable. If your task returns multiple results, pass `nout` to the task decorator/constructor, or provide a `Tuple` return-type annotation to your task.
    What am I doing wrong?
    Anna Geller

    Anna Geller

    4 months ago
    This is an understandable source of confusion but in Prefect 1.0 you can't use a for loop as you did it in:
    for each in list_of_slices:
    the Flow block is only to call tasks and define the structure. to run multiple child flow runs in parallel, try
    create_flow_run.map()
    instead