From a61b557b052d4cf3a55ebb0d6ececdd85abf02d6 Mon Sep 17 00:00:00 2001 From: "marius.baseten" Date: Wed, 29 May 2024 16:39:35 -0700 Subject: [PATCH] Allow python 3.8 for context builder but not CLI, (partial revert of #921) * Import guard for chains requiring py3.9+ and pydantic v2 --- .github/workflows/integration-tests.yml | 2 +- .github/workflows/main.yml | 2 +- .pre-commit-config.yaml | 11 +- poetry.lock | 141 +++++++++++++---------- pyproject.toml | 7 +- truss-chains/truss_chains/__init__.py | 17 ++- truss/cli/cli.py | 14 +-- truss/constants.py | 2 +- truss/model_inference.py | 9 +- truss/templates/base.Dockerfile.jinja | 4 +- truss/templates/control/requirements.txt | 2 +- truss/test_data/server.Dockerfile | 4 +- truss/tests/conftest.py | 2 +- truss/tests/test_config.py | 3 +- truss/tests/test_model_inference.py | 6 +- truss/tests/test_truss_handle.py | 4 +- truss/tests/util/test_path.py | 10 +- truss/truss_config.py | 6 +- truss/truss_handle.py | 2 - 19 files changed, 142 insertions(+), 106 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 577c3905a..7baa1c768 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python_version: ["3.9", "3.10", "3.11"] + python_version: ["3.8", "3.9", "3.10", "3.11"] use_gpu: ["y", "n"] job_type: ["server"] steps: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01ebf30f3..405e0a0cf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python_version: ["3.9", "3.10", "3.11"] + python_version: ["3.8", "3.9", "3.10", "3.11"] use_gpu: ["y", "n"] job_type: ["server"] steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f89f8823..07959e16c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,5 +41,14 @@ repos: entry: poetry run mypy language: python types: [python] - exclude: ^examples/|^truss/test.+/|model.py$ + exclude: ^examples/|^truss/test.+/|model.py$|^truss-chains/.* + pass_filenames: true + - id: mypy + name: mypy-local (3.9) + entry: poetry run mypy + language: python + types: [python] + files: ^truss-chains/.* + args: + - --python-version=3.9 pass_filenames: true diff --git a/poetry.lock b/poetry.lock index 2fb4b5adc..2e29c7efd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,6 +11,9 @@ files = [ {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} + [[package]] name = "anyio" version = "4.4.0" @@ -215,17 +218,17 @@ files = [ [[package]] name = "boto3" -version = "1.34.114" +version = "1.34.115" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.34.114-py3-none-any.whl", hash = "sha256:4460958d2b0c53bd2195b23ed5d45db2350e514486fe8caeb38b285b30742280"}, - {file = "boto3-1.34.114.tar.gz", hash = "sha256:eeb11bca9b19d12baf93436fb8a16b8b824f1f7e8b9bcc722607e862c46b1b08"}, + {file = "boto3-1.34.115-py3-none-any.whl", hash = "sha256:0a580de3d25364da5db26ecc7dde9438ee1be1e529a7c04cc96972b6e2258378"}, + {file = "boto3-1.34.115.tar.gz", hash = "sha256:67f5a6d6e6eff9c15711c265173b53eb4ad8d05b756b76ef33ac792cea7958f6"}, ] [package.dependencies] -botocore = ">=1.34.114,<1.35.0" +botocore = ">=1.34.115,<1.35.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -234,13 +237,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.34.114" +version = "1.34.115" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.34.114-py3-none-any.whl", hash = "sha256:606d1e55984d45e41a812badee292755f4db0233eed9cca63ea3bb8f5755507f"}, - {file = "botocore-1.34.114.tar.gz", hash = "sha256:5705f74fda009656a218ffaf4afd81228359160f2ab806ab8222d07e9da3a73b"}, + {file = "botocore-1.34.115-py3-none-any.whl", hash = "sha256:15b8ad1ee0e9cd57884fb0bcaf3a9551d2552e44a02c2ffb55ec583eebdb888e"}, + {file = "botocore-1.34.115.tar.gz", hash = "sha256:a5d5e28b9c847b17a1ecb7660b46b83d9512b125f671e03e93d14bf6f0b274c2"}, ] [package.dependencies] @@ -1220,6 +1223,24 @@ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.link perf = ["ipython"] testing = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] +[[package]] +name = "importlib-resources" +version = "6.4.0" +description = "Read resources from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_resources-6.4.0-py3-none-any.whl", hash = "sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c"}, + {file = "importlib_resources-6.4.0.tar.gz", hash = "sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145"}, +] + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] + [[package]] name = "iniconfig" version = "2.0.0" @@ -1419,7 +1440,9 @@ files = [ [package.dependencies] attrs = ">=22.2.0" +importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} jsonschema-specifications = ">=2023.03.6" +pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""} referencing = ">=0.28.4" rpds-py = ">=0.7.1" @@ -1439,6 +1462,7 @@ files = [ ] [package.dependencies] +importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} referencing = ">=0.31.0" [[package]] @@ -1934,61 +1958,50 @@ files = [ [[package]] name = "nodeenv" -version = "1.8.0" +version = "1.9.0" description = "Node.js virtual environment builder" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ - {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, - {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, + {file = "nodeenv-1.9.0-py2.py3-none-any.whl", hash = "sha256:508ecec98f9f3330b636d4448c0f1a56fc68017c68f1e7857ebc52acf0eb879a"}, + {file = "nodeenv-1.9.0.tar.gz", hash = "sha256:07f144e90dae547bf0d4ee8da0ee42664a42a04e02ed68e06324348dafe4bdb1"}, ] -[package.dependencies] -setuptools = "*" - [[package]] name = "numpy" -version = "1.26.4" +version = "1.24.4" description = "Fundamental package for array computing in Python" optional = false -python-versions = ">=3.9" -files = [ - {file = "numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0"}, - {file = "numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2e4ee3380d6de9c9ec04745830fd9e2eccb3e6cf790d39d7b98ffd19b0dd754a"}, - {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d209d8969599b27ad20994c8e41936ee0964e6da07478d6c35016bc386b66ad4"}, - {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f"}, - {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:62b8e4b1e28009ef2846b4c7852046736bab361f7aeadeb6a5b89ebec3c7055a"}, - {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a4abb4f9001ad2858e7ac189089c42178fcce737e4169dc61321660f1a96c7d2"}, - {file = "numpy-1.26.4-cp310-cp310-win32.whl", hash = "sha256:bfe25acf8b437eb2a8b2d49d443800a5f18508cd811fea3181723922a8a82b07"}, - {file = "numpy-1.26.4-cp310-cp310-win_amd64.whl", hash = "sha256:b97fe8060236edf3662adfc2c633f56a08ae30560c56310562cb4f95500022d5"}, - {file = "numpy-1.26.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c66707fabe114439db9068ee468c26bbdf909cac0fb58686a42a24de1760c71"}, - {file = "numpy-1.26.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:96ff0b2ad353d8f990b63294c8986f1ec3cb19d749234014f4e7eb0112ceba5a"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:60dedbb91afcbfdc9bc0b1f3f402804070deed7392c23eb7a7f07fa857868e8a"}, - {file = "numpy-1.26.4-cp311-cp311-win32.whl", hash = "sha256:1af303d6b2210eb850fcf03064d364652b7120803a0b872f5211f5234b399f20"}, - {file = "numpy-1.26.4-cp311-cp311-win_amd64.whl", hash = "sha256:cd25bcecc4974d09257ffcd1f098ee778f7834c3ad767fe5db785be9a4aa9cb2"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b3ce300f3644fb06443ee2222c2201dd3a89ea6040541412b8fa189341847218"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ab47dbe5cc8210f55aa58e4805fe224dac469cde56b9f731a4c098b91917159a"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1dda2e7b4ec9dd512f84935c5f126c8bd8b9f2fc001e9f54af255e8c5f16b0e0"}, - {file = "numpy-1.26.4-cp312-cp312-win32.whl", hash = "sha256:50193e430acfc1346175fcbdaa28ffec49947a06918b7b92130744e81e640110"}, - {file = "numpy-1.26.4-cp312-cp312-win_amd64.whl", hash = "sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818"}, - {file = "numpy-1.26.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7349ab0fa0c429c82442a27a9673fc802ffdb7c7775fad780226cb234965e53c"}, - {file = "numpy-1.26.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:52b8b60467cd7dd1e9ed082188b4e6bb35aa5cdd01777621a1658910745b90be"}, - {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5241e0a80d808d70546c697135da2c613f30e28251ff8307eb72ba696945764"}, - {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3"}, - {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:679b0076f67ecc0138fd2ede3a8fd196dddc2ad3254069bcb9faf9a79b1cebcd"}, - {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:47711010ad8555514b434df65f7d7b076bb8261df1ca9bb78f53d3b2db02e95c"}, - {file = "numpy-1.26.4-cp39-cp39-win32.whl", hash = "sha256:a354325ee03388678242a4d7ebcd08b5c727033fcff3b2f536aea978e15ee9e6"}, - {file = "numpy-1.26.4-cp39-cp39-win_amd64.whl", hash = "sha256:3373d5d70a5fe74a2c1bb6d2cfd9609ecf686d47a2d7b1d37a8f3b6bf6003aea"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:afedb719a9dcfc7eaf2287b839d8198e06dcd4cb5d276a3df279231138e83d30"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95a7476c59002f2f6c590b9b7b998306fba6a5aa646b1e22ddfeaf8f78c3a29c"}, - {file = "numpy-1.26.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7e50d0a0cc3189f9cb0aeb3a6a6af18c16f59f004b866cd2be1c14b36134a4a0"}, - {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, +python-versions = ">=3.8" +files = [ + {file = "numpy-1.24.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0bfb52d2169d58c1cdb8cc1f16989101639b34c7d3ce60ed70b19c63eba0b64"}, + {file = "numpy-1.24.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ed094d4f0c177b1b8e7aa9cba7d6ceed51c0e569a5318ac0ca9a090680a6a1b1"}, + {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79fc682a374c4a8ed08b331bef9c5f582585d1048fa6d80bc6c35bc384eee9b4"}, + {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7ffe43c74893dbf38c2b0a1f5428760a1a9c98285553c89e12d70a96a7f3a4d6"}, + {file = "numpy-1.24.4-cp310-cp310-win32.whl", hash = "sha256:4c21decb6ea94057331e111a5bed9a79d335658c27ce2adb580fb4d54f2ad9bc"}, + {file = "numpy-1.24.4-cp310-cp310-win_amd64.whl", hash = "sha256:b4bea75e47d9586d31e892a7401f76e909712a0fd510f58f5337bea9572c571e"}, + {file = "numpy-1.24.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f136bab9c2cfd8da131132c2cf6cc27331dd6fae65f95f69dcd4ae3c3639c810"}, + {file = "numpy-1.24.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e2926dac25b313635e4d6cf4dc4e51c8c0ebfed60b801c799ffc4c32bf3d1254"}, + {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:222e40d0e2548690405b0b3c7b21d1169117391c2e82c378467ef9ab4c8f0da7"}, + {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7215847ce88a85ce39baf9e89070cb860c98fdddacbaa6c0da3ffb31b3350bd5"}, + {file = "numpy-1.24.4-cp311-cp311-win32.whl", hash = "sha256:4979217d7de511a8d57f4b4b5b2b965f707768440c17cb70fbf254c4b225238d"}, + {file = "numpy-1.24.4-cp311-cp311-win_amd64.whl", hash = "sha256:b7b1fc9864d7d39e28f41d089bfd6353cb5f27ecd9905348c24187a768c79694"}, + {file = "numpy-1.24.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1452241c290f3e2a312c137a9999cdbf63f78864d63c79039bda65ee86943f61"}, + {file = "numpy-1.24.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:04640dab83f7c6c85abf9cd729c5b65f1ebd0ccf9de90b270cd61935eef0197f"}, + {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5425b114831d1e77e4b5d812b69d11d962e104095a5b9c3b641a218abcc050e"}, + {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd80e219fd4c71fc3699fc1dadac5dcf4fd882bfc6f7ec53d30fa197b8ee22dc"}, + {file = "numpy-1.24.4-cp38-cp38-win32.whl", hash = "sha256:4602244f345453db537be5314d3983dbf5834a9701b7723ec28923e2889e0bb2"}, + {file = "numpy-1.24.4-cp38-cp38-win_amd64.whl", hash = "sha256:692f2e0f55794943c5bfff12b3f56f99af76f902fc47487bdfe97856de51a706"}, + {file = "numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2541312fbf09977f3b3ad449c4e5f4bb55d0dbf79226d7724211acc905049400"}, + {file = "numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9667575fb6d13c95f1b36aca12c5ee3356bf001b714fc354eb5465ce1609e62f"}, + {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3a86ed21e4f87050382c7bc96571755193c4c1392490744ac73d660e8f564a9"}, + {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d11efb4dbecbdf22508d55e48d9c8384db795e1b7b51ea735289ff96613ff74d"}, + {file = "numpy-1.24.4-cp39-cp39-win32.whl", hash = "sha256:6620c0acd41dbcb368610bb2f4d83145674040025e5536954782467100aa8835"}, + {file = "numpy-1.24.4-cp39-cp39-win_amd64.whl", hash = "sha256:befe2bf740fd8373cf56149a5c23a0f601e82869598d41f8e188a0e9869926f8"}, + {file = "numpy-1.24.4-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:31f13e25b4e304632a4619d0e0777662c2ffea99fcae2029556b17d8ff958aef"}, + {file = "numpy-1.24.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95f7ac6540e95bc440ad77f56e520da5bf877f87dca58bd095288dce8940532a"}, + {file = "numpy-1.24.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e98f220aa76ca2a977fe435f5b04d7b3470c0a2e6312907b37ba6068f26787f2"}, + {file = "numpy-1.24.4.tar.gz", hash = "sha256:80f5e3a4e498641401868df4208b74581206afbee7cf7b8329daae82676d9463"}, ] [[package]] @@ -2133,6 +2146,17 @@ files = [ {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"}, ] +[[package]] +name = "pkgutil-resolve-name" +version = "1.3.10" +description = "Resolve a name to an object." +optional = false +python-versions = ">=3.6" +files = [ + {file = "pkgutil_resolve_name-1.3.10-py3-none-any.whl", hash = "sha256:ca27cc078d25c5ad71a9de0a7a330146c4e014c2462d9af19c6b828280649c5e"}, + {file = "pkgutil_resolve_name-1.3.10.tar.gz", hash = "sha256:357d6c9e6a755653cfd78893817c0853af365dd51ec97f3d358a819373bbd174"}, +] + [[package]] name = "platformdirs" version = "4.2.2" @@ -2801,13 +2825,13 @@ rpds-py = ">=0.7.0" [[package]] name = "requests" -version = "2.32.2" +version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" files = [ - {file = "requests-2.32.2-py3-none-any.whl", hash = "sha256:fc06670dd0ed212426dfeb94fc1b983d917c4f9847c863f313c9dfaaffb7c23c"}, - {file = "requests-2.32.2.tar.gz", hash = "sha256:dd951ff5ecf3e3b3aa26b40703ba77495dab41da839ae72ef3c8e5d8e2433289"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -2851,6 +2875,7 @@ files = [ [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" +typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] @@ -3700,5 +3725,5 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" -python-versions = ">=3.9,<3.12" -content-hash = "ca670ed6bedc56c744bedeba058424a6dba170597a89d4e370cb6045f117e8c2" +python-versions = ">=3.8,<3.12" +content-hash = "f25f12b0a9f65ebf3ec2eecdcde7b19ebac9d7087b17404eea3b09253bb13fed" diff --git a/pyproject.toml b/pyproject.toml index 0f7667794..d1e41d9ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,8 @@ pathspec = ">=0.9.0" psutil = ">=5.9.4" pydantic = ">=1.10.0" pytest-asyncio = "^0.23.6" -python = ">=3.9,<3.12" +# Note: when using chains, 3.9 will be required at runtime, but other truss functionality works with 3.8. +python = ">=3.8,<3.12" python-json-logger = ">=2.0.2" python-on-whales = "^0.68.0" PyYAML = ">=6.0" @@ -72,7 +73,7 @@ loguru = ">=0.7.2" packaging = ">=20.9" pathspec = ">=0.9.0" psutil = ">=5.9.4" -python = ">=3.9,<3.12" +python = ">=3.8,<3.12" python-json-logger = ">=2.0.2" PyYAML = ">=6.0" requests = ">=2.31" @@ -117,7 +118,7 @@ src_paths = ["isort", "test"] [tool.mypy] ignore_missing_imports = true -python_version = "3.9" +python_version = "3.8" plugins = ["pydantic.mypy"] [tool.pytest.ini_options] diff --git a/truss-chains/truss_chains/__init__.py b/truss-chains/truss_chains/__init__.py index cb0a04896..55dddbe28 100644 --- a/truss-chains/truss_chains/__init__.py +++ b/truss-chains/truss_chains/__init__.py @@ -1,17 +1,22 @@ -import warnings +import sys +if (sys.version_info.major, sys.version_info.minor) <= (3, 8): + raise RuntimeError( + "Python version 3.8 or older is not supported for `Truss-Chains`. Please" + "upgrade to Python 3.9 or newer. You can still use other Truss functionality." + ) +del sys import pydantic pydantic_major_version = int(pydantic.VERSION.split(".")[0]) if pydantic_major_version < 2: - warnings.warn( - f"Pydantic major version is less than 2 ({pydantic.VERSION}). You use Truss, " - "but for using Truss-Chains, you must upgrade to pydantic-v2.", - UserWarning, + raise RuntimeError( + f"Pydantic v2 is not supported for `Truss-Chains`. Please upgrade to v2. " + "You can still use other Truss functionality." ) del pydantic -del warnings + # flake8: noqa F401 from truss_chains.definitions import ( diff --git a/truss/cli/cli.py b/truss/cli/cli.py index d90e11aaa..aa1e084b6 100644 --- a/truss/cli/cli.py +++ b/truss/cli/cli.py @@ -112,16 +112,10 @@ def image(): class ChainsGroup(click.Group): def invoke(self, ctx: click.Context) -> None: - import pydantic - - pydantic_major_version = int(pydantic.VERSION.split(".")[0]) - if pydantic_major_version < 2: - raise ImportError( - f"Pydantic major version is less than 2 ({pydantic.VERSION}). " - "You can use Truss, but for using Truss-Chains, you must upgrade " - "to pydantic-v2.", - ) - del pydantic + # This import raises error messages if pydantic v2 or python older than 3.9 + # are installed. + import truss_chains # noqa: F401 + super().invoke(ctx) diff --git a/truss/constants.py b/truss/constants.py index f7a10853b..7aab8a743 100644 --- a/truss/constants.py +++ b/truss/constants.py @@ -30,7 +30,7 @@ ) CONTROL_SERVER_CODE_DIR: pathlib.Path = TEMPLATES_DIR / "control" -SUPPORTED_PYTHON_VERSIONS = {"3.9", "3.10", "3.11"} +SUPPORTED_PYTHON_VERSIONS = {"3.8", "3.9", "3.10", "3.11"} # Alias for TEMPLATES_DIR diff --git a/truss/model_inference.py b/truss/model_inference.py index eea967876..f2379fc95 100644 --- a/truss/model_inference.py +++ b/truss/model_inference.py @@ -36,7 +36,7 @@ def map_to_supported_python_version(python_version: str) -> str: python_major_version = int(python_version[2:3]) python_minor_version = int(python_version[3:]) - if python_major_version != 3: + if python_major_version > 3: raise NotImplementedError("Only python version 3 is supported") if python_minor_version > 11: @@ -46,12 +46,13 @@ def map_to_supported_python_version(python_version: str) -> str: ) return "py311" - if python_minor_version < 9: + if python_minor_version < 8: + # TODO: consider raising an error instead - it doesn't' seem safe. logger.info( f"Mapping python version {python_major_version}.{python_minor_version}" - " to 3.9, the lowest version that Truss currently supports." + " to 3.8, the lowest version that Truss currently supports." ) - return "py39" + return "py38" return python_version diff --git a/truss/templates/base.Dockerfile.jinja b/truss/templates/base.Dockerfile.jinja index 49e8c82ad..604fdd975 100644 --- a/truss/templates/base.Dockerfile.jinja +++ b/truss/templates/base.Dockerfile.jinja @@ -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 >=9 and sys.version_info.minor <=11 else sys.exit(1)" \ - || { echo "ERROR: Supplied base image does not have 3.9 <= python <= 3.11"; 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 <=11 else sys.exit(1)" \ + || { echo "ERROR: Supplied base image does not have 3.8 <= python <= 3.11"; exit 1; } {% endblock %} RUN pip install --upgrade pip --no-cache-dir \ diff --git a/truss/templates/control/requirements.txt b/truss/templates/control/requirements.txt index 9b2ab1c0f..f9bc7e9a3 100644 --- a/truss/templates/control/requirements.txt +++ b/truss/templates/control/requirements.txt @@ -1,5 +1,5 @@ dataclasses-json==0.5.7 -truss==0.9.12 +truss==0.9.10 # This needs to support py3.8. It can be incremented to releases after #955 (i.e. >0.9.12). fastapi==0.109.1 uvicorn==0.24.0 uvloop==0.19.0 diff --git a/truss/test_data/server.Dockerfile b/truss/test_data/server.Dockerfile index 1812ec445..7be57e609 100644 --- a/truss/test_data/server.Dockerfile +++ b/truss/test_data/server.Dockerfile @@ -4,8 +4,8 @@ FROM baseten/truss-server-base:3.9-v0.4.3 as truss_server ENV PYTHON_EXECUTABLE /usr/local/bin/python3 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 >=9 and sys.version_info.minor <=11 else sys.exit(1)" \ - || { echo "ERROR: Supplied base image does not have 3.9 <= python <= 3.11"; 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 <=11 else sys.exit(1)" \ + || { echo "ERROR: Supplied base image does not have 3.8 <= python <= 3.11"; exit 1; } RUN pip install --upgrade pip --no-cache-dir \ && rm -rf /root/.cache/pip diff --git a/truss/tests/conftest.py b/truss/tests/conftest.py index 2066f2a55..333db8c2a 100644 --- a/truss/tests/conftest.py +++ b/truss/tests/conftest.py @@ -403,7 +403,7 @@ def custom_model_truss_dir_with_hidden_files(tmp_path): _ = init(str(truss_dir_path)) (truss_dir_path / "__pycache__").mkdir(parents=True, exist_ok=True) (truss_dir_path / ".git").mkdir(parents=True, exist_ok=True) - (truss_dir_path / "__pycache__" / "test.cpython-39.pyc").touch() + (truss_dir_path / "__pycache__" / "test.cpython-311.pyc").touch() (truss_dir_path / ".DS_Store").touch() (truss_dir_path / ".git" / ".test_file").touch() (truss_dir_path / "data" / "test_file").write_text("123456789") diff --git a/truss/tests/test_config.py b/truss/tests/test_config.py index de55da472..f57c39ea3 100644 --- a/truss/tests/test_config.py +++ b/truss/tests/test_config.py @@ -350,10 +350,9 @@ def test_from_yaml_secrets_as_list(): def test_from_yaml_python_version(): - yaml_path = Path("test.yaml") invalid_py_version_data = { "description": "this is a test", - "python_version": "py38", + "python_version": "py37", } with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file: yaml_path = Path(yaml_file.name) diff --git a/truss/tests/test_model_inference.py b/truss/tests/test_model_inference.py index 7c2e2de72..586e257ac 100644 --- a/truss/tests/test_model_inference.py +++ b/truss/tests/test_model_inference.py @@ -61,13 +61,13 @@ def join(self, timeout=None): @pytest.mark.parametrize( "python_version, expected_python_version", [ - ("py36", "py39"), - ("py37", "py39"), - ("py38", "py39"), + ("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): diff --git a/truss/tests/test_truss_handle.py b/truss/tests/test_truss_handle.py index 27490ed24..13d577e94 100644 --- a/truss/tests/test_truss_handle.py +++ b/truss/tests/test_truss_handle.py @@ -100,7 +100,7 @@ def test_build_docker_image(custom_model_truss_dir_with_pre_and_post): "base_image, path, expected_fail", [ ("baseten/truss-server-base:3.9-v0.4.8rc4", "/usr/local/bin/python3", False), - ("python:3.9", "/usr/local/bin/python3", False), + ("python:3.8", "/usr/local/bin/python3", False), ("python:3.10", "/usr/local/bin/python3", False), ("python:3.11", "/usr/local/bin/python3", False), ("python:alpine", "/usr/local/bin/python3", True), @@ -396,6 +396,8 @@ def test_enable_gpu(custom_model_truss_dir_with_pre_and_post): @pytest.mark.parametrize( "python_version, expected_python_version", [ + ("3.8", "py38"), + ("py38", "py38"), ("3.9", "py39"), ("py39", "py39"), ], diff --git a/truss/tests/util/test_path.py b/truss/tests/util/test_path.py index 4fe69948a..4764801ce 100644 --- a/truss/tests/util/test_path.py +++ b/truss/tests/util/test_path.py @@ -43,7 +43,7 @@ def test_copy_tree_path_with_hidden_files(custom_model_truss_dir_with_hidden_fil with path.given_or_temporary_dir() as dir: path.copy_tree_path(custom_model_truss_dir_with_hidden_files, dir) - assert not (dir / "__pycache__" / "test.cpython-39.pyc").exists() + assert not (dir / "__pycache__" / "test.cpython-311.pyc").exists() assert not (dir / ".DS_Store").exists() assert not (dir / ".git").exists() assert (dir / "model").exists() @@ -56,7 +56,7 @@ def test_is_ignored(custom_model_truss_dir_with_hidden_files): assert path.is_ignored( custom_model_truss_dir_with_hidden_files / "__pycache__" - / "test.cpython-39.pyc", + / "test.cpython-311.pyc", patterns, ) @@ -127,7 +127,7 @@ def test_ignored_files_in_docker_context( assert dir.exists() - assert not (dir / "__pycache__" / "test.cpython-39.pyc").exists() + assert not (dir / "__pycache__" / "test.cpython-311.pyc").exists() assert not (dir / ".DS_Store").exists() assert not (dir / ".git").exists() assert (dir / "model").exists() @@ -135,7 +135,7 @@ def test_ignored_files_in_docker_context( assert ( custom_model_truss_dir_with_hidden_files / "__pycache__" - / "test.cpython-39.pyc" + / "test.cpython-311.pyc" ).exists() assert (custom_model_truss_dir_with_hidden_files / ".DS_Store").exists() assert (custom_model_truss_dir_with_hidden_files / ".git").exists() @@ -220,7 +220,7 @@ def test_get_ignored_relative_paths_from_root(custom_model_truss_dir_with_hidden ) ignored_relative_paths_strs = { "__pycache__", - "__pycache__/test.cpython-39.pyc", + "__pycache__/test.cpython-311.pyc", ".DS_Store", ".git", ".git/.test_file", diff --git a/truss/truss_config.py b/truss/truss_config.py index 1a86c11f9..a0d9f227f 100644 --- a/truss/truss_config.py +++ b/truss/truss_config.py @@ -39,7 +39,7 @@ DEFAULT_BLOB_BACKEND = HTTP_PUBLIC_BLOB_BACKEND -VALID_PYTHON_VERSIONS = ["py39", "py310", "py311"] +VALID_PYTHON_VERSIONS = ["py38", "py39", "py310", "py311"] # Set up logging logging.basicConfig(level=logging.INFO) @@ -502,8 +502,10 @@ class TrussConfig: @property def canonical_python_version(self) -> str: return { - "py39": "3.9", "py311": "3.11", + "py39": "3.9", + "py38": "3.8", + "py37": "3.7", }[self.python_version] @staticmethod diff --git a/truss/truss_handle.py b/truss/truss_handle.py index 0139040d0..e7e785251 100644 --- a/truss/truss_handle.py +++ b/truss/truss_handle.py @@ -703,8 +703,6 @@ def update_python_version(self, python_version: str): self._update_config( lambda conf: replace( conf, - # TODO: should this be wrapped in - # `map_to_supported_python_version`? python_version=inferred_python_version, ) )