From a3898b5738082185f540e1f7fb906e65100207de Mon Sep 17 00:00:00 2001 From: marvinfriede <51965259+marvinfriede@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:16:44 +0200 Subject: [PATCH] Test all PyTorch versions >=1.11.0 --- .github/workflows/python.yaml | 61 ++++++++++++++++++++++++++++------ .github/workflows/release.yaml | 14 ++++++++ tox.ini | 25 ++++++++++++-- 3 files changed, 87 insertions(+), 13 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 0085bd3..e86fb3c 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -1,3 +1,17 @@ +# This file is part of tad-dftd3. +# SPDX-Identifier: Apache-2.0 +# +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. name: Tests on: @@ -7,41 +21,57 @@ on: - master paths-ignore: - "doc*/**" + - "./*.ya?ml" - "**/*.md" - "**/*.rst" pull_request: paths-ignore: - "doc*/**" + - "./*.ya?ml" - "**/*.md" - "**/*.rst" workflow_dispatch: jobs: - python: - runs-on: ${{ matrix.os }} + main: strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - # PyTorch now fully supports Python =<3.11 - # see: https://github.com/pytorch/pytorch/issues/86566 - # - # PyTorch does not support Python 3.12 (all platforms) - # see: https://github.com/pytorch/pytorch/issues/110436 + torch-version: ["1.11.0", "1.12.1", "1.13.1", "2.0.1", "2.1.2", "2.2.2"] exclude: + # PyTorch now fully supports Python=<3.11 + # see: https://github.com/pytorch/pytorch/issues/86566 + # + # PyTorch does not support Python 3.12 (all platforms) + # see: https://github.com/pytorch/pytorch/issues/110436 - os: ubuntu-latest python-version: "3.12" - os: macos-latest python-version: "3.12" - os: windows-latest python-version: "3.12" + # PyTorch<1.13.0 does only support Python=<3.10 + - python-version: "3.11" + torch-version: "1.11.0" + - python-version: "3.11" + torch-version: "1.12.1" + # On macOS and Windows, 1.13.x is also not supported for Python>=3.10 + - os: macos-latest + python-version: "3.11" + torch-version: "1.13.1" + - os: windows-latest + python-version: "3.11" + torch-version: "1.13.1" + + runs-on: ${{ matrix.os }} defaults: run: - shell: ${{ contains(matrix.os, 'windows') && 'powershell' || 'bash {0}' }} + shell: bash {0} steps: - name: Checkout code @@ -57,11 +87,20 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install tox - - name: Test Python API - run: tox -e py + - name: Determine TOXENV + run: echo "TOXENV=py$(echo ${{ matrix.python-version }} | tr -d '.')-torch$(echo ${{ matrix.torch-version }} | tr -d '.')" >> $GITHUB_ENV + + - name: Print TOXENV + run: echo "TOXENV is set to '${{ env.TOXENV }}'." + + - name: Unittests with tox + run: tox -e ${{ env.TOXENV }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 - if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' + if: > + matrix.python-version == '3.11' && + matrix.torch-version == '2.2.2' && + matrix.os == 'ubuntu-latest' with: files: ./coverage.xml # optional diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 75f66ae..bf9177d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,3 +1,17 @@ +# This file is part of tad-dftd3. +# SPDX-Identifier: Apache-2.0 +# +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. name: Build on: diff --git a/tox.ini b/tox.ini index 0360127..0c67add 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ # This file is part of tad-dftd3. +# # SPDX-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +16,30 @@ [tox] min_version = 4.0 isolated_build = True -envlist = py{38,39,310,311} +envlist = + py38-torch{1110,1121,1131,201,212,222}, + py39-torch{1110,1121,1131,201,212,222}, + py310-torch{1110,1121,1131,201,212,222}, + py311-torch{1131,201,212,221} [testenv] -deps = .[tox] +setenv = + PIP_EXTRA_INDEX_URL = {env:PIP_EXTRA_INDEX_URL:https://download.pytorch.org/whl/cpu} +deps = + torch1110: torch==1.11.0 + torch1120: torch==1.12.0 + torch1121: torch==1.12.1 + torch1130: torch==1.13.0 + torch1131: torch==1.13.1 + torch200: torch==2.0.0 + torch201: torch==2.0.1 + torch210: torch==2.1.0 + torch211: torch==2.1.1 + torch212: torch==2.1.2 + torch220: torch==2.2.0 + torch221: torch==2.2.1 + torch222: torch==2.2.2 + .[tox] commands = pytest -vv {posargs: \ -n logical \