From 909c7ebb2cdab01fad8396670acdc806cae8af13 Mon Sep 17 00:00:00 2001 From: Krithika Sundararajan Date: Mon, 11 Sep 2023 12:16:19 +0800 Subject: [PATCH] Remove multi-stage build from Pyfunc ensembler service (#361) * Skip conda pack and unpack * Activate conda env before running pyfunc server * Update Pyfunc base image * Set FOLDER_NAME env * Upgrade Kaniko version to latest --- README.md | 2 +- engines/pyfunc-ensembler-service/Dockerfile | 3 --- .../pyfunc-ensembler-service/app.Dockerfile | 23 +++---------------- infra/charts/turing/values.yaml | 2 +- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 559814baf..cd6d247dd 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ BatchEnsemblingConfig: BuildContextURI: git://github.com/caraml-dev/turing.git#refs/heads/main DockerfileFilePath: engines/pyfunc-ensembler-job/app.Dockerfile Image: gcr.io/kaniko-project/executor - ImageVersion: v1.6.0 + ImageVersion: v1.15.0 ResourceRequestsLimits: Requests: CPU: "1" diff --git a/engines/pyfunc-ensembler-service/Dockerfile b/engines/pyfunc-ensembler-service/Dockerfile index 015883951..d55f9990b 100644 --- a/engines/pyfunc-ensembler-service/Dockerfile +++ b/engines/pyfunc-ensembler-service/Dockerfile @@ -15,6 +15,3 @@ COPY ./temp-deps/sdk ./../../sdk RUN conda env create -f ./env-${PYTHON_VERSION}.yaml -n $CONDA_ENV_NAME && \ rm -rf /root/.cache - -# Install conda-pack: -RUN conda install conda-pack diff --git a/engines/pyfunc-ensembler-service/app.Dockerfile b/engines/pyfunc-ensembler-service/app.Dockerfile index 3f3b17be7..5182175c4 100644 --- a/engines/pyfunc-ensembler-service/app.Dockerfile +++ b/engines/pyfunc-ensembler-service/app.Dockerfile @@ -10,26 +10,9 @@ ARG GOOGLE_APPLICATION_CREDENTIALS RUN if [[-z "$GOOGLE_APPLICATION_CREDENTIALS"]]; then gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}; fi RUN gsutil -m cp -r ${MODEL_URL} . -# Install dependencies required by the user-defined ensembler -RUN conda env update --name ${CONDA_ENV_NAME} --file ./${FOLDER_NAME}/conda.yaml +RUN /bin/bash -c "conda env update --name ${CONDA_ENV_NAME} --file ./${FOLDER_NAME}/conda.yaml" -# Use conda-pack to create a standalone environment -# in /venv: -RUN conda-pack -n ${CONDA_ENV_NAME} -o /tmp/env.tar && \ - mkdir /venv && cd /venv && tar xf /tmp/env.tar && \ - rm /tmp/env.tar - -RUN /venv/bin/conda-unpack - -FROM debian:bullseye-slim - -ARG FOLDER_NAME ENV FOLDER_NAME=$FOLDER_NAME - -COPY --from=builder /${FOLDER_NAME} ./${FOLDER_NAME} -COPY --from=builder /pyfunc_ensembler_runner ./pyfunc_ensembler_runner -COPY --from=builder /venv ./venv - SHELL ["/bin/bash", "-c"] -ENTRYPOINT source /venv/bin/activate && \ - python -m pyfunc_ensembler_runner --mlflow_ensembler_dir /${FOLDER_NAME} -l INFO +ENTRYPOINT . activate ${CONDA_ENV_NAME} && \ + python -m pyfunc_ensembler_runner --mlflow_ensembler_dir ./${FOLDER_NAME} -l INFO diff --git a/infra/charts/turing/values.yaml b/infra/charts/turing/values.yaml index fad4293c1..0de399dc2 100644 --- a/infra/charts/turing/values.yaml +++ b/infra/charts/turing/values.yaml @@ -149,7 +149,7 @@ turing: BuildContextURI: git://github.com/caraml-dev/turing.git#refs/heads/main DockerfileFilePath: engines/pyfunc-ensembler-service/app.Dockerfile Image: gcr.io/kaniko-project/executor - ImageVersion: v1.6.0 + ImageVersion: v1.15.0 ResourceRequestsLimits: Requests: CPU: "1"