Hi, I'm using Kedro 0.18.14 with OmegaConfigLoader...
# questions
j
Hi, I'm using Kedro 0.18.14 with OmegaConfigLoader to parse run-time parameters. Can I print or save all (run-time) parameters to see if values are correctly passed after I do
kedro run --params=.....
?
a
sure, some hooks have
runtime_params
argument like
before_pipeline_run
- you can catch them and print them there
👍 1
I'm think there's another solution to do it with omegaconfigloader custom functions, I don't remember the details now though
👍 1
j
I am not sure how to do any of approaches. I printed out config using the below, but it print out defaults not what I passed to kedro. Could you give an example for either of approaches you think it works?
Copy code
from kedro.config import OmegaConfigLoader   
import yaml
CONF_SOURCE = "conf"
conf_loader = OmegaConfigLoader(conf_source=CONF_SOURCE, env="local")
conf_params = conf_loader["parameters"]
print(yaml.dump(conf_params))
m
Hi @Jonghyun Yun, the above snippet you sent will indeed only show the parameters defined in your config and not anything you pass at runtime. You'd have to use hooks like @Artur Dobrogowski suggests. The docs give more of an explanation on how to use them: https://docs.kedro.org/en/stable/hooks/introduction.html but roughly it would be something like:
Copy code
@hook_impl
    def before_pipeline_run(
        self, run_params: dict[str, Any], pipeline: Pipeline, catalog: DataCatalog
    ) -> None:
        print(run_params)
j
Hi @Merel, thanks for sharing this. I can see this print out extra_params! It’s great to learn the hook works too.
a
Yeah and hook is probably the best approach here
Just as a side note, the other solution I was thinking of is not practical in standard kedro;
OmegaConfigLoader
class gets
runtime_params
filled and stores them, so you can access it when you get access to
KedroContext
, as it refers to
config_loader
instance. You can use that in unit tests/jupyter notebooks/kedro plugins where you have kedro context access.
j
Understood. Thanks @Artur Dobrogowski.