Hi all, Quick question: I have a run env, here bef...
# questions
s
Hi all, Quick question: I have a run env, here before I run a pipeline I need query some endpoint that returns a parameter dict. Like:
Copy code
extra_args: dict = client.get_params(run_desc)
Then I would do something like:
Copy code
actual_params = OmegaConf.merge(catalog.load("parameters"), extra_args)
Where can I best do this? I noticed for example that if I try to modify parameters in a
before_pipeline_run
hook, the catalog params has already been split out as
parameters
,
params:sec1
etc, and if this
extra_args
changes parameters broadly then it's not trivial walk through all and manipulate via the catalog. What's the best way to do this?
🥳 1
One option I came to: use a
after_context_created
and add these params as
context._runtime_params
. Doesn't seem ideal using the
_
method but seems to what I want for now. Happy to hear better suggestions
r
after_context_created
is the right hook to use. There are two approaches depending on your use case: If
extra_args
only overrides keys already defined in
parameters.yml
, you can use the
runtime_params
resolver [link] If
extra_args
adds new keys not already in
parameters.yml
, you can bypass the config loader directly. See the docs on bypassing configuration loading rules [link].
s
Thanks @Rashida Kanchwala Here, I want to both override and add new, so per my understanding,
runtime_params
is the right approach. However, one small question: in
after_context_created
, the
context
has already been instantiated.
runtime_params
is an init arg for
KedroContext
but actually stored as a
_runtime_params
, i.e. implied to be "private". -> Is there any risk or downside to modifying the
_runtime_params
after instantiation?
r
You can access runtime_params this way instead
context.config_loader.runtime_params
s
👍