mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-10-29 16:59:47 +00:00
Fix dependency related build issues in Dockerfiles (#2135)
* Fix a path issue in Dockerfile-GPU * Fix paths in Dockerfile-GPU * Add workflow_dispatch to docker build task * Remove reference to optional component from ui/, not needed anymore * Move pytorch installation last to avoid replacing it later * Remove optional import from rest_api too, no more needed * Change path in ui/Dockerfile * ui container works again * Complete review of import paths Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
aca52ea39c
commit
9dc89d2bd2
1
.github/workflows/docker_build.yml
vendored
1
.github/workflows/docker_build.yml
vendored
@ -1,6 +1,7 @@
|
||||
name: docker-build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
@ -22,7 +22,7 @@ COPY haystack /home/user/haystack/
|
||||
# Copy package files & models
|
||||
COPY setup.py setup.cfg pyproject.toml VERSION.txt LICENSE README.md models* /home/user/
|
||||
# Copy REST API code
|
||||
COPY rest_api /home/user/rest_api
|
||||
COPY rest_api /home/user/rest_api/
|
||||
|
||||
# Install package
|
||||
RUN pip install --upgrade pip
|
||||
@ -33,8 +33,8 @@ RUN pip freeze
|
||||
RUN python3 -c "from haystack.utils.docker import cache_models;cache_models()"
|
||||
|
||||
# create folder for /file-upload API endpoint with write permissions, this might be adjusted depending on FILE_UPLOAD_PATH
|
||||
RUN mkdir -p /home/user/file-upload
|
||||
RUN chmod 777 /home/user/file-upload
|
||||
RUN mkdir -p /home/user/rest_api/file-upload
|
||||
RUN chmod 777 /home/user/rest_api/file-upload
|
||||
|
||||
# optional : copy sqlite db if needed for testing
|
||||
#COPY qa.db /home/user/
|
||||
|
||||
@ -5,9 +5,6 @@ WORKDIR /home/user
|
||||
ENV LC_ALL=C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# create folder for /file-upload API endpoint with write permissions, this might be adjusted depending on FILE_UPLOAD_PATH
|
||||
RUN mkdir -p /home/user/file-upload && chmod 777 /home/user/file-upload
|
||||
|
||||
# Install software dependencies
|
||||
RUN apt-get update && apt-get install -y software-properties-common && \
|
||||
add-apt-repository ppa:deadsnakes/ppa && \
|
||||
@ -36,24 +33,26 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
|
||||
update-alternatives --set python3 /usr/bin/python3.7
|
||||
|
||||
# Copy Haystack code
|
||||
COPY haystack /home/user/haystack
|
||||
COPY haystack /home/user/haystack/
|
||||
# Copy package files & models
|
||||
COPY setup.py setup.cfg pyproject.toml VERSION.txt LICENSE README.md models* /home/user/
|
||||
# Copy REST API code
|
||||
COPY rest_api /home/user/
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
RUN echo "Install required packages" && \
|
||||
# Install PyTorch for CUDA 11
|
||||
pip3 install --no-cache-dir torch==1.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
|
||||
COPY rest_api /home/user/rest_api/
|
||||
|
||||
# Install package
|
||||
RUN pip install --no-cache .[docstores-gpu,crawler,preprocessing,ocr,ray]
|
||||
RUN pip install --no-cache rest_api/
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache-dir .[docstores-gpu,crawler,preprocessing,ocr,ray]
|
||||
RUN pip install --no-cache-dir rest_api/
|
||||
# Install PyTorch for CUDA 11
|
||||
RUN pip3 install --no-cache-dir torch==1.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
|
||||
|
||||
# Cache Roberta and NLTK data
|
||||
RUN python3 -c "from haystack.utils.docker import cache_models;cache_models()"
|
||||
|
||||
# create folder for /file-upload API endpoint with write permissions, this might be adjusted depending on FILE_UPLOAD_PATH
|
||||
RUN mkdir -p /home/user/rest_api/file-upload
|
||||
RUN chmod 777 /home/user/rest_api/file-upload
|
||||
|
||||
# optional : copy sqlite db if needed for testing
|
||||
#COPY qa.db /home/user/
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ services:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
# Mount custom Pipeline YAML and custom Components.
|
||||
# # Mount custom Pipeline YAML and custom Components.
|
||||
# volumes:
|
||||
# - ./rest_api/pipeline:/home/user/rest_api/pipeline
|
||||
ports:
|
||||
@ -59,4 +59,4 @@ services:
|
||||
- DEFAULT_QUESTION_AT_STARTUP
|
||||
- DEFAULT_DOCS_FROM_RETRIEVER
|
||||
- DEFAULT_NUMBER_OF_ANSWERS
|
||||
command: "/bin/bash -c 'sleep 15 && streamlit run webapp.py'"
|
||||
command: "/bin/bash -c 'sleep 15 && python -m streamlit run ui/webapp.py'"
|
||||
|
||||
@ -48,4 +48,4 @@ services:
|
||||
- DEFAULT_QUESTION_AT_STARTUP
|
||||
- DEFAULT_DOCS_FROM_RETRIEVER
|
||||
- DEFAULT_NUMBER_OF_ANSWERS
|
||||
command: "/bin/bash -c 'sleep 15 && streamlit run webapp.py'"
|
||||
command: "/bin/bash -c 'sleep 15 && python -m streamlit run ui/webapp.py'"
|
||||
|
||||
@ -5,21 +5,15 @@ logger = logging.getLogger(__name__)
|
||||
logging.getLogger("elasticsearch").setLevel(logging.WARNING)
|
||||
logging.getLogger("haystack").setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.routing import APIRoute
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.routing import APIRoute
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
from rest_api.controller.errors.http_error import http_error_handler
|
||||
from rest_api.config import ROOT_PATH
|
||||
from rest_api.controller.router import router as api_router
|
||||
|
||||
except (ImportError, ModuleNotFoundError) as ie:
|
||||
from haystack.utils.import_utils import _optional_component_not_installed
|
||||
|
||||
_optional_component_not_installed("rest_api", "rest", ie)
|
||||
from rest_api.controller.errors.http_error import http_error_handler
|
||||
from rest_api.config import ROOT_PATH
|
||||
from rest_api.controller.router import router as api_router
|
||||
|
||||
|
||||
def get_application() -> FastAPI:
|
||||
|
||||
@ -5,15 +5,17 @@ WORKDIR /home/user
|
||||
RUN apt-get update && apt-get install -y curl git pkg-config cmake
|
||||
|
||||
# copy code
|
||||
COPY setup.py /home/user/
|
||||
COPY utils.py /home/user/
|
||||
COPY webapp.py /home/user/
|
||||
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/
|
||||
|
||||
# install as a package
|
||||
RUN pip install .
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install ui/
|
||||
|
||||
EXPOSE 8501
|
||||
|
||||
# cmd for running the API
|
||||
CMD ["streamlit", "run", "webapp.py"]
|
||||
CMD ["python", "-m", "streamlit", "run", "ui/webapp.py"]
|
||||
|
||||
@ -5,13 +5,7 @@ import logging
|
||||
import requests
|
||||
from time import sleep
|
||||
from uuid import uuid4
|
||||
|
||||
try:
|
||||
import streamlit as st
|
||||
except (ImportError, ModuleNotFoundError) as ie:
|
||||
from haystack.utils.import_utils import _optional_component_not_installed
|
||||
|
||||
_optional_component_not_installed(__name__, "ui", ie)
|
||||
import streamlit as st
|
||||
|
||||
|
||||
API_ENDPOINT = os.getenv("API_ENDPOINT", "http://localhost:8000")
|
||||
|
||||
15
ui/webapp.py
15
ui/webapp.py
@ -1,21 +1,14 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import logging
|
||||
import pandas as pd
|
||||
from json import JSONDecodeError
|
||||
from pathlib import Path
|
||||
import streamlit as st
|
||||
from annotated_text import annotation
|
||||
from markdown import markdown
|
||||
|
||||
try:
|
||||
import streamlit as st
|
||||
from annotated_text import annotation
|
||||
from markdown import markdown
|
||||
|
||||
from ui.utils import haystack_is_ready, query, send_feedback, upload_doc, haystack_version, get_backlink
|
||||
except (ImportError, ModuleNotFoundError) as ie:
|
||||
from haystack.utils.import_utils import _optional_component_not_installed
|
||||
|
||||
_optional_component_not_installed(__name__, "ui", ie)
|
||||
from ui.utils import haystack_is_ready, query, send_feedback, upload_doc, haystack_version, get_backlink
|
||||
|
||||
|
||||
# Adjust to a question that you would like users to see in the search bar when they load the UI:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user