Evaluator Registry#

class EvaluatorRegistry[source]#

Bases: object

Registry for managing evaluator instances.

Provides a centralized registry for managing evaluator instances in the Brisk framework. Allows registration of evaluators and retrieval by name, with duplicate name protection.

Attributes:
evaluatorsDict[str, Any]

Dictionary mapping evaluator names to evaluator instances

Notes

The registry maintains a mapping of evaluator names to their instances, allowing for easy lookup and management. Each evaluator must have a unique method_name to prevent conflicts.

Examples

Create and use a registry:
>>> registry = EvaluatorRegistry()
>>> evaluator = SomeEvaluator()
>>> registry.register(evaluator)
>>> retrieved = registry.get("some_evaluator")
get(name: str) BaseEvaluator[source]#

Get an evaluator by name.

Retrieves an evaluator instance from the registry by its name. Returns None if no evaluator with the given name is found.

Parameters:
namestr

Name of the evaluator to retrieve

Returns:
BaseEvaluator or None

The evaluator instance if found, None otherwise

register(evaluator: BaseEvaluator) None[source]#

Register an evaluator instance.

Adds an evaluator instance to the registry using its method_name as the key. Prevents duplicate registrations by raising an error if an evaluator with the same name is already registered.

Parameters:
evaluatorBaseEvaluator

Instance of an evaluator class to register

Returns:
None
Raises:
ValueError

If an evaluator with the same method_name is already registered

Notes

The evaluator’s method_name is used as the key for storage and retrieval. This ensures that each evaluator can be uniquely identified and accessed.