refactor(vector): address PR #775 review — drop unused payload key, fix resource leaks
- Drop chunk_bbox_page from Qdrant payload — viz endpoints never read it (page_number is the canonical PDF page field). - Bump upsert BATCH_SIZE 10 → 100 now that payloads no longer carry PNGs. - compute_chunk_bboxes_batch: move doc.close() into finally, replace unused stored_page_num with _. - purge_page_images.py: switch to anyio.run() per project convention, and wrap AsyncQdrantClient in try/finally so the aiohttp session is always closed (the class doesn't implement async-context-manager). - Decorate new bbox unit tests with @pytest.mark.unit so they run under the fast-feedback selector. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
ee402ea00e
commit
80b27b1bc6
@@ -37,6 +37,7 @@ def _page_boundaries(pages: list[str]) -> tuple[list[dict], str]:
|
||||
return boundaries, "".join(parts)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_compute_chunk_bboxes_returns_normalized_rects():
|
||||
"""Each returned bbox should be 4 floats in [0, 1] tagged with the page."""
|
||||
pages = [
|
||||
@@ -89,6 +90,7 @@ def test_compute_chunk_bboxes_returns_normalized_rects():
|
||||
assert 0.0 <= y0 < y1 <= 1.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_compute_chunk_bboxes_empty_input():
|
||||
assert (
|
||||
PDFHighlighter.compute_chunk_bboxes_batch(
|
||||
@@ -101,6 +103,7 @@ def test_compute_chunk_bboxes_empty_input():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize("page_index", [0, 1])
|
||||
def test_compute_chunk_bboxes_assigns_correct_page(page_index: int):
|
||||
"""Verify the page number returned matches the page the chunk lives on."""
|
||||
|
||||
Reference in New Issue
Block a user