Skip to content

Commit 3319ef6

Browse files
masciZanSara
andauthored
refactor: refactor FAISS tests (#3537)
* fix write docs behaviour * refactor FAISS tests * do not remove the sqlite db * try * remove extra slash * Apply suggestions from code review Co-authored-by: Sara Zan <[email protected]> * review comments * Update test/document_stores/test_faiss.py Co-authored-by: Sara Zan <[email protected]> * review comments Co-authored-by: Sara Zan <[email protected]>
1 parent 9539a20 commit 3319ef6

File tree

3 files changed

+266
-364
lines changed

3 files changed

+266
-364
lines changed

.github/workflows/tests.yml

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,41 @@ jobs:
295295
status: ${{ job.status }}
296296
channel: '#haystack'
297297
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
298+
299+
integration-tests-faiss:
300+
name: Integration / faiss / ${{ matrix.os }}
301+
needs:
302+
- unit-tests
303+
strategy:
304+
fail-fast: false
305+
matrix:
306+
os: [ubuntu-latest,macos-latest,windows-latest]
307+
runs-on: ${{ matrix.os }}
308+
steps:
309+
- uses: actions/checkout@v3
310+
311+
- name: Setup Python
312+
uses: ./.github/actions/python_cache/
313+
314+
- name: Install Haystack
315+
run: pip install -U .
316+
317+
- name: Run tests
318+
run: |
319+
pytest --maxfail=5 -m "document_store and integration" test/document_stores/test_faiss.py
320+
321+
- uses: act10ns/slack@v1
322+
with:
323+
status: ${{ job.status }}
324+
channel: '#haystack'
325+
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
326+
327+
298328
#
299329
# TODO: the following steps need to be revisited
300330
#
301331

332+
302333
unit-tests-linux:
303334
needs: [mypy, pylint, black]
304335
strategy:
@@ -392,73 +423,6 @@ jobs:
392423
channel: '#haystack'
393424
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
394425

395-
faiss-tests-linux:
396-
needs:
397-
- mypy
398-
- pylint
399-
runs-on: ubuntu-latest
400-
if: contains(github.event.pull_request.labels.*.name, 'topic:faiss') || !github.event.pull_request.draft
401-
402-
steps:
403-
- uses: actions/checkout@v3
404-
405-
- name: Setup Python
406-
uses: ./.github/actions/python_cache/
407-
408-
# TODO Let's try to remove this one from the unit tests
409-
- name: Install pdftotext
410-
run: wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.04.tar.gz && tar -xvf xpdf-tools-linux-4.04.tar.gz && sudo cp xpdf-tools-linux-4.04/bin64/pdftotext /usr/local/bin
411-
412-
- name: Install Haystack
413-
run: pip install .[faiss]
414-
415-
- name: Run tests
416-
env:
417-
TOKENIZERS_PARALLELISM: 'false'
418-
run: |
419-
pytest ${{ env.PYTEST_PARAMS }} -m "faiss and not integration" test/document_stores/ --document_store_type=faiss
420-
421-
- uses: act10ns/slack@v1
422-
with:
423-
status: ${{ job.status }}
424-
channel: '#haystack'
425-
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
426-
427-
faiss-tests-windows:
428-
needs:
429-
- mypy
430-
- pylint
431-
runs-on: windows-latest
432-
if: contains(github.event.pull_request.labels.*.name, 'topic:faiss') && contains(github.event.pull_request.labels.*.name, 'topic:windows') || !github.event.pull_request.draft || !github.event.pull_request.draft
433-
434-
steps:
435-
- uses: actions/checkout@v3
436-
437-
- name: Setup Python
438-
uses: ./.github/actions/python_cache/
439-
with:
440-
prefix: windows
441-
442-
- name: Install pdftotext
443-
run: |
444-
choco install xpdf-utils
445-
choco install openjdk11
446-
refreshenv
447-
- name: Install Haystack
448-
run: pip install .[faiss]
449-
450-
- name: Run tests
451-
env:
452-
TOKENIZERS_PARALLELISM: 'false'
453-
run: |
454-
pytest ${{ env.PYTEST_PARAMS }} -m "faiss and not integration" ${{ env.SUITES_EXCLUDED_FROM_WINDOWS }} test/document_stores/ --document_store_type=faiss
455-
456-
- uses: act10ns/slack@v1
457-
with:
458-
status: ${{ job.status }}
459-
channel: '#haystack'
460-
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
461-
462426
milvus-tests-linux:
463427
needs: [mypy, pylint, black]
464428
runs-on: ubuntu-latest

haystack/document_stores/faiss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def write_documents(
258258
documents=document_objects, index=index, duplicate_documents=duplicate_documents
259259
)
260260
if len(document_objects) > 0:
261-
add_vectors = False if document_objects[0].embedding is None else True
261+
add_vectors = all(doc.embedding is not None for doc in document_objects)
262262

263263
if self.duplicate_documents == "overwrite" and add_vectors:
264264
logger.warning(
@@ -494,7 +494,7 @@ def delete_all_documents(
494494
raise NotImplementedError("FAISSDocumentStore does not support headers.")
495495

496496
logger.warning(
497-
"""DEPRECATION WARNINGS:
497+
"""DEPRECATION WARNINGS:
498498
1. delete_all_documents() method is deprecated, please use delete_documents method
499499
For more details, please refer to the issue: https://github.com/deepset-ai/haystack/issues/1045
500500
"""

0 commit comments

Comments
 (0)