HOW-TO

Override Configs

Override Configs

See also: API: laco.load, Concepts: Interpolation

URL Query Syntax

Append ?key=value pairs to the path when calling laco.load:

cfg = laco.load("configs/train.py?lr=5e-4&model.out_features=512")

Multiple keys are separated by &. Values are coerced to the field's declared type when the field is part of a @L.config schema.

Positional Overrides

Pass override strings as positional arguments:

cfg = laco.load("configs/train.py", "lr=5e-4", "model.out_features=512")

Equivalent to the URL form; useful when constructing overrides programmatically.

Fragment Selector

Select a sub-tree of the config with #key.nested:

model_cfg = laco.load("configs/train.py#model")
# model_cfg is the DictConfig subtree at cfg.model

Override Grammar

SyntaxEffect
key=valueSet key to value
+key=valueAppend value to list at key
~keyDelete key from the config
key=nullSet key to None

Type Coercion

Values are parsed as:

  • true / falsebool
  • Integer strings → int
  • Float strings → float
  • [a,b,c] → list
  • Everything else → str

When the target field is typed (@L.config), the coerced value is validated against the declared type. A mismatch raises ValidationError.

CLI Overrides

laco compose configs/train.py lr=5e-4 model.out_features=512
laco run     configs/train.py optimizer=adam

The CLI passes override strings directly to apply_overrides.