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
@@ -726,6 +726,7 @@ class PDFHighlighter:
|
||||
return results
|
||||
|
||||
temp_pdf_path = None
|
||||
doc = None
|
||||
try:
|
||||
temp_dir = Path(tempfile.mkdtemp(prefix="pdf_bbox_batch_"))
|
||||
temp_pdf_path = temp_dir / "pdf.pdf"
|
||||
@@ -737,7 +738,7 @@ class PDFHighlighter:
|
||||
chunk_index,
|
||||
start_offset,
|
||||
end_offset,
|
||||
stored_page_num,
|
||||
_,
|
||||
chunk_text,
|
||||
) in chunks:
|
||||
chunk_page_info = PDFHighlighter.find_chunk_page(
|
||||
@@ -781,7 +782,6 @@ class PDFHighlighter:
|
||||
)
|
||||
results[chunk_index] = ([normalized], page_num)
|
||||
|
||||
doc.close()
|
||||
logger.info(f"Computed bboxes for {len(results)}/{len(chunks)} chunks")
|
||||
return results
|
||||
|
||||
@@ -790,6 +790,8 @@ class PDFHighlighter:
|
||||
return results
|
||||
|
||||
finally:
|
||||
if doc is not None:
|
||||
doc.close()
|
||||
if temp_pdf_path and temp_pdf_path.parent.exists():
|
||||
try:
|
||||
shutil.rmtree(temp_pdf_path.parent)
|
||||
|
||||
Reference in New Issue
Block a user