diff --git a/integrations/qdrant/pyproject.toml b/integrations/qdrant/pyproject.toml index d1086fcdf..9c19d144e 100644 --- a/integrations/qdrant/pyproject.toml +++ b/integrations/qdrant/pyproject.toml @@ -35,6 +35,9 @@ Source = "https://github.com/deepset-ai/haystack-core-integrations" Documentation = "https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/qdrant/README.md" Issues = "https://github.com/deepset-ai/haystack-core-integrations/issues" +[tool.hatch.build.targets.wheel] +packages = ["src/haystack_integrations"] + [tool.hatch.version] source = "vcs" tag-pattern = 'integrations\/qdrant-v(?P.*)' @@ -71,7 +74,7 @@ dependencies = [ "ruff>=0.0.243", ] [tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/qdrant_haystack tests}" +typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}" style = [ "ruff {args:.}", "black --check --diff {args:.}", @@ -136,23 +139,18 @@ unfixable = [ "F401", ] -[tool.ruff.isort] -known-first-party = ["qdrant_haystack"] - [tool.ruff.flake8-tidy-imports] -ban-relative-imports = "all" +ban-relative-imports = "parents" [tool.ruff.per-file-ignores] # Tests can use magic values, assertions, and relative imports "tests/**/*" = ["PLR2004", "S101", "TID252"] [tool.coverage.run] -source_pkgs = ["qdrant_haystack", "tests"] +source_pkgs = ["src", "tests"] branch = true parallel = true -omit = [ - "src/qdrant_haystack/__about__.py", -] + [tool.coverage.paths] qdrant_haystack = ["src/qdrant_haystack", "*/qdrant-haystack/src/qdrant_haystack"] @@ -168,6 +166,7 @@ exclude_lines = [ [[tool.mypy.overrides]] module = [ "haystack.*", + "haystack_integrations.*", "pytest.*", "qdrant_client.*", "numpy", diff --git a/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py new file mode 100644 index 000000000..41b59e42d --- /dev/null +++ b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/__init__.py @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2023-present deepset GmbH +# +# SPDX-License-Identifier: Apache-2.0 + +from .retriever import QdrantEmbeddingRetriever + +__all__ = ("QdrantEmbeddingRetriever",) diff --git a/integrations/qdrant/src/qdrant_haystack/retriever.py b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/retriever.py similarity index 97% rename from integrations/qdrant/src/qdrant_haystack/retriever.py rename to integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/retriever.py index bf378688c..e59dca3ad 100644 --- a/integrations/qdrant/src/qdrant_haystack/retriever.py +++ b/integrations/qdrant/src/haystack_integrations/components/retrievers/qdrant/retriever.py @@ -1,8 +1,7 @@ from typing import Any, Dict, List, Optional from haystack import Document, component, default_from_dict, default_to_dict - -from qdrant_haystack import QdrantDocumentStore +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore @component diff --git a/integrations/qdrant/src/qdrant_haystack/__init__.py b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/__init__.py similarity index 70% rename from integrations/qdrant/src/qdrant_haystack/__init__.py rename to integrations/qdrant/src/haystack_integrations/document_stores/qdrant/__init__.py index 765ced0ef..dc3def997 100644 --- a/integrations/qdrant/src/qdrant_haystack/__init__.py +++ b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/__init__.py @@ -2,6 +2,6 @@ # # SPDX-License-Identifier: Apache-2.0 -from qdrant_haystack.document_store import QdrantDocumentStore +from .document_store import QdrantDocumentStore __all__ = ("QdrantDocumentStore",) diff --git a/integrations/qdrant/src/qdrant_haystack/converters.py b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/converters.py similarity index 100% rename from integrations/qdrant/src/qdrant_haystack/converters.py rename to integrations/qdrant/src/haystack_integrations/document_stores/qdrant/converters.py diff --git a/integrations/qdrant/src/qdrant_haystack/document_store.py b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/document_store.py similarity index 99% rename from integrations/qdrant/src/qdrant_haystack/document_store.py rename to integrations/qdrant/src/haystack_integrations/document_stores/qdrant/document_store.py index 4fd724f67..50dd0220c 100644 --- a/integrations/qdrant/src/qdrant_haystack/document_store.py +++ b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/document_store.py @@ -16,8 +16,8 @@ from qdrant_client.http.exceptions import UnexpectedResponse from tqdm import tqdm -from qdrant_haystack.converters import HaystackToQdrant, QdrantToHaystack -from qdrant_haystack.filters import QdrantFilterConverter +from .converters import HaystackToQdrant, QdrantToHaystack +from .filters import QdrantFilterConverter logger = logging.getLogger(__name__) diff --git a/integrations/qdrant/src/qdrant_haystack/filters.py b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/filters.py similarity index 99% rename from integrations/qdrant/src/qdrant_haystack/filters.py rename to integrations/qdrant/src/haystack_integrations/document_stores/qdrant/filters.py index cc6b2b6a5..21e29e570 100644 --- a/integrations/qdrant/src/qdrant_haystack/filters.py +++ b/integrations/qdrant/src/haystack_integrations/document_stores/qdrant/filters.py @@ -4,7 +4,7 @@ from haystack.utils.filters import COMPARISON_OPERATORS, LOGICAL_OPERATORS, FilterError from qdrant_client.http import models -from qdrant_haystack.converters import HaystackToQdrant +from .converters import HaystackToQdrant COMPARISON_OPERATORS = COMPARISON_OPERATORS.keys() LOGICAL_OPERATORS = LOGICAL_OPERATORS.keys() diff --git a/integrations/qdrant/tests/test_converters.py b/integrations/qdrant/tests/test_converters.py index dc4866293..0c6c5676a 100644 --- a/integrations/qdrant/tests/test_converters.py +++ b/integrations/qdrant/tests/test_converters.py @@ -1,9 +1,8 @@ import numpy as np import pytest +from haystack_integrations.document_stores.qdrant.converters import HaystackToQdrant, QdrantToHaystack from qdrant_client.http import models as rest -from qdrant_haystack.converters import HaystackToQdrant, QdrantToHaystack - CONTENT_FIELD = "content" NAME_FIELD = "name" EMBEDDING_FIELD = "vector" diff --git a/integrations/qdrant/tests/test_dict_converters.py b/integrations/qdrant/tests/test_dict_converters.py index 1a211655c..1c9eb36e2 100644 --- a/integrations/qdrant/tests/test_dict_converters.py +++ b/integrations/qdrant/tests/test_dict_converters.py @@ -1,11 +1,11 @@ -from qdrant_haystack import QdrantDocumentStore +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore def test_to_dict(): document_store = QdrantDocumentStore(location=":memory:", index="test") expected = { - "type": "qdrant_haystack.document_store.QdrantDocumentStore", + "type": "haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore", "init_parameters": { "location": ":memory:", "url": None, @@ -50,7 +50,7 @@ def test_to_dict(): def test_from_dict(): document_store = QdrantDocumentStore.from_dict( { - "type": "qdrant_haystack.document_store.QdrantDocumentStore", + "type": "haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore", "init_parameters": { "location": ":memory:", "index": "test", diff --git a/integrations/qdrant/tests/test_document_store.py b/integrations/qdrant/tests/test_document_store.py index 0118ae0cf..8316ee565 100644 --- a/integrations/qdrant/tests/test_document_store.py +++ b/integrations/qdrant/tests/test_document_store.py @@ -9,8 +9,7 @@ DeleteDocumentsTest, WriteDocumentsTest, ) - -from qdrant_haystack import QdrantDocumentStore +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore class TestQdrantStoreBaseTests(CountDocumentsTest, WriteDocumentsTest, DeleteDocumentsTest): diff --git a/integrations/qdrant/tests/test_filters.py b/integrations/qdrant/tests/test_filters.py index a25f4a672..848d799e4 100644 --- a/integrations/qdrant/tests/test_filters.py +++ b/integrations/qdrant/tests/test_filters.py @@ -4,8 +4,7 @@ from haystack import Document from haystack.testing.document_store import FilterDocumentsTest from haystack.utils.filters import FilterError - -from qdrant_haystack import QdrantDocumentStore +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore class TestQdrantStoreBaseTests(FilterDocumentsTest): diff --git a/integrations/qdrant/tests/test_legacy_filters.py b/integrations/qdrant/tests/test_legacy_filters.py index 957603423..ff01c3971 100644 --- a/integrations/qdrant/tests/test_legacy_filters.py +++ b/integrations/qdrant/tests/test_legacy_filters.py @@ -5,8 +5,7 @@ from haystack.document_stores.types import DocumentStore from haystack.testing.document_store import LegacyFilterDocumentsTest from haystack.utils.filters import FilterError - -from qdrant_haystack import QdrantDocumentStore +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore # The tests below are from haystack.testing.document_store.LegacyFilterDocumentsTest # Updated to include `meta` prefix for filter keys wherever necessary diff --git a/integrations/qdrant/tests/test_retriever.py b/integrations/qdrant/tests/test_retriever.py index ed220c5bc..7521642ff 100644 --- a/integrations/qdrant/tests/test_retriever.py +++ b/integrations/qdrant/tests/test_retriever.py @@ -5,9 +5,8 @@ FilterableDocsFixtureMixin, _random_embeddings, ) - -from qdrant_haystack import QdrantDocumentStore -from qdrant_haystack.retriever import QdrantEmbeddingRetriever +from haystack_integrations.components.retrievers.qdrant import QdrantEmbeddingRetriever +from haystack_integrations.document_stores.qdrant import QdrantDocumentStore class TestQdrantRetriever(FilterableDocsFixtureMixin): @@ -24,10 +23,10 @@ def test_to_dict(self): retriever = QdrantEmbeddingRetriever(document_store=document_store) res = retriever.to_dict() assert res == { - "type": "qdrant_haystack.retriever.QdrantEmbeddingRetriever", + "type": "haystack_integrations.components.retrievers.qdrant.retriever.QdrantEmbeddingRetriever", "init_parameters": { "document_store": { - "type": "qdrant_haystack.document_store.QdrantDocumentStore", + "type": "haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore", "init_parameters": { "location": ":memory:", "url": None, @@ -74,11 +73,11 @@ def test_to_dict(self): def test_from_dict(self): data = { - "type": "qdrant_haystack.retriever.QdrantEmbeddingRetriever", + "type": "haystack_integrations.components.retrievers.qdrant.retriever.QdrantEmbeddingRetriever", "init_parameters": { "document_store": { "init_parameters": {"location": ":memory:", "index": "test"}, - "type": "qdrant_haystack.document_store.QdrantDocumentStore", + "type": "haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore", }, "filters": None, "top_k": 5,