Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(client): fix weights in helper indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 11, 2019
1 parent b88de19 commit 31c796d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions gnes/client/cli.py
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions gnes/indexer/base.py
Expand Up @@ -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
Expand Down

0 comments on commit 31c796d

Please sign in to comment.