Download tests_r5eval/run_all.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/tests_r5eval/run_all.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/tests_r5eval/run_all.py
-
curl -L -o run_all.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/tests_r5eval/run_all.py
1.75 kB
| """Runs every test file of r5eval (J2's unchanged scorelib test first) and prints one summary. usage: python -I run_all.py SCRATCH_DIR | |
| Exit code 0 only if all pass. Synthetic data only; scratch files go under SCRATCH_DIR.""" | |
| import os | |
| import subprocess | |
| import sys | |
| import time | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| scratch = sys.argv[1] | |
| os.makedirs(scratch, exist_ok=True) | |
| SRC = os.path.join(HERE, "..", "src", "r5eval", "frozen", "scorelib_j2.py") | |
| jobs = [("test_scorelib_j2_unchanged.py (J2's own tests, unchanged file)", ["test_scorelib_j2_unchanged.py", SRC]), | |
| ("test_core.py", ["test_core.py"]), ("test_pages.py", ["test_pages.py"]), ("test_ktrain.py", ["test_ktrain.py"]), | |
| ("test_curve.py", ["test_curve.py"]), ("test_cli.py", ["test_cli.py", os.path.join(scratch, "cli")]), | |
| ("test_report_cards.py", ["test_report_cards.py", os.path.join(scratch, "cards")]), | |
| ("test_leaders.py", ["test_leaders.py", os.path.join(scratch, "leaders")]), | |
| ("test_verdict.py", ["test_verdict.py", os.path.join(scratch, "verdict")])] | |
| bad = 0 | |
| for label, args in jobs: | |
| t0 = time.time() | |
| p = subprocess.run([sys.executable, "-I", os.path.join(HERE, args[0])] + args[1:], capture_output=True, text=True, cwd=HERE) | |
| tail = [l for l in p.stdout.strip().split("\n") if l.startswith(("tests:", "all scorelib"))] | |
| fails = [l for l in p.stdout.split("\n") if l.startswith("FAIL")] | |
| print("%-70s exit %d %s (%.1f s)" % (label, p.returncode, tail[-1] if tail else "", time.time() - t0)) | |
| for f in fails: | |
| print(" ", f) | |
| if p.returncode: | |
| bad += 1 | |
| print(p.stdout[-2500:], p.stderr[-1500:]) | |
| print("ALL PASSED" if not bad else "%d test files FAILED" % bad) | |
| sys.exit(1 if bad else 0) | |