Is there any way to define which task executes first
and second task has to be executed only after first task is executed
Both of these tasks loads same data from a loader function
👀 1
Kayvan Shah
04/20/2021, 6:30 PM
Tried passing upstream_tasks in decorator but not able to achieve the flow diagram desired
n
nicholas
04/20/2021, 6:31 PM
Hi @Kayvan Shah - would you mind sharing some minimal code for what you've tried?
upstream_tasks
should work for what you're thinking
k
Kevin Kho
04/20/2021, 6:33 PM
Sample code for `upstream_tasks`:
Copy code
import prefect
from prefect import Flow, task
@task
def mytask():
return 1
with Flow('test-flow') as flow:
a = mytask()
b = mytask(upstream_tasks=[a])
flow.run()
with Flow("Harvest_Demo") as flow:
path_config = load_path_config()
x = harvest_metadata(path_config)
harvest_master_data(path_config, upstream_tasks=[x])
k
Kayvan Shah
04/20/2021, 6:40 PM
Thanks
That worked
k
Kevin Kho
04/20/2021, 6:40 PM
The x will hold the value and state of the
harvest_metadata
task and the
harvest_master_data
task will grab the state from x even if there is no return value in this case.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.