Hi all, I ran into an issue similar to <https://g...
# questions
e
Hi all, I ran into an issue similar to https://github.com/kedro-org/kedro/issues/3966, whereby unit tests failed because
OmegaConfigLoader(conf_source=str(Path.cwd()))
doesn’t point to the
conf_source
. Other examples use:
Copy code
from kedro.config import OmegaConfigLoader
from kedro.framework.project import settings
from pathlib import Path

config_loader = OmegaConfigLoader(
        conf_source=str(Path.cwd() / settings.CONF_SOURCE)
    )
But there is another issue, which I’m not sure is a bug, or just an incorrect docstring. The argument description of
OmegaConfigLoader
is:
Copy code
"""Instantiates a ``OmegaConfigLoader``.

        Args:
            conf_source: Path to use as root directory for loading configuration.
            env: Environment that will take precedence over base.
            runtime_params: Extra parameters passed to a Kedro run.
            config_patterns: Regex patterns that specify the naming convention for configuration
                files so they can be loaded. Can be customised by supplying config_patterns as
                in `CONFIG_LOADER_ARGS` in `settings.py`.
            base_env: Name of the base environment. Defaults to `"base"`.
                This is used in the `conf_paths` property method to construct
                the configuration paths.
            default_run_env: Name of the default run environment. Defaults to `"local"`.
                Can be overridden by supplying the `env` argument.
            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>
            merge_strategy: A dictionary that specifies the merging strategy for each configuration type.
             The accepted merging strategies are `soft` and `destructive`. Defaults to `destructive`.
        """
The issue is that
base_env
and
default_run_env
don’t default to
"base"
and
"local"
, they both default to
""
:
Copy code
self.base_env = base_env or ""
        self.default_run_env = default_run_env or ""
and the whole
conf
source will get scanned for
base_config
. This caused duplicate key errors, since I worked with
base
and
test
environments. So the question is, is
"base"
and
"local"
supposed to default to
""
and the argument docstring is wrong, or are they supposed to default to
"base"
and
"local"
and it’s a bug? Manually setting
base_config="base"
resolves all issues, so it’s not a major issue:
Copy code
from kedro.config import OmegaConfigLoader
from kedro.framework.project import settings
from pathlib import Path

config_loader = OmegaConfigLoader(
        conf_source=str(Path.cwd() / settings.CONF_SOURCE), base_config="base"
    )
PS. Happy to file an issue, just thought it worth checking if it should go under bugs or documentation.
m
Hi @Elias WILLEMSE, this is indeed an outdated docstring. It's documented correctly in our documentation: https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#advanced-configuration-without-a-full-kedro-project Thanks for flagging! I will update this 🙂
e
Ah yes, I see it now:
However, when you use the
OmegaConfigLoader
directly, it assumes no environment.
Like they say, through 3h of debugging you can save up to 10 minutes of reading through documentation!
m
Sorry about that! The docstring should definitely have been updated as well when we made the change.
e
No need to apologise, it’s a super well-maintained and active open-source project. Finding these discrepancies is community service. And I now understand OmegaConfigLoader a lot better. So wins all around.
💛 1