Is there any way to define which task executes fir...
# ask-community
k
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
Tried passing upstream_tasks in decorator but not able to achieve the flow diagram desired
n
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
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()
upvote 2
k
Untitled
Created a weird looking flow diagram
k
You can try something like this:
Copy code
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
Thanks That worked
k
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.