ocr: say which pipeline actually ran (v0.3.75)

`_read_on_pods` returned None in silence when no pod could serve, and the caller
then read the document locally. So an install configured for the pod-side
pipeline could fall back on EVERY request and look exactly like a success: the
OCR works, the text is right, and the operator concludes the new path is working
when it has never run once. A test that cannot distinguish the two paths proves
nothing about either.

Both paths now announce themselves in one line -- the fallback naming the CAUSE
("placement answered 'local' — nothing rented, or the pool could not serve")
rather than only the effect, and the success saying the pages were rasterised
and read on the pods rather than here.

Found while answering "can I launch the new OCR to test?", which is exactly when
it mattered: the answer was yes, and the test would have been uninterpretable.
Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXRMe9ZPUQCCCtBai9uqt3
parent bd855536
......@@ -16,7 +16,7 @@
# Canonical product version for CoderAI — single source of truth. Both the API
# metadata and the admin web UI read from here.
__version__ = "0.3.74"
__version__ = "0.3.75"
__tagline__ = "Complete orchestration, distribution and escalation of remotizable advanced inference."
# Configure the CUDA caching allocator BEFORE torch is imported anywhere.
......
......@@ -1328,11 +1328,27 @@ class OcrManager:
# At least one page had no pod. Do the WHOLE document locally rather
# than stitch two pipelines together: a document read half one way
# and half the other is the hardest kind of result to explain.
#
# SAY SO. This used to return None in silence, which meant a
# deployment could be configured for the pod-side pipeline, fall
# back to the local one on every request, and look exactly like a
# success -- the operator would conclude the new path worked when it
# had never run. One line is the difference between a test that
# proves something and a test that proves nothing.
_n = sum(1 for r in got if r is None)
print(f"[ocr] the pod-side pipeline was configured for {model_id!r} "
f"but {_n} of {len(parts)} page(s) had no pod to run it "
f"(placement answered 'local' — nothing rented, or the pool "
f"could not serve) — reading the WHOLE document here instead",
flush=True)
return None
bad = [r for r in got if isinstance(r, BaseException)]
if bad:
raise bad[0]
print(f"[ocr] read {len(parts)} page(s) ON THE PODS for {model_id!r}: "
f"each page went as a one-page PDF and was rasterised and read "
f"there, not here", flush=True)
pages, blank, stamps, sigs = [], [], [], []
served = ""
for idx, res in enumerate(got):
......
......@@ -449,3 +449,22 @@ def test_an_unreachable_pod_is_a_503(monkeypatch):
om._post_page_to_pod("https://1.2.3.4:8000/v1", "", b"x", "0.pdf",
0, {}, None)
assert e.value.status == 503
# ------------------------------------------- which path ran must be visible #
def test_a_silent_fallback_would_make_a_test_prove_nothing():
"""An install configured for the pod-side pipeline that falls back on every
request looks EXACTLY like a success. Without a line in the log an operator
would conclude the new path worked when it had never run -- so both the
fallback and the success say which one happened."""
src = (ROOT / "codai/ocr/manager.py").read_text()
fn = src.split("async def _read_on_pods")[1].split("\n def ")[0]
assert "but {_n} of {len(parts)} page(s) had no pod" in fn
assert "ON THE PODS" in fn
def test_the_fallback_message_names_the_cause_not_just_the_effect():
src = (ROOT / "codai/ocr/manager.py").read_text()
fn = src.split("async def _read_on_pods")[1].split("\n def ")[0]
assert "placement answered 'local'" in fn
assert "nothing rented" in fn
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