Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Parameters

Parameters are read-only configuration values that feed into pipeline nodes. They are defined using Param<T>, a thin wrapper that implements the Dataset trait. For more on Param, nested parameters, and struct parameters, see the Params & Catalog chapter.

In the minimal example

The Params struct holds a single threshold value:

#[derive(Serialize, Deserialize)]
struct Params {
    threshold: Param<f64>,
}

Configured via YAML:

# params.yml
threshold: 0.5

The “report” node reads the threshold as one of its inputs. When Param appears in a node’s input tuple, .load() clones the inner value. Because Param::Error is Infallible, this can never fail.

        Node {
            name: "report",
            func: |mean: f64, threshold: f64| {
                (json!({ "mean": mean, "passed": mean >= threshold }),)
            },
            input: (&cat.summary, &params.threshold),
            output: (&cat.report,),
        },

Overriding from the CLI

When using the App framework, parameters can be overridden at runtime without editing YAML files:

$ my_app run --params threshold=0.8

Dot notation works for nested parameter structs:

$ my_app run --params model.learning_rate=0.01

See the YAML Configuration chapter for details.