Skip to content

Commit 98e8b8c

Browse files
fffoivosclaude
andcommitted
tests: add runner default-resolution coverage for vLLM defaults
Forward-port test_runner_resolves_standard_vllm_defaults_when_omitted from codex/ocr-vllm-defaults-refactor. Asserts that calling run_for_files with runtime_backend="vllm" and explicit None for render_dpi / gpu_memory_utilization resolves to DEFAULT_RENDER_DPI and DEFAULT_GPU_MEMORY_UTILIZATION respectively. Pins the contract that "None means default" rather than "None means unset". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fad78e6 commit 98e8b8c

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/test_deepseek_runner_contract.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,46 @@ def fake_run_cli(input_dir, output_dir, **kwargs):
615615
assert result["doc"]["page_count"] == 1
616616

617617

618+
def test_runner_resolves_standard_vllm_defaults_when_omitted(tmp_path, monkeypatch):
619+
from glossapi.ocr.deepseek import runner
620+
from glossapi.ocr.deepseek.defaults import DEFAULT_GPU_MEMORY_UTILIZATION, DEFAULT_RENDER_DPI
621+
622+
corpus = _mk_corpus(tmp_path)
623+
(corpus.input_dir / "doc.pdf").write_bytes(b"%PDF-1.4\n%real\n")
624+
625+
calls = {}
626+
627+
def fake_run_cli(input_dir, output_dir, **kwargs):
628+
calls["input_dir"] = input_dir
629+
calls["kwargs"] = dict(kwargs)
630+
md_dir = output_dir / "markdown"
631+
metrics_dir = output_dir / "json" / "metrics"
632+
md_dir.mkdir(parents=True, exist_ok=True)
633+
metrics_dir.mkdir(parents=True, exist_ok=True)
634+
(md_dir / "doc.md").write_text("ok\n", encoding="utf-8")
635+
(metrics_dir / "doc.metrics.json").write_text('{"page_count": 1}', encoding="utf-8")
636+
637+
monkeypatch.setattr(runner, "_run_cli", fake_run_cli)
638+
monkeypatch.setenv("GLOSSAPI_DEEPSEEK_MODEL_DIR", str(tmp_path))
639+
monkeypatch.setenv(
640+
"GLOSSAPI_DEEPSEEK_RUNNER_SCRIPT",
641+
str(Path(runner.__file__).resolve().parent / "run_pdf_ocr_vllm.py"),
642+
)
643+
monkeypatch.setenv("GLOSSAPI_DEEPSEEK_PYTHON", sys.executable)
644+
645+
runner.run_for_files(
646+
corpus,
647+
["doc.pdf"],
648+
runtime_backend="vllm",
649+
render_dpi=None,
650+
gpu_memory_utilization=None,
651+
)
652+
653+
assert calls["input_dir"] == corpus.input_dir.resolve()
654+
assert calls["kwargs"]["render_dpi"] == DEFAULT_RENDER_DPI
655+
assert calls["kwargs"]["gpu_memory_utilization"] == DEFAULT_GPU_MEMORY_UTILIZATION
656+
657+
618658
def test_runner_prefers_repo_local_deepseek_runtime_when_env_missing(tmp_path, monkeypatch):
619659
from glossapi.ocr.deepseek import runner, runtime_paths
620660

0 commit comments

Comments
 (0)