Join the Kedro community

Updated last month

Summary of files and code snippets

Hi everyone,

I have the following files:
settings.py

CONFIG_LOADER_ARGS = {
    "base_env": "base",
    "default_run_env": "local",
    "config_patterns": {
        # Also include models.yml in the catalog
        "catalog": [
            "catalog*",
            "models*",
            "catalog*/**",
            "models*/**",
            "**/catalog*",
            "**/models*",

        ],
    }
}
conftest.py
from kedro.framework.project import settings


@fixture(scope='session')
def config_loader():
    kwargs = settings.CONFIG_LOADER_ARGS
    kwargs.update(env="test", base_env="base", default_run_env="test")

    return OmegaConfigLoader(
        conf_source=str(PROJECT_PATH / settings.CONF_SOURCE), **kwargs,
    )

I expect my settings valued to loaded but this doesnt seem to be the case as I can't get config patters in the dict itself. Any idea why is that?

F
N
3 comments

@fixture(scope='session')
def config_loader():
    bootstrap_project(PROJECT_PATH)

    kwargs = settings.CONFIG_LOADER_ARGS
    kwargs.update(env="test", base_env="base", default_run_env="test")

    return OmegaConfigLoader(
        conf_source=str(PROJECT_PATH / settings.CONF_SOURCE), **kwargs,
    )
adding boostrap_project makes it work, I guess i have to add this

^ I missed this question completely. You either have to bootstrap_project to make sure project settings are read (because you are creating the class directly).

Or you can pass in the kwargs explicitly (i.e. passing env=test if you have a separate test env)

kwargs only doesn't work as you see kwargs includes env but without bootstrap didn't work. That's why i needed to add the bootstrap function

Add a reply
Sign up and join the conversation on Slack