Presets¶
A preset is a saved group of parameter values. Instead of overriding multiple values every time you want a particular configuration, give those values a name and apply them all at once with a preset. This is useful for creating defined variations of models such as different sizes and feature sets.
Declaring presets¶
Presets are declared alongside fields using
Preset.
Presets don't need to cover every field. Any field not listed in a preset keeps its default value.
Using presets via the CLI¶
Select a preset with --preset:
python model.py --preset large
Combining presets with overrides¶
Specific field values take precedence over preset values. Use a preset as a baseline and adjust individual fields as needed. For example, in the CLI:
python model.py --preset large --thickness 5.0
Field value precedence, from highest to lowest:
- Field override values
- Preset values
- Field default values
Preset descriptions¶
Presets accept an optional description shown in --help output:
Preset("large", description="Extra large version", width=100.0, thickness=10.0)
Programmatic use¶
Presets can be applied when instantiating a
Model or
Params subclass in code.
- Apply a preset by name:
model = MyBox(preset="large") - Apply a preset and override additional fields:
model = MyBox(preset="large", thickness=5.0) with_presetis equivalent but may more easily pass static type checks:model = MyBox.with_preset("large", thickness=5.0)