Skip to content

feat(config): pass kwargs to custom resolvers registered with OmegaConfigLoader - #5813

Merged
ankatiyar merged 2 commits into
kedro-org:mainfrom
charan-rathore:feat/custom-resolver-kwargs-2925
Oct 15, 2026
Merged

ankatiyar merged 2 commits into
kedro-org:mainfrom
charan-rathore:feat/custom-resolver-kwargs-2925

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Description

Fixes #2925. Since #2896, custom resolvers can be registered with OmegaConfigLoader through CONFIG_LOADER_ARGS["custom_resolvers"], but there is no way to pass keyword arguments (such as use_cache or replace) on to OmegaConf.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 passes kwargs on to OmegaConf.register_new_resolver(); a plain callable registers exactly as before, so existing settings.py files are unaffected.

CONFIG_LOADER_ARGS = {
    "custom_resolvers": {
        "add": lambda *my_list: sum(my_list),
        "today": (date_today, {"use_cache": True}),
    }
}

Development notes

  • _register_new_resolvers() unpacks the tuple and forwards the kwargs; the type hints and the OmegaConfigLoader docstring are updated to match.
  • Docs: docs/configure/how_to_use_templating.md shows the tuple form.
  • Tests: test_custom_resolvers_with_kwargs registers 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 current main the test errors at registration (TypeError: resolver must be callable).
  • tests/config/ suite: 94 passed. ruff format clean. ruff check reports only the same 4 pre-existing findings as on main. The full repo suite and mypy --strict were not run; happy to address anything CI turns up.

Developer Certificate of Origin

All commits are signed off.

Checklist

  • Read the contributing guidelines
  • Linked to a relevant GitHub issue
  • Signed off each commit with a DCO
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes

…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]>
@ankatiyar

Copy link
Copy Markdown
Contributor

Hi @charan-rathore, thanks for your interest in contributing to this issue #2925
We usually can only accept contributions for issues listed on our open source ticket board: OS contribution tasks. Other issues in the repository are not yet ready for external contribution -they may need further scoping or are marked for internal work.
I've discussed with the team and decided to include #2925 on the OS board but for future reference, please stick to issues from the board and pick up tickets marked as "Ready"
For more details, please see our contribution guidelines: https://github.com/kedro-org/kedro/blob/main/CONTRIBUTING.md and the developer guide: https://github.com/kedro-org/kedro/wiki/Guidelines-for-contributing-developers.

We'll look through the PR and review it soon!

@ankatiyar
ankatiyar self-requested a review October 12, 2026 14:22
@charan-rathore

Copy link
Copy Markdown
Contributor Author

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.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks for adding it to the board, and understood - I'll pick future tickets from the board's Ready column.

@ankatiyar
ankatiyar requested a review from noklam October 15, 2026 11:45

@ankatiyar ankatiyar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @charan-rathore, seems like a reasonable approach!

@ankatiyar
ankatiyar enabled auto-merge (squash) October 15, 2026 14:17
@ankatiyar
ankatiyar merged commit 4b62b05 into kedro-org:main Oct 15, 2026
28 checks passed
Shahzeb-DataEngineer added a commit to Shahzeb-DataEngineer/kedro that referenced this pull request Nov 3, 2026
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]>
merelcht added a commit that referenced this pull request Nov 5, 2026
)

* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass kwargs to _register_new_resolvers from settings.py

3 participants