Skip to content

Commit a5c701e

Browse files
author
Dylan Huang
committed
for generating some test data
1 parent 41c74b6 commit a5c701e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import random
3+
from typing import List
4+
5+
import pytest
6+
7+
from eval_protocol.models import EvaluateResult, EvaluationRow, Message
8+
from eval_protocol.pytest import default_no_op_rollout_processor, evaluation_test
9+
10+
11+
# skip in CI since it will intentionally fail. This is useful for local generation of logs
12+
@pytest.mark.skipif(os.getenv("CI") == "true", reason="Skipping flaky test in CI")
13+
@evaluation_test(
14+
input_messages=[[Message(role="user", content="Return HEADS or TAILS at random.")]],
15+
model=["dummy/local-model"],
16+
rollout_processor=default_no_op_rollout_processor,
17+
mode="pointwise",
18+
num_runs=5,
19+
)
20+
def test_flaky_passes_sometimes(row: EvaluationRow) -> EvaluationRow:
21+
"""
22+
A deliberately flaky evaluation that only passes occasionally.
23+
24+
With num_runs=5 and a success probability of ~0.3 per run, the aggregated mean
25+
will clear the threshold (0.8) only rarely. Uses the no-op rollout to avoid any
26+
actual model calls.
27+
"""
28+
# Stochastic score: 1.0 with 30% probability, else 0.0
29+
score = 1.0 if random.random() < 0.3 else 0.0
30+
row.evaluation_result = EvaluateResult(score=score, reason=f"stochastic={score}")
31+
return row

0 commit comments

Comments
 (0)