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

Commit

Permalink
feat(client): add a client for benchmarking and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 13, 2019
1 parent bdbc9df commit 0133905
Show file tree
Hide file tree
Showing 21 changed files with 10 additions and 38 deletions.
1 change: 0 additions & 1 deletion gnes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.



# do not change this line
# this is managed by git tag and replaced on every release
__version__ = '0.0.27'
2 changes: 0 additions & 2 deletions gnes/client/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.


import time

import grpc

from ..helper import TimeContext
Expand Down
1 change: 0 additions & 1 deletion gnes/encoder/audio/mfcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.



from typing import List

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/numeric/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import numpy as np

from ..base import BaseNumericEncoder
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/numeric/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import numpy as np

from ..base import BaseNumericEncoder
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/numeric/pq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import numpy as np

from ..base import BaseBinaryEncoder
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/numeric/tf_pq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




from typing import Dict, Any

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/numeric/vlad.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import copy

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/text/bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




from typing import List

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/text/elmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




from typing import List

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/text/flair.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




from typing import List

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/encoder/text/w2v.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




from typing import List

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions gnes/indexer/fulltext/leveldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import pickle
from threading import Thread, Event
from typing import List, Any
Expand Down
8 changes: 4 additions & 4 deletions gnes/indexer/vector/annoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def query(self, keys: 'np.ndarray', top_k: int, *args, **kwargs) -> List[List[Tu

def normalize_score(self, score: List[float], metrics: str, *args, **kwargs) -> List[float]:
if metrics == 'angular':
return list(map(lambda x:1 / (1 + x), score))
return list(map(lambda x: 1 / (1 + x), score))
elif metrics == 'euclidean':
import math
return list(map(lambda x:1 / (1 + math.sqrt(x) / self.num_dim), score))
return list(map(lambda x: 1 / (1 + math.sqrt(x) / self.num_dim), score))
elif metrics == 'manhattan':
return list(map(lambda x:1 / (1 + x / self.num_dim), score))
return list(map(lambda x: 1 / (1 + x / self.num_dim), score))
elif metrics == 'hamming':
return list(map(lambda x:1 / (1 + x), score))
return list(map(lambda x: 1 / (1 + x), score))
elif metrics == 'dot':
raise NotImplementedError

Expand Down
1 change: 0 additions & 1 deletion gnes/indexer/vector/bindexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.



import os
from typing import List, Tuple, Any

Expand Down
2 changes: 0 additions & 2 deletions gnes/indexer/vector/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.




import os
from typing import List, Tuple, Any

Expand Down
1 change: 0 additions & 1 deletion gnes/indexer/vector/hbindexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.



import os
from typing import List, Tuple, Any

Expand Down
1 change: 0 additions & 1 deletion gnes/indexer/vector/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.



from typing import List, Tuple, Any

import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion gnes/preprocessor/video/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import random
from typing import List

import numpy as np
import random

from .base import BaseVideoPreprocessor
from ..helper import get_video_frames, phash_descriptor
from ...proto import gnes_pb2, array2blob
Expand Down
4 changes: 2 additions & 2 deletions gnes/router/reduce/chunk_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List
from collections import defaultdict
from typing import List

from ..base import BaseReduceRouter
from ...proto import gnes_pb2
Expand Down Expand Up @@ -42,4 +42,4 @@ def apply(self, msg: 'gnes_pb2.Message', accum_msgs: List['gnes_pb2.Message'], *
r.score = v
r.score_explained = doc_score_explained[k]

super().apply(msg, accum_msgs)
super().apply(msg, accum_msgs)
4 changes: 2 additions & 2 deletions gnes/router/reduce/doc_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List
from collections import defaultdict
from typing import List

from ..base import BaseReduceRouter
from ...proto import gnes_pb2
Expand Down Expand Up @@ -52,4 +52,4 @@ def apply(self, msg: 'gnes_pb2.Message', accum_msgs: List['gnes_pb2.Message'], *
msg.response.search.ClearField('topk_results')
msg.response.search.topk_results.extend(final_fulltext_docs[:msg.response.search.top_k])

super().apply(msg, accum_msgs)
super().apply(msg, accum_msgs)

0 comments on commit 0133905

Please sign in to comment.