is it possible to override globals in omegaconfig ...
# questions
e
is it possible to override globals in omegaconfig loader with extra params? [Im testing kedro 0.18.13]
👀 1
m
This was recently merged https://github.com/kedro-org/kedro/pull/2921 so yes
[EDITED: I haven’t noticed the “extra params”] Globals in OmegaConfigLoader are available from 0.18.13, but I’m not sure whether they play along the extra params https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-use-global-variables-with-the-omegaconfigloader
j
the good thing of living in the bleeding edge 😄
🤠 2
m
What is your use case @Erwin?
e
Hi! I have in
conf/base/parameters/balls.yml
Copy code
ball_level:
  start_date: ${globals:start_date} #kedro 0.18.13
  #start_date: ${start_date} #kedro 0.18.12
and in
conf/base/globals.yml
[
conf/base/parameters_globals.yml
in 0.18.12]
Copy code
start_date: 202307
So I was trying to override this using:
Copy code
from kedro.framework.session import KedroSession
from kedro.framework.startup import bootstrap_project
from kedro.runner import ThreadRunner

bootstrap_project(project_root)


params = {"start_date": previous_month}

with KedroSession.create(
    project_path=project_root,
    env=env,
    extra_params=params,
) as session:
    session.run(pipeline_name=pipeline, runner=ThreadRunner())
Which worked in previous kedro 0.18.12, not anymore in 0.18.13 Am I doing something wrong?
m
Please show
settings.py
e
Copy code
from kedro.config import OmegaConfigLoader  # noqa

CONFIG_LOADER_CLASS = OmegaConfigLoader
# Keyword arguments to pass to the `CONFIG_LOADER_CLASS` constructor.
CONFIG_LOADER_ARGS = {
    "config_patterns": {
        "spark": ["spark*/"],
        "parameters": ["parameters*", "parameters*/**", "**/parameters*"],
    }
}
m
So in 0.18.12 it was not using globals, it was actually a side-effect of variable interpolation. Maybe @Ankita Katiyar can chip in here 🤔
a
Yep, you can override
parameters
with extra params but not
globals
which are in
globals.yml
m
But do the
extra_params
work in OmegaConfig’s variable interpolation? 🤔
a
Yeah, they should work for regular variable interpolation. Only for parameters though I think
m
I guess that should answer the question @Erwin
a
What Erwin was doing previously would still work with
0.18.13
just not for “globals” that are supposed to be used with the globals resolver and read from
globals.yml
☝️ 2
e
I see so, this works:
Copy code
params = {"ball_level.start_date": previous_month}
To clarify, it won’t be possible to override a global variable, correct?
a
Yeah, correct.