Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: uv pip install results in "Error no virtual environment found" #4936

Closed
poudrouxj opened this issue Aug 23, 2024 · 8 comments
Closed

bug: uv pip install results in "Error no virtual environment found" #4936

poudrouxj opened this issue Aug 23, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@poudrouxj
Copy link

Describe the bug

When running bentoml cointainerize on a bento with a custom base image which was built using bentoml==1.3.2 in a build environment with bentoml==1.3.2 we receive the following error:

#11 [base-container 6/8] RUN --mount=type=cache,target=/root/.cache/uv bash -euxo pipefail /home/bentoml/bento/env/python/install.sh
#11 0.054 + set -exuo pipefail
#11 0.055 +++ dirname -- /home/bentoml/bento/env/python/install.sh
#11 0.057 ++ cd -- /home/bentoml/bento/env/python
#11 0.057 ++ pwd
#11 0.058 + BASEDIR=/home/bentoml/bento/env/python
#11 0.058 + PIP_ARGS=()
#11 0.058 + REQUIREMENTS_TXT=/home/bentoml/bento/env/python/requirements.txt
#11 0.058 + REQUIREMENTS_LOCK=/home/bentoml/bento/env/python/requirements.lock.txt
#11 0.058 + WHEELS_DIR=/home/bentoml/bento/env/python/wheels
#11 0.058 + BENTOML_VERSION=1.3.2
#11 0.058 + pushd /home/bentoml/bento/env/python
#11 0.059 + '[' -f /home/bentoml/bento/env/python/requirements.lock.txt ']'
#11 0.059 + '[' -f /home/bentoml/bento/env/python/requirements.txt ']'
#11 0.059 Installing pip packages from 'requirements.txt'..
#11 0.059 + echo 'Installing pip packages from '\''requirements.txt'\''..'
#11 0.059 + pip_install -r /home/bentoml/bento/env/python/requirements.txt
#11 0.059 + command -v uv
#11 0.059 + uv pip install -r /home/bentoml/bento/env/python/requirements.txt
#11 0.199 error: No virtual environment found
#11 ERROR: process "/bin/sh -c bash -euxo pipefail /home/bentoml/bento/env/python/install.sh" did not complete successfully: exit code: 2
------
 > [base-container 6/8] RUN --mount=type=cache,target=/root/.cache/uv bash -euxo pipefail /home/bentoml/bento/env/python/install.sh:
: No virtual environment found

Perhaps by adding a --system as disclosed in astral-sh/uv#1374 (comment) will help?

Note we're using a custom base image.

To reproduce

No response

Expected behavior

No response

Environment

bentoml==1.3.2
platform=linux/amd64

(We're running this in the CI on a github workflow runner)

@poudrouxj poudrouxj added the bug Something isn't working label Aug 23, 2024
@frostming
Copy link
Contributor

You can set ENV UV_SYSTEM_PYTHON=1 which is set on our built-in docker template:

@frostming frostming closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2024
@poudrouxj
Copy link
Author

You can set ENV UV_SYSTEM_PYTHON=1 which is set on our built-in docker template:

Still not working - no idea what to do @frostming , open issue again ?

@frostming frostming reopened this Aug 23, 2024
@frostming
Copy link
Contributor

Still not working - no idea what to do @frostming , open issue again ?

What does your Dockerfile look like? You can find it at $BENTOML_HOME/bentos/$BENTO_NAME/$BENTO_VERSION/env/docker/Dockerfile

@poudrouxj
Copy link
Author

# ===========================================
#
# THIS IS A GENERATED DOCKERFILE. DO NOT EDIT
#
# ===========================================

# Block SETUP_BENTO_BASE_IMAGE
FROM europe-docker.pkg.dev/nube-hub/docker/<IMAGE>:<IMAGE_TAG> as base-container

ENV LANG=C.UTF-8

ENV LC_ALL=C.UTF-8

ENV PYTHONIOENCODING=UTF-8

ENV PYTHONUNBUFFERED=1



# Block SETUP_BENTO_USER
ARG BENTO_USER=bentoml
ARG BENTO_USER_UID=1034
ARG BENTO_USER_GID=1034
RUN groupadd -g $BENTO_USER_GID -o $BENTO_USER && useradd -m -u $BENTO_USER_UID -g $BENTO_USER_GID -o -r $BENTO_USER
ARG BENTO_PATH=/home/bentoml/bento
ENV BENTO_PATH=$BENTO_PATH
ENV BENTOML_HOME=/home/bentoml/

RUN mkdir $BENTO_PATH && chown bentoml:bentoml $BENTO_PATH -R
WORKDIR $BENTO_PATH


# Block SETUP_BENTO_COMPONENTS

COPY --chown=bentoml:bentoml ./env/python ./env/python/
# install python packages with install.sh
RUN bash -euxo pipefail /home/bentoml/bento/env/python/install.sh
COPY --chown=bentoml:bentoml . ./

# Block SETUP_BENTO_ENTRYPOINT
# Default port for BentoServer
EXPOSE 3000

# Expose Prometheus port
EXPOSE 3001

RUN chmod +x /home/bentoml/bento/env/docker/entrypoint.sh

USER bentoml

ENTRYPOINT [ "/home/bentoml/bento/env/docker/entrypoint.sh" ]

(I've obfuscated the IMAGE and IMAGE_TAG)

@poudrouxj
Copy link
Author

We've also got uv installed in the base image, could that be a culprit 🤔

@frostming
Copy link
Contributor

frostming commented Aug 23, 2024

@poudrouxj try adding ENV UV_SYSTEM_PYTHON=1 to the dockerfile

using dockerfile template: https://docs.bentoml.com/en/latest/guides/build-options.html#docker-options-table

@poudrouxj
Copy link
Author

poudrouxj commented Aug 23, 2024

@poudrouxj try adding ENV UV_SYSTEM_PYTHON=1 to the dockerfile

using dockerfile template: https://docs.bentoml.com/en/latest/guides/build-options.html#docker-options-table

Do you have an example on the syntax? Is it like this? https://docs.bentoml.com/en/v1.1.11/guides/containerization.html#writing-dockerfile-template (couldnt find it in the latest docs)

Edit: My buest guess from looking at the docs:

{% extends bento_base_template %}
{% block SETUP_BENTO_BASE_IMAGE %}
{{ super() }}
ENV UV_SYSTEM_PYTHON=1
{% endblock %}

@poudrouxj
Copy link
Author

The above seemed to have worked 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants