Skip to content

Commit

Permalink
Revert special logic handling DictConfig (#2582)
Browse files Browse the repository at this point in the history
* Partially revert #2378 as OCL no longer returning DictConfig

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

* Revert #2176 with special logging handling

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

* remove unused import

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

---------

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam authored May 16, 2023
1 parent 0b5fc97 commit 6df4d40
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
8 changes: 2 additions & 6 deletions kedro/framework/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from urllib.parse import urlparse
from warnings import warn

from omegaconf import DictConfig
from pluggy import PluginManager

from kedro.config import ConfigLoader, MissingConfigException
Expand Down Expand Up @@ -93,7 +92,6 @@ def _convert_paths_to_absolute_posix(
conf_keys_with_filepath = ("filename", "filepath", "path")

for conf_key, conf_value in conf_dictionary.items():

# if the conf_value is another dictionary, absolutify its paths first.
if isinstance(conf_value, dict):
conf_dictionary[conf_key] = _convert_paths_to_absolute_posix(
Expand Down Expand Up @@ -156,9 +154,7 @@ def _update_nested_dict(old_dict: dict[Any, Any], new_dict: dict[Any, Any]) -> N
if key not in old_dict:
old_dict[key] = value
else:
if isinstance(old_dict[key], (dict, DictConfig)) and isinstance(
value, (dict, DictConfig)
):
if isinstance(old_dict[key], dict) and isinstance(value, dict):
_update_nested_dict(old_dict[key], value)
else:
old_dict[key] = value
Expand Down Expand Up @@ -326,7 +322,7 @@ def _add_param_to_feed_dict(param_name, param_value):
"""
key = f"params:{param_name}"
feed_dict[key] = param_value
if isinstance(param_value, (dict, DictConfig)):
if isinstance(param_value, dict):
for key, val in param_value.items():
_add_param_to_feed_dict(f"{param_name}.{key}", val)

Expand Down
3 changes: 0 additions & 3 deletions kedro/framework/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import Any, Iterable

import click
from omegaconf import OmegaConf, omegaconf

from kedro import __version__ as kedro_version
from kedro.config import ConfigLoader, MissingConfigException
Expand Down Expand Up @@ -200,8 +199,6 @@ def create( # pylint: disable=too-many-arguments

def _get_logging_config(self) -> dict[str, Any]:
logging_config = self._get_config_loader()["logging"]
if isinstance(logging_config, omegaconf.DictConfig):
logging_config = OmegaConf.to_container(logging_config) # pragma: no cover
# turn relative paths in logging config into absolute path
# before initialising loggers
logging_config = _convert_paths_to_absolute_posix(
Expand Down
6 changes: 0 additions & 6 deletions tests/framework/context/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pytest
import toml
import yaml
from omegaconf import OmegaConf
from pandas.util.testing import assert_frame_equal

from kedro import __version__ as kedro_version
Expand Down Expand Up @@ -486,11 +485,6 @@ def test_validate_layers_error(layers, conflicting_datasets, mocker):
{"a": {"a.c": {"a.c.b": 4}}},
{"a": {"a.a": 1, "a.b": 2, "a.c": {"a.c.a": 3, "a.c.b": 4}}},
),
(
{"a": OmegaConf.create({"b": 1}), "x": 3},
{"a": {"c": 2}},
{"a": {"b": 1, "c": 2}, "x": 3},
),
],
)
def test_update_nested_dict(old_dict: dict, new_dict: dict, expected: dict):
Expand Down

0 comments on commit 6df4d40

Please sign in to comment.