Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianshu Cheng authored and Tianshu Cheng committed Sep 19, 2024
1 parent 2e38c60 commit 442497d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions truss/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
CONTROL_SERVER_CODE_DIR: pathlib.Path = TEMPLATES_DIR / "control"

SUPPORTED_PYTHON_VERSIONS = {"3.8", "3.9", "3.10", "3.11"}
MAX_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE = "3.12"
MIN_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE = "3.8"

TRTLLM_PREDICT_CONCURRENCY = 512
TRTLLM_MIN_MEMORY_REQUEST_GI = 24
Expand Down
24 changes: 24 additions & 0 deletions truss/contexts/image_builder/serving_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
CONTROL_SERVER_CODE_DIR,
DOCKER_SERVER_TEMPLATES_DIR,
FILENAME_CONSTANTS_MAP,
MAX_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE,
MIN_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE,
MODEL_DOCKERFILE_NAME,
OPENAI_COMPATIBLE_TAG,
REQUIREMENTS_TXT_FILENAME,
Expand Down Expand Up @@ -569,9 +571,31 @@ def _render_dockerfile(
)

hf_access_token = config.secrets.get(HF_ACCESS_TOKEN_SECRET_NAME)

max_supported_python_version_in_custom_base_image = (
MAX_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE
)
min_supported_python_version_in_custom_base_image = (
MIN_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE
)
max_supported_python_minor_version_in_custom_base_image = (
MAX_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE.split(".")[1]
)
min_supported_python_minor_version_in_custom_base_image = (
MIN_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE.split(".")[1]
)
supported_python_major_version_in_custom_base_image = (
MIN_SUPPORTED_PYTHON_VERSION_IN_CUSTOM_BASE_IMAGE.split(".")[0]
)

dockerfile_contents = dockerfile_template.render(
should_install_server_requirements=should_install_server_requirements,
base_image_name_and_tag=base_image_name_and_tag,
max_supported_python_version_in_custom_base_image=max_supported_python_version_in_custom_base_image,
min_supported_python_version_in_custom_base_image=min_supported_python_version_in_custom_base_image,
max_supported_python_minor_version_in_custom_base_image=max_supported_python_minor_version_in_custom_base_image,
min_supported_python_minor_version_in_custom_base_image=min_supported_python_minor_version_in_custom_base_image,
supported_python_major_version_in_custom_base_image=supported_python_major_version_in_custom_base_image,
should_install_system_requirements=should_install_system_requirements,
should_install_requirements=should_install_python_requirements,
should_install_user_requirements_file=should_install_user_requirements_file,
Expand Down
4 changes: 2 additions & 2 deletions truss/templates/base.Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ENV PYTHON_EXECUTABLE={{ config.base_image.python_executable_path or 'python3' }

{% block fail_fast %}
RUN grep -w 'ID=debian\|ID_LIKE=debian' /etc/os-release || { echo "ERROR: Supplied base image is not a debian image"; exit 1; }
RUN $PYTHON_EXECUTABLE -c "import sys; sys.exit(0) if sys.version_info.major == 3 and sys.version_info.minor >=8 and sys.version_info.minor <=12 else sys.exit(1)" \
|| { echo "ERROR: Supplied base image does not have 3.8 <= python <= 3.12"; exit 1; }
RUN $PYTHON_EXECUTABLE -c "import sys; sys.exit(0) if sys.version_info.major == {{supported_python_major_version_in_custom_base_image}} and sys.version_info.minor >={{min_supported_python_minor_version_in_custom_base_image}} and sys.version_info.minor <={{max_supported_python_minor_version_in_custom_base_image}} else sys.exit(1)" \
|| { echo "ERROR: Supplied base image does not have {{min_supported_python_version_in_custom_base_image}} <= python <= {{max_supported_python_version_in_custom_base_image}}"; exit 1; }
{% endblock %}

RUN pip install --upgrade pip --no-cache-dir \
Expand Down

0 comments on commit 442497d

Please sign in to comment.