diff --git a/truss/base/truss_config.py b/truss/base/truss_config.py index c20f3adc4..60d42ea41 100644 --- a/truss/base/truss_config.py +++ b/truss/base/truss_config.py @@ -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 diff --git a/truss/tests/test_model_inference.py b/truss/tests/test_model_inference.py index dec4fc71e..07121aacf 100644 --- a/truss/tests/test_model_inference.py +++ b/truss/tests/test_model_inference.py @@ -102,13 +102,11 @@ 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): @@ -116,6 +114,26 @@ def test_map_to_supported_python_version(python_version, expected_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 = """