Skip to content

Commit

Permalink
able to connect now
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Apr 14, 2023
1 parent b89394b commit 72fda01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion ann_benchmarks/algorithms/redisearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
import sys
import time

from redis import Redis

Expand All @@ -14,8 +15,11 @@ def __init__(self, metric, M):

def fit(self, X):
# Start Redis in the background
subprocess.run("redis-server --loadmodule /usr/lib/redis/modules/redisearch.so", shell=True, check=True, stdout=sys.stdout, stderr=sys.stderr)
subprocess.run("redis-server --daemonize yes --loadmodule /usr/lib/redis/modules/redisearch.so", shell=True, check=True, stdout=sys.stdout, stderr=sys.stderr)

# Sleep a bit to make sure the server is running
time.sleep(3)

# Connect to Redis
self.redis = Redis(host="localhost", port=6379, decode_responses=False)

Expand Down
7 changes: 2 additions & 5 deletions install/Dockerfile.redisearch
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
FROM redislabs/redisearch as redisearch
FROM ann-benchmarks

# Install Redis
RUN apt-get update && apt-get install -y curl lsb-core
RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
RUN apt-get update
RUN apt-get install -y redis

COPY --from=redisearch /usr/lib/redis/modules/redisearch.so /usr/lib/redisearch.so
RUN ls -al /usr/lib

# Sanity check that redis-server can run
RUN redis-server --loadmodule /usr/lib/redisearch.so
COPY --from=redisearch /usr/lib/redis/modules/redisearch.so /usr/lib/redis/modules/redisearch.so

RUN pip3 install redisearch redis

0 comments on commit 72fda01

Please sign in to comment.