Fix reindex_embeddings crash: add networkx for Unstructured xlsx.
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s

unstructured.partition.xlsx imports networkx; without it reindex dies
mid-run after clearing Chroma. Also skip per-document ingest failures
so one bad file cannot abort the whole rebuild.
This commit is contained in:
2026-08-02 13:54:58 -05:00
parent d8f5b8ebf2
commit 8ff3ad83d1
4 changed files with 33 additions and 1 deletions
@@ -46,7 +46,18 @@ class Command(BaseCommand):
self.stdout.write("Clearing Chroma collection…")
rag.clear_vector_store()
self.stdout.write("Re-ingesting documents…")
rag.ingest_documents()
try:
rag.ingest_documents()
except Exception as exc:
# Partial ingest may still have written some chunks; report and re-raise.
count = rag.vector_store._collection.count()
self.stderr.write(
self.style.ERROR(
f"Reindex failed after clearing Chroma ({exc}). "
f"Vector chunks currently: {count}. Fix the error and re-run."
)
)
raise
count = rag.vector_store._collection.count()
self.stdout.write(
self.style.SUCCESS(f"Reindex complete. Vector chunks now: {count}")
@@ -161,6 +161,13 @@ class RAGService(BaseService):
)
if chunks:
self.vector_store.add_documents(chunks)
except Exception:
# Keep reindex/ingest moving; one bad file must not wipe progress.
logger.exception(
"Failed to ingest document_id=%s file=%s",
doc.id,
doc.file.name,
)
finally:
if os.path.exists(tmp_path):
os.unlink(tmp_path)