simplebench.reporters.reporter_manager package🔗
Reporter manager for benchmark results.
- class simplebench.reporters.reporter_manager.ReporterManager(load_defaults: bool = True)[source]🔗
Bases:
objectManager for all available
Reporterclasses.This class maintains a registry of
Reporterinstances and their associated CLI arguments. It allows for the registration, retrieval, and unregistration ofReporterinstances.Initially, it registers a set of built-in
Reporterinstances:CSVReporter,ScatterPlotReporter, andRichTableReporter.New
Reporterinstances can be added using theregister()method, and existing ones can be removed using theunregister()orunregister_by_name()methods.Reporterinstances are required to have unique names and CLI arguments in theirChoicesto avoid conflicts and the manager will raise exceptions if duplicates are detected during registration.reporter_manager = ReporterManager() my_custom_reporter = CustomReporter() reporter_manager.register(my_custom_reporter)
- add_reporters_to_argparse(
- parser: ArgumentParser,
Add all registered reporter choices to an
ArgumentParser.This method adds the CLI arguments for all registered reporters to the provided
ArgumentParserinstance using theadd_flags_to_argparse()method of eachReporter.- Parameters:
parser (
ArgumentParser) – TheArgumentParserto add the flags to.
- all_reporters() dict[str, Reporter][source]🔗
Return all available
Reporterinstances as a dictionary keyed by their names.
- choice_for_arg(
- arg: str,
Return the
Choiceinstance for a given CLI argument.
- register(
- reporter: Reporter,
Register a new
Reporter.This method adds a new
Reporterto the registry. Unlike the predefined reporters and theregister_reporter()decorator which both register by class, this method requires an instance of theReporter.This allows for more flexibility, such as registering
Reporterinstances with custom initialization parameters.- Parameters:
- Raises:
SimpleBenchValueError – If a
Reporterwith the same name or CLI argument is already registered.SimpleBenchTypeError – If the provided reporter is not an instance of
Reporter.
- unregister(
- reporter: Reporter,
Unregister a
Reporterby an instance exemplar.It looks up the reporter by its name and removes it from the registry.
reporter_manager.unregister(MyCustomReporter())
- Parameters:
reporter (
Reporter) –Reporterinstance exemplar to unregister.- Raises:
SimpleBenchKeyError – If no reporter with the given name is registered.
SimpleBenchTypeError – If the provided reporter is not an instance of
Reporter.