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

Moved the environment assumption from ConfigLoader to _ProjectSettings #3311

Merged
merged 22 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6a363cf
update release notes
noklam Nov 14, 2023
80b2a78
Remove the default env in config loader - add the env in tests
noklam Nov 15, 2023
ab67d37
remove unncessary `default_run_env`
noklam Nov 15, 2023
6ecbdef
fix tests
noklam Nov 15, 2023
7731883
Added a couple of tests to make sure config loader standalone mode works
noklam Nov 15, 2023
54273f1
Merge branch 'develop' into noklam/remove-the-environment-default-2971
noklam Nov 15, 2023
417874b
fix tests
noklam Nov 15, 2023
ef6769c
Merge branch 'noklam/remove-the-environment-default-2971' of github.c…
noklam Nov 15, 2023
f295f3a
lint
noklam Nov 15, 2023
ffbb45d
Merge branch 'develop' into noklam/remove-the-environment-default-2971
noklam Nov 15, 2023
6ddf591
Fix tests
noklam Nov 16, 2023
0a574d6
update default
noklam Nov 16, 2023
42ba4f9
fix test coverage
noklam Nov 16, 2023
585a472
fix test and lint
noklam Nov 16, 2023
adf72fb
Merge branch 'develop' into noklam/remove-the-environment-default-2971
noklam Nov 17, 2023
42189ea
Merge branch 'develop' into noklam/remove-the-environment-default-2971
noklam Nov 20, 2023
b7d46c3
rename test to 'without_environment' to reflect the change of defaults
noklam Nov 20, 2023
1c30daa
fix tests according to comments
noklam Nov 20, 2023
aa02d6c
update test to test arbitary env explicitly
noklam Nov 21, 2023
c361ac3
Merge branch 'develop' into noklam/remove-the-environment-default-2971
merelcht Nov 21, 2023
7c21f81
Merge branch 'develop' into noklam/remove-the-environment-default-2971
merelcht Nov 21, 2023
92ecbad
Merge branch 'develop' into noklam/remove-the-environment-default-2971
merelcht Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +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 enable the use of config loader as a standalone class without affecting existing Kedro Project users.

* 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
40 changes: 36 additions & 4 deletions tests/config/test_omegaconf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,7 @@ def test_ignore_hidden_keys(self, tmp_path):
_write_yaml(tmp_path / _BASE_ENV / "catalog1.yml", {"k1": "v1", "_k2": "v2"})
_write_yaml(tmp_path / _BASE_ENV / "catalog2.yml", {"k3": "v3", "_k2": "v4"})

conf = OmegaConfigLoader(
str(tmp_path), base_env=_BASE_ENV, default_run_env=_DEFAULT_RUN_ENV
)
conf = OmegaConfigLoader(str(tmp_path), base_env=_BASE_ENV)
conf.default_run_env = ""
merelcht marked this conversation as resolved.
Show resolved Hide resolved
catalog = conf["catalog"]
assert catalog.keys() == {"k1", "k3"}
Expand Down Expand Up @@ -1067,15 +1065,31 @@ def test_runtime_params_missing_default(self, tmp_path):

def test_runtime_params_in_globals_not_allowed(self, tmp_path):
base_globals = tmp_path / _BASE_ENV / "globals.yml"
local_globals = tmp_path / _DEFAULT_RUN_ENV / "globals.yml"

runtime_params = {
"x": 45,
}

base_globals_config = {
"my_global_var": "${runtime_params:x}", # x does exist but shouldn't be allowed in globals
"my_global_var": "${runtime_params:x}",
}
local_globals_config = {
"my_local_var": "${runtime_params:x}", # x does exist but shouldn't be allowed in globals
}

_write_yaml(base_globals, base_globals_config)
_write_yaml(local_globals, local_globals_config)

with pytest.raises(
UnsupportedInterpolationType,
match=r"The `runtime_params:` resolver is not supported for globals.",
):
OmegaConfigLoader(
tmp_path,
default_run_env=_DEFAULT_RUN_ENV,
runtime_params=runtime_params,
)
with pytest.raises(
UnsupportedInterpolationType,
match=r"The `runtime_params:` resolver is not supported for globals.",
Expand Down Expand Up @@ -1214,6 +1228,24 @@ def test_load_config_without_environment(self, tmp_path):
conf["catalog"]["companies"]["type"] == catalog_config["companies"]["type"]
)

def test_load_config_only_base_environment(self, tmp_path):
base_parameters = tmp_path / _BASE_ENV / "parameters.yml"
base_parameters_config = {"dummy": "base"}

_write_yaml(base_parameters, base_parameters_config)

conf = OmegaConfigLoader(tmp_path, base_env=_BASE_ENV)
assert conf["parameters"]["dummy"] == "base"

def test_load_config_only_default_run_environment(self, tmp_path):
default_env_parameters = tmp_path / _DEFAULT_RUN_ENV / "parameters.yml"
default_env_parameters_config = {"dummy": "default"}

_write_yaml(default_env_parameters, default_env_parameters_config)

conf = OmegaConfigLoader(tmp_path, default_run_env=_DEFAULT_RUN_ENV)
assert conf["parameters"]["dummy"] == "default"

def test_variable_interpolation_in_catalog_with_templates(self, tmp_path):
base_catalog = tmp_path / "catalog.yml"
catalog_config = {
Expand Down