Skip to content
Permalink
Browse files

fix(client): fix weights in helper indexer

  • Loading branch information...
hanxiao committed Sep 11, 2019
1 parent b88de19 commit 31c796d3f09216ce6643e533041f65e355d725cf
Showing with 17 additions and 7 deletions.
  1. +14 −4 gnes/client/cli.py
  2. +3 −3 gnes/indexer/base.py
@@ -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(resp)
print('query %d result: %s' % (idx, resp))
input('press any key to continue...')
self.query_callback(resp, req)

@staticmethod
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
:return:
"""
print(query)
print(resp)

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):
@staticmethod
def update_helper_indexer(func):
@wraps(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.
You can’t perform that action at this time.