i.e. make task a an implicit dependency of task b,...
# prefect-community
i.e. make task a an implicit dependency of task b, even though no data flows from a to b
Hi @David Hogarty, you definitely can! For that you can use the
kwarg, which will explicitly set that dependency. You can read more about it here.
how do I use that within the functional api?
do I just do b(regular_params, upstream_tasks=[a])
or, i guess
b_res = b(...)
err a_res = a(...)
b_res = b(..., upstream_tasks=[a_res])
Hi David! If you want to operate within the functional API, you can also use
to explicitly define which tasks are upstream and downstream of each other. https://docs.prefect.io/api/latest/core/task.html#task-2
upvote 1
roger, so when I have a @prefect.task
and call it from within the functional api, its return is a Task object?
and consequently, I can use the return from a task invocation for set_upstream or the upstream_tasks kwarg?
makes sense
i think this solved my problem
Yep, you have a couple of options here. You can explicitly declare tasks and upstream/downstream dependencies like this naive example:
Copy code
f = Flow(name="test")
t1 = Task()
t2 = Task()
t2.set_upstream(t1, flow=f)
or you can pass them in as arguments, like in this example:
Copy code
with Flow("Example Flow") as flow:
    task_a = task_a()
    task_b = task_b(upstream_tasks=[task_a])
It really just depends on your style and use case. Sounds like you're on the right track, but don't hesitate to reach out if you have any more questions!