alins

    alins

    9 months ago
    Hi i have a problem when i define three task and add call them one by one under a flow they didn't run step by step !! how can i say to a flow to how run task (which task 1st which one 2nd and which one 3rd) ??? I'm adding a sample code as an reply to my message
    Anna Geller

    Anna Geller

    9 months ago
    @alins if you pass data dependencies, then you don’t need to set this at all. But if you don’t pass data, then: Method 1:
    with Flow(...) as flow:
        a = first_task()
        b = second_task()
        c = third_task(c_inputs, upstream_tasks=[a,b])
    Method 2:
    from prefect import task, Flow
    
    @task
    def first_task():
        pass
    
    @task
    def second_task():
        pass
    
    @task
    def third_task():
        pass
    
    with Flow("ex") as flow:
        a = first_task()
        b = second_task(upstream_tasks=[a])
        c = third_task(upstream_tasks=[b])
    
    flow.visualize()
    alins

    alins

    9 months ago
    thanks @Anna Geller I will test you method and tell you if its work tnx again :heart: