From ff42b9502ebc45d3a96011ca54e409b14b14f775 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Mon, 11 May 2026 10:08:09 +0800 Subject: [PATCH] enhance: upgrade test Python runtime to 3.12 (#49622) issue: #49516 ### What changed - Upgrade test runtime pins and Docker base images to Python 3.12. - Update tests ruff target and Python-version docs to 3.12. - Refresh Python client dependency pins that block Python 3.12 installation. - Scope TestPyPI lookup to pymilvus via find-links so uv does not require unsafe-best-match. - Suppress third-party invalid escape sequence SyntaxWarning noise seen during Python 3.12 pytest collection. ### Verification - git diff --check - uv pip install --python /tmp/milvus-tests-py312-uv-default/bin/python --dry-run -r tests/python_client/requirements.txt - python3.12 -m venv /tmp/milvus-tests-py312-pip-requirements && pip install -r tests/python_client/requirements.txt --timeout 30 --retries 6 - pip check - python -c 'import pymilvus, ujson; print(pymilvus.__version__, ujson.__version__)' - python -m pytest --collect-only -q milvus_client/test_milvus_client_collection.py Signed-off-by: zhuwenxing --- .github/workflows/mac.yaml | 4 ++-- tests/.python-version | 2 +- tests/README.md | 2 +- tests/README_CN.md | 2 +- tests/docker/Dockerfile | 2 +- tests/python_client/Dockerfile | 2 +- tests/python_client/README.md | 2 +- tests/python_client/README_CN.md | 2 +- tests/python_client/pytest.ini | 1 + tests/python_client/requirements.txt | 16 ++++++++-------- tests/ruff.toml | 2 +- 11 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/mac.yaml b/.github/workflows/mac.yaml index bef1987380..1272bad917 100644 --- a/.github/workflows/mac.yaml +++ b/.github/workflows/mac.yaml @@ -51,9 +51,9 @@ jobs: with: ref: ${{ github.event.inputs.branch || github.ref }} - name: Setup Python environment - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '<3.12' + python-version: '3.12' - name: Install CMake 3.31.8 run: | cmake --version || true diff --git a/tests/.python-version b/tests/.python-version index c8cfe39591..e4fba21835 100644 --- a/tests/.python-version +++ b/tests/.python-version @@ -1 +1 @@ -3.10 +3.12 diff --git a/tests/README.md b/tests/README.md index f30e11f0ab..65542fd6b9 100644 --- a/tests/README.md +++ b/tests/README.md @@ -105,7 +105,7 @@ $ ruff format . # format in place $ ruff format --check . # format check only (CI-friendly) ``` -Rules enabled: `E`, `F`, `W`, `I`, `UP`. Target Python version: `3.10`. +Rules enabled: `E`, `F`, `W`, `I`, `UP`. Target Python version: `3.12`. #### Lint only PR-changed files (Python Lint CI parity) diff --git a/tests/README_CN.md b/tests/README_CN.md index ddaaee2a70..096024d47e 100644 --- a/tests/README_CN.md +++ b/tests/README_CN.md @@ -104,7 +104,7 @@ $ ruff format . # 原地格式化 $ ruff format --check . # 只检查不修改 (CI 友好) ``` -启用的规则:`E`、`F`、`W`、`I`、`UP`;目标 Python 版本:`3.10`。 +启用的规则:`E`、`F`、`W`、`I`、`UP`;目标 Python 版本:`3.12`。 #### 仅检查 PR 修改的文件 (与 Python Lint CI 一致) diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 24d7bc854b..bcfd1604ee 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -9,7 +9,7 @@ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing permissions and limitations under the License. -FROM python:3.8-buster +FROM python:3.12-bullseye RUN apt-get update && apt-get install -y jq diff --git a/tests/python_client/Dockerfile b/tests/python_client/Dockerfile index 531067eab3..d505b43d95 100644 --- a/tests/python_client/Dockerfile +++ b/tests/python_client/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-bullseye +FROM python:3.12-bullseye RUN apt-get update && apt-get install -y jq diff --git a/tests/python_client/README.md b/tests/python_client/README.md index 98424e61b0..de31d38ac3 100644 --- a/tests/python_client/README.md +++ b/tests/python_client/README.md @@ -73,7 +73,7 @@ $ kind export logs . ### PyMilvus Test Environment Deployment and Case Execution -We recommend using Python 3 (3.8 or higher), consistent with the version supported by PyMilvus. +We recommend using Python 3.12, consistent with the Python client CI runtime. > Note: Procedures listed below will be completed automatically if you deployed Milvus using KinD. diff --git a/tests/python_client/README_CN.md b/tests/python_client/README_CN.md index 5220d31306..21f41e041c 100644 --- a/tests/python_client/README_CN.md +++ b/tests/python_client/README_CN.md @@ -65,7 +65,7 @@ Milvus 支持4种部署方式,请根据需求选择部署方式,PyMilvus 支 ### PyMilvus 测试环境部署及用例执行 -推荐使用 **Python 3(>= 3.8)** ,与 **[PyMilvus](https://pymilvus.readthedocs.io/en/latest/install.html)** 支持的 Python 版本保持一致。 +推荐使用 **Python 3.12**,与 Python client CI 运行环境保持一致。 > **_NOTE:_** 如选择KinD部署方式,以下步骤可以自动完成 diff --git a/tests/python_client/pytest.ini b/tests/python_client/pytest.ini index 7b6f7cb240..c9bca261c4 100644 --- a/tests/python_client/pytest.ini +++ b/tests/python_client/pytest.ini @@ -12,6 +12,7 @@ markers = filterwarnings = ignore::DeprecationWarning + ignore:invalid escape sequence:SyntaxWarning asyncio_default_fixture_loop_scope = function timeout_method = thread diff --git a/tests/python_client/requirements.txt b/tests/python_client/requirements.txt index 149c4b2522..1024b8a462 100644 --- a/tests/python_client/requirements.txt +++ b/tests/python_client/requirements.txt @@ -1,8 +1,8 @@ ---extra-index-url https://test.pypi.org/simple/ +--find-links https://test.pypi.org/simple/pymilvus/ pytest-cov==2.8.1 requests>=2.32.4 scikit-learn>=1.5.2 -ujson==5.5.0 +ujson==5.10.0 pytest==8.3.4 pytest-asyncio==0.24.0 pytest-timeout==1.3.3 @@ -18,7 +18,7 @@ pytest_tagging==1.6.0 pytest-html==3.1.1 delayed-assert==0.3.5 kubernetes==17.17.0 -PyYAML==6.0 +PyYAML==6.0.2 pytest-sugar==0.9.5 pytest-random-order @@ -37,14 +37,14 @@ npy-append-array==0.9.15 Faker==19.2.0 # for benchmark -h5py==3.8.0 +h5py==3.11.0 # for log loguru==0.7.0 # util -psutil==5.9.4 -pandas==1.5.3 +psutil==5.9.8 +pandas==2.2.3 numpy==1.26.4 tenacity==8.1.0 rich==13.7.0 @@ -55,10 +55,10 @@ deepdiff==8.6.1 # for test result analyzer prettytable==3.8.0 pyarrow==14.0.1 -fastparquet==2023.7.0 +fastparquet==2024.11.0 # for bf16 datatype -ml-dtypes==0.2.0 +ml-dtypes==0.5.1 # for text processing Unidecode==1.3.8 diff --git a/tests/ruff.toml b/tests/ruff.toml index 69330606db..7d74df9248 100644 --- a/tests/ruff.toml +++ b/tests/ruff.toml @@ -1,5 +1,5 @@ line-length = 120 -target-version = "py310" +target-version = "py312" extend-exclude = [ ".venv", "__pycache__",