-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: 'Test aiohttp dependencies' | ||
description: 'Runs asyncio sanity test with specific aiohttp dependencies' | ||
|
||
inputs: | ||
PINECONE_API_KEY: | ||
description: 'The Pinecone API key' | ||
required: true | ||
index_name: | ||
description: 'The name of the index' | ||
required: true | ||
python_version: | ||
description: 'The version of Python to use' | ||
required: false | ||
default: '3.9' | ||
aiohttp_version: | ||
description: 'The version of aiohttp to install' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
|
||
- name: Setup Poetry | ||
uses: ./.github/actions/setup-poetry | ||
with: | ||
include_grpc: false | ||
include_types: false | ||
|
||
- name: 'Install aiohttp ${{ matrix.aiohttp-version }}' | ||
run: 'poetry add aiohttp==${{ matrix.aiohttp-version }}' | ||
shell: bash | ||
|
||
- uses: nick-fields/retry@v3 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 3 | ||
retry_on: error | ||
command: poetry run pytest tests/dependency/asyncio-rest -s -v | ||
env: | ||
PINECONE_API_KEY: '${{ inputs.PINECONE_API_KEY }}' | ||
INDEX_NAME: '${{ inputs.index_name }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import pytest | ||
import os | ||
import asyncio | ||
from pinecone import PineconeAsyncio | ||
|
||
|
||
@pytest.fixture | ||
def index_name(): | ||
name = os.environ.get("INDEX_NAME", None) | ||
if name is None or name == "": | ||
raise "INDEX_NAME environment variable is not set" | ||
return name | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestSanityRest: | ||
async def test_sanity(self, index_name, client): | ||
async with PineconeAsyncio() as pc: | ||
print("Testing with index name: " + index_name) | ||
assert index_name != "" | ||
|
||
# Verify index exists with expected properties | ||
available_indexes = await pc.list_indexes() | ||
assert index_name in available_indexes.names() | ||
|
||
description = await pc.describe_index(name=index_name) | ||
assert description.dimension == 2 | ||
|
||
idx = pc.Index(index_name) | ||
await idx.upsert(vectors=[("1", [1.0, 2.0]), ("2", [3.0, 4.0]), ("3", [5.0, 6.0])]) | ||
|
||
# Wait for index freshness | ||
await asyncio.sleep(30) | ||
|
||
# Check the vector count reflects some data has been upserted | ||
description = await idx.describe_index_stats() | ||
assert description.dimension == 2 | ||
assert description.total_vector_count >= 3 | ||
|
||
# Query for results | ||
query_results = await idx.query(id="1", top_k=10, include_values=True) | ||
assert query_results.matches[0].id == "1" | ||
assert len(query_results.matches) == 3 | ||
|
||
# Call a bulk import api method, should not raise an exception | ||
await idx.list_imports() | ||
|
||
# Call an inference method, should not raise an exception | ||
from pinecone import EmbedModel | ||
|
||
await pc.inference.embed( | ||
model=EmbedModel.Multilingual_E5_Large, | ||
inputs=["Hello, how are you?", "I am doing well, thank you for asking."], | ||
parameters={"input_type": "passage", "truncate": "END"}, | ||
) | ||
|
||
await idx.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters