FastAPI service wrapping the Surya-OCR-2 model (datalab-to) served through vLLM: legacy /v1/api/ai/* endpoints, an OpenAI-compatible /v1/chat/completions endpoint, a coalescing request batcher, a local OCR CLI, Docker packaging, multilingual example outputs, and quantization/concurrency benchmarks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from scripts.quant.aggregate import SUMMARY_FIELDS, build_row, rows_to_csv, rows_to_markdown
|
|
|
|
|
|
def test_build_row_defaults_unset_fields_to_none():
|
|
row = build_row(method="awq", status="ok", t4_deployable=True, mean_cer=0.01)
|
|
assert row["method"] == "awq"
|
|
assert row["status"] == "ok"
|
|
assert row["t4_deployable"] is True
|
|
assert row["mean_cer"] == 0.01
|
|
assert row["throughput_rps"] is None
|
|
assert set(row.keys()) == set(SUMMARY_FIELDS)
|
|
|
|
|
|
def test_build_row_rejects_unknown_field():
|
|
try:
|
|
build_row(method="awq", bogus=1)
|
|
assert False, "expected KeyError"
|
|
except KeyError as exc:
|
|
assert "bogus" in str(exc)
|
|
|
|
|
|
def test_rows_to_csv_has_header_and_order():
|
|
rows = [build_row(method="bf16", status="ok")]
|
|
csv_text = rows_to_csv(rows)
|
|
assert csv_text.splitlines()[0] == ",".join(SUMMARY_FIELDS)
|
|
assert "bf16" in csv_text.splitlines()[1]
|
|
|
|
|
|
def test_rows_to_markdown_renders_failed_row():
|
|
rows = [build_row(method="gptq", status="failed", error="OOM at load")]
|
|
md = rows_to_markdown(rows)
|
|
assert "| gptq |" in md
|
|
assert "failed" in md
|
|
assert "OOM at load" in md
|