From 172b42e90683a16a548b568b393e245eb7079990 Mon Sep 17 00:00:00 2001 From: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:16:37 +0200 Subject: [PATCH] chore: add python 3.11 support (#169) Signed-off-by: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com> --- .github/workflows/main-check.yml | 2 +- .github/workflows/validate-pr.yml | 2 +- .github/workflows/windows-subprocess-check.yml | 2 +- CHANGELOG.md | 4 ++++ benchmark/camelyon/README.md | 6 +++--- benchmark/camelyon/pure_substrafl/register_assets.py | 6 +++--- benchmark/camelyon/requirements.txt | 8 ++++---- benchmark/camelyon/workflows.py | 2 +- docker/substrafl-tests/Dockerfile | 2 +- examples/template/template.py | 2 +- setup.py | 3 ++- substrafl/remote/register/register.py | 4 ++-- tests/remote/register/test_register.py | 2 +- 13 files changed, 25 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main-check.yml b/.github/workflows/main-check.yml index 0b2bae25..97d48d9a 100644 --- a/.github/workflows/main-check.yml +++ b/.github/workflows/main-check.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - python: ["3.8", "3.9", "3.10"] + python: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index fb809968..b5b6c5dc 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - python: ["3.8", "3.9", "3.10"] + python: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/windows-subprocess-check.yml b/.github/workflows/windows-subprocess-check.yml index 494cdd25..b002d0c0 100644 --- a/.github/workflows/windows-subprocess-check.yml +++ b/.github/workflows/windows-subprocess-check.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [windows-latest] - python: ["3.8", "3.9", "3.10"] + python: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index b31ee454..d35f421b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## \[Unreleased\] +### Added + +- Support on Python 3.11 ([#169](https://github.com/Substra/substrafl/pull/169)) + ## [0.41.1](https://github.com/Substra/substrafl/releases/tag/0.41.1) - 2023-10-06 ### Fixed diff --git a/benchmark/camelyon/README.md b/benchmark/camelyon/README.md index 77c5a498..d430c028 100644 --- a/benchmark/camelyon/README.md +++ b/benchmark/camelyon/README.md @@ -19,7 +19,7 @@ Being able to compare substrafl local speed to a full torch example with a varia **All the commands should be run from `benchmark/camelyon`** -In a new python 3.10 environment : +In a new python 3.11 environment : ```sh pip install -r requirements.txt @@ -33,13 +33,13 @@ Please ensure that your python installation is complete. For Mac users if you ge UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError. ``` -You'll need to uninstall python 3.10, and install the `xz` package : +You'll need to uninstall python 3.11, and install the `xz` package : ```sh brew install xz ``` -then reinstall python 3.10. +then reinstall python 3.11. ### Getting Started diff --git a/benchmark/camelyon/pure_substrafl/register_assets.py b/benchmark/camelyon/pure_substrafl/register_assets.py index ec48721c..e0659243 100644 --- a/benchmark/camelyon/pure_substrafl/register_assets.py +++ b/benchmark/camelyon/pure_substrafl/register_assets.py @@ -98,7 +98,7 @@ def add_duplicated_dataset( data_sample_folder: os.PathLike, asset_keys: dict, msp_id: str, - kind: str = TaskType.TRAIN, + kind: str = TaskType.TRAIN.value, ) -> dict: """Update asset_keys.msp_id.{kind}_data_sample_keys so there is exactly `nb_data_sample` keys by adding the `data_sample_folder` as a data sample with the provided `client` as many times as it's need @@ -126,7 +126,7 @@ def add_duplicated_dataset( } msp_id (str): asset_keys key where to find the registered assets for the given client kind (str, optional): Kind of data sample to add, either train or test. Defaults to - TaskType.TRAIN. + TaskType.TRAIN.value. Returns: dict: The updated asset_keys. @@ -193,7 +193,7 @@ def get_train_data_nodes( data_sample_folder=train_folder, asset_keys=asset_keys, msp_id=msp_id, - kind=TaskType.TRAIN, + kind=TaskType.TRAIN.value, ) train_data_nodes.append( diff --git a/benchmark/camelyon/requirements.txt b/benchmark/camelyon/requirements.txt index 499c3aea..6d196e93 100644 --- a/benchmark/camelyon/requirements.txt +++ b/benchmark/camelyon/requirements.txt @@ -1,5 +1,5 @@ tqdm==4.62.3 -numpy==1.23.1 -scikit-learn==1.1.1 -torch==1.13.1 -torchvision==0.14.1 +numpy==1.24.3 +scikit-learn==1.3.1 +torch==2.0.1 +torchvision==0.15.2 diff --git a/benchmark/camelyon/workflows.py b/benchmark/camelyon/workflows.py index d2e2e967..91c217ab 100644 --- a/benchmark/camelyon/workflows.py +++ b/benchmark/camelyon/workflows.py @@ -87,7 +87,7 @@ def substrafl_fed_avg( # Dependencies base = Path(__file__).parent dependencies = Dependency( - pypi_dependencies=["numpy==1.23.5", "torch==2.0.1", "scikit-learn==1.1.1"], + pypi_dependencies=["numpy==1.24.3", "torch==2.0.1", "scikit-learn==1.3.1"], local_code=[base / "common", base / "weldon_fedavg.py"], # Keeping editable_mode=True to ensure nightly test benchmarks are ran against main substrafl git ref editable_mode=True, diff --git a/docker/substrafl-tests/Dockerfile b/docker/substrafl-tests/Dockerfile index 359d04ad..959ad1d7 100644 --- a/docker/substrafl-tests/Dockerfile +++ b/docker/substrafl-tests/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10 +FROM python:3.11 WORKDIR /usr/src/app diff --git a/examples/template/template.py b/examples/template/template.py index e661170d..891df248 100644 --- a/examples/template/template.py +++ b/examples/template/template.py @@ -195,7 +195,7 @@ def __init__(self): # Algo dependencies # ================= -algo_deps = Dependency(pypi_dependencies=["numpy==1.23.1", "torch==1.12.0"]) +algo_deps = Dependency(pypi_dependencies=["numpy==1.24.3", "torch==2.0.1"]) # %% # Federated Learning strategies diff --git a/setup.py b/setup.py index 43778906..72e98f74 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], keywords=["substrafl"], packages=find_packages(exclude=["tests*", "benchmark*"]), @@ -40,7 +41,7 @@ # that release is private and in the Docker container # it has access only to the public PyPi install_requires=[ - "numpy>=1.20.3, <1.24", + "numpy>=1.24", "cloudpickle>=1.6.0", "substra~=0.48.1", "substratools~=0.21.0", diff --git a/substrafl/remote/register/register.py b/substrafl/remote/register/register.py index db9e7874..b0cf910f 100644 --- a/substrafl/remote/register/register.py +++ b/substrafl/remote/register/register.py @@ -33,9 +33,9 @@ MINIMAL_DOCKER_SUBSTRATOOLS_VERSION = "0.16.0" # minimal and maximal values of Python 3 minor versions supported -# we need to store this as integer, else "3.10" < "3.9" (string comparison) +# we need to store this as integer, else "3.11" < "3.9" (string comparison) MINIMAL_PYTHON_VERSION = 8 # 3.8 -MAXIMAL_PYTHON_VERSION = 10 # 3.10 +MAXIMAL_PYTHON_VERSION = 11 # 3.11 _DEFAULT_SUBSTRATOOLS_IMAGE = "ghcr.io/substra/substra-tools:\ {substratools_version}-nvidiacuda11.8.0-base-ubuntu22.04-python{python_version}" diff --git a/tests/remote/register/test_register.py b/tests/remote/register/test_register.py index 3cd06064..53833cd9 100644 --- a/tests/remote/register/test_register.py +++ b/tests/remote/register/test_register.py @@ -40,7 +40,7 @@ def test_check_python_version(version): register._check_python_version(version) -@pytest.mark.parametrize("version", ["3.8", "3.9", "3.10"]) +@pytest.mark.parametrize("version", ["3.8", "3.9", "3.10", "3.11"]) def test_check_python_version_valid(version): """Does not raise for supported versions""" register._check_python_version(version)