Skip to content

Commit

Permalink
change import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Jan 22, 2024
1 parent f8efcfe commit 98561d0
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 27 deletions.
10 changes: 7 additions & 3 deletions integrations/pinecone/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/m
Issues = "https://github.com/deepset-ai/haystack-core-integrations/issues"
Source = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/pinecone"

[tool.hatch.build.targets.wheel]
packages = ["src/haystack_integrations"]

[tool.hatch.version]
source = "vcs"
tag-pattern = 'integrations\/pinecone-v(?P<version>.*)'
Expand Down Expand Up @@ -74,7 +77,7 @@ dependencies = [
"numpy",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/pinecone_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 @@ -146,7 +149,7 @@ unfixable = [
known-first-party = ["pinecone_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
Expand All @@ -157,7 +160,7 @@ source_pkgs = ["pinecone_haystack", "tests"]
branch = true
parallel = true
omit = [
"example"
"examples"
]

[tool.coverage.paths]
Expand All @@ -182,6 +185,7 @@ markers = [
module = [
"pinecone.*",
"haystack.*",
"haystack_integrations.*",
"pytest.*"
]
ignore_missing_imports = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .dense_retriever import PineconeDenseRetriever

__all__ = ["PineconeDenseRetriever"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from haystack import component, default_from_dict, default_to_dict
from haystack.dataclasses import Document

from pinecone_haystack.document_store import PineconeDocumentStore
from haystack_integrations.document_stores.pinecone import PineconeDocumentStore


@component
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
from .document_store import PineconeDocumentStore

__all__ = ["PineconeDocumentStore"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
from typing import Any, Dict, List, Optional

import pandas as pd
import pinecone
from haystack import default_to_dict
from haystack.dataclasses import Document
from haystack.document_stores.types import DuplicatePolicy
from haystack.utils.filters import convert

from pinecone_haystack.filters import _normalize_filters
import pinecone

from .filters import _normalize_filters

logger = logging.getLogger(__name__)

Expand Down
7 changes: 0 additions & 7 deletions integrations/pinecone/src/pinecone_haystack/__init__.py

This file was deleted.

3 changes: 1 addition & 2 deletions integrations/pinecone/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import pytest
from haystack.document_stores.types import DuplicatePolicy

from pinecone_haystack.document_store import PineconeDocumentStore
from haystack_integrations.document_stores.pinecone import PineconeDocumentStore

# This is the approximate time it takes for the documents to be available
SLEEP_TIME = 20
Expand Down
17 changes: 8 additions & 9 deletions integrations/pinecone/tests/test_dense_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from unittest.mock import Mock, patch

from haystack.dataclasses import Document

from pinecone_haystack.dense_retriever import PineconeDenseRetriever
from pinecone_haystack.document_store import PineconeDocumentStore
from haystack_integrations.components.retrievers.pinecone import PineconeDenseRetriever
from haystack_integrations.document_stores.pinecone import PineconeDocumentStore


def test_init_default():
Expand All @@ -17,7 +16,7 @@ def test_init_default():
assert retriever.top_k == 10


@patch("pinecone_haystack.document_store.pinecone")
@patch("haystack_integrations.document_stores.pinecone.document_store.pinecone")
def test_to_dict(mock_pinecone):
mock_pinecone.Index.return_value.describe_index_stats.return_value = {"dimension": 512}
document_store = PineconeDocumentStore(
Expand All @@ -31,7 +30,7 @@ def test_to_dict(mock_pinecone):
retriever = PineconeDenseRetriever(document_store=document_store)
res = retriever.to_dict()
assert res == {
"type": "pinecone_haystack.dense_retriever.PineconeDenseRetriever",
"type": "haystack_integrations.components.retrievers.pinecone.dense_retriever.PineconeDenseRetriever",
"init_parameters": {
"document_store": {
"init_parameters": {
Expand All @@ -41,18 +40,18 @@ def test_to_dict(mock_pinecone):
"batch_size": 50,
"dimension": 512,
},
"type": "pinecone_haystack.document_store.PineconeDocumentStore",
"type": "haystack_integrations.document_stores.pinecone.document_store.PineconeDocumentStore",
},
"filters": {},
"top_k": 10,
},
}


@patch("pinecone_haystack.document_store.pinecone")
@patch("haystack_integrations.document_stores.pinecone.document_store.pinecone")
def test_from_dict(mock_pinecone, monkeypatch):
data = {
"type": "pinecone_haystack.dense_retriever.PineconeDenseRetriever",
"type": "haystack_integrations.components.retrievers.pinecone.dense_retriever.PineconeDenseRetriever",
"init_parameters": {
"document_store": {
"init_parameters": {
Expand All @@ -62,7 +61,7 @@ def test_from_dict(mock_pinecone, monkeypatch):
"batch_size": 50,
"dimension": 512,
},
"type": "pinecone_haystack.document_store.PineconeDocumentStore",
"type": "haystack_integrations.document_stores.pinecone.document_store.PineconeDocumentStore",
},
"filters": {},
"top_k": 10,
Expand Down
4 changes: 2 additions & 2 deletions integrations/pinecone/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import pytest
from haystack import Document
from haystack.testing.document_store import CountDocumentsTest, DeleteDocumentsTest, WriteDocumentsTest

from pinecone_haystack.document_store import PineconeDocumentStore
from haystack_integrations.document_stores.pinecone import PineconeDocumentStore


@pytest.mark.integration
class TestDocumentStore(CountDocumentsTest, DeleteDocumentsTest, WriteDocumentsTest):
def test_write_documents(self, document_store: PineconeDocumentStore):
docs = [Document(id="1")]
Expand Down
1 change: 1 addition & 0 deletions integrations/pinecone/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)


@pytest.mark.integration
class TestFilters(FilterDocumentsTest):
def assert_documents_are_equal(self, received: List[Document], expected: List[Document]):
for doc in received:
Expand Down

0 comments on commit 98561d0

Please sign in to comment.