⚑Instantiating a Config Function

Use instantiate(func, values=...) to execute your configuration function with optional overrides.

from hypster import instantiate

result = instantiate(model_cfg, values={
    "kind": "rf",
    "n_estimators": 200,
    "max_depth": 12.5,
})
# => {"model": ("rf", 200, 12.5)}

Unknown parameters

Control how unknown or conditionally unreachable values are handled via on_unknown:

  • on_unknown="warn" (default): issue a warning and continue

  • on_unknown="raise": raise a ValueError

  • on_unknown="ignore": silently ignore

instantiate(model_cfg, values={"n_trees": 200}, on_unknown="warn")

Dotted keys vs nested dicts

See In Depth β†’ Values & Overrides for how to pass nested overrides and precedence.

Passing args/kwargs to nested configs

When using hp.nest, you can pass args=/kwargs= to the child function; these are forwarded at call time.

Last updated

Was this helpful?