Skip to content

MaxMetricCallsStopper

gepa.utils.stop_condition.MaxMetricCallsStopper(max_metric_calls: int)

Bases: StopperProtocol

Stop callback that stops after a maximum number of metric calls.

Source code in gepa/utils/stop_condition.py
def __init__(self, max_metric_calls: int):
    self.max_metric_calls = max_metric_calls

Attributes

max_metric_calls = max_metric_calls instance-attribute

Functions

__call__(gepa_state: GEPAState) -> bool

Source code in gepa/utils/stop_condition.py
def __call__(self, gepa_state: GEPAState) -> bool:
    # return true if max metric calls reached
    return gepa_state.total_num_evals >= self.max_metric_calls