https://prefect.io logo
#prefect-community
Title
# prefect-community
j

John Faucett

10/21/2019, 7:09 PM
Hi, is there any more document on parameters? other than here: https://docs.prefect.io/core/concepts/parameters.html, I’m having a confusing time getting them to work especially when I need multiple
c

Chris White

10/21/2019, 7:17 PM
Hi @John Faucett - could you describe the pain points you’re having? Ultimately Parameters are just a special type of Task so they have the same imperative interface
j

John Faucett

10/21/2019, 7:19 PM
hi @Chris White thanks for the response. Yes, I guess its just not clear to me how to add multiple parameter dependencies for a task, and pass results of task computations as parameters further downstream to other tasks
c

Chris White

10/21/2019, 7:20 PM
so for example,
Copy code
with Flow("parameter-example") as flow:
    p, q = Parameter("p"), Parameter("q")
    result = my_task(input_kwarg=p, another_kwarg=q)
j

John Faucett

10/21/2019, 7:21 PM
ah ok, right now I had
my_task.set_upstream(my_param, flow=flow, key='my_param_name')
c

Chris White

10/21/2019, 7:22 PM
that works as well!
as long as
my_task
accepts a
my_param_name
keyword argument in its
run
signature
j

John Faucett

10/21/2019, 7:22 PM
but what about when my task needs both p and q?
and r and z?
does the order not matter then, so I just set multiple upstreams on
my_task
and it will just work?
c

Chris White

10/21/2019, 7:25 PM
yea, ultimately you’re binding the results of the upstream tasks / parameters to the keyword arguments of the downstream task’s run method, so the order isn’t important
j

John Faucett

10/21/2019, 7:26 PM
ok nice. Thanks for the help. I just have one other question? Is there a way to set which task should be run first?
c

Chris White

10/21/2019, 7:28 PM
anytime! yea sure, just set the appropriate dependencies. So for example, if you want A to run before B, all you need to do is:
Copy code
task_b.set_upstream(task_a, flow=flow)
in this case, no data is exchanged but there is now an enforced dependency relationship. You can also see these relationships with
flow.visualize()
for easier introspection
j

John Faucett

10/21/2019, 7:29 PM
oh nice, and if I do
Copy code
task_b.set_upstream(task_a, flow=flow)
task_b.set_upstream(task_c, flow=flow)
will it wait for both upstreams to finish?
c

Chris White

10/21/2019, 7:29 PM
yup exactly!
j

John Faucett

10/21/2019, 7:30 PM
sweet! I must say I’m really liking prefect a lot
🙂
c

Chris White

10/21/2019, 7:31 PM
awesome - thank you! if you have any other questions or need further clarification we’re always here to help!
j

John Faucett

10/21/2019, 7:34 PM
well, I’m testing prefect out to see if we can use it to replace some luigi pipelines right now so I’m sure I’ll probably be taking you up on that one 🙂
c

Chris White

10/21/2019, 7:34 PM
oh awesome! If you collect any notes on the pros / cons of the replacement we’d love to hear them and I’m sure other people would as well
j

John Faucett

10/21/2019, 7:39 PM
ok yea thats a good idea, right now I’m liking state a lot over saving output files, thats nice