-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a decorator function to extract options from Strategy #180
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #180 +/- ##
==========================================
- Coverage 60.32% 60.28% -0.04%
==========================================
Files 33 33
Lines 5727 5749 +22
==========================================
+ Hits 3455 3466 +11
- Misses 2272 2283 +11 ☔ View full report in Codecov by Sentry. |
At the moment in order to get round specific options from the
Strategy
yaml file an explicit call has to be made intoget_options_from_strategy
with a set of keywords that specify the mode, self cal round and operation to uniquely identify the target set of user provided options. If these do not exist an empty dictionary is returned.This has worked fine in the past, but requires an explicit function call to get options, which are passed through into the target function.
This pull request explores whether a decorator function is of any use. The idea being that we can add the strategy extraction parameters to a target function, such that the target function itself extracts the appropriate options. Functionally, there is still a call into the Strategy yaml file, but it is hidden.
At best, it keeps all keyword arguments that act as inputs to a particular processing stage together and removes some clutter in the larger prefect workflow.
At worst, it can be seen as confusing and hides logic that may not be immediately obvious to someone who does not know the task has been wrapped.
This pull request does not remove the old approach of separating the call into the strategy options getter - that is still a completely supported mode.
Thoughts are welcome. After doing this I have two issues:
__name__
and__doc__
to the wrapped function. There might be other gotchas that come from this. I already found thatfunctools.wraps
causes errors with theprefect.task
argument validation