In certain scenarios, you may have parameters that multiple nodes within the pipeline share. Instead of manually updating each node individually when parameter values change, you can define pipeline parameters.
These parameters supersede the default values specified in valohai.yaml
, even when the default value is left empty.
This approach streamlines parameter management and updates across multiple nodes.
Define pipeline parameters in valohai.yaml
Similarly to step parameters, pipeline parameters are added in the valohai.yaml
file. You will need to specify the targets for them, i.e. the step parameters that they will override.
Example valohai.yaml
- The syntax for defining pipeline parameter targets is
<node-name>.parameters.<step-parameter-name>
. - The pipeline parameter id gets two targets:
preprocess.parameters.exec_id
andtrain.parameters.exec_id
. This means that the pipeline parameter value overrides theexec_id
value in both preprocess and train nodes. - The
exec_id
for the train_in_task node is not affected by the pipeline parameter id but gets the default value from the step definition.
Keep in mind that you can’t directly access the pipeline parameter’s value; you’ll need to read it from the execution, like reading any other parameter, parsing the command-line argument or using valohai-utils valohai.parameters("exec_id").value
.
- pipeline:
name: Example for Pipeline Parameters
parameters:
- name: id
targets:
- preprocess.parameters.exec_id
- train.parameters.exec_id
- name: training_parameter
targets:
- train.parameters.train_param
default: 3
- name: task_parameter
target: train_in_task.parameters.train_param
default: 123
nodes:
- name: preprocess
step: pre_step
type: execution
- name: train
step: train_step
type: execution
- name: train_in_task
step: train_step
type: task
edges:
- [preprocess.output.preprocessed_mnist.npz, train.input.dataset]
- [preprocess.output.preprocessed_mnist.npz, train_in_task.input.dataset]
In the web app
In the image below, you can find the node parameters and the pipeline parameters.
- Under the Shared Parameters section in the user interface, you’ll find pipeline parameters and which node parameters they’ll replace. You can also find the
- In the example below the parameter
exec_id
will be overwritten by the pipeline parameterid
, and its value cannot be modified in the node’s parameter section. - In the image, the pipeline parameter
id
is empty because there was no default value for it invalohai.yaml
. - The parameter
pre_param
hasn’t been designated as a target for any pipeline parameter, so you can edit its value under the node parameters.
You’ll also notice that train_in_task node
has been set as a Task node, allowing you to specify multiple values for the pipeline parameter. If you define 10 parameter values, you’ll end up with 10 executions in this node, each having its unique parameter value.