Skip to content

Commit 2588016

Browse files
Merge pull request #118 from pinecone-io/fix_parse_query
Use _check_type=False in GRPCIndex.query()
2 parents 83b1df4 + 0451234 commit 2588016

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pinecone/core/grpc/index_grpc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ def parse_fetch_response(response: dict):
170170
return FetchResponse(vectors=vd, namespace=namespace, _check_type=False)
171171

172172

173-
def parse_query_response(response: dict, unary_query: bool):
173+
def parse_query_response(response: dict, unary_query: bool, _check_type: bool = False):
174174
res = []
175175

176+
# TODO: consider deleting this deprecated case
176177
for match in response.get('results', []):
177178
namespace = match.get('namespace', '')
178179
m = []
@@ -186,10 +187,10 @@ def parse_query_response(response: dict, unary_query: bool):
186187
m = []
187188
for item in response.get('matches', []):
188189
sc = ScoredVector(id=item['id'], score=item.get('score', 0.0), values=item.get('values', []),
189-
metadata=item.get('metadata', {}))
190+
metadata=item.get('metadata', {}), _check_type=_check_type)
190191
m.append(sc)
191192

192-
kwargs = {'check_type': False}
193+
kwargs = {'_check_type': _check_type}
193194
if unary_query:
194195
kwargs['namespace'] = response.get('namespace', '')
195196
kwargs['matches'] = m
@@ -463,7 +464,7 @@ def _query_transform(item):
463464
timeout = kwargs.pop('timeout', None)
464465
response = self._wrap_grpc_call(self.stub.Query, request, timeout=timeout)
465466
json_response = json_format.MessageToDict(response)
466-
return parse_query_response(json_response, vector is not None or id)
467+
return parse_query_response(json_response, vector is not None or id, _check_type=False)
467468

468469
def update(self,
469470
id: str,

0 commit comments

Comments
 (0)