persianeval 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {persianeval-0.2.0 → persianeval-0.2.1}/CHANGELOG.md +31 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/PKG-INFO +19 -2
- {persianeval-0.2.0 → persianeval-0.2.1}/README.md +18 -1
- persianeval-0.2.1/docs/submissions.md +139 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/pyproject.toml +1 -1
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/cli.py +39 -0
- persianeval-0.2.1/src/persianeval/harness/validation.py +181 -0
- persianeval-0.2.1/tests/test_validation.py +276 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/.gitignore +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/LICENSE +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/adding_a_task.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/adr/0001-task-design.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/adr/0002-scoring-policy.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/adr/0003-leaderboard-freshness.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/assets/banner.svg +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/assets/social_preview.png +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/docs/methodology.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/results/README.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/common.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_bias.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_code.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_cultural.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_rag.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_reading.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_reasoning.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_spelling.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/gen_translation.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/scripts/generate_data/run_all.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/README.md +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/SHA256SUMS +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/bias_detection.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/code_with_persian_comments.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/cultural_knowledge.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/rag_faithfulness.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/reading_comprehension.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/reasoning.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/spelling.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/translation_fa_en.jsonl +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/harness/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/harness/providers.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/harness/results.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/harness/runner.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/harness/scorers.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/leaderboard/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/leaderboard/generate.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/leaderboard/templates/index.html.j2 +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/py.typed +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/__init__.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/base.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/bias_detection.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/code_with_persian_comments.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/cultural_knowledge.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/rag_faithfulness.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/reading_comprehension.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/reasoning.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/spelling.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/tasks/translation_fa_en.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/tests/test_data_integrity.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/tests/test_runner.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/tests/test_scorers.py +0 -0
- {persianeval-0.2.0 → persianeval-0.2.1}/tests/test_tasks.py +0 -0
|
@@ -4,6 +4,36 @@ All notable changes to PersianEval are documented here.
|
|
|
4
4
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
5
5
|
and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.2.1] - 2026-11-25
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `persianeval validate-results`: offline structural checks for submitted
|
|
12
|
+
run-result JSON files — schema conformance and version, registered task
|
|
13
|
+
names, `n_items` vs listed items, duplicate ids, scores within [0, 1],
|
|
14
|
+
`accuracy`/`mean_score` recomputed from the per-item data (4-decimal
|
|
15
|
+
rounding tolerance), ISO-8601 timestamps and their ordering, empty
|
|
16
|
+
model/provider. Errors fail CI; warnings (nonzero temperature, cache
|
|
17
|
+
hits, subset runs, empty org/license metadata) never do. 33 new tests,
|
|
18
|
+
including one that validates every committed result file on each CI run.
|
|
19
|
+
- Results-PR gate: PRs touching `results/` run the validator through a
|
|
20
|
+
dedicated workflow that also rejects committed parquet files.
|
|
21
|
+
- `docs/submissions.md`: both entry paths to the leaderboard — the weekly
|
|
22
|
+
model-matrix edit and validated results PRs — documented in English and
|
|
23
|
+
Persian, with the ADR 0003 protocol spelled out.
|
|
24
|
+
- Dependabot (pip + GitHub Actions, weekly, dev deps grouped) and
|
|
25
|
+
pre-commit hooks mirroring the ruff gates.
|
|
26
|
+
- Coverage uploads to Codecov from the Python 3.13 job; badge in README.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- The week-48 leaderboard run is now complete: `code_with_persian_comments`
|
|
31
|
+
landed at accuracy 80 (20 items, seed 202648) and GLM-4-Plus's overall
|
|
32
|
+
moved 82.9 -> 82.5 across all eight tasks. The 0.2.0 note about that
|
|
33
|
+
task staying pending no longer applies.
|
|
34
|
+
- README and CONTRIBUTING route leaderboard-model submissions through
|
|
35
|
+
`docs/submissions.md`.
|
|
36
|
+
|
|
7
37
|
## [0.2.0] - 2026-11-25
|
|
8
38
|
|
|
9
39
|
### Added
|
|
@@ -82,6 +112,7 @@ Initial public release.
|
|
|
82
112
|
- **Docs**: bilingual README/methodology/CONTRIBUTING, task-authoring guide,
|
|
83
113
|
three ADRs, CITATION.cff, Code of Conduct.
|
|
84
114
|
|
|
115
|
+
[0.2.1]: https://github.com/Abolfazlrwm/persianeval/releases/tag/v0.2.1
|
|
85
116
|
[0.2.0]: https://github.com/Abolfazlrwm/persianeval/releases/tag/v0.2.0
|
|
86
117
|
[0.1.2]: https://github.com/Abolfazlrwm/persianeval/releases/tag/v0.1.2
|
|
87
118
|
[0.1.1]: https://github.com/Abolfazlrwm/persianeval/releases/tag/v0.1.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: persianeval
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: PersianEval: the first serious open-source benchmark for evaluating LLMs on Persian (Farsi) — 8 tasks, reproducible async harness, weekly leaderboard.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Abolfazlrwm/persianeval
|
|
6
6
|
Project-URL: Repository, https://github.com/Abolfazlrwm/persianeval
|
|
@@ -50,6 +50,7 @@ Description-Content-Type: text/markdown
|
|
|
50
50
|
[](LICENSE)
|
|
51
51
|
[](https://github.com/Abolfazlrwm/persianeval/stargazers)
|
|
52
52
|
[](https://pypi.org/project/persianeval/)
|
|
53
|
+
[](https://codecov.io/gh/Abolfazlrwm/persianeval)
|
|
53
54
|
|
|
54
55
|
[English](#english) · [فارسی](#فارسی) · [Leaderboard](https://Abolfazlrwm.github.io/persianeval/)
|
|
55
56
|
|
|
@@ -135,6 +136,14 @@ are committed under [`results/`](results/). The open-source Ollama models (Qwen
|
|
|
135
136
|
Llama 3.1, Gemma 2, Aya Expanse) join the table once a weekly CPU run fits the runner
|
|
136
137
|
budget again.
|
|
137
138
|
|
|
139
|
+
### Adding a model to the leaderboard
|
|
140
|
+
|
|
141
|
+
Two paths: a one-line addition to the weekly model matrix
|
|
142
|
+
(`.github/workflows/leaderboard.yml`) for models reachable from CI runners, or
|
|
143
|
+
a results PR from your own run — validated locally with
|
|
144
|
+
`persianeval validate-results` before you submit. Full walkthrough:
|
|
145
|
+
[`docs/submissions.md`](docs/submissions.md).
|
|
146
|
+
|
|
138
147
|
### Adding a task in 15 minutes
|
|
139
148
|
|
|
140
149
|
Implement `AbstractTask`, ship a JSONL file with `{"id","prompt","expected","metadata"}`,
|
|
@@ -158,7 +167,7 @@ PersianEval, please cite (see [`CITATION.cff`](CITATION.cff)):
|
|
|
158
167
|
author = {PersianEval Contributors},
|
|
159
168
|
year = {2026},
|
|
160
169
|
url = {https://github.com/Abolfazlrwm/persianeval},
|
|
161
|
-
version= {v0.2.
|
|
170
|
+
version= {v0.2.1}
|
|
162
171
|
}
|
|
163
172
|
```
|
|
164
173
|
|
|
@@ -241,6 +250,14 @@ results : results/reasoning__demo.parquet
|
|
|
241
250
|
کامیت شدهاند. مدلهای اپنسورس Ollama (Qwen 2.5، Llama 3.1، Gemma 2، Aya Expanse) وقتی
|
|
242
251
|
بودجهٔ رانر CPU اجازهٔ اجرای هفتگی بدهد به جدول اضافه میشوند.
|
|
243
252
|
|
|
253
|
+
### افزودن مدل به لیدربورد
|
|
254
|
+
|
|
255
|
+
دو مسیر وجود دارد: افزودن یک خط به ماتریس مدلهای هفتگی در
|
|
256
|
+
`.github/workflows/leaderboard.yml` برای مدلهایی که از رانرهای CI در دسترساند،
|
|
257
|
+
یا ارسال PR نتایج از اجرای شخصی — که قبل از ارسال با
|
|
258
|
+
`persianeval validate-results` اعتبارسنجی میشود. راهنمای کامل:
|
|
259
|
+
[`docs/submissions.md`](docs/submissions.md).
|
|
260
|
+
|
|
244
261
|
### اضافهکردن تسک جدید در ۱۵ دقیقه
|
|
245
262
|
|
|
246
263
|
کافی است `AbstractTask` را پیاده کنید و یک فایل JSONL با اسکیمای
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
[](https://github.com/Abolfazlrwm/persianeval/stargazers)
|
|
15
15
|
[](https://pypi.org/project/persianeval/)
|
|
16
|
+
[](https://codecov.io/gh/Abolfazlrwm/persianeval)
|
|
16
17
|
|
|
17
18
|
[English](#english) · [فارسی](#فارسی) · [Leaderboard](https://Abolfazlrwm.github.io/persianeval/)
|
|
18
19
|
|
|
@@ -98,6 +99,14 @@ are committed under [`results/`](results/). The open-source Ollama models (Qwen
|
|
|
98
99
|
Llama 3.1, Gemma 2, Aya Expanse) join the table once a weekly CPU run fits the runner
|
|
99
100
|
budget again.
|
|
100
101
|
|
|
102
|
+
### Adding a model to the leaderboard
|
|
103
|
+
|
|
104
|
+
Two paths: a one-line addition to the weekly model matrix
|
|
105
|
+
(`.github/workflows/leaderboard.yml`) for models reachable from CI runners, or
|
|
106
|
+
a results PR from your own run — validated locally with
|
|
107
|
+
`persianeval validate-results` before you submit. Full walkthrough:
|
|
108
|
+
[`docs/submissions.md`](docs/submissions.md).
|
|
109
|
+
|
|
101
110
|
### Adding a task in 15 minutes
|
|
102
111
|
|
|
103
112
|
Implement `AbstractTask`, ship a JSONL file with `{"id","prompt","expected","metadata"}`,
|
|
@@ -121,7 +130,7 @@ PersianEval, please cite (see [`CITATION.cff`](CITATION.cff)):
|
|
|
121
130
|
author = {PersianEval Contributors},
|
|
122
131
|
year = {2026},
|
|
123
132
|
url = {https://github.com/Abolfazlrwm/persianeval},
|
|
124
|
-
version= {v0.2.
|
|
133
|
+
version= {v0.2.1}
|
|
125
134
|
}
|
|
126
135
|
```
|
|
127
136
|
|
|
@@ -204,6 +213,14 @@ results : results/reasoning__demo.parquet
|
|
|
204
213
|
کامیت شدهاند. مدلهای اپنسورس Ollama (Qwen 2.5، Llama 3.1، Gemma 2، Aya Expanse) وقتی
|
|
205
214
|
بودجهٔ رانر CPU اجازهٔ اجرای هفتگی بدهد به جدول اضافه میشوند.
|
|
206
215
|
|
|
216
|
+
### افزودن مدل به لیدربورد
|
|
217
|
+
|
|
218
|
+
دو مسیر وجود دارد: افزودن یک خط به ماتریس مدلهای هفتگی در
|
|
219
|
+
`.github/workflows/leaderboard.yml` برای مدلهایی که از رانرهای CI در دسترساند،
|
|
220
|
+
یا ارسال PR نتایج از اجرای شخصی — که قبل از ارسال با
|
|
221
|
+
`persianeval validate-results` اعتبارسنجی میشود. راهنمای کامل:
|
|
222
|
+
[`docs/submissions.md`](docs/submissions.md).
|
|
223
|
+
|
|
207
224
|
### اضافهکردن تسک جدید در ۱۵ دقیقه
|
|
208
225
|
|
|
209
226
|
کافی است `AbstractTask` را پیاده کنید و یک فایل JSONL با اسکیمای
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Submitting results to the leaderboard
|
|
2
|
+
|
|
3
|
+
The leaderboard has two entry paths. Pick the one that matches your setup;
|
|
4
|
+
both end up on the same page, and neither bypasses the validator.
|
|
5
|
+
|
|
6
|
+
<div dir="rtl">
|
|
7
|
+
|
|
8
|
+
# ارسال نتایج به لیدربورد
|
|
9
|
+
|
|
10
|
+
برای رسیدن به لیدربورد دو مسیر وجود دارد؛ مسیری را انتخاب کنید که با شرایط
|
|
11
|
+
شما سازگار است. هر دو مسیر از یک اعتبارسنج عبور میکنند.
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Path A — one line in the weekly workflow
|
|
18
|
+
|
|
19
|
+
If your model is reachable from GitHub-hosted runners (OpenAI, Anthropic,
|
|
20
|
+
Z.ai hosted APIs, or anything behind a public endpoint), add it to the
|
|
21
|
+
model matrix in `.github/workflows/leaderboard.yml`. The weekly schedule
|
|
22
|
+
then evaluates it with the current ISO-week seed and rebuilds the page.
|
|
23
|
+
No result files to attach — the run is reproducible from the workflow log.
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
strategy:
|
|
27
|
+
matrix:
|
|
28
|
+
model: [glm-4-plus, gpt-4o-mini] # add yours here
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Requirement:** the repository secret that carries your API key
|
|
32
|
+
(e.g. `OPENAI_API_KEY`) must exist. Keep `temperature` at `0` — the
|
|
33
|
+
harness default — so the run is deterministic.
|
|
34
|
+
|
|
35
|
+
<div dir="rtl">
|
|
36
|
+
|
|
37
|
+
## مسیر الف — یک خط در ورکفلوی هفتگی
|
|
38
|
+
|
|
39
|
+
اگر مدل شما از رانرهای GitHub در دسترس است، آن را به ماتریس مدلها در
|
|
40
|
+
`.github/workflows/leaderboard.yml` اضافه کنید. اجرای هفتگی با seed هفتهٔ
|
|
41
|
+
ISO جاری انجام میشود و صفحه بازسازی میشود. کلید API را بهصورت secret
|
|
42
|
+
نگه دارید و `temperature` را صفر بگذارید تا اجرا قطعی باشد.
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Path B — a results PR from your own run
|
|
49
|
+
|
|
50
|
+
For local models (Ollama, vLLM) or hosted models whose keys cannot be
|
|
51
|
+
shared, run the harness yourself and open a PR with the JSON files.
|
|
52
|
+
|
|
53
|
+
### 1. Pick the protocol (ADR 0003)
|
|
54
|
+
|
|
55
|
+
| Mode | Command | Notes |
|
|
56
|
+
|------|---------|-------|
|
|
57
|
+
| Full corpus (preferred) | omit `--limit` | all 200 items per task |
|
|
58
|
+
| Weekly subsample | `--limit 20 --seed $(date -u +%G%V)` | the exact weekly protocol |
|
|
59
|
+
|
|
60
|
+
State which mode you used in the PR description; a result without a
|
|
61
|
+
protocol statement cannot be ranked next to full-corpus runs.
|
|
62
|
+
|
|
63
|
+
### 2. Run the harness
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install persianeval
|
|
67
|
+
|
|
68
|
+
# Hosted API example
|
|
69
|
+
persianeval run --task reasoning --provider openai --model gpt-4o \
|
|
70
|
+
--org "OpenAI" --license "Proprietary (hosted API)" --out results
|
|
71
|
+
|
|
72
|
+
# Local model example
|
|
73
|
+
persianeval run --task reasoning --provider ollama \
|
|
74
|
+
--model qwen2.5:7b-instruct --org "community" \
|
|
75
|
+
--license "Apache-2.0" --request-timeout 300 --out results
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Repeat per task, or loop over `persianeval tasks`. Keep `temperature`
|
|
79
|
+
at its default (0.0) and set `--org`/`--license` so the leaderboard
|
|
80
|
+
renders complete rows.
|
|
81
|
+
|
|
82
|
+
### 3. Validate before opening the PR
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
persianeval validate-results results
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Everything printed as `FAIL` must be fixed — CI runs the same command and
|
|
89
|
+
will reject the PR. `WARN` lines are informational: cache hits, subset
|
|
90
|
+
runs below the task minimum, nonzero temperature, empty metadata.
|
|
91
|
+
|
|
92
|
+
### 4. What to commit
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git checkout -b results/my-model
|
|
96
|
+
git add results/<task>__<model>.json # JSON only
|
|
97
|
+
git commit -m "results: my-model over the week-N subsample"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- Commit the JSON files only. `results/*.parquet` and `.persianeval_cache/`
|
|
101
|
+
stay local (the JSON *is* the audit trail — see `results/README.md`).
|
|
102
|
+
- Never edit metrics or per-item scores by hand. The validator recomputes
|
|
103
|
+
`accuracy` and `mean_score` from the per-item data and a mismatch fails
|
|
104
|
+
CI; hand-edited entries are also a ban-worthy offense against the
|
|
105
|
+
project's honesty policy.
|
|
106
|
+
|
|
107
|
+
### 5. Open the PR
|
|
108
|
+
|
|
109
|
+
Use the default PR template, state the protocol (mode, seed, command) and
|
|
110
|
+
link to where a reviewer can reproduce the run. A maintainer re-checks the
|
|
111
|
+
metadata (provider, org, license) before merging; the next leaderboard
|
|
112
|
+
build picks the files up automatically.
|
|
113
|
+
|
|
114
|
+
<div dir="rtl">
|
|
115
|
+
|
|
116
|
+
## مسیر ب — PR نتایج از اجرای شخصی
|
|
117
|
+
|
|
118
|
+
برای مدلهای محلی (Ollama، vLLM) یا مدلهایی که کلیدشان قابل اشتراک نیست،
|
|
119
|
+
خودتان هارنس را اجرا کنید و فایلهای JSON را با PR بفرستید.
|
|
120
|
+
|
|
121
|
+
**۱. پروتکل را انتخاب کنید (ADR 0003):** یا کورپوس کامل (بدون `--limit`)
|
|
122
|
+
یا زیرنمونهٔ هفتگی با `--limit 20 --seed $(date -u +%G%V)`. حالت مورد
|
|
123
|
+
استفاده را در توضیح PR بنویسید.
|
|
124
|
+
|
|
125
|
+
**۲. هارنس را اجرا کنید:** به نمونههای بالا نگاه کنید؛ `temperature` صفر
|
|
126
|
+
بماند و `--org`/`--license` را تنظیم کنید.
|
|
127
|
+
|
|
128
|
+
**۳. قبل از PR اعتبارسنجی کنید:** `persianeval validate-results results` —
|
|
129
|
+
هر خط `FAIL` باید رفع شود، چون CI همین دستور را اجرا میکند.
|
|
130
|
+
|
|
131
|
+
**۴. چه چیزی کامیت شود:** فقط JSON. فایلهای parquet و کش محلی میمانند.
|
|
132
|
+
ویرایش دستی متریکها ممنوع است؛ اعتبارسنج دقت را از دادهٔ آیتمها
|
|
133
|
+
بازمحاسبه میکند و مغایرت، CI را قرمز میکند.
|
|
134
|
+
|
|
135
|
+
**۵. PR را باز کنید:** پروتکل (حالت، seed، دستور اجرا) را ذکر کنید تا
|
|
136
|
+
بازبینی بتواند اجرا را بازتولید کند. پس از مرج، ساخت بعدی لیدربورد فایلها
|
|
137
|
+
را خودکار برمیدارد.
|
|
138
|
+
|
|
139
|
+
</div>
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "persianeval"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "PersianEval: the first serious open-source benchmark for evaluating LLMs on Persian (Farsi) — 8 tasks, reproducible async harness, weekly leaderboard."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -5,6 +5,7 @@ Examples:
|
|
|
5
5
|
persianeval run --task reasoning --provider openai --model gpt-4o --rpm 60
|
|
6
6
|
persianeval run --task spelling --provider ollama --model qwen2.5:7b-instruct
|
|
7
7
|
persianeval leaderboard --results-dir results --out leaderboard
|
|
8
|
+
persianeval validate-results results
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
from __future__ import annotations
|
|
@@ -20,6 +21,7 @@ import typer
|
|
|
20
21
|
from persianeval.harness.providers import ProviderError, create_provider
|
|
21
22
|
from persianeval.harness.results import RunResult, save_json, save_parquet
|
|
22
23
|
from persianeval.harness.runner import run_task
|
|
24
|
+
from persianeval.harness.validation import collect_json_files, validate_file
|
|
23
25
|
from persianeval.leaderboard.generate import generate_site
|
|
24
26
|
from persianeval.tasks import get_task
|
|
25
27
|
|
|
@@ -159,6 +161,43 @@ def leaderboard(
|
|
|
159
161
|
typer.echo(f"leaderboard written to {index_path}")
|
|
160
162
|
|
|
161
163
|
|
|
164
|
+
@app.command("validate-results")
|
|
165
|
+
def validate_results(
|
|
166
|
+
paths: Annotated[
|
|
167
|
+
list[Path], typer.Argument(help="Result JSON files and/or directories containing *.json files.")
|
|
168
|
+
],
|
|
169
|
+
) -> None:
|
|
170
|
+
"""Validate run-result JSON files before submitting them to the leaderboard.
|
|
171
|
+
|
|
172
|
+
Errors (schema violations, metric drift, duplicate ids, unknown tasks,
|
|
173
|
+
broken timestamps) exit non-zero so CI can gate results PRs; warnings
|
|
174
|
+
(nondeterministic temperature, cached items, subset runs, missing
|
|
175
|
+
metadata) are informational only.
|
|
176
|
+
"""
|
|
177
|
+
json_files = collect_json_files(paths)
|
|
178
|
+
if not json_files:
|
|
179
|
+
typer.secho("error: no *.json files found in the given paths", fg=typer.colors.RED, err=True)
|
|
180
|
+
raise typer.Exit(code=2)
|
|
181
|
+
|
|
182
|
+
total_errors = 0
|
|
183
|
+
for path in json_files:
|
|
184
|
+
errors, warnings = validate_file(path)
|
|
185
|
+
for message in errors:
|
|
186
|
+
typer.secho(f"FAIL {path}: {message}", fg=typer.colors.RED, err=True)
|
|
187
|
+
for message in warnings:
|
|
188
|
+
typer.secho(f"WARN {path}: {message}", fg=typer.colors.YELLOW)
|
|
189
|
+
if errors:
|
|
190
|
+
total_errors += len(errors)
|
|
191
|
+
else:
|
|
192
|
+
suffix = f" ({len(warnings)} warning(s))" if warnings else ""
|
|
193
|
+
typer.secho(f"OK {path}{suffix}", fg=typer.colors.GREEN)
|
|
194
|
+
|
|
195
|
+
if total_errors:
|
|
196
|
+
typer.secho(f"{total_errors} error(s) in {len(json_files)} file(s)", fg=typer.colors.RED, err=True)
|
|
197
|
+
raise typer.Exit(code=1)
|
|
198
|
+
typer.echo(f"all {len(json_files)} file(s) valid")
|
|
199
|
+
|
|
200
|
+
|
|
162
201
|
@app.callback()
|
|
163
202
|
def _root_callback(
|
|
164
203
|
version: Annotated[
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""Structural validation of run-result files for leaderboard submissions.
|
|
2
|
+
|
|
3
|
+
``persianeval validate-results`` runs a set of offline, objective checks on
|
|
4
|
+
``RunResult`` JSON files before they are submitted to the leaderboard:
|
|
5
|
+
|
|
6
|
+
* schema conformance (pydantic ``RunResult``) and schema version
|
|
7
|
+
* the task name must be a registered task
|
|
8
|
+
* ``n_items`` must match the number of scored items; ids must be unique
|
|
9
|
+
* per-item scores must be within ``[0, 1]``
|
|
10
|
+
* reported ``accuracy`` / ``mean_score`` must match the per-item data
|
|
11
|
+
(beyond the 4-decimal rounding tolerance used by the runner)
|
|
12
|
+
* timestamps must be ISO-8601 and ordered (``finished_at >= started_at``)
|
|
13
|
+
|
|
14
|
+
Anything that cannot be verified objectively (sampling temperature, cached
|
|
15
|
+
responses, subset runs, missing metadata) is reported as a *warning*, never
|
|
16
|
+
an error: warnings do not fail CI.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from datetime import UTC, datetime
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Final
|
|
24
|
+
|
|
25
|
+
from pydantic import ValidationError
|
|
26
|
+
|
|
27
|
+
from persianeval.harness.results import SCHEMA_VERSION, RunResult, load_json
|
|
28
|
+
from persianeval.tasks import all_task_classes
|
|
29
|
+
|
|
30
|
+
#: Max drift between reported and recomputed metrics caused by the runner
|
|
31
|
+
#: rounding metrics to four decimal places.
|
|
32
|
+
ROUNDING_TOLERANCE: Final[float] = 5e-4
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _parse_timestamp(raw: str) -> datetime:
|
|
36
|
+
"""Parse an ISO-8601 timestamp, assuming UTC for naive values.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
raw: Timestamp string from a result file.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
A timezone-aware datetime.
|
|
43
|
+
|
|
44
|
+
Raises:
|
|
45
|
+
ValueError: If the string is not valid ISO-8601.
|
|
46
|
+
"""
|
|
47
|
+
parsed = datetime.fromisoformat(raw)
|
|
48
|
+
if parsed.tzinfo is None:
|
|
49
|
+
parsed = parsed.replace(tzinfo=UTC)
|
|
50
|
+
return parsed
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def check_result(result: RunResult) -> tuple[list[str], list[str]]:
|
|
54
|
+
"""Validate one parsed run result.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
result: The run result to inspect.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
A ``(errors, warnings)`` tuple. Errors mean the file is not a
|
|
61
|
+
trustworthy leaderboard entry; warnings are informational only.
|
|
62
|
+
"""
|
|
63
|
+
errors: list[str] = []
|
|
64
|
+
warnings: list[str] = []
|
|
65
|
+
|
|
66
|
+
if result.schema_version != SCHEMA_VERSION:
|
|
67
|
+
errors.append(f"unsupported schema_version {result.schema_version!r} (expected {SCHEMA_VERSION!r})")
|
|
68
|
+
if not result.model:
|
|
69
|
+
errors.append("model is empty")
|
|
70
|
+
if not result.provider:
|
|
71
|
+
errors.append("provider is empty")
|
|
72
|
+
|
|
73
|
+
tasks = all_task_classes()
|
|
74
|
+
min_samples: int | None = None
|
|
75
|
+
if result.task not in tasks:
|
|
76
|
+
errors.append(f"unknown task {result.task!r}; registered tasks: {', '.join(sorted(tasks))}")
|
|
77
|
+
else:
|
|
78
|
+
min_samples = tasks[result.task]().min_samples
|
|
79
|
+
|
|
80
|
+
if result.n_items == 0:
|
|
81
|
+
errors.append("run has no scored items")
|
|
82
|
+
elif result.n_items != len(result.items):
|
|
83
|
+
errors.append(f"n_items={result.n_items} but {len(result.items)} items are listed")
|
|
84
|
+
|
|
85
|
+
seen_ids: set[str] = set()
|
|
86
|
+
for item in result.items:
|
|
87
|
+
if item.id in seen_ids:
|
|
88
|
+
errors.append(f"duplicate item id {item.id!r}")
|
|
89
|
+
seen_ids.add(item.id)
|
|
90
|
+
if not 0.0 <= item.score <= 1.0:
|
|
91
|
+
errors.append(f"item {item.id!r}: score {item.score} outside [0, 1]")
|
|
92
|
+
|
|
93
|
+
if result.items:
|
|
94
|
+
n_passed = sum(item.passed for item in result.items)
|
|
95
|
+
recomputed_accuracy = n_passed / len(result.items)
|
|
96
|
+
if not 0.0 <= result.metrics.get("accuracy", -1.0) <= 1.0:
|
|
97
|
+
errors.append("metrics.accuracy outside [0, 1]")
|
|
98
|
+
elif abs(result.metrics.get("accuracy", 0.0) - recomputed_accuracy) > ROUNDING_TOLERANCE:
|
|
99
|
+
errors.append(
|
|
100
|
+
f"metrics.accuracy {result.metrics.get('accuracy', 0.0)} does not match the "
|
|
101
|
+
f"per-item data (recomputed {recomputed_accuracy:.4f} "
|
|
102
|
+
f"from {n_passed}/{len(result.items)} passed)"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
recomputed_mean = sum(item.score for item in result.items) / len(result.items)
|
|
106
|
+
if not 0.0 <= result.metrics.get("mean_score", -1.0) <= 1.0:
|
|
107
|
+
errors.append("metrics.mean_score outside [0, 1]")
|
|
108
|
+
elif abs(result.metrics.get("mean_score", 0.0) - recomputed_mean) > ROUNDING_TOLERANCE:
|
|
109
|
+
errors.append(
|
|
110
|
+
f"metrics.mean_score {result.metrics.get('mean_score', 0.0)} does not match the "
|
|
111
|
+
f"per-item scores (recomputed {recomputed_mean:.4f})"
|
|
112
|
+
)
|
|
113
|
+
elif "accuracy" in result.metrics or "mean_score" in result.metrics:
|
|
114
|
+
errors.append("metrics reported without any items")
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
started = _parse_timestamp(result.started_at)
|
|
118
|
+
finished = _parse_timestamp(result.finished_at)
|
|
119
|
+
except ValueError:
|
|
120
|
+
errors.append("started_at/finished_at are not valid ISO-8601 timestamps")
|
|
121
|
+
else:
|
|
122
|
+
if finished < started:
|
|
123
|
+
errors.append(f"finished_at {result.finished_at} is before started_at {result.started_at}")
|
|
124
|
+
|
|
125
|
+
if result.temperature != 0.0:
|
|
126
|
+
warnings.append(
|
|
127
|
+
f"temperature={result.temperature} (leaderboard runs are expected to be deterministic)"
|
|
128
|
+
)
|
|
129
|
+
if result.n_cached > 0:
|
|
130
|
+
warnings.append(f"{result.n_cached} item(s) were served from the response cache")
|
|
131
|
+
if min_samples is not None and 0 < result.n_items < min_samples:
|
|
132
|
+
warnings.append(
|
|
133
|
+
f"subset run: {result.n_items} items is below the task minimum of {min_samples} "
|
|
134
|
+
"(full-corpus runs are preferred; seeded weekly subsamples are accepted)"
|
|
135
|
+
)
|
|
136
|
+
if not result.org:
|
|
137
|
+
warnings.append("org metadata is empty; the leaderboard will render an empty cell")
|
|
138
|
+
if not result.license:
|
|
139
|
+
warnings.append("license metadata is empty; the leaderboard will render an empty cell")
|
|
140
|
+
|
|
141
|
+
return errors, warnings
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def validate_file(path: Path) -> tuple[list[str], list[str]]:
|
|
145
|
+
"""Load and validate one result JSON file.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
path: Path to a ``RunResult`` JSON file.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
A ``(errors, warnings)`` tuple. An unreadable or unparsable file
|
|
152
|
+
yields a single error and no warnings.
|
|
153
|
+
"""
|
|
154
|
+
try:
|
|
155
|
+
result = load_json(path)
|
|
156
|
+
except (OSError, ValidationError) as exc:
|
|
157
|
+
summary = str(exc).split("For more information", maxsplit=1)[0].strip()
|
|
158
|
+
return ([f"not a valid RunResult JSON file: {summary}"], [])
|
|
159
|
+
return check_result(result)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def collect_json_files(paths: list[Path]) -> list[Path]:
|
|
163
|
+
"""Expand user-supplied paths into the concrete list of JSON files.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
paths: Files and/or directories. Directories are scanned
|
|
167
|
+
(non-recursively) for ``*.json``.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
The expanded, de-duplicated file list in input order.
|
|
171
|
+
"""
|
|
172
|
+
files: list[Path] = []
|
|
173
|
+
seen: set[Path] = set()
|
|
174
|
+
for path in paths:
|
|
175
|
+
candidates = sorted(path.glob("*.json")) if path.is_dir() else [path]
|
|
176
|
+
for candidate in candidates:
|
|
177
|
+
resolved = candidate.resolve()
|
|
178
|
+
if resolved not in seen:
|
|
179
|
+
seen.add(resolved)
|
|
180
|
+
files.append(candidate)
|
|
181
|
+
return files
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"""Tests for persianeval.harness.validation and the validate-results CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from typer.testing import CliRunner
|
|
10
|
+
|
|
11
|
+
from persianeval.cli import app
|
|
12
|
+
from persianeval.harness.results import ItemResult, RunResult, save_json, utc_now_iso
|
|
13
|
+
from persianeval.harness.validation import check_result, collect_json_files, validate_file
|
|
14
|
+
|
|
15
|
+
runner = CliRunner()
|
|
16
|
+
|
|
17
|
+
# Registered task names are stable; reasoning is used as the fixture task.
|
|
18
|
+
FIXTURE_TASK = "reasoning"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def make_items(n: int, *, score: float = 1.0) -> list[ItemResult]:
|
|
22
|
+
"""Build n deterministic, uniquely-identified items."""
|
|
23
|
+
return [
|
|
24
|
+
ItemResult(
|
|
25
|
+
id=f"item-{i:04d}",
|
|
26
|
+
score=score,
|
|
27
|
+
passed=score >= 0.5,
|
|
28
|
+
response=f"response {i}",
|
|
29
|
+
expected=f"expected {i}",
|
|
30
|
+
scorer="exact_match",
|
|
31
|
+
latency_ms=10.0,
|
|
32
|
+
)
|
|
33
|
+
for i in range(n)
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def make_result(n: int = 2, **overrides: Any) -> RunResult:
|
|
38
|
+
"""Build a self-consistent result whose metrics match its items."""
|
|
39
|
+
supplied: list[ItemResult] | None = overrides.pop("items", None)
|
|
40
|
+
items = supplied if supplied is not None else make_items(n)
|
|
41
|
+
n_passed = sum(item.passed for item in items)
|
|
42
|
+
count = len(items)
|
|
43
|
+
defaults: dict[str, Any] = {
|
|
44
|
+
"run_id": "deadbeef1234",
|
|
45
|
+
"task": FIXTURE_TASK,
|
|
46
|
+
"model": "test-model",
|
|
47
|
+
"provider": "dummy",
|
|
48
|
+
"org": "Test Org",
|
|
49
|
+
"license": "Apache-2.0",
|
|
50
|
+
"seed": 42,
|
|
51
|
+
"temperature": 0.0,
|
|
52
|
+
"max_tokens": 128,
|
|
53
|
+
"concurrency": 1,
|
|
54
|
+
"started_at": utc_now_iso(),
|
|
55
|
+
"finished_at": utc_now_iso(),
|
|
56
|
+
"n_items": count,
|
|
57
|
+
"n_cached": 0,
|
|
58
|
+
"metrics": {
|
|
59
|
+
"accuracy": round(n_passed / count, 4) if count else 0.0,
|
|
60
|
+
"mean_score": round(sum(i.score for i in items) / count, 4) if count else 0.0,
|
|
61
|
+
"avg_latency_ms": 10.0,
|
|
62
|
+
},
|
|
63
|
+
"items": items,
|
|
64
|
+
}
|
|
65
|
+
defaults.update(overrides)
|
|
66
|
+
return RunResult.model_validate(defaults)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def write_result(tmp_path: Path, result: RunResult, name: str = "run.json") -> Path:
|
|
70
|
+
"""Persist a result fixture and return its path."""
|
|
71
|
+
path = tmp_path / name
|
|
72
|
+
save_json(result, path)
|
|
73
|
+
return path
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
# check_result: clean pass
|
|
78
|
+
# ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_check_result_accepts_full_corpus_run() -> None:
|
|
82
|
+
"""A 200-item run (task minimum) with matching metrics has no findings."""
|
|
83
|
+
errors, warnings = check_result(make_result(200))
|
|
84
|
+
assert errors == []
|
|
85
|
+
assert warnings == []
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_check_result_flags_subset_run_as_warning_only() -> None:
|
|
89
|
+
errors, warnings = check_result(make_result(20))
|
|
90
|
+
assert errors == []
|
|
91
|
+
assert any("subset run" in warning for warning in warnings)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------------------------
|
|
95
|
+
# check_result: errors
|
|
96
|
+
# ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_check_result_flags_unknown_task() -> None:
|
|
100
|
+
errors, _ = check_result(make_result(task="not_a_task"))
|
|
101
|
+
assert any("unknown task" in error for error in errors)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_check_result_flags_n_items_mismatch() -> None:
|
|
105
|
+
errors, _ = check_result(make_result(n=5, n_items=9))
|
|
106
|
+
assert any("n_items=9 but 5 items" in error for error in errors)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_check_result_flags_zero_items() -> None:
|
|
110
|
+
errors, _ = check_result(make_result(n=1, items=make_items(0), n_items=0))
|
|
111
|
+
assert any("no scored items" in error for error in errors)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_check_result_flags_duplicate_item_ids() -> None:
|
|
115
|
+
items = make_items(2)
|
|
116
|
+
items[1] = items[0].model_copy()
|
|
117
|
+
errors, _ = check_result(make_result(items=items))
|
|
118
|
+
assert any("duplicate item id" in error for error in errors)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_check_result_flags_score_out_of_range() -> None:
|
|
122
|
+
items = [make_items(1)[0].model_copy(update={"score": 1.5})]
|
|
123
|
+
errors, _ = check_result(make_result(items=items))
|
|
124
|
+
assert any("outside [0, 1]" in error for error in errors)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_check_result_flags_accuracy_drift() -> None:
|
|
128
|
+
result = make_result()
|
|
129
|
+
result.metrics["accuracy"] = 0.99 # items say 1.0
|
|
130
|
+
errors, _ = check_result(result)
|
|
131
|
+
assert any("accuracy" in error and "does not match" in error for error in errors)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def test_check_result_flags_mean_score_drift() -> None:
|
|
135
|
+
result = make_result()
|
|
136
|
+
result.metrics["mean_score"] = 0.42 # items say 1.0
|
|
137
|
+
errors, _ = check_result(result)
|
|
138
|
+
assert any("mean_score" in error and "does not match" in error for error in errors)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_check_result_flags_metrics_outside_unit_range() -> None:
|
|
142
|
+
result = make_result()
|
|
143
|
+
result.metrics["accuracy"] = 1.5
|
|
144
|
+
result.metrics["mean_score"] = -0.1
|
|
145
|
+
errors, _ = check_result(result)
|
|
146
|
+
assert any("metrics.accuracy outside" in error for error in errors)
|
|
147
|
+
assert any("metrics.mean_score outside" in error for error in errors)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def test_check_result_flags_finished_before_started() -> None:
|
|
151
|
+
errors, _ = check_result(
|
|
152
|
+
make_result(
|
|
153
|
+
started_at="2026-11-25T12:00:00+00:00",
|
|
154
|
+
finished_at="2026-11-25T11:00:00+00:00",
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
assert any("before started_at" in error for error in errors)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_check_result_flags_invalid_timestamps() -> None:
|
|
161
|
+
errors, _ = check_result(make_result(started_at="yesterday", finished_at="tomorrow-ish"))
|
|
162
|
+
assert any("ISO-8601" in error for error in errors)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_check_result_flags_empty_model_and_provider() -> None:
|
|
166
|
+
errors, _ = check_result(make_result(model="", provider=""))
|
|
167
|
+
assert any("model is empty" in error for error in errors)
|
|
168
|
+
assert any("provider is empty" in error for error in errors)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_check_result_flags_wrong_schema_version() -> None:
|
|
172
|
+
errors, _ = check_result(make_result(schema_version="9.9"))
|
|
173
|
+
assert any("unsupported schema_version" in error for error in errors)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# ---------------------------------------------------------------------------
|
|
177
|
+
# check_result: warnings
|
|
178
|
+
# ---------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def test_check_result_warns_on_nondeterministic_temperature() -> None:
|
|
182
|
+
_, warnings = check_result(make_result(temperature=0.7))
|
|
183
|
+
assert any("temperature" in warning for warning in warnings)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_check_result_warns_on_cached_items() -> None:
|
|
187
|
+
_, warnings = check_result(make_result(n_cached=3))
|
|
188
|
+
assert any("cache" in warning for warning in warnings)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_check_result_warns_on_missing_metadata() -> None:
|
|
192
|
+
_, warnings = check_result(make_result(org="", license=""))
|
|
193
|
+
assert any("org metadata is empty" in warning for warning in warnings)
|
|
194
|
+
assert any("license metadata is empty" in warning for warning in warnings)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# ---------------------------------------------------------------------------
|
|
198
|
+
# validate_file / collect_json_files
|
|
199
|
+
# ---------------------------------------------------------------------------
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def test_validate_file_reports_unparsable_json(tmp_path: Path) -> None:
|
|
203
|
+
path = tmp_path / "broken.json"
|
|
204
|
+
path.write_text('{"hello": "world"}', encoding="utf-8")
|
|
205
|
+
errors, warnings = validate_file(path)
|
|
206
|
+
assert len(errors) == 1
|
|
207
|
+
assert "not a valid RunResult JSON file" in errors[0]
|
|
208
|
+
assert warnings == []
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def test_collect_json_files_expands_directories(tmp_path: Path) -> None:
|
|
212
|
+
(tmp_path / "a.json").write_text("{}", encoding="utf-8")
|
|
213
|
+
(tmp_path / "b.json").write_text("{}", encoding="utf-8")
|
|
214
|
+
(tmp_path / "ignored.txt").write_text("nope", encoding="utf-8")
|
|
215
|
+
sub = tmp_path / "sub"
|
|
216
|
+
sub.mkdir()
|
|
217
|
+
files = collect_json_files([tmp_path / "a.json", tmp_path])
|
|
218
|
+
names = [file.name for file in files]
|
|
219
|
+
assert names == ["a.json", "b.json"]
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# ---------------------------------------------------------------------------
|
|
223
|
+
# CLI
|
|
224
|
+
# ---------------------------------------------------------------------------
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def test_cli_validate_results_passes_with_warnings(tmp_path: Path) -> None:
|
|
228
|
+
path = write_result(tmp_path, make_result(20)) # subset run -> warnings
|
|
229
|
+
exit_code = runner.invoke(app, ["validate-results", str(path)]).exit_code
|
|
230
|
+
assert exit_code == 0
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def test_cli_validate_results_fails_on_drift(tmp_path: Path) -> None:
|
|
234
|
+
result = make_result()
|
|
235
|
+
result.metrics["accuracy"] = 0.123
|
|
236
|
+
path = write_result(tmp_path, result)
|
|
237
|
+
outcome = runner.invoke(app, ["validate-results", str(path)])
|
|
238
|
+
assert outcome.exit_code == 1
|
|
239
|
+
assert "FAIL" in outcome.output
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_cli_validate_results_fails_on_unparsable_file(tmp_path: Path) -> None:
|
|
243
|
+
path = tmp_path / "garbage.json"
|
|
244
|
+
path.write_text("[]", encoding="utf-8")
|
|
245
|
+
outcome = runner.invoke(app, ["validate-results", str(path)])
|
|
246
|
+
assert outcome.exit_code == 1
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def test_cli_validate_results_directory(tmp_path: Path) -> None:
|
|
250
|
+
write_result(tmp_path, make_result(20), name="one.json")
|
|
251
|
+
write_result(tmp_path, make_result(20), name="two.json")
|
|
252
|
+
(tmp_path / "notes.txt").write_text("skip me", encoding="utf-8")
|
|
253
|
+
outcome = runner.invoke(app, ["validate-results", str(tmp_path)])
|
|
254
|
+
assert outcome.exit_code == 0
|
|
255
|
+
assert "all 2 file(s) valid" in outcome.output
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_cli_validate_results_no_files_found(tmp_path: Path) -> None:
|
|
259
|
+
outcome = runner.invoke(app, ["validate-results", str(tmp_path)])
|
|
260
|
+
assert outcome.exit_code == 2
|
|
261
|
+
assert "no *.json files" in outcome.output
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
# ---------------------------------------------------------------------------
|
|
265
|
+
# Real committed results must validate cleanly (structure, not scores).
|
|
266
|
+
# ---------------------------------------------------------------------------
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
@pytest.mark.parametrize(
|
|
270
|
+
"result_file",
|
|
271
|
+
sorted((Path(__file__).parent.parent / "results").glob("*.json")),
|
|
272
|
+
ids=lambda path: path.stem,
|
|
273
|
+
)
|
|
274
|
+
def test_committed_results_have_no_errors(result_file: Path) -> None:
|
|
275
|
+
errors, _ = validate_file(result_file)
|
|
276
|
+
assert errors == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{persianeval-0.2.0 → persianeval-0.2.1}/src/persianeval/data/v1/code_with_persian_comments.jsonl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|