Skip to content

Commit

Permalink
fix(container): preheat packages support markers
Browse files Browse the repository at this point in the history
  • Loading branch information
bojiang committed May 16, 2024
1 parent 078b137 commit 6d005da
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
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import shlex
import os
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 6d005da

Please sign in to comment.