Fix reindex_embeddings crash: add networkx for Unstructured xlsx.
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user