Skip to content

Commit 671c882

Browse files
author
Dylan Huang
authored
enforce passing preprocess_fn to data_loaders (#216)
1 parent 521091f commit 671c882

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

eval_protocol/pytest/evaluation_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,13 @@ def _log_eval_error(status: Status, rows: list[EvaluationRow] | None, passed: bo
284284
to specially handle data_loaders here so we don't double
285285
apply preprocess_fn.
286286
"""
287-
if preprocess_fn and not data_loaders:
288-
data = preprocess_fn(data)
287+
if preprocess_fn:
288+
if not data_loaders:
289+
data = preprocess_fn(data)
290+
else:
291+
raise ValueError(
292+
"preprocess_fn should not be used with data_loaders. Pass preprocess_fn to data_loaders instead."
293+
)
289294

290295
for row in data:
291296
# generate a stable row_id for each row

eval_protocol/quickstart/llm_judge_braintrust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def braintrust_data_generator():
5454
@evaluation_test(
5555
data_loaders=DynamicDataLoader(
5656
generators=[braintrust_data_generator],
57+
preprocess_fn=multi_turn_assistant_to_ground_truth,
5758
),
5859
rollout_processor=SingleTurnRolloutProcessor(),
59-
preprocess_fn=multi_turn_assistant_to_ground_truth,
6060
max_concurrent_evaluations=2,
6161
)
6262
async def test_llm_judge(row: EvaluationRow) -> EvaluationRow:

eval_protocol/quickstart/llm_judge_langfuse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def langfuse_data_generator():
5151
@evaluation_test(
5252
data_loaders=DynamicDataLoader(
5353
generators=[langfuse_data_generator],
54+
preprocess_fn=multi_turn_assistant_to_ground_truth,
5455
),
5556
rollout_processor=SingleTurnRolloutProcessor(),
56-
preprocess_fn=multi_turn_assistant_to_ground_truth,
5757
max_concurrent_evaluations=2,
5858
)
5959
async def test_llm_judge(row: EvaluationRow) -> EvaluationRow:

eval_protocol/quickstart/llm_judge_langsmith.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def langsmith_data_generator() -> List[EvaluationRow]:
6868
@evaluation_test(
6969
data_loaders=DynamicDataLoader(
7070
generators=[langsmith_data_generator],
71+
preprocess_fn=multi_turn_assistant_to_ground_truth,
7172
),
7273
rollout_processor=SingleTurnRolloutProcessor(),
7374
preprocess_fn=multi_turn_assistant_to_ground_truth,

eval_protocol/quickstart/llm_judge_openai_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def openai_responses_data_generator():
5757
@evaluation_test(
5858
data_loaders=DynamicDataLoader(
5959
generators=[openai_responses_data_generator],
60+
preprocess_fn=multi_turn_assistant_to_ground_truth,
6061
),
6162
rollout_processor=SingleTurnRolloutProcessor(),
62-
preprocess_fn=multi_turn_assistant_to_ground_truth,
6363
max_concurrent_evaluations=2,
6464
)
6565
async def test_llm_judge_openai_responses(row: EvaluationRow) -> EvaluationRow:

0 commit comments

Comments
 (0)