Skip to content

Commit 0a78e79

Browse files
committed
fix test
1 parent 999ed18 commit 0a78e79

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

eval_protocol/pytest/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
RolloutProcessorConfig,
1717
)
1818

19+
def is_in_event_loop():
20+
try:
21+
asyncio.get_event_loop()
22+
return True
23+
except RuntimeError:
24+
return False
25+
1926

2027
def execute_function(func: Callable, **kwargs) -> Any:
2128
"""

tests/pytest/test_pytest_ensure_logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import Mock, patch
33

44

5-
async def test_ensure_logging(monkeypatch):
5+
def test_ensure_logging(monkeypatch):
66
"""
77
Ensure that default SQLITE logger gets called by mocking the storage and checking that the storage is called.
88
"""
@@ -37,7 +37,7 @@ async def test_ensure_logging(monkeypatch):
3737
def eval_fn(row: EvaluationRow) -> EvaluationRow:
3838
return row
3939

40-
await eval_fn(
40+
eval_fn(
4141
dataset_path=["tests/pytest/data/markdown_dataset.jsonl"],
4242
completion_params={"temperature": 0.0, "model": "dummy/local-model"},
4343
)

tests/pytest/test_pytest_ids.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def read(self):
1919
return list(self._rows.values())
2020

2121

22-
async def test_evaluation_test_decorator(monkeypatch):
22+
def test_evaluation_test_decorator(monkeypatch):
2323
from eval_protocol.pytest.evaluation_test import evaluation_test
2424

2525
logger = InMemoryLogger()
@@ -45,13 +45,13 @@ def eval_fn(row: EvaluationRow) -> EvaluationRow:
4545

4646
# Manually invoke all parameter combinations within a single test
4747
for ds_path in dataset_paths:
48-
await eval_fn(dataset_path=[ds_path], completion_params={"temperature": 0.0, "model": "dummy/local-model"})
48+
eval_fn(dataset_path=[ds_path], completion_params={"temperature": 0.0, "model": "dummy/local-model"})
4949

5050
# Assertions on IDs generated by the decorator logic
5151
assert len(logger.read()) == 38
5252

5353

54-
async def test_evaluation_test_decorator_ids_single(monkeypatch):
54+
def test_evaluation_test_decorator_ids_single(monkeypatch):
5555
in_memory_logger = InMemoryLogger()
5656
unique_run_ids = set()
5757
unique_experiment_ids = set()
@@ -97,7 +97,7 @@ def eval_fn(row: EvaluationRow) -> EvaluationRow:
9797
# Manually invoke all parameter combinations within a single test
9898
for ds_path in dataset_paths:
9999
for params in completion_params_list:
100-
await eval_fn(dataset_path=[ds_path], completion_params=params)
100+
eval_fn(dataset_path=[ds_path], completion_params=params)
101101

102102
# Assertions on IDs generated by the decorator logic
103103
assert len(unique_invocation_ids) == 1

tests/pytest/test_pytest_stable_row_id.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from tests.pytest.test_markdown_highlighting import markdown_dataset_to_evaluation_row
66

77

8-
async def test_evaluation_test_decorator_ids_single():
8+
def test_evaluation_test_decorator_ids_single():
99
from eval_protocol.pytest.evaluation_test import evaluation_test
1010

1111
row_ids = set()
@@ -35,18 +35,18 @@ def eval_fn(row: EvaluationRow) -> EvaluationRow:
3535
# Manually invoke all parameter combinations within a single test
3636
for ds_path in input_dataset:
3737
for params in completion_params_list:
38-
await eval_fn(dataset_path=[ds_path], completion_params=params)
38+
eval_fn(dataset_path=[ds_path], completion_params=params)
3939

4040
# Second invocation to ensure that IDs are stable across multiple invocations
4141
for ds_path in input_dataset:
4242
for params in completion_params_list:
43-
await eval_fn(dataset_path=[ds_path], completion_params=params)
43+
eval_fn(dataset_path=[ds_path], completion_params=params)
4444

4545
# Assertions on IDs generated by the decorator logic
4646
assert len(row_ids) == 19 # from the markdown dataset
4747

4848

49-
async def test_evaluation_test_generated_row_ids_without_dataset_keys():
49+
def test_evaluation_test_generated_row_ids_without_dataset_keys():
5050
from eval_protocol.pytest.evaluation_test import evaluation_test
5151

5252
# Adapter that does NOT set row_id; lets evaluation_test generate IDs
@@ -86,12 +86,12 @@ def eval_fn(row: EvaluationRow) -> EvaluationRow:
8686
# Single invocation (one dataset, one param set) with multiple runs
8787
for ds_path in input_dataset:
8888
for params in completion_params:
89-
await eval_fn(dataset_path=[ds_path], completion_params=params)
89+
eval_fn(dataset_path=[ds_path], completion_params=params)
9090

9191
# Second invocation to ensure that IDs are stable across multiple invocations
9292
for ds_path in input_dataset:
9393
for params in completion_params:
94-
await eval_fn(dataset_path=[ds_path], completion_params=params)
94+
eval_fn(dataset_path=[ds_path], completion_params=params)
9595

9696
# Even with multiple runs, generated row_ids should be stable within the invocation
9797
assert len(row_ids) == 19 # equals dataset size when IDs are generated once and preserved across runs

0 commit comments

Comments
 (0)