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

fix: don't overwrite user base image #3329

Merged
merged 1 commit into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bentoml/_internal/bento/build_config.py
Expand Up @@ -149,13 +149,13 @@ class DockerOptions:
# always omit config values in case of default values got changed in future BentoML releases
__omit_if_default__ = False

distro: str = attr.field(
distro: t.Optional[str] = attr.field(
default=None,
validator=attr.validators.optional(
attr.validators.in_(CONTAINER_SUPPORTED_DISTROS)
),
)
python_version: str = attr.field(
python_version: t.Optional[str] = attr.field(
converter=_convert_python_version,
default=None,
validator=attr.validators.optional(
Expand Down
19 changes: 11 additions & 8 deletions src/bentoml/_internal/container/generate.py
Expand Up @@ -58,24 +58,27 @@ def get_templates_variables(
"""
Returns a dictionary of variables to be used in BentoML base templates.
"""
spec = DistroSpec.from_options(docker, conda)
conda_python_version = conda.get_python_version(bento_fs)
if conda_python_version is None:
conda_python_version = docker.python_version

python_version = docker.python_version
if docker.distro in ("ubi8"):
# ubi8 base images uses "py38" instead of "py3.8" in its image tag
python_version = python_version.replace(".", "")
base_image = spec.image.format(spec_version=python_version)
if docker.cuda_version is not None:
base_image = spec.image.format(spec_version=docker.cuda_version)
if docker.base_image is not None:
base_image = docker.base_image
logger.info(
"BentoML will not install Python to custom base images; ensure the base image '%s' has Python installed.",
base_image,
)
else:
spec = DistroSpec.from_options(docker, conda)
python_version = docker.python_version
assert docker.distro is not None and python_version is not None
if docker.distro in ("ubi8"):
# ubi8 base images uses "py38" instead of "py3.8" in its image tag
python_version = python_version.replace(".", "")
base_image = spec.image.format(spec_version=python_version)
if docker.cuda_version is not None:
base_image = spec.image.format(spec_version=docker.cuda_version)

# bento__env
default_env = {
"uid_gid": BENTO_UID_GID,
Expand Down
2 changes: 2 additions & 0 deletions src/bentoml/_internal/server/grpc/servicer/v1/__init__.py
Expand Up @@ -7,6 +7,7 @@
from typing import TYPE_CHECKING

import anyio

from .....utils import LazyLoader
from ......exceptions import InvalidArgument
from ......exceptions import BentoMLException
Expand All @@ -22,6 +23,7 @@

import grpc
from google.protobuf import struct_pb2

from ......grpc.v1 import service_pb2 as pb
from ......grpc.v1 import service_pb2_grpc as services
from ......grpc.types import BentoServicerContext
Expand Down