Skip to content

Commit

Permalink
Remove changes to index grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Nov 11, 2024
1 parent 2102ea6 commit 7941ee8
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions pinecone/grpc/index_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
SparseValues as GRPCSparseValues,
)
from pinecone import Vector as NonGRPCVector
from pinecone.data.query_results_aggregator import QueryNamespacesResults, QueryResultsAggregator
from pinecone.core.grpc.protos.vector_service_pb2_grpc import VectorServiceStub
from .base import GRPCIndexBase
from .future import PineconeGrpcFuture
Expand Down Expand Up @@ -403,53 +402,6 @@ def query(
json_response = json_format.MessageToDict(response)
return parse_query_response(json_response, _check_type=False)

def query_namespaces(
self,
vector: List[float],
namespaces: List[str],
top_k: Optional[int] = None,
filter: Optional[Dict[str, Union[str, float, int, bool, List, dict]]] = None,
include_values: Optional[bool] = None,
include_metadata: Optional[bool] = None,
sparse_vector: Optional[Union[GRPCSparseValues, SparseVectorTypedDict]] = None,
**kwargs,
) -> QueryNamespacesResults:
if namespaces is None or len(namespaces) == 0:
raise ValueError("At least one namespace must be specified")
if len(vector) == 0:
raise ValueError("Query vector must not be empty")

overall_topk = top_k if top_k is not None else 10
aggregator = QueryResultsAggregator(top_k=overall_topk)

target_namespaces = set(namespaces) # dedup namespaces
futures = [
self.query(
vector=vector,
namespace=ns,
top_k=overall_topk,
filter=filter,
include_values=include_values,
include_metadata=include_metadata,
sparse_vector=sparse_vector,
async_req=True,
**kwargs,
)
for ns in target_namespaces
]

from concurrent.futures import wait, ALL_COMPLETED

done, _ = wait(futures, return_when=ALL_COMPLETED)

for future in done:
response = future.result()
json_result = json_format.MessageToDict(response)
aggregator.add_results(json_result)

final_results = aggregator.get_results()
return final_results

def update(
self,
id: str,
Expand Down

0 comments on commit 7941ee8

Please sign in to comment.