ocr: the surya deep check imported a module that does not exist

My own check broke the build: `from surya.common.surya.schema import
TaskNames` is not a path in surya-ocr 0.22.1, so the ocr image failed with
ModuleNotFoundError at the venv deep check — I wrote an import from memory
instead of reading what the worker uses.

It now imports what codai/ocr/workers/ocr_worker.py actually constructs,
DetectionPredictor and RecognitionPredictor, and keeps the pillow assertion.
The test asserts those paths are present and that the invented one is gone.
Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
parent 76f41f65
# Deep check for the surya venv: the vLLM-backed path must import, not just the # Deep check for the surya venv. The generic step already proved `import surya`;
# package. surya's vLLM client is what talks to the pod, and an import error # this proves the predictors the worker actually constructs are importable, and
# here is the difference between a working /v1/ocr and one that is never ready. # that the pillow pin held — surya caps pillow<11 and a resolver that quietly
import surya # noqa # brought 12 in would break image loading at the first page, not here.
from surya.common.surya.schema import TaskNames # noqa
from PIL import Image
import PIL import PIL
from PIL import Image # noqa
assert int(PIL.__version__.split(".")[0]) < 11, f"pillow {PIL.__version__} — surya caps <11" assert int(PIL.__version__.split(".")[0]) < 11, f"pillow {PIL.__version__} — surya caps <11"
# 0.17+ layout. codai/ocr/workers/ocr_worker.py falls back to the older
# surya.model.* path at runtime, so only the modern one is required here.
from surya.detection import DetectionPredictor # noqa
from surya.recognition import RecognitionPredictor # noqa
import surya
print("surya", getattr(surya, "__version__", "ok"), "pillow", PIL.__version__) print("surya", getattr(surya, "__version__", "ok"), "pillow", PIL.__version__)
...@@ -149,7 +149,13 @@ def test_the_ocr_image_bakes_a_surya_venv(): ...@@ -149,7 +149,13 @@ def test_the_ocr_image_bakes_a_surya_venv():
assert "surya-ocr==0.22.1" in body assert "surya-ocr==0.22.1" in body
assert "pillow<11" in body, "without the cap the resolver may pull pillow 12 in" assert "pillow<11" in body, "without the cap the resolver may pull pillow 12 in"
# The check must prove the pillow pin held, not just that surya imports. # The check must prove the pillow pin held, not just that surya imports.
assert "pillow" in chk.read_text().lower() body = chk.read_text()
assert "pillow" in body.lower()
# And it must import module paths that actually exist in 0.22.1 — an
# invented one fails the build with ModuleNotFoundError at the deep check.
assert "from surya.detection import DetectionPredictor" in body
assert "from surya.recognition import RecognitionPredictor" in body
assert "surya.common.surya" not in body, "that module path does not exist"
# ------------------------------------- bug 3: one image = orchestrator + GUI # ------------------------------------- bug 3: one image = orchestrator + GUI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment