Join the Kedro community

Updated 4 weeks ago

Accessing parameters in the pipeline.py file

Hey Kedro users,
A quick question about how parameters are handled in Kedro.
I know I can use parameters defined in parameters/xxx.yml to then pass those parameters as input of node.
My question is : is there a "Kedro way" to also access those parameters in the pipeline.py file to create the node ? My purpose is to build nodes based on a parameter defined in this yml file

Cheers !

P
L
2 comments

Hi, does this answer your question ?

from kedro.config import OmegaConfigLoader
from kedro.framework.project import settings

conf_path = str(project_path / settings.CONF_SOURCE)
conf_loader = OmegaConfigLoader(conf_source=conf_path)
parameters = conf_loader["parameters"]

Put that in a pipeline.py file, as shown here https://docs.kedro.org/en/stable/configuration/parameters.html

That's exactly what I was looking for thx

Add a reply
Sign up and join the conversation on Slack