Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact!:change import paths #255

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions integrations/qdrant/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>.*)'
Expand Down Expand Up @@ -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:.}",
Expand Down Expand Up @@ -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"]
Expand All @@ -168,6 +166,7 @@ exclude_lines = [
[[tool.mypy.overrides]]
module = [
"haystack.*",
"haystack_integrations.*",
"pytest.*",
"qdrant_client.*",
"numpy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

from .retriever import QdrantEmbeddingRetriever

__all__ = ("QdrantEmbeddingRetriever",)
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

from qdrant_haystack.document_store import QdrantDocumentStore
from .document_store import QdrantDocumentStore

__all__ = ("QdrantDocumentStore",)
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions integrations/qdrant/tests/test_converters.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions integrations/qdrant/tests/test_dict_converters.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions integrations/qdrant/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
DeleteDocumentsTest,
WriteDocumentsTest,
)

from qdrant_haystack import QdrantDocumentStore
from haystack_integrations.document_stores.qdrant import QdrantDocumentStore


class TestQdrantStoreBaseTests(CountDocumentsTest, WriteDocumentsTest, DeleteDocumentsTest):
Expand Down
3 changes: 1 addition & 2 deletions integrations/qdrant/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions integrations/qdrant/tests/test_legacy_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions integrations/qdrant/tests/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down