From 758ac45ff6615f1cceb19e7df716d25069925f8a Mon Sep 17 00:00:00 2001 From: ElenaKhaustova <157851531+ElenaKhaustova@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:40:53 +0100 Subject: [PATCH] Clarify docs around custom resolvers (#3759) * Updated custom resolver docs section Signed-off-by: Elena Khaustova * Updated advanced configuration section for consistency Signed-off-by: Elena Khaustova * Updated RELEASE.md Signed-off-by: Elena Khaustova * Updated RELEASE.md Signed-off-by: Elena Khaustova * Test linkcheck_workers decrease Signed-off-by: Elena Khaustova * Increased the By default, the linkcheck_rate_limit_timeout to default Signed-off-by: Elena Khaustova * Returned old docs build settings Signed-off-by: Elena Khaustova * Fixed typo Signed-off-by: Elena Khaustova * Ignore forbidden url Signed-off-by: Elena Khaustova * Returned linkcheck retries Signed-off-by: Elena Khaustova --------- Signed-off-by: Elena Khaustova --- RELEASE.md | 1 + .../configuration/advanced_configuration.md | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index d3b6e7f061..7f247098f3 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,7 @@ # Upcoming Release 0.19.4 ## Major features and improvements +* Clarified docs around using custom resolvers without a full Kedro project. * Improved error message when passing wrong value to node. * Cookiecutter errors are shown in short format without the `--verbose` flag. * Kedro commands now work from any subdirectory within a Kedro project. diff --git a/docs/source/configuration/advanced_configuration.md b/docs/source/configuration/advanced_configuration.md index 82da1d729b..f9c96c7e31 100644 --- a/docs/source/configuration/advanced_configuration.md +++ b/docs/source/configuration/advanced_configuration.md @@ -329,8 +329,9 @@ tree . └── parameters.yml ``` +Consider the following `parameters.yml` file and example Python script: + ```yaml -# parameters.yml learning_rate: 0.01 train_test_ratio: 0.7 ``` @@ -342,7 +343,12 @@ config_loader = OmegaConfigLoader(conf_source=".") # Optionally, you can also use environments # config_loader = OmegaConfigLoader(conf_source=".", base_env="base", default_run_env="local") ->>> config_loader["parameters"] +print(config_loader["parameters"]) +``` + +If you run it from the same directory where `parameters.yml` placed it gives the following output: + +```console {'learning_rate': 0.01, 'train_test_ratio': 0.7} ``` @@ -351,8 +357,9 @@ For the full list of features, please refer to [configuration_basics](./configur ### How to use Custom Resolvers with `OmegaConfigLoader` You can register custom resolvers to use non-primitive types for parameters. +Consider the following `parameters.yml` file an example of Python script for registering a custom resolver: + ```yaml -# parameters.yml polars_float64: "${polars: Float64}" today: "${today:}" ``` @@ -368,6 +375,12 @@ custom_resolvers = {"polars": lambda x: getattr(pl, x), # Register custom resolvers config_loader = OmegaConfigLoader(conf_source=".", custom_resolvers=custom_resolvers) ->>> print(config_loader["parameters"]) + +print(config_loader["parameters"]) +``` + +If you run it from the same directory where `parameters.yml` placed it gives the following output: + +```console {'polars_float64': Float64, 'today': datetime.date(2023, 11, 23)} ```