Skip to content

Commit

Permalink
Moved the environment assumption from ConfigLoader to `_ProjectSett…
Browse files Browse the repository at this point in the history
…ings` (#3311)

* update release notes

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* Remove the default env in config loader - add the env in tests

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* remove unncessary `default_run_env`

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* fix tests

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Added a couple of tests to make sure config loader standalone mode works

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* fix tests

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* lint

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Fix tests

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* update default

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* fix test coverage

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* fix test and lint

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* rename test to 'without_environment' to reflect the change of defaults

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* fix tests according to comments

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

* update test to test arbitary env explicitly

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

---------

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam authored Nov 21, 2023
1 parent 84b3e5c commit c1cf255
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 66 deletions.
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Added the functionality to choose a merging strategy for config files loaded with `OmegaConfigLoader`.
* Modified the mechanism of importing datasets, raise more explicit error when dependencies are missing.
* Added validation for configuration file used to override run commands via the CLI.

* Moved the default environment `base` and `local` from config loader to `_ProjectSettings`. This enables the use of config loader as a standalone class without affecting existing Kedro Framework users.
## Bug fixes and other changes
* Added a new field `add-ons` to `pyproject.toml` when a project is created.
* Reduced `spaceflights` data to minimise waiting times during tutorial execution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# CONFIG_LOADER_CLASS = OmegaConfigLoader
# Keyword arguments to pass to the `CONFIG_LOADER_CLASS` constructor.
# CONFIG_LOADER_ARGS = {
# "base_env": "base",
# "default_run_env": "local",
# "config_patterns": {
# "spark" : ["spark*/"],
# "parameters": ["parameters*", "parameters*/**", "**/parameters*"],
Expand Down
8 changes: 4 additions & 4 deletions kedro/config/omegaconf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __init__( # noqa: PLR0913
runtime_params: dict[str, Any] = None,
*,
config_patterns: dict[str, list[str]] = None,
base_env: str = "base",
default_run_env: str = "local",
base_env: str = None,
default_run_env: str = None,
custom_resolvers: dict[str, Callable] = None,
merge_strategy: dict[str, str] = None,
):
Expand All @@ -102,8 +102,8 @@ def __init__( # noqa: PLR0913
custom_resolvers: A dictionary of custom resolvers to be registered. For more information,
see here: https://omegaconf.readthedocs.io/en/2.3_branch/custom_resolvers.html#custom-resolvers
"""
self.base_env = base_env
self.default_run_env = default_run_env
self.base_env = base_env or ""
self.default_run_env = default_run_env or ""
self.merge_strategy = merge_strategy or {}

self.config_patterns = {
Expand Down
4 changes: 3 additions & 1 deletion kedro/framework/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class _ProjectSettings(LazySettings):
"CONFIG_LOADER_CLASS",
default=_get_default_class("kedro.config.OmegaConfigLoader"),
)
_CONFIG_LOADER_ARGS = Validator("CONFIG_LOADER_ARGS", default={})
_CONFIG_LOADER_ARGS = Validator(
"CONFIG_LOADER_ARGS", default={"base_env": "base", "default_run_env": "local"}
)
_DATA_CATALOG_CLASS = _IsSubclassValidator(
"DATA_CATALOG_CLASS", default=_get_default_class("kedro.io.DataCatalog")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

# Keyword arguments to pass to the `CONFIG_LOADER_CLASS` constructor.
# CONFIG_LOADER_ARGS = {
# "base_env": "base",
# "default_run_env": "local",
# "config_patterns": {
# "spark" : ["spark*/"],
# "parameters": ["parameters*", "parameters*/**", "**/parameters*"],
Expand Down
Loading

0 comments on commit c1cf255

Please sign in to comment.