refactor: Mark MilvusDocumentStore as deprecated (#4498)

* Mark MilvusDocumentStore as deprecated

* Fix mypy
This commit is contained in:
Silvano Cerza 2023-03-27 15:31:48 +02:00 committed by GitHub
parent 5b63c2086e
commit 3b5223fa1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -16,7 +16,7 @@ except (ImportError, ModuleNotFoundError) as ie:
_optional_component_not_installed(__name__, "milvus2", ie)
from haystack.schema import Document, FilterType
from haystack.document_stores.sql import SQLDocumentStore
from haystack.document_stores import SQLDocumentStore
from haystack.document_stores.base import get_batches_from_generator
from haystack.nodes.retriever import DenseRetriever
@ -128,6 +128,11 @@ class MilvusDocumentStore(SQLDocumentStore):
lost if you choose to recreate the index. Be aware that both the document_index and the label_index will
be recreated.
"""
warnings.warn(
"The MilvusDocumentStore node is deprecated and will be removed in future versions.",
category=DeprecationWarning,
)
super().__init__(
url=sql_url, index=index, duplicate_documents=duplicate_documents, isolation_level=isolation_level
)

View File

@ -1,10 +1,13 @@
import pytest
import numpy as np
from unittest.mock import patch, DEFAULT
from haystack.document_stores.milvus import MilvusDocumentStore
from haystack.schema import Document
from haystack.testing import DocumentStoreBaseTestAbstract
from ..conftest import fail_at_version
class TestMilvusDocumentStore(DocumentStoreBaseTestAbstract):
@pytest.fixture
@ -47,6 +50,23 @@ class TestMilvusDocumentStore(DocumentStoreBaseTestAbstract):
return documents
@pytest.mark.unit
@fail_at_version(1, 17)
def test_deprecation_warning(self):
with patch.multiple(
"haystack.document_stores.milvus",
SQLDocumentStore=DEFAULT,
FieldSchema=DEFAULT,
CollectionSchema=DEFAULT,
Collection=DEFAULT,
connections=DEFAULT,
utility=DEFAULT,
QueryResult=DEFAULT,
DataType=DEFAULT,
):
with pytest.warns(DeprecationWarning):
MilvusDocumentStore()
@pytest.mark.integration
def test_delete_index(self, ds, documents):
"""Contrary to other Document Stores, MilvusDocumentStore doesn't raise if the index is empty"""