simplebench.reporters.choices.choices module🔗

Choices for reporters.

class simplebench.reporters.choices.choices.Choices(
choices: Iterable[Choice] | Choices | None = None,
)[source]🔗

Bases: _BaseChoices[Choice, _ChoicesErrorTag]

A dictionary-like container for Choice instances.

This class enforces that only Choice instances can be added to it, and provides methods to manage and retrieve those instances.

It is designed to be used in the context of reporters that require a collection of Choice instances.

Construct a Choices container.

Parameters:

choices (Iterable[Choice] | Choices | None) – An Iterable of Choice instances or another Choices instance to initialize the container with. If None, an empty container is created.

add(choice: Choice) None[source]🔗

Add a Choice instance to the container.

The choice.name attribute is used as the key in the container and is required to be unique withing the container.

Parameters:

choice (Choice) – The Choice instance to add.

Raises:
all_choice_args() set[str][source]🔗

Return a set of all Namespace arg names from all Choice instances in the container.

Returns:

A set of all Namespace arg names from all Choice instances.

Return type:

set[str]

all_choice_flags() set[str][source]🔗

Return a set of all CLI flags from all Choice instances in the container.

Returns:

A set of all CLI flags from all Choice instances.

Return type:

set[str]

extend(
choices: Iterable[Choice] | Choices,
) None[source]🔗

Add Choice instances to the container. It does so by adding each Choice in the provided Iterable of Choice or by adding the Choice instances from the provided Choices instance.

Parameters:

choices (Iterable[Choice] | Choices) – An Iterable of Choice instances or an instance of Choices.

Raises:
get_choice_for_arg(
arg: str,
) Choice | None[source]🔗

Return the Choice instance associated with the given Namespace arg name.

Parameters:

arg (str) – The Namespace arg name to look up.

Returns:

The Choice instance associated with the arg, or None if no such Choice exists.

Return type:

Choice | None

Raises:

SimpleBenchTypeError – If the arg is not a string.

remove(name: str) None[source]🔗

Remove a Choice instance from the container by its name.

Parameters:

name (str) – The name of the Choice instance to remove.

Raises:

SimpleBenchKeyError – If no Choice under the given name exists in the container.

simplebench.reporters.choices.choices.deferred_choice_import() None[source]🔗

Deferred import of Choice to avoid circular imports during initialization.