chore: removing deprecated SentenceWindowRetrieval (#8294)

* removing deprecated SentenceWindowRetrieval

* adding release notes

* Rename TestSentenceWindowRetrieval to TestSentenceWindowRetriever

---------

Co-authored-by: Julian Risch <julian.risch@deepset.ai>
This commit is contained in:
David S. Batista 2024-08-28 10:04:52 +02:00 committed by GitHub
parent 25d333bed3
commit 2f3257b77a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 34 deletions

View File

@ -5,13 +5,6 @@
from haystack.components.retrievers.filter_retriever import FilterRetriever
from haystack.components.retrievers.in_memory.bm25_retriever import InMemoryBM25Retriever
from haystack.components.retrievers.in_memory.embedding_retriever import InMemoryEmbeddingRetriever
from haystack.components.retrievers.sentence_window_retrieval import SentenceWindowRetrieval
from haystack.components.retrievers.sentence_window_retriever import SentenceWindowRetriever
__all__ = [
"FilterRetriever",
"InMemoryEmbeddingRetriever",
"InMemoryBM25Retriever",
"SentenceWindowRetriever",
"SentenceWindowRetrieval",
]
__all__ = ["FilterRetriever", "InMemoryEmbeddingRetriever", "InMemoryBM25Retriever", "SentenceWindowRetriever"]

View File

@ -1,22 +0,0 @@
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
#
# SPDX-License-Identifier: Apache-2.0
import warnings
from .sentence_window_retriever import SentenceWindowRetriever
class SentenceWindowRetrieval(SentenceWindowRetriever):
"""
This class is deprecated. Please use `SentenceWindowRetriever` instead.
"""
def __init__(self, *args, **kwargs):
warnings.warn(
"The class `SentenceWindowRetrieval` is deprecated and will be removed in a future release. "
"Please use `SentenceWindowRetriever` instead.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Removing deprecated `SentenceWindowRetrieval`, replaced by `SentenceWindowRetriever`

View File

@ -1,16 +1,15 @@
from haystack.components.retrievers.sentence_window_retrieval import SentenceWindowRetrieval
from haystack.components.retrievers.sentence_window_retriever import SentenceWindowRetriever
from haystack.document_stores.in_memory import InMemoryDocumentStore
from unittest.mock import patch
class TestSentenceWindowRetrieval:
class TestSentenceWindowRetriever:
def test_init_default(self):
retriever = SentenceWindowRetrieval(InMemoryDocumentStore())
retriever = SentenceWindowRetriever(InMemoryDocumentStore())
assert retriever.window_size == 3
def test_init_calls_parent(self):
with patch.object(SentenceWindowRetriever, "__init__", return_value=None) as mock_init:
document_store = InMemoryDocumentStore()
retriever = SentenceWindowRetrieval(document_store)
retriever = SentenceWindowRetriever(document_store)
mock_init.assert_called_once_with(document_store)