mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-11-02 02:39:51 +00:00
fix: demo won't start through Docker compose (#3337)
* use new Docker images and add a health check for ES * try * silence streamlit errors * remove CMD override * final touches * leftover * make pylint happy
This commit is contained in:
parent
159cd5a666
commit
7d0f89b6f5
@ -1,30 +1,23 @@
|
||||
version: "3"
|
||||
services:
|
||||
|
||||
haystack-api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: "deepset/haystack-cpu:latest"
|
||||
# Mount custom Pipeline YAML and custom Components.
|
||||
# volumes:
|
||||
# - ./rest_api/pipeline:/home/user/rest_api/pipeline
|
||||
# Pull Haystack's latest commit
|
||||
image: "deepset/haystack:cpu-main"
|
||||
ports:
|
||||
- 8000:8000
|
||||
restart: on-failure
|
||||
environment:
|
||||
# See rest_api/pipeline/pipelines.haystack-pipeline.yml for configurations of Search & Indexing Pipeline.
|
||||
- DOCUMENTSTORE_PARAMS_HOST=elasticsearch
|
||||
- PIPELINE_YAML_PATH=/home/user/rest_api/rest_api/pipeline/pipelines.haystack-pipeline.yml
|
||||
- CONCURRENT_REQUEST_PER_WORKER
|
||||
- PIPELINE_YAML_PATH=/opt/venv/lib/python3.10/site-packages/rest_api/pipeline/pipelines.haystack-pipeline.yml
|
||||
- QUERY_PIPELINE_NAME=query
|
||||
- TOKENIZERS_PARALLELISM=false
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
# Starts REST API with only 2 workers so that it can be run on systems with just 4GB of memory
|
||||
# If you need to handle large loads of incoming requests and have memory to spare, consider increasing the number of workers
|
||||
command: "/bin/bash -c 'sleep 10 && gunicorn rest_api.application:app -b 0.0.0.0 -k uvicorn.workers.UvicornWorker --workers 2 --timeout 180'"
|
||||
elasticsearch:
|
||||
condition: service_healthy
|
||||
|
||||
elasticsearch:
|
||||
# This will start an empty elasticsearch instance (so you have to add your documents yourself)
|
||||
#image: "elasticsearch:7.9.2"
|
||||
# If you want a demo image instead that is "ready-to-query" with some indexed articles
|
||||
# This image is "ready-to-query" with some indexed articles
|
||||
# about countries and capital cities from Wikipedia:
|
||||
image: "deepset/elasticsearch-countries-and-capitals"
|
||||
ports:
|
||||
@ -32,22 +25,29 @@ services:
|
||||
restart: on-failure
|
||||
environment:
|
||||
- discovery.type=single-node
|
||||
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
|
||||
healthcheck:
|
||||
test: curl --fail http://localhost:9200/_cat/health || exit 1
|
||||
interval: 10s
|
||||
timeout: 1s
|
||||
retries: 10
|
||||
|
||||
ui:
|
||||
depends_on:
|
||||
- haystack-api
|
||||
build:
|
||||
context: ui
|
||||
dockerfile: Dockerfile
|
||||
image: "deepset/haystack-streamlit-ui:latest"
|
||||
ports:
|
||||
- 8501:8501
|
||||
restart: on-failure
|
||||
environment:
|
||||
- API_ENDPOINT=http://haystack-api:8000
|
||||
- EVAL_FILE=eval_labels_example.csv
|
||||
# The value fot the following variables will be read from the host, if present.
|
||||
- EVAL_FILE=ui/eval_labels_example.csv
|
||||
# The value of the following variables will be read from the host, if present.
|
||||
# They can also be temporarily set for docker-compose, for example:
|
||||
# DISABLE_FILE_UPLOAD=1 DEFAULT_DOCS_FROM_RETRIEVER=5 docker-compose up
|
||||
- DISABLE_FILE_UPLOAD
|
||||
- DEFAULT_QUESTION_AT_STARTUP
|
||||
- DEFAULT_DOCS_FROM_RETRIEVER
|
||||
- DEFAULT_NUMBER_OF_ANSWERS
|
||||
command: "/bin/bash -c 'sleep 15 && python -m streamlit run ui/webapp.py'"
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
FROM python:3.7.4-stretch
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
RUN apt-get update && apt-get install -y curl git pkg-config cmake
|
||||
# RUN apt-get update && apt-get install -y curl git pkg-config cmake
|
||||
|
||||
# copy code
|
||||
RUN mkdir ui/
|
||||
COPY setup.py /home/user/ui
|
||||
COPY utils.py /home/user/ui
|
||||
COPY webapp.py /home/user/ui
|
||||
COPY eval_labels_example.csv /home/user/
|
||||
COPY . /opt/ui
|
||||
|
||||
# install as a package
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install ui/
|
||||
RUN pip install --upgrade pip && \
|
||||
pip install /opt/ui/
|
||||
|
||||
WORKDIR /opt
|
||||
EXPOSE 8501
|
||||
|
||||
# cmd for running the API
|
||||
|
||||
12
ui/webapp.py
12
ui/webapp.py
@ -88,7 +88,9 @@ Ask any question on this topic and see if Haystack can find the correct answer t
|
||||
# File upload block
|
||||
if not DISABLE_FILE_UPLOAD:
|
||||
st.sidebar.write("## File Upload:")
|
||||
data_files = st.sidebar.file_uploader("", type=["pdf", "txt", "docx"], accept_multiple_files=True)
|
||||
data_files = st.sidebar.file_uploader(
|
||||
"upload", type=["pdf", "txt", "docx"], accept_multiple_files=True, label_visibility="hidden"
|
||||
)
|
||||
for data_file in data_files:
|
||||
# Upload file
|
||||
if data_file:
|
||||
@ -143,7 +145,13 @@ Ask any question on this topic and see if Haystack can find the correct answer t
|
||||
)
|
||||
|
||||
# Search bar
|
||||
question = st.text_input("", value=st.session_state.question, max_chars=100, on_change=reset_results)
|
||||
question = st.text_input(
|
||||
value=st.session_state.question,
|
||||
max_chars=100,
|
||||
on_change=reset_results,
|
||||
label="question",
|
||||
label_visibility="hidden",
|
||||
)
|
||||
col1, col2 = st.columns(2)
|
||||
col1.markdown("<style>.stButton button {width:100%;}</style>", unsafe_allow_html=True)
|
||||
col2.markdown("<style>.stButton button {width:100%;}</style>", unsafe_allow_html=True)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user