sleap.nn.config.utils#
Utilities for config building and validation.
- sleap.nn.config.utils.oneof(attrs_cls, must_be_set: bool = False)[source]#
Ensure that the decorated attrs class only has a single attribute set.
This decorator is inspired by the
oneof
protobuffer field behavior.- Parameters:
attrs_cls – An attrs decorated class.
must_be_set – If True, raise an error if none of the attributes are set. If not, error will only be raised if more than one attribute is set.
- Returns:
The
attrs_cls
with an__init__
method that checks for the number of attributes that are set.