https://prefect.io logo
Title
a

Andrew Vaccaro

12/12/2019, 5:28 PM
How would I go about using Parameters with the imperative API? I have a few tasks that need to run in order but don't have data dependencies (all in a database already).
c

Chris White

12/12/2019, 5:30 PM
Hey @Andrew Vaccaro - there are two things: - any task that relies on a Parameter has a data dependency on that Parameter - to specify order I’d recommend using the
set_upstream
and
set_downstream
methods on task objects to specify their upstream / downstream dependencies
a

Andrew Vaccaro

12/12/2019, 5:36 PM
Fast response, thanks! 🙂 Couple clarifications: 1. In this particular cases, there are three tasks (A, B, and C) that rely on the same Parameter. But the execution order also needs to be A => B => C. 2. I'm looking at https://docs.prefect.io/core/concepts/flows.html#imperative-api and https://docs.prefect.io/core/concepts/parameters.html but I don't see how to combine the two?
c

Chris White

12/12/2019, 5:38 PM
Awesome thanks for the added context; here’s what I’d recommend:
with Flow("my-flow") as flow:
    A.set_dependencies(downstream_tasks=[B], keyword_tasks={"x": param})
    B.set_dependencies(downstream_tasks=[C], keyword_tasks={"x": param})
    C.set_dependencies(keyword_tasks={"x": param})
where
x
is the keyword argument of the task for the parameter
a

Andrew Vaccaro

12/12/2019, 8:02 PM
Aha! I think that's exactly what I'm looking for, thanks.
👍 1
c

Chris White

12/12/2019, 8:33 PM
@Marvin archive “How to specify Parameter dependencies using the imperative API”
a

Andrew Vaccaro

12/12/2019, 9:18 PM
That is an awesome usage of a bot
:marvin: 1
c

Chris White

12/12/2019, 9:38 PM
Haha thank you! Yea it helps keep our productive slack conversations discoverable by other users