Skip to content

Commit

Permalink
import es_wait from .elasticsearch instead
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenleo committed Dec 13, 2020
1 parent c2d25d8 commit a210dc6
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions ann_benchmarks/algorithms/opendistroknn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@

from ann_benchmarks.algorithms.base import BaseANN

from .elasticsearch import es_wait

# Configure the logger.
logging.getLogger("elasticsearch").setLevel(logging.WARN)

def es_wait():
print("Waiting for elasticsearch health endpoint...")
req = Request("http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s")
for i in range(30):
try:
res = urlopen(req)
if res.getcode() == 200:
print("Elasticsearch is ready")
return
except URLError:
pass
sleep(1)
raise RuntimeError("Failed to connect to local elasticsearch")

class OpenDistroKNN(BaseANN):
def __init__(self, metric, dimension, method_param):
self.metric = {"angular": "cosinesimil", "euclidean": "l2"}[metric]
Expand Down

0 comments on commit a210dc6

Please sign in to comment.