Skip to content

Commit

Permalink
Merge pull request #16 from ittia-research/dev
Browse files Browse the repository at this point in the history
add /health endpoint to wiki_dpr server
  • Loading branch information
etwk authored Aug 25, 2024
2 parents e247de4 + d7edfe1 commit fe03620
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
14 changes: 10 additions & 4 deletions datasets/wiki_dpr/Dockerfile.serve.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ FROM python:3.11-bookworm
RUN apt update && apt install python3 python3-pip git -y
RUN pip install --no-cache-dir colbert-ai[torch,faiss-cpu]
RUN pip install --no-cache-dir "numpy<2"
RUN pip install --no-cache-dir tenacity

WORKDIR /app

CP prepare_files.py .
CP server.py .
CP start.sh .
COPY prepare_files.py .
COPY server.py .
COPY start.sh .

CMD ['/app/start.sh']
RUN chmod +x /app/start.sh

ENV INDEX_ROOT=/data/indexes
ENV INDEX_NAME=wiki

CMD ["/app/start.sh"]
14 changes: 10 additions & 4 deletions datasets/wiki_dpr/Dockerfile.serve.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
RUN apt update && apt install python3 python3-pip git -y
RUN pip install --no-cache-dir colbert-ai[torch,faiss-gpu]
RUN pip install --no-cache-dir "numpy<2"
RUN pip install --no-cache-dir tenacity

WORKDIR /app

CP prepare_files.py .
CP server.py .
CP start.sh .
COPY prepare_files.py .
COPY server.py .
COPY start.sh .

CMD ['/app/start.sh']
RUN chmod +x /app/start.sh

ENV INDEX_ROOT=/data/indexes
ENV INDEX_NAME=wiki

CMD ["/app/start.sh"]
4 changes: 4 additions & 0 deletions datasets/wiki_dpr/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def api_search_query(query, k):
topk = list(sorted(topk, key=lambda p: (-1 * p['score'], p['pid'])))
return {"query" : query, "topk": topk}

@app.route("/health", methods=["GET"])
def health():
return ('ok', 200)

@app.route("/api/search", methods=["GET"])
def api_search():
if request.method == "GET":
Expand Down
2 changes: 1 addition & 1 deletion datasets/wiki_dpr/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/bin/bash

python ./prepare_files.py
python ./server.py

0 comments on commit fe03620

Please sign in to comment.