Skip to content
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

Allow registering of custom resolvers to OmegaConfigLoader through CONFIG_LOADER_ARGS #2622

Closed
ankatiyar opened this issue May 31, 2023 · 1 comment · Fixed by #2869
Closed
Assignees
Labels
Component: Configuration Issue: Feature Request New feature or improvement to existing feature

Comments

@ankatiyar
Copy link
Contributor

Description

Allowing users to register custom resolvers will make it easy for users to do more advanced interpolation in their configs.
OmegaConf documentation about custom resolvers - https://omegaconf.readthedocs.io/en/2.3_branch/custom_resolvers.html

Context

Follow up task for #2407

Possible Implementation

Users should be able to add custom resolvers in their settings.py files -

from kedro.config import OmegaConfigLoader


CONFIG_LOADER_CLASS = OmegaConfigLoader

CONFIG_LOADER_ARGS = {
    "custom_resolvers": {
        "add": lambda *x: sum(x),
    }
}

The config files then could look like this -
parameters.yml

model_options:
  test_size: ${add:1,2,3}
  random_state: 3
  • The implementation of this on the OmegaConfigLoader side should be a very thin wrapper for OmegaConf.register_new_resolver() so that any future changes to OmegaConf don't affect anything on Kedro side.
  • Users can overwrite built-in resolvers using replace=True
@noklam
Copy link
Contributor

noklam commented Jun 5, 2023

Do we need anything special to enable this? The only thing we need to do is add custom_resolvers as an argument to OmegaConfigLoader.

Then test both scenarios works

  1. Custom Resolvers can be registered when using standalone
  2. custom_resolvers can be registered via settings.py (This should just work since it's just an additional argument, we always pass all of them to the constructor anyway)

@merelcht merelcht changed the title Allow registering of custom resolvers to OmegaConfigLoader through CONFIG_LOADER_ARGS Allow registering of custom resolvers to OmegaConfigLoader through CONFIG_LOADER_ARGS Jun 5, 2023
@merelcht merelcht moved this to To Do in Kedro Framework Jul 10, 2023
@ankatiyar ankatiyar self-assigned this Jul 27, 2023
@ankatiyar ankatiyar moved this from To Do to In Progress in Kedro Framework Jul 28, 2023
@merelcht merelcht moved this from In Progress to In Review in Kedro Framework Jul 31, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Kedro Framework Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Configuration Issue: Feature Request New feature or improvement to existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants