https://kedro.org/ logo
#questions
Title
# questions
t

Tom Chau

12/21/2023, 3:37 AM
Hi team, a question when using Kedro params at runtime: Right now i have a project with the following parameters.yml (example):
Copy code
aaa:
  bbb:
    aba: "2023-11-01"
    abb: "2023-11-01"
    abc: 14
I was using Kedro 0.18.2, and running kedro command with the following works fine:
Copy code
kedro run --pipeline deploy --params="aaa.bbb.aba=2023-12-01, aaa.bbb.abb=2023-12-01"
Recently we are deploying a new image which got the version bumped to 0.18.14, and now the pipelines throws the following error:
Copy code
KeyError: 'abc'
which implies aaa.bbb.abc in this nested parameter is not presented anymore. May I know is it an expected change? We read the docs but it does not specify nested parameter overwriting rules at runtime (https://docs.kedro.org/en/latest/configuration/parameters.html#how-to-specify-parameters-at-runtime) and what would the suggested solution for such case? Thanks in advance πŸ™
Right now it is solved with OmegaConfigLoader with runtime_params. Still I would like to know what the expected behaviour should be πŸ™
n

Nok Lam Chan

12/21/2023, 12:48 PM
Which config loader are you using?
For the record, the
.
syntax isn't available in 0.18.2, it is still using the older
:
syntax.
Copy code
kedro run --params="aaa.bbb.aba:2023-12-01, aaa.bbb.abb:2023-12-01"
I get this result in 0.18.2
Copy code
{'aaa': {'bbb': {'aba': '2023-12-01', 'abb': '2023-12-01', 'abc': 14}}}
and identical result in 0.18.14
Copy code
{'aaa': {'bbb': {'aba': '2023-12-01', 'abb': '2023-12-01', 'abc': 14}}}
Can you try to work on it in a minimal example?
I have my testing project here: https://github.com/noklam/debug_kedro_0182
t

Tom Chau

12/21/2023, 4:35 PM
Hi Nok, thanks for the heads-up. Upon further checking, seems we reproduce by this setting, under 0.18.14 (and it is not related to 0.18.2), by: β€’ Switching to OmegaConfigLoader in settings.py β€’ Having a separate env conf (e.g. conf/add/parameters.yml) β€’ Invoke kedro run per:
Copy code
kedro run --env=add --params="aaa.bbb.abb=2023-11-11"
From the two images, you can see that only top-level key aaa (which we overwrite at runtime) is affected, other top-level keys (def, xyz) are not.
n

Nok Lam Chan

12/21/2023, 4:40 PM
Would you be able to push this fork somewhere I can reproduce?
β€’ Having a separate env conf (e.g. conf/add/parameters.yml)
Is this related? if you remove the extra parameters does the override key get recovered?
t

Tom Chau

12/22/2023, 1:43 AM
I forked the project and uploaded the files to reproduce the result, please see if you can access it via here: https://github.com/chy111126/debug_kedro_0182 The README contains results from different combinations of flags for your reference.
n

Nok Lam Chan

12/22/2023, 12:24 PM
Right now it is solved with OmegaConfigLoader with runtime_params. Still I would like to know what the expected behaviour should be πŸ™
Did you still manage to use runtime_params to solve this issue with env? It's not immediately obvious to me is there a workaround yet.
I keep my update in the Github issues here: https://github.com/kedro-org/kedro/issues/3456 It seems that the issue is with the OmegaConfigLoader, on 0.18.x if I switch back to ConfigLoader I don't see this merging behavior. I don't think this is expected.
Can you try adding this in
settings.py
Copy code
CONFIG_LOADER_ARGS = {
    "merge_strategy": {"parameters": "destructive"},
}
I can confirm this is a bug now, the
merge_strategy
workaround should work. For the details, it appears that the parameters that get passed via CLI is set as a parameters in both environments, thus the destructive merging behavior.
kedro run  --params="aaa.bbb.abb=2023-11-1199999" --env add
Copy code
config={'aaa': {'bbb': {'aba': '2023-11-01', 'abb': '2023-11-1199999', 'abc': 14}}, 'xyz': {'asdf': 123123}}

env_config={'def': {'gg': 123}, 'aaa': {'bbb': {'abb': '2023-11-1199999'}}}

resulting_config={'aaa': {'bbb': {'abb': '2023-11-1199999'}}, 'xyz': {'asdf': 123123}, 'def': {'gg': 123}}
πŸ™ 1
πŸ‘€ 1
t

Tom Chau

12/22/2023, 1:52 PM
i got this error after adding CONFIG_LOADER_ARGS in settings.py, as image shown
Did you still manage to use runtime_params to solve this issue with env? It’s not immediately obvious to me is there a workaround yet. -> yes, we do workaround by defining another set of runtime params and overwriting those at runtime instead
n

Nok Lam Chan

12/25/2023, 12:22 AM
I just checked again the changes was committed at 2023 Nov, so unfortunately it's not in 0.18.14, the first available version is 0.19
t

Tom Chau

12/27/2023, 1:59 AM
got it, does this behaviour persist on 0.19 or only works on >=0.18.14 + OmegaConfigLoader? i might consider upgrading if this bug is fixed by latest version
n

Nok Lam Chan

01/02/2024, 12:24 PM
It still exist in the latest version,
merge_strategy
workaround is only available in 0.19. I don't have a timeline of when this will be fixed yet, since I just wrote the ticket before the holiday and it hasn't been discussed by the team. PRs are welcomed if you are interested.
t

Tom Chau

01/03/2024, 3:00 AM
Thanks for the heads-up! Will wait for the ticket since our side is not too familiar with how Kedro works internally. Again, much appreciated for the troubleshooting πŸ‘
K 1
πŸ™πŸΌ 1
s

Sam Yuen

03/04/2024, 1:09 PM
Hi team, I have encountered the same issue in the 0.19.3 release. In config\omegaconf_config.py, the env_config calls the load_and_merge_dir_config function and merged with the input parameters. I propose a fix that adds a Boolean flag for the function, such that the parameters will not be merged with env_config Cheers!
Sorry for missing the attachment:
n

Nok Lam Chan

03/04/2024, 1:17 PM
Did the solution works for you?
@Ankita Katiyar
πŸ‘€ 1
There is a ticket created for this but we haven’t implemented a fix, the solution in this thread is a workaround
@Sam Yuen Can you explains a little bit more, why would runtime params only merge with base env but not the runtime_env? It would be great if you can leave comments on https://github.com/kedro-org/kedro/issues/3456, PRs are very welcome too but I suggest to have some discussion first.
s

Sam Yuen

03/04/2024, 2:17 PM
@Nok Lam Chan Sure! I think we may add one more check condition for merging action as illustrated
πŸ‘πŸΌ 1
10 Views