Skip to content

Commit

Permalink
chore: use separate docker image for mlflow server (#101)
Browse files Browse the repository at this point in the history
* Use mlflow-skinny instead of mlflow
* Update example dockerfile to have multi-stage; one for udf and one for mlflow
* Update docs to use quay.io images, instead of requiring build

Signed-off-by: Avik Basu <avikbasu93@gmail.com>
  • Loading branch information
ab93 committed Nov 29, 2022
1 parent d2c6293 commit f0993d3
Show file tree
Hide file tree
Showing 9 changed files with 907 additions and 1,479 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[flake8]
ignore = |
E203, F821
ignore = E203, F821
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
max-complexity = 10
max-line-length = 100
8 changes: 3 additions & 5 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ Once Numaflow is installed, create a simple Numalogic pipeline, which takes in t

For building this pipeline, navigate to [numalogic-simple-pipeline](https://github.com/numaproj/numalogic/tree/main/examples/numalogic-simple-pipeline) under the examples folder and execute the following commands.

1. Build the docker image, import it to k3d, and apply the pipeline. *Note Make sure the pipeline and, numaflow controllers and isbsvc pods are running in the same namespace (`default` in this case).*
1. Apply the pipeline. *Note Make sure the pipeline and, numaflow controllers and isbsvc pods are running in the same namespace (`default` in this case).*
```shell
docker build -t numalogic-simple-pipeline:v1 . && k3d image import docker.io/library/numalogic-simple-pipeline:v1

kubectl apply -f numa-pl.yaml
```
2. To verify if the pipeline has been deployed successfully, check the status of each pod.
Expand All @@ -101,9 +99,9 @@ numalogic-simple-pipeline-in-0-tmd0v 1/1 Running 0

Once the pipeline has been created, the data can be sent to the pipeline by port-forwarding the input vertex.

1. Port-forward to the http-source vertex
1. Port-forward to the http-source vertex. From the above pod output, this would be:
```shell
kubectl port-forward numalogic-simple-pipeline-in-0-xxxxx 8443
kubectl port-forward numalogic-simple-pipeline-in-0-tmd0v 8443
```

2. Send the data to the pod via curl
Expand Down
6 changes: 6 additions & 0 deletions examples/numalogic-simple-pipeline/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
__pycache__/
**/__pycache__/
*.py[cod]
*$py.class
.idea/
40 changes: 34 additions & 6 deletions examples/numalogic-simple-pipeline/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM python:3.9.12-slim
####################################################################################################
# builder: install needed dependencies
####################################################################################################

FROM python:3.10-slim-bullseye AS builder

ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_NO_CACHE_DIR=on \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.2.2 \
Expand All @@ -13,6 +18,7 @@ ENV PYTHONFAULTHANDLER=1 \
VENV_PATH="/opt/pysetup/.venv"

ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
Expand All @@ -25,14 +31,36 @@ RUN apt-get update \
# install dumb-init
&& wget -O /dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64 \
&& chmod +x /dumb-init \
\
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
&& curl -sSL https://install.python-poetry.org | python3 -

####################################################################################################
# mlflow: used for running the mlflow server
####################################################################################################
FROM builder AS mlflow

WORKDIR $PYSETUP_PATH
COPY ./pyproject.toml ./poetry.lock ./
RUN poetry install --only mlflowserver --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
WORKDIR /app

RUN chmod +x entry.sh

ENTRYPOINT ["/dumb-init", "--"]
CMD ["/app/entry.sh"]

EXPOSE 5000

####################################################################################################
# udf: used for running the udf vertices
####################################################################################################
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY ./pyproject.toml ./poetry.lock $PYSETUP_PATH
RUN poetry install --without dev --no-cache --no-root && \
COPY ./pyproject.toml ./poetry.lock ./
RUN poetry install --without mlflowserver --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
Expand Down
10 changes: 5 additions & 5 deletions examples/numalogic-simple-pipeline/numa-pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
min: 1
udf:
container:
image: docker.io/library/numalogic-simple-pipeline:v1
image: quay.io/numaio/numalogic/example-udf
env:
- name: WIN_SIZE
value: "12"
Expand All @@ -31,7 +31,7 @@ spec:
min: 1
udf:
container:
image: docker.io/library/numalogic-simple-pipeline:v1
image: quay.io/numaio/numalogic/example-udf
env:
- name: WIN_SIZE
value: "12"
Expand All @@ -44,7 +44,7 @@ spec:
min: 1
udf:
container:
image: docker.io/library/numalogic-simple-pipeline:v1
image: quay.io/numaio/numalogic/example-udf
env:
- name: WIN_SIZE
value: "12"
Expand All @@ -65,7 +65,7 @@ spec:
env:
- name: WIN_SIZE
value: "12"
image: docker.io/library/numalogic-simple-pipeline:v1
image: quay.io/numaio/numalogic/example-udf
args:
- python
- starter.py
Expand Down Expand Up @@ -106,7 +106,7 @@ spec:
app: mlflow
spec:
containers:
- image: docker.io/library/numalogic-simple-pipeline:v1
- image: quay.io/numaio/numalogic/example-mlflow
name: mlflow
args:
- server
Expand Down

0 comments on commit f0993d3

Please sign in to comment.