Skip to content

test: cover custom base_image without python_version (#5198)#5629

Open
Bharath-970 wants to merge 1 commit into
bentoml:mainfrom
Bharath-970:test/containerfile-base-image-no-python-version
Open

test: cover custom base_image without python_version (#5198)#5629
Bharath-970 wants to merge 1 commit into
bentoml:mainfrom
Bharath-970:test/containerfile-base-image-no-python-version

Conversation

@Bharath-970

Copy link
Copy Markdown

Adds a regression test for the Dockerfile generation path used by custom base_image.

What

When a custom docker.base_image is set without a python_version, generate_containerfile must not emit uv venv -p None (which crashes bentoml containerize), and uv must be auto-installed rather than assumed present on the base image.

This behavior is currently correct on main (the base.j2 template guards -p behind {% if __options__python_version %} and runs command -v uv >/dev/null || pip install uv), but it was not covered by a test — the scenario originally reported in #5198.

Test

test_generate_containerfile_custom_base_image_without_python_version renders the containerfile for DockerOptions(base_image=...) (where python_version defaults to None) and asserts:

  • uv venv is present
  • -p None / --python None are absent
  • uv is auto-installed (command -v uv >/dev/null || pip install uv)

Verified as a true regression guard: it fails if the {% if %} guard in base.j2 is removed, and passes with it intact. Full file passes:

tests/unit/_internal/container/test_generate.py ......  6 passed

Closes #5198.

A custom docker base_image with no python_version must not generate
`uv venv -p None`, which crashes `bentoml containerize`, and uv must be
auto-installed rather than assumed present on the base image. Add a
regression test over the generated Dockerfile guarding this behavior.
@Bharath-970
Bharath-970 requested a review from a team as a code owner June 2, 2026 11:01
@Bharath-970
Bharath-970 requested review from parano and removed request for a team June 2, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure to recognise python version in custom base_image

1 participant