Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pydantic_evals/pydantic_evals/online.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class OnlineEvaluator:
"""

def __post_init__(self) -> None:
if self.max_concurrency < 1:
raise ValueError(f'max_concurrency must be >= 1, got {self.max_concurrency}')
self.semaphore = threading.Semaphore(self.max_concurrency)


Expand Down
7 changes: 7 additions & 0 deletions tests/evals/test_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ async def test_online_evaluator_custom_config():
assert online.max_concurrency == 5


@pytest.mark.parametrize('max_concurrency', [0, -1])
def test_online_evaluator_invalid_max_concurrency(max_concurrency: int):
"""OnlineEvaluator rejects non-positive concurrency limits."""
with pytest.raises(ValueError, match=f'max_concurrency must be >= 1, got {max_concurrency}'):
OnlineEvaluator(evaluator=AlwaysTrue(), max_concurrency=max_concurrency)


@pytest.mark.anyio
async def test_run_evaluators_success():
"""run_evaluators returns results from all evaluators."""
Expand Down
Loading