-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] Extract GrpcRunner from GRPCIndexBase class #395
Conversation
|
||
return wrapped() | ||
|
||
async def run_asyncio( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using or testing run_asyncio
anywhere yet, but I will. It's the same as run
but with the addition of the async
/await
bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, seems like a nice cleanup overall.
from pinecone.utils.constants import REQUEST_ID, CLIENT_VERSION | ||
from pinecone.exceptions.exceptions import PineconeException | ||
|
||
_logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't being used, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently unused. The _logger
reference is now used in the GrpcChannelFactory
which is logic I recently pulled out of this base class. Cleaning up this reference should have happened in that PR, but got overlooked.
from google.protobuf.message import Message | ||
|
||
|
||
class GrpcRunner: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea pulling all of this out into somewhere contained. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Problem
This is another extractive refactoring in preparation for grpc with asyncio.
Solution
The generated stub class,
VectorServiceStub
, is what knows how to call the Pinecone grpc service, but our wrapper code needs to do some work to make sure we have a consistent approach to "metadata" (grpc-speak for request headers) and handling other request params liketimeout
. Previously this work was accomplished in a private method of theGRPCIndexBase
base class called_wrap_grpc_call()
.Since we will need to perform almost identical marshaling of metadata for requests with asyncio, I pulled this logic out into a separate class
GrpcRunner
and renamed_wrap_grpc_call
torun
. You can see there is also a parallel method implementation calledrun_asyncio
; currently this is unused and untested, but kind of illustrates why this refactor is useful.Type of Change
Test Plan
Tests should still be green