Ben Fogelson
11/13/2020, 7:55 PMParameters
for some of its call method arguments. This can lead to a lot of boilerplate:
from prefect import Flow, Parameter, task
@task
def task_with_many_args(a, b, c, d, e=None, f=5, g='foo'):
pass
with Flow('flow') as flow:
a = some_other_task()
task_with_many_args(
a=a,
b=Parameter('task_with_many_args.b'),
c=Parameter('task_with_many_args.c'),
d=Parameter('task_with_many_args.d'),
e=Parameter('task_with_many_args.e', default=None),
f=Parameter('task_with_many_args.f', default=5),
g=Parameter('task_with_many_args.g', default='foo'),
)
This comes up often enough that we’ve written a helper function to populate these parameters by inspecting the task’s call signature.
with Flow('flow') as flow:
a = some_other_task()
call_and_populate_parameters(task_with_many_args, a=a)
These two examples produce identical flows.
What I’m wondering from the Prefect team is whether there’d be interest in incorporating some sort of populate_paramaters
kwarg directly into the Task.__call__
method. Happy to take a stab at implementing it myself, but wanted to check before I put in the effort.nicholas
Ben Fogelson
11/13/2020, 8:14 PMnicholas