designspace.destructure#

designspace.destructure(config: dict[str, Any], param_path: str) tuple[str, dict[str, Any] | None]#

Both the variant name and its payload, in one call.

Equivalent to ds.variant() and ds.payload() together, and the natural way to unpack a choice.

Parameters:
  • config (dict[str, Any]) – A configuration, in nested form.

  • param_path (str) – Path of the choice parameter.

Returns:

The variant name and its payload, the latter None when the variant carries no parameters.

Return type:

tuple[str, dict[str, Any] | None]

Examples

>>> name, params = ds.destructure({"opt": {"sgd": {"momentum": 0.5}}}, "opt")
>>> name, params
('sgd', {'momentum': 0.5})
>>> ds.destructure({"opt": "adagrad"}, "opt")
('adagrad', None)