K0nkere / MLOps_Car-prices-project

Covers the most important stages of ML system / Auction car prices prediction model for MLOps-zoomcamp
0 stars 0 forks source link

3 Deployment #4

Open K0nkere opened 2 years ago

K0nkere commented 2 years ago

Creating of virtual environment with pipenv pipenv install --python=3.9

requirements.txt

pipenv shell

Maybe its need to run if Pipfile is empty pipenv install -r requirements.txt

K0nkere commented 2 years ago

Dockerfile

The folowing Dockerfile has to be located in /project/3-deployment along with Pipfile Pipfile.lock predict.py

FROM python:3.9.7-slim

RUN pip install -U pip
RUN pip install pipenv

WORKDIR /app
COPY ["Pipfile", "Pipfile.lock", "./"]

ENV MLFLOW_S3_ENDPOINT_URL=https://storage.yandexcloud.net
ENV AWS_DEFAULT_REGION=ru-central1
ENV AWS_ACCESS_KEY_ID=<your_aws_key_id>
ENV AWS_SECRET_ACCESS_KEY=<your_aws_key>
ENV PUBLIC_SERVER_IP=51.250.101.205

RUN pipenv install --system --deploy

COPY ["predict.py", "./"]

EXPOSE 5000
EXPOSE 9696

ENTRYPOINT ["gunicorn", "--bind=0.0.0.0:9696", "predict:app"]

Flask entrypoint should be in format

"predict:app" After that its need to build docker image - run from the **/project** directory `docker build -t mlops-project-prediction-service:v1 ./3-deployment/` On the another terminal its need to start under **conda mlops-project-env** MLFlow server with that will be accessible via public IP run from the **/project** dir `mlflow server --backend-store-uri sqlite:///mlops-project.db --default-artifact-root s3://kkr-mlops-zoomcamp/mlflow-artifacts/ --host 0.0.0.0` And run previously created docker image with prediction web service on the flask `docker run -it --rm -p 9696:9696 mlops-project-prediction-service:v1` It is need to test via sending requests - under base env run from **/project/3-deployment** `python send-data.py`
K0nkere commented 2 years ago

docker build -t mlops-project-prediction-service:v1 ./3-deployment/ docker run -it --rm -p 9696:9696 mlops-project-prediction-service:v1

mlflow ui --backend-store-uri sqlite:///../mlops-project.db --default-artifact-root s3://kkr-mlops-zoomcamp/mlflow-artifacts/

mlflow server --backend-store-uri sqlite:///../mlops-project.db --default-artifact-root s3://kkr-mlops-zoomcamp/mlflow-artifacts/ --host 0.0.0.0