m

    Matthias

    2 years ago
    probably a very simple question, but i cannot find the answer in the docs. i have two tasks,
    task1
    and
    task2
    (defined by the
    @task
    decorator), which are both storing data in a database. for integrity i need to make sure that
    task1
    finished before
    task2
    starts. the tasks do not need to return anything. how do i make the dependency explicit and tell
    task2
    to wait for
    task1
    ?
    Chris White

    Chris White

    2 years ago
    We call this sort of dependency a “state dependency” (as the dependency only depends on whether the upstream’s state and not the data it passes). Setting state dependencies can be done in many ways but probably the simplest is:
    flow = Flow("my-flow")
    
    task2.set_upstream(task1, flow=flow)
    m

    Matthias

    2 years ago
    ahh, alright. thanks, i was just not searching the docs correctly. awesome!
    Chris White

    Chris White

    2 years ago
    no worries!
    @Marvin archive “How to ensure one task only runs only after another is finished?”