4

Is it possible to overwrite properties taken from the parameters.yaml file within a Kedro notebook?

I am trying to dynamically change parameter values within a notebook. I would like to be able to give users the ability to run a standard pipeline but with customizable parameters. I don't want to change the YAML file, I just want to change the parameter for the life of the notebook.

I have tried editing the params within the context but this has no affect.

context.params.update({"test_param": 2})

Am I missing something or is this not an intended use case?

Rahul Kumar
  • 2,184
  • 3
  • 24
  • 46
DHollett
  • 43
  • 2
  • Concrete use case: I create a pipeline that calculates mean and std of some metric over last 90 days. I would like to have this in production but allow users to run the same pipeline but for any number of days they want. – DHollett Feb 19 '20 at 11:43

1 Answers1

2

Kedro supports specifying extra parameters from the command line by running

kedro run --params "key1:value1,key2:value2"

which solves your second use case.

As for the notebook use case, updating context.params does not have any effect since the context does not store the parameters on self but rather pulls them from the config every time the property is being called.

However you can still add extra parameters to the context object after it being instantiated:

extra_params = context._extra_params or {}
extra_params.update({"test_param": 2})
context._extra_params = extra_params

This will update extra parameters that are applied on top of regular parameters coming from the config.

Dmitry Deryabin
  • 1,518
  • 2
  • 14
  • 27