Hey team,
Is it possible (or is there any workaround) to use a parameter in the catalog.yml using OmegaConfigLoader
? My use case is that i want to select a parameter in Databricks Workflows and have it override a kedro param at runtime. I was trying to use a global (in globals.yml), as those can be used in the catalog.yml, but unfortunately they can not be overriden at runtime, according to the docs
wdym? to use a parameter in the catalog.yml? oc.env reads from environment variables
Do you want to override a Kedro parameter or read a parameter defines in catalog.yml?
How did you select a parameter in workflow?
i want to:
mytable: catalog: mycatalog write_mode: overwrite database: gold_dm_${params:run_folder} table: mytable
You're likely looking for the runtime_params
resolver, identical to globals
but specifically for overriding params at runtime
In your above code snippet, just replace params
with runtime_params
:
mytable:
catalog: mycatalog
write_mode: overwrite
database: gold_dm_${runtime_params:run_folder}
table: mytableace
Ah nice, I didn't know about runtime_params
. Very useful, especially for changing output folder. But does it also try to find it in globals, or do we have to provide it everytime we run?
Although I am using a custom loader based on TemplatedConfigLoader
in 1 project.
Another simple solution could be the following:
In your main entrypoint script, dump the global parameters needed to be overriden in conf/local/globals.yml
main.py
import os import yaml os.makedirs("conf/local", exist_ok=True) with open("conf/local/globals.yml", "w") as f: yaml.dump(global_params_to_override) # Now run your kedro pipeline (assure that local env is default else specify it)
Ah this is great, didn't know about runtime_params
either. That solves for my use case entirely! Thank you!
well, to be fair, the section on runtime_params
was right above the one i've linked to in my question, even though I could swear I had read the entire parametrization docs 😅 so i was helpless, the docs are great!
well maybe the configuration docs could be organized by use cases / usage patterns - or at least provided a summary of use cases and solutions at the end, something like:
catalog.yml
-> regular parameters.yml
and globals.yml
with no custom resolverscatalog.yml
but will not override them at runtime -> use globals
and resolve them in catalog.yml
(and parameters.yml
, if needed)catalog.yml
AND will override them at runtime -> use runtime_params
and resolve them in catalog.yml
(and parameters.yml
, if needed)