Skip to content

Commit

Permalink
Add unit tests for grpc runner
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Oct 15, 2024
1 parent 236e577 commit a1bc758
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
28 changes: 15 additions & 13 deletions pinecone/grpc/grpc_runner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps
from typing import Dict, Tuple
from typing import Dict, Tuple, Optional

from grpc._channel import _InactiveRpcError

Expand All @@ -8,6 +8,8 @@
from .config import GRPCClientConfig
from pinecone.utils.constants import REQUEST_ID, CLIENT_VERSION
from pinecone.exceptions.exceptions import PineconeException
from grpc import CallCredentials, Compression
from google.protobuf.message import Message


class GrpcRunner:
Expand All @@ -26,12 +28,12 @@ def __init__(self, index_name: str, config: Config, grpc_config: GRPCClientConfi
def run(
self,
func,
request,
timeout=None,
metadata=None,
credentials=None,
wait_for_ready=None,
compression=None,
request: Message,
timeout: Optional[int] = None,
metadata: Optional[Dict[str, str]] = None,
credentials: Optional[CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[Compression] = None,
):
@wraps(func)
def wrapped():
Expand All @@ -54,12 +56,12 @@ def wrapped():
async def run_asyncio(
self,
func,
request,
timeout=None,
metadata=None,
credentials=None,
wait_for_ready=None,
compression=None,
request: Message,
timeout: Optional[int] = None,
metadata: Optional[Dict[str, str]] = None,
credentials: Optional[CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[Compression] = None,
):
@wraps(func)
async def wrapped():
Expand Down
6 changes: 1 addition & 5 deletions pinecone/grpc/index_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ def upsert(
return UpsertResponse(upserted_count=total_upserted)

def _upsert_batch(
self,
vectors: List[GRPCVector],
namespace: Optional[str],
timeout: Optional[float],
**kwargs,
self, vectors: List[GRPCVector], namespace: Optional[str], timeout: Optional[int], **kwargs
) -> UpsertResponse:
args_dict = self._parse_non_empty_args([("namespace", namespace)])
request = UpsertRequest(vectors=vectors, **args_dict)
Expand Down

0 comments on commit a1bc758

Please sign in to comment.