designspace.variant#

designspace.variant(config: dict[str, Any], param_path: str) str#

Which variant a choice parameter selected.

A choice value is either a bare name, when the variant has no parameters of its own, or a single-key dict when it does. This reads the name either way, so callers need not branch on the shape.

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

  • param_path (str) – Path of the choice parameter. Use an instance path such as “pipeline[0]” to address one element of a lifted choice.

Returns:

The selected variant’s name.

Return type:

str

Examples

>>> config = {"opt": {"sgd": {"momentum": 0.5}}}
>>> ds.variant(config, "opt")
'sgd'
>>> ds.variant({"opt": "adagrad"}, "opt")
'adagrad'