Skip to content

Commit

Permalink
fix(container): preheat packages support markers (#4737)
Browse files Browse the repository at this point in the history
* fix(container): preheat packages support markers

* ci: auto fixes from pre-commit.ci

For more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
bojiang and pre-commit-ci[bot] authored May 16, 2024
1 parent 078b137 commit 0f06eb4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/bentoml/_internal/bento/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,14 @@ def is_empty(self) -> bool:

@property
def _jinja_environment(self) -> jinja2.Environment:
return jinja2.Environment(
env = jinja2.Environment(
extensions=["jinja2.ext.debug"],
variable_start_string="<<",
variable_end_string=">>",
loader=jinja2.FileSystemLoader(os.path.dirname(__file__), followlinks=True),
)
env.filters["bash_quote"] = shlex.quote
return env

def write_to_bento(self, bento_fs: FS, build_ctx: str) -> None:
from .bentoml_builder import build_bentoml_sdist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ WORKDIR $BENTO_PATH

{% if __pip_preheat_packages__ %}
{% for value in __pip_preheat_packages__ -%}
{% call common.RUN(__enable_buildkit__) -%} {{ __pip_cache__ }} {% endcall -%} bash -c "pip3 install {{value}} || true"
{% call common.RUN(__enable_buildkit__) -%} {{ __pip_cache__ }} {% endcall -%} pip3 install {{value | bash_quote}} ; exit 0
{% endfor -%}
{% endif -%}

Expand Down
2 changes: 2 additions & 0 deletions src/bentoml/_internal/container/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import os
import shlex
import typing as t
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -166,6 +167,7 @@ def generate_containerfile(
lstrip_blocks=True,
loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True),
)
ENVIRONMENT.filters["bash_quote"] = shlex.quote

if docker.cuda_version is not None:
release_type = "cuda"
Expand Down

0 comments on commit 0f06eb4

Please sign in to comment.