Skip to content

Commit

Permalink
tests: remove sleep calls to prevent race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
orkhank committed Nov 11, 2024
1 parent 6cd571f commit 696ee9d
Showing 1 changed file with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def test_from_texts(
index_name=INDEX_NAME,
namespace=NAMESPACE_NAME,
)
time.sleep(DEFAULT_SLEEP) # prevent race condition
output = docsearch.similarity_search(unique_id, k=1, namespace=NAMESPACE_NAME)
output[0].id = None # overwrite ID for ease of comparison
assert output == [Document(page_content=needs)]
Expand All @@ -113,7 +112,6 @@ def test_from_texts_with_metadatas(
metadatas=metadatas,
namespace=namespace,
)
time.sleep(DEFAULT_SLEEP) # prevent race condition
output = docsearch.similarity_search(needs, k=1, namespace=namespace)

output[0].id = None
Expand All @@ -133,7 +131,6 @@ def test_from_texts_with_scores(self, embedding_openai: OpenAIEmbeddings) -> Non
namespace=NAMESPACE_NAME,
)
print(texts) # noqa: T201
time.sleep(DEFAULT_SLEEP) # prevent race condition
output = docsearch.similarity_search_with_score(
"foo", k=3, namespace=NAMESPACE_NAME
)
Expand Down Expand Up @@ -178,8 +175,6 @@ def test_from_existing_index_with_namespaces(
namespace=f"{INDEX_NAME}-2",
)

time.sleep(DEFAULT_SLEEP) # prevent race condition

# Search with namespace
docsearch = PineconeVectorStore.from_existing_index(
index_name=INDEX_NAME,
Expand All @@ -203,7 +198,6 @@ def test_add_documents_with_ids(
index_name=INDEX_NAME,
namespace=NAMESPACE_NAME,
)
time.sleep(DEFAULT_SLEEP) # prevent race condition
index_stats = self.index.describe_index_stats()
assert index_stats["namespaces"][NAMESPACE_NAME]["vector_count"] == len(texts)

Expand All @@ -215,7 +209,6 @@ def test_add_documents_with_ids(
index_name=INDEX_NAME,
namespace=NAMESPACE_NAME,
)
time.sleep(DEFAULT_SLEEP) # prevent race condition
index_stats = self.index.describe_index_stats()
assert (
index_stats["namespaces"][NAMESPACE_NAME]["vector_count"] == len(texts) * 2
Expand All @@ -234,8 +227,6 @@ def test_relevance_score_bound(self, embedding_openai: OpenAIEmbeddings) -> None
index_name=INDEX_NAME,
metadatas=metadatas,
)
# wait for the index to be ready
time.sleep(DEFAULT_SLEEP)
output = docsearch.similarity_search_with_relevance_scores("foo", k=3)
print(output) # noqa: T201
assert all(
Expand Down

0 comments on commit 696ee9d

Please sign in to comment.