when using the `[Kedro]DataCatalog` as a library, ...
# questions
j
when using the
[Kedro]DataCatalog
as a library, what's the best way of loading the parameters too? in other words, what should I add to
Copy code
catalog = DataCatalog.from_config(conf_loader["catalog"])
so that I can do
catalog.load("params:model_size")
?
👀 1
h
Someone will reply to you shortly. In the meantime, this might help:
j
Hall's AI suggests this:
Copy code
# Load parameters and add them to catalog
parameters = conf_loader["parameters"]
catalog.add_feed_dict({"parameters": parameters})
but that didn't work 🤔
e
Both new and old catalogs doesn’t differ parameters from other datasets. So you add them as usual datasets. With the new catalog you can use
__setitem__
.
Copy code
for param_name, param in params_dict.items():
    catalog[param_name] = param
But if you use catalog as a library you need to construct
params_dict
by yourself.
j
oh nice. I ended up doing this:
Copy code
for param_name, param_value in parameters.items():
    catalog[f"params:{param_name}"] = param_value
thanks!
(this assumes that my params dict is flat etc etc)
👍 1
d
this feels like something that should be nicer
e
Maybe context can expose static methods for that
d
I'm sort of the view that if the user ever has to touch the context they've gone too far, do you not?
this 2
e
Hmm, but having nested parameters is not a requirement. So technically, one can use any name, the same as for datasets. But if someone wants to follow the format we use during the session, the method might be accessed through related components.