Gauging interest in a feature: A pattern we tend t...
# prefect-community
b
Gauging interest in a feature: A pattern we tend to encounter is where we have a task that we call to add to a flow, and we’d like to make
Parameters
for some of its call method arguments. This can lead to a lot of boilerplate:
Copy code
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.
Copy code
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.
n
Hi @Ben Fogelson - this seems like a good candidate for a GitHub discussion; would you mind posting this there so others can participate without the discussion getting lost?
It's also a good place to propose the API you have in mind 🙂
b
Thanks @nicholas! Just started a discussion: https://github.com/PrefectHQ/prefect/discussions/3663
n
Thanks @Ben Fogelson! 😄