-
Notifications
You must be signed in to change notification settings - Fork 904
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
Pass kwargs to _register_new_resolvers from settings.py #2925
Comments
We had a little discussion about having
|
I am in favor of the kwargs over using the internal method |
I did not see the right PR, sorry for that ;) I did not really think carefully about it and I don't have a strong opinion. I vaguely imagine one of the two following syntax: Declare kwargs directly in
|
Alternative: when given a single value the function gets passed, when passed a 2-tuple it's (function, kwargs) CONFIG_LOADER_ARGS = {
"custom_resolvers": {
"add": lambda *my_list: sum(my_list),
"polars": lambda x: getattr(pl, x),
"today": (lambda: date_today(), dict(use_cache=True)),
}
} |
Curious to see if this is a good candidate for hacktoberfest - the implementation should be simple but any preference on which format to pass on the |
Option 1 seems out of the competition, but I am not really opinionated between options 2 and 3 which both seems ok albeit not very elegant. Definitely ok for me if someone's want to give a stab at it for Hacktoberfest, I can commit to review. |
Thinking about this again, isn't this addressed by something like |
Description
Since #2896, it is possible to register custom resolvers for
OmegaConfigLoader
. I'd like to pass kwargs to the_register_custom_resolvers
function to have more control on resolvers behaviour.Context
I wanted to add a resolver which will behave differently when called several times, e.g.:
If this resolver is called 2 times in the catalog, it will likely return different results because of a couple of milliseconds delay between each call.
OmegaConf
offers fine grained control on this behaviour through theuse_cache
argument of theregister_new_resolver
Possible Implementation
Add an extra key in
CONFIG_LOADER_ARGS
?Possible Alternatives
Document that it is possible to register resolver with more control in
after_context_created
hook, e.g. :EDIT: you cannot pass arg with the
KedroContext._register_new_resolvers
methodbut you can directly with
Omegaconf.register_new_resolver
:The text was updated successfully, but these errors were encountered: