Repository navigation
feat(config): pass kwargs to custom resolvers registered with OmegaConfigLoader - #5813
Conversation
…nfigLoader A custom resolver can now be given as a (callable, kwargs) tuple in CONFIG_LOADER_ARGS['custom_resolvers']; the kwargs are passed on to OmegaConf.register_new_resolver(), so options such as use_cache and replace can be set per resolver. Plain callables register exactly as before, so existing settings are unaffected. Fixes kedro-org#2925 Signed-off-by: Charan Rathore <[email protected]>
|
Hi @charan-rathore, thanks for your interest in contributing to this issue #2925 We'll look through the PR and review it soon! |
|
Thanks @ankatiyar, noted. I'll stick to the board's "Ready" tickets for future picks. Appreciate you adding #2925 to the board, and happy to adjust anything once you've had a look. |
|
Thanks for adding it to the board, and understood - I'll pick future tickets from the board's Ready column. |
ankatiyar
left a comment
There was a problem hiding this comment.
Thank you @charan-rathore, seems like a reasonable approach!
Signed-off-by: Ankita Katiyar <[email protected]>
Move the RELEASE.md note from Bug fixes into the kedro-org#5813 entry under Major features and improvements, since kedro-org#5813 is unreleased; document the skip-unless-replace rule in the OmegaConfigLoader docstrings and in the templating guide; and clear the test resolvers after each test so the tests stay valid when re-run in the same process. Signed-off-by: Shahzeb Ali <[email protected]>
) * fix: respect replace=True for already-registered custom resolvers _register_new_resolvers skipped every resolver whose name was already registered, so kwargs such as replace=True never reached OmegaConf.register_new_resolver() and the old resolver was kept silently. An already-registered resolver is now skipped only when the resolver kwargs do not contain replace=True; plain callables and tuples without replace keep their previous behaviour. Signed-off-by: Shahzeb Ali <[email protected]> * fix: address review feedback on replace for registered resolvers Move the RELEASE.md note from Bug fixes into the #5813 entry under Major features and improvements, since #5813 is unreleased; document the skip-unless-replace rule in the OmegaConfigLoader docstrings and in the templating guide; and clear the test resolvers after each test so the tests stay valid when re-run in the same process. Signed-off-by: Shahzeb Ali <[email protected]> * Update secrets baseline line number Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Merel Theisen <[email protected]> --------- Signed-off-by: Shahzeb Ali <[email protected]> Signed-off-by: Merel Theisen <[email protected]> Signed-off-by: Merel Theisen <[email protected]> Co-authored-by: Merel Theisen <[email protected]> Co-authored-by: Merel Theisen <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Description
Fixes #2925. Since #2896, custom resolvers can be registered with
OmegaConfigLoaderthroughCONFIG_LOADER_ARGS["custom_resolvers"], but there is no way to pass keyword arguments (such asuse_cacheorreplace) on toOmegaConf.register_new_resolver(), which is what the issue asks for.This implements the tuple form proposed in the issue discussion: a resolver given as a
(callable, kwargs)tuple passeskwargson toOmegaConf.register_new_resolver(); a plain callable registers exactly as before, so existingsettings.pyfiles are unaffected.Development notes
_register_new_resolvers()unpacks the tuple and forwards the kwargs; the type hints and theOmegaConfigLoaderdocstring are updated to match.docs/configure/how_to_use_templating.mdshows the tuple form.test_custom_resolvers_with_kwargsregisters a counter resolver twice (cached via the tuple form and uncached as a plain callable) and asserts the cached interpolations resolve equal while the uncached ones do not. On currentmainthe test errors at registration (TypeError: resolver must be callable).tests/config/suite: 94 passed.ruff formatclean.ruff checkreports only the same 4 pre-existing findings as onmain. The full repo suite andmypy --strictwere not run; happy to address anything CI turns up.Developer Certificate of Origin
All commits are signed off.
Checklist
RELEASE.mdfile