Hello everyone! Just a noobie question here, how d...
# ask-community
i
Hello everyone! Just a noobie question here, how do I create edges (one task can only execute if the previous is successful) between tasks that don't pass "results" between them? For example, let suppose that I have a program that creates some folders, login to an API, and collects some results being: Create Folder 1 > Create Folder 2 > Login to API > Collect Results The three initial tasks don't return results, but I want to run in "chained" execution.
t
You can set tasks as being upstream of one another. There's some examples of it here https://docs.prefect.io/core/concepts/execution.html#triggers
😍 1
k
The docs @Thomas Weatherston will help, but here is the syntax
Copy code
@task()
def abc(a):
    return a
with Flow("ecs_testing") as flow:
    x = abc(1)
    y = abc(1, upstream_tasks=[x])
with Flow("ecs_tes") as flow2:
    x = abc(1)
    y = abc(1)
    y.set_upstream(x)
😍 1
c
Is
flow.add_edge()
no longer used?
k
You could do that if it suits you. Do you use that along with the functional API or do you use the imperative API?
πŸ‘ 1
c
Using both upstream/edge and func/imper api - I need to land on a style for sure πŸ˜‰
i
Hey @Kevin Kho, the task must return some variable to be properly upstreamed?
k
If you only reference it once like
abc()
, I think you can do
upstream_tasks=[abc]
, but of course when you do it multiple times, you should probably use the variable assignment. And no you don’t need to return anything. That variable is just a reference for the Task, and the result can be None