https://prefect.io logo
Title
m

Matthias

05/08/2020, 10:24 PM
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
?
c

Chris White

05/08/2020, 10:27 PM
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

05/08/2020, 10:28 PM
ahh, alright. thanks, i was just not searching the docs correctly. awesome!
c

Chris White

05/08/2020, 10:28 PM
no worries!
@Marvin archive “How to ensure one task only runs only after another is finished?”
m

Marvin

05/08/2020, 10:29 PM