Skip to content

Commit

Permalink
simplified tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Dec 19, 2023
1 parent 7ee262c commit f5c5028
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 761 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pinecone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# Pinecone tests are time expensive, so the matrix is limited to Python 3.9 and 3.10
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion integrations/pinecone/src/pinecone_haystack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present John Doe <[email protected]>
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
from pinecone_haystack.document_store import PineconeDocumentStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _embedding_retrieval(
self,
query_embedding: List[float],
*,
filters: Optional[Dict[str, Any]] = None, # noqa: ARG002
filters: Optional[Dict[str, Any]] = None, # noqa: ARG002 (filters to be implemented)
top_k: int = 10,
) -> List[Document]:
"""
Expand Down
2 changes: 1 addition & 1 deletion integrations/pinecone/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-FileCopyrightText: 2023-present John Doe <[email protected]>
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
46 changes: 46 additions & 0 deletions integrations/pinecone/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import time
from random import randint

import pytest

from pinecone_haystack.document_store import PineconeDocumentStore

# This is the approximate time it takes for the documents to be available
SLEEP_TIME = 17


@pytest.fixture()
def sleep_time():
return SLEEP_TIME


@pytest.fixture
def document_store(request):
"""
This is the most basic requirement for the child class: provide
an instance of this document store so the base class can use it.
"""
environment = "gcp-starter"
index = "default"
# Use a different namespace for each test so we can run them in parallel
namespace = f"{request.node.name}-{randint(0, 1000)}" # noqa: S311 Ruff complains about using random numbers for cryptographic purposes
dimension = 10

store = PineconeDocumentStore(
environment=environment,
index=index,
namespace=namespace,
dimension=dimension,
)

# Override the count_documents method to wait for the documents to be available
original_count_documents = store.count_documents

def count_documents_sleep():
time.sleep(SLEEP_TIME)
return original_count_documents()

store.count_documents = count_documents_sleep

yield store
store._index.delete(delete_all=True, namespace=namespace)
Loading

0 comments on commit f5c5028

Please sign in to comment.