Join the Kedro community

Updated 3 days ago

Loading Parameters with the Kedro DataCatalog

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"])

so that I can do catalog.load("params:model_size")?

1
J
A
E
11 comments

Hall's AI suggests this:

# Load parameters and add them to catalog
parameters = conf_loader["parameters"]
catalog.add_feed_dict({"parameters": parameters})

but that didn't work 🤔

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

But if you use catalog as a library you need to construct params_dict by yourself.

oh nice. I ended up doing this:

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)

this feels like something that should be nicer

Maybe context can expose static methods for that

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.

Add a reply
Sign up and join the conversation on Slack