Proposal: populate_parameters kwarg for Task.__call__ #3663
Unanswered
benfogelson
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
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:
This comes up often enough that we’ve written a helper function to populate these parameters by inspecting the task’s call signature:
These two snippets produce identical flows.
Proposal
Would there be appetite for supporting this pattern directly via a kwarg added to
Task.__call__
? The API I'm imagining would involve changing the signature ofTask.__call__
to the following:When
populate_parameters
is True,__call__
would instantiateParameters
for any arguments present in thetask.run
signature that weren't supplied by eitherargs
andkwargs
. If the signature specifies argument defaults, the instantiatedParameters
will also have those defaults, otherwise they will be required. Then, the task is copied and bound to the flow as usual, with a binding that includes edges for the generated parameters. I'm imagining also that the instantiated Parameters would follow a naming convention of something liketask_name.parameter_name
.I'm happy to take a crack at adapting our helper function to do this (I don't think it will be that hard), but wanted to gauge whether people would be receptive to this idea before putting in the work.
Beta Was this translation helpful? Give feedback.
All reactions