Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
fix(client): fix weights in helper indexer
  • Loading branch information
hanhxiao committed Sep 11, 2019
1 parent b88de19 commit 31c796d3f09216ce6643e533041f65e355d725cf
Showing with 17 additions and 7 deletions.
  1. +14 −4 gnes/client/
  2. +3 −3 gnes/indexer/
@@ -23,7 +23,7 @@
from termcolor import colored

from .base import GrpcClient
from ..proto import RequestGenerator
from ..proto import RequestGenerator, gnes_pb2

class CLIClient(GrpcClient):
@@ -50,9 +50,19 @@ def query(self, all_bytes: List[bytes]):
for idx, q in enumerate(all_bytes):
for req in RequestGenerator.query(q, request_id_start=idx, top_k=self.args.top_k):
resp = self._stub.Call(req)
print('query %d result: %s' % (idx, resp))
input('press any key to continue...')
self.query_callback(resp, req)

def query_callback(resp: 'gnes_pb2.Response', query: 'gnes_pb2.Request'):
callback after get the query result
override this method to customize query behavior
:param resp: response
:param query: query

def read_all(self) -> List[bytes]:
if self.args.txt_file:
@@ -118,10 +118,10 @@ def arg_wrapper(self, keys: List[Tuple[int, int]], *args, **kwargs):
def update_helper_indexer(func):
def arg_wrapper(self, keys: List[Tuple[int, int]], *args, **kwargs):
r = func(self, keys, *args, **kwargs)
def arg_wrapper(self, keys: List[Tuple[int, int]], vectors: np.ndarray, weights: List[float], *args, **kwargs):
r = func(self, keys, vectors, weights, *args, **kwargs)
if self.helper_indexer:
self.helper_indexer.add(keys, *args, **kwargs)
self.helper_indexer.add(keys, weights, *args, **kwargs)
return r

return arg_wrapper

0 comments on commit 31c796d

Please sign in to comment.