Skip to content

Commit

Permalink
raising ValueError for py38 or less for truss supported version (#1350)
Browse files Browse the repository at this point in the history
* Adding error check

* Remain on prior version

* Fixing errors
  • Loading branch information
sumerjoshi authored Feb 1, 2025
1 parent 105eb1d commit 070de58
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 1 addition & 3 deletions truss/base/truss_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,9 @@ def map_to_supported_python_version(python_version: str) -> str:
return "py311"

if python_minor_version < 8:
# TODO: consider raising an error instead - it doesn't' seem safe.
logger.info(
raise ValueError(
f"Mapping python version {python_major_version}.{python_minor_version}"
" to 3.8, the lowest version that Truss currently supports."
)
return "py38"

return python_version
22 changes: 20 additions & 2 deletions truss/tests/test_model_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,38 @@ def _temp_truss(model_src: str, config_src: str = "") -> Iterator[TrussHandle]:
@pytest.mark.parametrize(
"python_version, expected_python_version",
[
("py37", "py38"),
("py38", "py38"),
("py39", "py39"),
("py310", "py310"),
("py311", "py311"),
("py312", "py311"),
("py36", "py38"),
],
)
def test_map_to_supported_python_version(python_version, expected_python_version):
out_python_version = map_to_supported_python_version(python_version)
assert out_python_version == expected_python_version


def test_not_supported_python_minor_versions():
with pytest.raises(
ValueError,
match="Mapping python version 3.6 to 3.8, "
"the lowest version that Truss currently supports.",
):
map_to_supported_python_version("py36")
with pytest.raises(
ValueError,
match="Mapping python version 3.7 to 3.8, "
"the lowest version that Truss currently supports.",
):
map_to_supported_python_version("py37")


def test_not_supported_python_major_versions():
with pytest.raises(NotImplementedError, match="Only python version 3 is supported"):
map_to_supported_python_version("py211")


@pytest.mark.integration
def test_model_load_logs(test_data_path):
model = """
Expand Down

0 comments on commit 070de58

Please sign in to comment.