Remove python checks and deps from custom server #3462
GitHub Actions / JUnit Test Report
failed
Dec 10, 2024 in 0s
441 tests run, 439 passed, 1 skipped, 1 failed.
Annotations
Check failure on line 53 in truss/tests/contexts/image_builder/test_serving_image_builder.py
github-actions / JUnit Test Report
test_serving_image_builder.test_serving_image_dockerfile_from_user_base_image
assert ['ARG PYVERSI... 1; }\n', ...] == ['ARG PYVERSI... 1; }\n', ...]
At index 2 diff: '# If user base image is supplied in config, apply build commands from truss base image\n' != 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n'
Full diff:
[
'ARG PYVERSION=py39\n',
'FROM baseten/truss-server-base:3.9-v0.4.3 AS truss_server\n',
- 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n',
+ '# If user base image is supplied in config, apply build commands from truss '
+ 'base image\n',
'RUN grep -w \'ID=debian\\|ID_LIKE=debian\' /etc/os-release || { echo "ERROR: '
'Supplied base image is not a debian image"; exit 1; }\n',
'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)" \\\n',
' || { echo "ERROR: Supplied base image does not have 3.8 <= python <= '
'3.12"; exit 1; }\n',
+ 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n',
'RUN pip install --upgrade pip --no-cache-dir \\\n',
' && rm -rf /root/.cache/pip\n',
- '# If user base image is supplied in config, apply build commands from truss '
- 'base image\n',
'ENV PYTHONUNBUFFERED="True"\n',
'ENV DEBIAN_FRONTEND="noninteractive"\n',
'RUN apt update && \\\n',
' apt install -y bash \\\n',
' build-essential \\\n',
' git \\\n',
' curl \\\n',
' ca-certificates \\\n',
' software-properties-common \\\n',
' && apt-get autoremove -y \\\n',
' && apt-get clean -y \\\n',
' && rm -rf /var/lib/apt/lists/*\n',
'COPY ./base_server_requirements.txt base_server_requirements.txt\n',
'RUN pip install -r base_server_requirements.txt --no-cache-dir && rm -rf '
'/root/.cache/pip\n',
'COPY ./requirements.txt requirements.txt\n',
'RUN cat requirements.txt\n',
'RUN pip install -r requirements.txt --no-cache-dir && rm -rf '
'/root/.cache/pip\n',
'ENV APP_HOME="/app"\n',
'WORKDIR $APP_HOME\n',
'# Copy data before code for better caching\n',
'COPY ./data /app/data\n',
'COPY ./server /app\n',
'COPY ./config.yaml /app/config.yaml\n',
'COPY ./model /app/model\n',
'COPY ./packages /packages\n',
'ENV INFERENCE_SERVER_PORT="8080"\n',
'ENV SERVER_START_CMD="/usr/local/bin/python3 /app/main.py"\n',
'ENTRYPOINT ["/usr/local/bin/python3", "/app/main.py"]\n',
]
Raw output
test_data_path = PosixPath('/home/runner/work/truss/truss/truss/tests/test_data')
custom_model_truss_dir = PosixPath('/tmp/pytest-of-runner/pytest-0/test_serving_image_dockerfile_0/custom_truss')
def test_serving_image_dockerfile_from_user_base_image(
test_data_path, custom_model_truss_dir
):
th = TrussHandle(custom_model_truss_dir)
# The test fixture python varies with host version, need to pin here.
th.update_python_version("py39")
th.set_base_image("baseten/truss-server-base:3.9-v0.4.3", "/usr/local/bin/python3")
builder_context = ServingImageBuilderContext
image_builder = builder_context.run(th.spec.truss_dir)
with TemporaryDirectory() as tmp_dir:
tmp_path = Path(tmp_dir)
image_builder.prepare_image_build_dir(tmp_path)
with open(tmp_path / "Dockerfile", "r") as f:
gen_docker_lines = f.readlines()
with open(
test_data_path / "server.Dockerfile",
"r",
) as f:
server_docker_lines = f.readlines()
def filter_empty_lines(lines):
return list(filter(lambda x: x and x != "\n" and x != "", lines))
gen_docker_lines = filter_empty_lines(gen_docker_lines)
server_docker_lines = filter_empty_lines(server_docker_lines)
> assert gen_docker_lines == server_docker_lines
E assert ['ARG PYVERSI... 1; }\n', ...] == ['ARG PYVERSI... 1; }\n', ...]
E At index 2 diff: '# If user base image is supplied in config, apply build commands from truss base image\n' != 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n'
E Full diff:
E [
E 'ARG PYVERSION=py39\n',
E 'FROM baseten/truss-server-base:3.9-v0.4.3 AS truss_server\n',
E - 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n',
E + '# If user base image is supplied in config, apply build commands from truss '
E + 'base image\n',
E 'RUN grep -w \'ID=debian\\|ID_LIKE=debian\' /etc/os-release || { echo "ERROR: '
E 'Supplied base image is not a debian image"; exit 1; }\n',
E 'RUN $PYTHON_EXECUTABLE -c "import sys; sys.exit(0) if sys.version_info.major '
E '== 3 and sys.version_info.minor >=8 and sys.version_info.minor <=12 else '
E 'sys.exit(1)" \\\n',
E ' || { echo "ERROR: Supplied base image does not have 3.8 <= python <= '
E '3.12"; exit 1; }\n',
E + 'ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"\n',
E 'RUN pip install --upgrade pip --no-cache-dir \\\n',
E ' && rm -rf /root/.cache/pip\n',
E - '# If user base image is supplied in config, apply build commands from truss '
E - 'base image\n',
E 'ENV PYTHONUNBUFFERED="True"\n',
E 'ENV DEBIAN_FRONTEND="noninteractive"\n',
E 'RUN apt update && \\\n',
E ' apt install -y bash \\\n',
E ' build-essential \\\n',
E ' git \\\n',
E ' curl \\\n',
E ' ca-certificates \\\n',
E ' software-properties-common \\\n',
E ' && apt-get autoremove -y \\\n',
E ' && apt-get clean -y \\\n',
E ' && rm -rf /var/lib/apt/lists/*\n',
E 'COPY ./base_server_requirements.txt base_server_requirements.txt\n',
E 'RUN pip install -r base_server_requirements.txt --no-cache-dir && rm -rf '
E '/root/.cache/pip\n',
E 'COPY ./requirements.txt requirements.txt\n',
E 'RUN cat requirements.txt\n',
E 'RUN pip install -r requirements.txt --no-cache-dir && rm -rf '
E '/root/.cache/pip\n',
E 'ENV APP_HOME="/app"\n',
E 'WORKDIR $APP_HOME\n',
E '# Copy data before code for better caching\n',
E 'COPY ./data /app/data\n',
E 'COPY ./server /app\n',
E 'COPY ./config.yaml /app/config.yaml\n',
E 'COPY ./model /app/model\n',
E 'COPY ./packages /packages\n',
E 'ENV INFERENCE_SERVER_PORT="8080"\n',
E 'ENV SERVER_START_CMD="/usr/local/bin/python3 /app/main.py"\n',
E 'ENTRYPOINT ["/usr/local/bin/python3", "/app/main.py"]\n',
E ]
truss/tests/contexts/image_builder/test_serving_image_builder.py:53: AssertionError
Loading