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
catalog = DataCatalog.from_config(conf_loader["catalog"])
catalog.load("params:model_size")
?Hall's AI suggests this:
# Load parameters and add them to catalog parameters = conf_loader["parameters"] catalog.add_feed_dict({"parameters": parameters})
this section of the docs isn't very helpful https://docs.kedro.org/en/stable/configuration/parameters.html#how-to-load-parameters-in-code
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__
.
for param_name, param in params_dict.items(): catalog[param_name] = param
params_dict
by yourself.That’s how we do it in the session: https://github.com/kedro-org/kedro/blob/74c640a1bbafc3cd01a16c8923aa1a53a4e8106b/kedro/framework/context/context.py#L254
oh nice. I ended up doing this:
for param_name, param_value in parameters.items(): catalog[f"params:{param_name}"] = param_value
I'm sort of the view that if the user ever has to touch the context they've gone too far, do you not?
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.