-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move milvus tests to their own module (#3596)
- Loading branch information
Showing
3 changed files
with
134 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from haystack.document_stores.milvus import MilvusDocumentStore | ||
from haystack.schema import Document | ||
|
||
from .test_base import DocumentStoreBaseTestAbstract | ||
|
||
|
||
class TestMilvusDocumentStore(DocumentStoreBaseTestAbstract): | ||
@pytest.fixture | ||
def ds(self, tmp_path): | ||
db_url = f"sqlite:///{tmp_path}/haystack_test_milvus.db" | ||
return MilvusDocumentStore(sql_url=db_url, return_embedding=True) | ||
|
||
@pytest.fixture | ||
def documents(self): | ||
""" | ||
write_documents will raise an exception if receives a document without | ||
embeddings, so we customize the documents fixture and always provide | ||
embeddings | ||
""" | ||
documents = [] | ||
for i in range(3): | ||
documents.append( | ||
Document( | ||
content=f"A Foo Document {i}", | ||
meta={"name": f"name_{i}", "year": "2020", "month": "01", "numbers": [2, 4]}, | ||
embedding=np.random.rand(768).astype(np.float32), | ||
) | ||
) | ||
|
||
documents.append( | ||
Document( | ||
content=f"A Bar Document {i}", | ||
meta={"name": f"name_{i}", "year": "2021", "month": "02", "numbers": [-2, -4]}, | ||
embedding=np.random.rand(768).astype(np.float32), | ||
) | ||
) | ||
|
||
documents.append( | ||
Document( | ||
content=f"Document {i}", | ||
meta={"name": f"name_{i}", "month": "03"}, | ||
embedding=np.random.rand(768).astype(np.float32), | ||
) | ||
) | ||
|
||
return documents | ||
|
||
@pytest.mark.integration | ||
def test_delete_index(self, ds, documents): | ||
"""Contrary to other Document Stores, MilvusDocumentStore doesn't raise if the index is empty""" | ||
ds.write_documents(documents, index="custom_index") | ||
assert ds.get_document_count(index="custom_index") == len(documents) | ||
ds.delete_index(index="custom_index") | ||
assert ds.get_document_count(index="custom_index") == 0 | ||
|
||
# NOTE: MilvusDocumentStore derives from the SQL one and behaves differently to the others when filters are applied. | ||
# While this should be considered a bug, the relative tests are skipped in the meantime | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_ne_filters(self, ds, documents): | ||
pass | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_nin_filters(self, ds, documents): | ||
pass | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_comparison_filters(self, ds, documents): | ||
pass | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_nested_condition_filters(self, ds, documents): | ||
pass | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_nested_condition_not_filters(self, ds, documents): | ||
pass | ||
|
||
# NOTE: again inherithed from the SQLDocumentStore, labels metadata are not supported | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_delete_labels_by_filter(self, ds, labels): | ||
pass | ||
|
||
@pytest.mark.skip | ||
@pytest.mark.integration | ||
def test_delete_labels_by_filter_id(self, ds, labels): | ||
pass |