simplebench.reporters.choices package🔗
simplebench.reporters.choices package.
- class simplebench.reporters.choices.Choices( )[source]🔗
Bases:
_BaseChoices[Choice,_ChoicesErrorTag]A dictionary-like container for
Choiceinstances.This class enforces that only
Choiceinstances 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
Choiceinstances.Construct a
Choicescontainer.- Parameters:
choices (Iterable[
Choice] |Choices| None) – AnIterableofChoiceinstances or anotherChoicesinstance to initialize the container with. IfNone, an empty container is created.
- add(choice: Choice) None[source]🔗
Add a
Choiceinstance to the container.The
choice.nameattribute is used as the key in the container and is required to be unique withing the container.- Parameters:
- Raises:
SimpleBenchTypeError – If the argument is not a
Choiceinstance.SimpleBenchValueError – If a
Choicewith the same name already exists in the container.
- all_choice_args() set[str][source]🔗
Return a set of all
Namespacearg names from allChoiceinstances in the container.
- all_choice_flags() set[str][source]🔗
Return a set of all CLI flags from all
Choiceinstances in the container.
- extend( ) None[source]🔗
Add
Choiceinstances to the container. It does so by adding eachChoicein the providedIterableofChoiceor by adding theChoiceinstances from the providedChoicesinstance.- Parameters:
choices (Iterable[
Choice] |Choices) – AnIterableofChoiceinstances or an instance ofChoices.- Raises:
SimpleBenchTypeError – If the
choicesargument is not anIterableofChoiceinstances or aChoicesinstance.SimpleBenchValueError – If any
Choicein theIterablehas a duplicate name that already exists in the container.
- get_choice_for_arg(
- arg: str,
Return the
Choiceinstance associated with the givenNamespacearg name.- Parameters:
arg (str) – The
Namespacearg name to look up.- Returns:
The
Choiceinstance associated with the arg, orNoneif no suchChoiceexists.- Return type:
Choice| None- Raises:
SimpleBenchTypeError – If the arg is not a string.
- class simplebench.reporters.choices.ChoicesConf(
- choices: Iterable[ChoiceConf] | ChoicesConf | None = None,
Bases:
_BaseChoices[ChoiceConf,_ChoicesErrorTag]A dictionary-like container for
ChoiceConfinstances.This class enforces that only
ChoiceConfinstances 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
ChoiceConfinstances.Construct a
Choicescontainer.- Parameters:
choices (Iterable[
ChoiceConf] |ChoicesConf| None) – AnIterableofChoiceConfinstances or anotherChoicesConfinstance to initialize the container with. IfNone, an empty container is created.
- add(
- choice: ChoiceConf,
Add a
ChoiceConfinstance to the container.The
choice.nameattribute is used as the key in the container and is required to be unique withing the container.- Parameters:
choice (
ChoiceConf) – TheChoiceConfinstance to add.- Raises:
SimpleBenchTypeError – If the argument is not a
ChoiceConfinstance.SimpleBenchValueError – If a
ChoiceConfwith the same name already exists in the container.
- extend(
- choices: Iterable[ChoiceConf] | ChoicesConf,
Add
ChoiceConfinstances to the container.It does so by adding each
ChoiceConfin the providedIterableofChoiceConfor by adding theChoiceConfinstances from the providedChoicesConfinstance.- Parameters:
choices (Iterable[
ChoiceConf] |ChoicesConf) – AnIterableofChoiceConfinstances or an instance ofChoicesConf.- Raises:
SimpleBenchTypeError – If the
choicesargument is not anIterableofChoiceConfinstances or aChoicesConfinstance.SimpleBenchValueError – If any
ChoiceConfin theIterablehas a duplicate name that already exists in the container.
- remove(name: str) None[source]🔗
Remove a
ChoiceConfinstance from the container by its name.- Parameters:
name (str) – The name of the
ChoiceConfinstance to remove.- Raises:
SimpleBenchKeyError – If no
ChoiceConfunder the given name exists in the container.