From 8a87e0d373338eff30556e3823a851fab703ba00 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Wed, 22 Dec 2021 09:23:22 +0000 Subject: [PATCH 1/4] drop py36 support Signed-off-by: Wenqi Li --- .github/workflows/pythonapp-gpu.yml | 2 +- .github/workflows/pythonapp-min.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/setupapp.yml | 2 +- .pre-commit-config.yaml | 2 +- CONTRIBUTING.md | 4 ++-- docs/source/installation.md | 2 +- monai/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pythonapp-gpu.yml b/.github/workflows/pythonapp-gpu.yml index bae009d0a1..faec9ec612 100644 --- a/.github/workflows/pythonapp-gpu.yml +++ b/.github/workflows/pythonapp-gpu.yml @@ -62,7 +62,7 @@ jobs: [ ${{ matrix.environment }} = "PT18+CUDA102" ] || \ [ ${{ matrix.environment }} = "PT110+CUDA102" ] then - PYVER=3.6 PYSFX=3 DISTUTILS=python3-distutils && \ + PYVER=3.7 PYSFX=3 DISTUTILS=python3-distutils && \ apt-get update && apt-get install -y --no-install-recommends \ curl \ pkg-config \ diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index b0db5c31c5..b7816542ea 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -74,7 +74,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9] timeout-minutes: 40 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34f8390fa9..9cef1ff090 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/setupapp.yml b/.github/workflows/setupapp.yml index 419c73fc10..2ad69a0037 100644 --- a/.github/workflows/setupapp.yml +++ b/.github/workflows/setupapp.yml @@ -74,7 +74,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea637fe329..980c0c0e06 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: rev: v2.29.0 hooks: - id: pyupgrade - args: [--py36-plus] + args: [--py37-plus] name: Upgrade code exclude: | (?x)^( diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b7782ae0d3..ec6bf35ef9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ or (for new features that would not break existing functionality): ``` It is recommended that the new test `test_[module_name].py` is constructed by using only -python 3.6+ build-in functions, `torch`, `numpy`, `coverage` (for reporting code coverages) and `parameterized` (for organising test cases) packages. +python 3.7+ build-in functions, `torch`, `numpy`, `coverage` (for reporting code coverages) and `parameterized` (for organising test cases) packages. If it requires any other external packages, please make sure: - the packages are listed in [`requirements-dev.txt`](requirements-dev.txt) - the new test `test_[module_name].py` is added to the `exclude_cases` in [`./tests/min_tests.py`](./tests/min_tests.py) so that @@ -228,7 +228,7 @@ Notably, for example, ``import monai.transforms.Spacing`` is the equivalent of ``monai.transforms.spatial.array.Spacing`` if ``class Spacing`` defined in file `monai/transforms/spatial/array.py` is decorated with ``@export("monai.transforms")``. -For string definition, [f-string](https://www.python.org/dev/peps/pep-0498/) is recommended to use over `%-print` and `format-print` from python 3.6. So please try to use `f-string` if you need to define any string object. +For string definition, [f-string](https://www.python.org/dev/peps/pep-0498/) is recommended to use over `%-print` and `format-print`. So please try to use `f-string` if you need to define any string object. #### Backwards compatibility MONAI is currently under active development, and with major version zero (following the [Semantic Versioning](https://semver.org/)). diff --git a/docs/source/installation.md b/docs/source/installation.md index c431b3389a..2635a6c386 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -14,7 +14,7 @@ --- -MONAI's core functionality is written in Python 3 (>= 3.6) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). +MONAI's core functionality is written in Python 3 (>= 3.7) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). The package is currently distributed via Github as the primary source code repository, and the Python package index (PyPI). The pre-built Docker images are made available on DockerHub. diff --git a/monai/__init__.py b/monai/__init__.py index f422ec5931..ef563b98f4 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -15,7 +15,7 @@ from ._version import get_versions PY_REQUIRED_MAJOR = 3 -PY_REQUIRED_MINOR = 6 +PY_REQUIRED_MINOR = 7 version_dict = get_versions() __version__: str = version_dict.get("version", "0+unknown") diff --git a/pyproject.toml b/pyproject.toml index b53a7640b1..03e9f49ab5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ [tool.black] line-length = 120 -target-version = ['py36', 'py37', 'py38'] +target-version = ['py37', 'py38', 'py39'] include = '\.pyi?$' exclude = ''' ( diff --git a/setup.cfg b/setup.cfg index e7be56c994..8842bf852a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ project_urls = Source Code=https://github.com/Project-MONAI/MONAI [options] -python_requires = >= 3.6 +python_requires = >= 3.7 # for compiling and develop setup only # no need to specify the versions so that we could # compile for multiple targeted versions. From 1f76b9101b636c6b2add34e6652640f9d7590a68 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Wed, 22 Dec 2021 11:11:44 +0000 Subject: [PATCH 2/4] drop 20.09 test because of python min version 3.6 Signed-off-by: Wenqi Li --- .github/workflows/pythonapp-gpu.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pythonapp-gpu.yml b/.github/workflows/pythonapp-gpu.yml index faec9ec612..e02ae73141 100644 --- a/.github/workflows/pythonapp-gpu.yml +++ b/.github/workflows/pythonapp-gpu.yml @@ -20,22 +20,24 @@ jobs: matrix: environment: - "PT17+CUDA102" - - "PT17+CUDA110" - "PT18+CUDA102" + - "PT18+CUDA110" - "PT19+CUDA114" - "PT110+CUDA115" - "PT110+CUDA102" include: + # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes - environment: PT17+CUDA102 pytorch: "torch==1.7.1 torchvision==0.8.2" base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" - - environment: PT17+CUDA110 - # we explicitly set pytorch to -h to avoid pip install error - pytorch: "-h" - base: "nvcr.io/nvidia/pytorch:20.09-py3" - environment: PT18+CUDA102 pytorch: "torch==1.8.1 torchvision==0.9.1" base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" + - environment: PT18+CUDA110 + # we explicitly set pytorch to -h to avoid pip install error + # 21.02: 1.8.0a0+52ea372 + pytorch: "-h" + base: "nvcr.io/nvidia/pytorch:21.02-py3" - environment: PT19+CUDA114 # we explicitly set pytorch to -h to avoid pip install error # 21.10: 1.10.0a0+0aef44c @@ -43,7 +45,6 @@ jobs: base: "nvcr.io/nvidia/pytorch:21.10-py3" - environment: PT110+CUDA115 # we explicitly set pytorch to -h to avoid pip install error - # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes # 21.12: 1.11.0a0+b6df043 pytorch: "-h" base: "nvcr.io/nvidia/pytorch:21.12-py3" From 95938846f4bf2f342d248b05049dea1d1e8b60f1 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Wed, 22 Dec 2021 17:14:54 +0000 Subject: [PATCH 3/4] update tests Signed-off-by: Wenqi Li --- .github/workflows/pythonapp-gpu.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonapp-gpu.yml b/.github/workflows/pythonapp-gpu.yml index e02ae73141..6bed2cc13c 100644 --- a/.github/workflows/pythonapp-gpu.yml +++ b/.github/workflows/pythonapp-gpu.yml @@ -21,7 +21,7 @@ jobs: environment: - "PT17+CUDA102" - "PT18+CUDA102" - - "PT18+CUDA110" + - "PT18+CUDA112" - "PT19+CUDA114" - "PT110+CUDA115" - "PT110+CUDA102" @@ -33,11 +33,11 @@ jobs: - environment: PT18+CUDA102 pytorch: "torch==1.8.1 torchvision==0.9.1" base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" - - environment: PT18+CUDA110 + - environment: PT18+CUDA112 # we explicitly set pytorch to -h to avoid pip install error - # 21.02: 1.8.0a0+52ea372 + # 21.03: 1.9.0a0+df837d0 pytorch: "-h" - base: "nvcr.io/nvidia/pytorch:21.02-py3" + base: "nvcr.io/nvidia/pytorch:21.03-py3" - environment: PT19+CUDA114 # we explicitly set pytorch to -h to avoid pip install error # 21.10: 1.10.0a0+0aef44c From 2af2cd5ecafc42cd6458ef9da646ccf27c817588 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Thu, 23 Dec 2021 09:46:23 +0000 Subject: [PATCH 4/4] error->warning, revise copyright Signed-off-by: Wenqi Li --- docs/source/conf.py | 2 +- monai/__init__.py | 12 +++++++----- monai/data/torchscript_utils.py | 2 +- tests/test_torchscript_utils.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index fe10c546cd..47a45a78e8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ # -- Project information ----------------------------------------------------- project = "MONAI" -copyright = "2020 - 2021 MONAI Consortium" +copyright = "MONAI Consortium" author = "MONAI Contributors" # The full version, including alpha/beta/rc tags diff --git a/monai/__init__.py b/monai/__init__.py index ef563b98f4..68a232b46d 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -22,15 +22,17 @@ __revision_id__: str = version_dict.get("full-revisionid") del get_versions, version_dict -__copyright__ = "(c) 2020 - 2021 MONAI Consortium" +__copyright__ = "(c) MONAI Consortium" __basedir__ = os.path.dirname(__file__) if sys.version_info.major != PY_REQUIRED_MAJOR or sys.version_info.minor < PY_REQUIRED_MINOR: - raise RuntimeError( - "MONAI requires Python {}.{} or higher. But the current Python is: {}".format( - PY_REQUIRED_MAJOR, PY_REQUIRED_MINOR, sys.version - ) + import warnings + + warnings.warn( + f"MONAI requires Python {PY_REQUIRED_MAJOR}.{PY_REQUIRED_MINOR} or higher. " + f"But the current Python is: {sys.version}", + category=RuntimeWarning, ) from .utils.module import load_submodules # noqa: E402 diff --git a/monai/data/torchscript_utils.py b/monai/data/torchscript_utils.py index 17539ce1dc..585db14712 100644 --- a/monai/data/torchscript_utils.py +++ b/monai/data/torchscript_utils.py @@ -1,4 +1,4 @@ -# Copyright 2020 - 2021 MONAI Consortium +# Copyright (c) MONAI Consortium # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/tests/test_torchscript_utils.py b/tests/test_torchscript_utils.py index b9840f68f1..b26d41345a 100644 --- a/tests/test_torchscript_utils.py +++ b/tests/test_torchscript_utils.py @@ -1,4 +1,4 @@ -# Copyright 2020 - 2021 MONAI Consortium +# Copyright (c) MONAI Consortium # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at