From 1c76372395e39a714ed76d81640b31a5136f9db0 Mon Sep 17 00:00:00 2001 From: MalteEbner Date: Tue, 17 Sep 2024 10:38:25 +0200 Subject: [PATCH] Support python 3.12 (#1648) --- .github/workflows/release_pypi.yml | 4 ++-- .github/workflows/test.yml | 8 ++++---- .github/workflows/test_api_deps_only.yml | 2 +- .github/workflows/weekly_dependency_test.yml | 2 +- pyproject.toml | 1 + tests/api/test_download.py | 6 +++--- tests/loss/test_DINOLoss.py | 4 ++-- tests/loss/test_VICRegLoss.py | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index ca2b8151b..a678a7f6e 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -21,10 +21,10 @@ jobs: LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG echo "tag_name=$LATEST_TAG" >> $GITHUB_OUTPUT; - - name: Set up Python 3.10 + - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Build and release id: build_and_release run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5842c4a29..22ef288ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.7", "3.10"] + python: ["3.7", "3.12"] steps: - name: Checkout Code @@ -59,15 +59,15 @@ jobs: source .venv/bin/activate export LIGHTLY_SERVER_LOCATION="localhost:-1" python -m pytest -s -v --runslow --ignore=./lightly/openapi_generated/ - - name: Run Pytest with Coverage (Python 3.10) - if: matrix.python == '3.10' + - name: Run Pytest with Coverage (Python 3.12) + if: matrix.python == '3.12' run: | source .venv/bin/activate export LIGHTLY_SERVER_LOCATION="localhost:-1" uv pip install pytest-cov==5.0.0 python -m pytest -s -v --runslow --cov=./lightly --cov-report=xml --ignore=./lightly/openapi_generated/ - name: Upload Coverage to Codecov - if: matrix.python == '3.10' + if: matrix.python == '3.12' uses: codecov/codecov-action@v4 with: fail_ci_if_error: false diff --git a/.github/workflows/test_api_deps_only.yml b/.github/workflows/test_api_deps_only.yml index 49723f1de..06aa0edec 100644 --- a/.github/workflows/test_api_deps_only.yml +++ b/.github/workflows/test_api_deps_only.yml @@ -38,7 +38,7 @@ jobs: - name: Set Up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Set Up Environment run: | make install-uv reset-venv diff --git a/.github/workflows/weekly_dependency_test.yml b/.github/workflows/weekly_dependency_test.yml index 3977946bf..fddc56202 100644 --- a/.github/workflows/weekly_dependency_test.yml +++ b/.github/workflows/weekly_dependency_test.yml @@ -19,7 +19,7 @@ jobs: - name: Set Up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Set Up Environment run: | make install-uv reset-venv diff --git a/pyproject.toml b/pyproject.toml index 5b083643d..40bbb50ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ] dependencies = [ diff --git a/tests/api/test_download.py b/tests/api/test_download.py index 8921d461f..4851d0c68 100644 --- a/tests/api/test_download.py +++ b/tests/api/test_download.py @@ -188,7 +188,7 @@ def test_download_all_video_frames(self): def test_download_all_video_frames_timeout(self): with tempfile.NamedTemporaryFile(suffix=".avi") as file: _generate_video(file.name) - with self.assertRaisesRegexp( + with self.assertRaisesRegex( RuntimeError, "Maximum retries exceeded.*av.error.ExitError.*Immediate exit requested.*", ): @@ -237,7 +237,7 @@ def test_download_video_frames_at_timestamps_timeout(self): with tempfile.NamedTemporaryFile(suffix=".avi") as file: n_frames = 5 _generate_video(file.name, n_frames) - with self.assertRaisesRegexp( + with self.assertRaisesRegex( RuntimeError, "Maximum retries exceeded.*av.error.ExitError.*Immediate exit requested.*", ): @@ -436,7 +436,7 @@ def test_download_video_frame_count(self): def test_download_video_Frame_count_timeout(self): with tempfile.NamedTemporaryFile(suffix=".avi") as file: _generate_video(file.name) - with self.assertRaisesRegexp( + with self.assertRaisesRegex( RuntimeError, "Maximum retries exceeded.*av.error.ExitError.*Immediate exit requested.*", ): diff --git a/tests/loss/test_DINOLoss.py b/tests/loss/test_DINOLoss.py index cfd452175..bfcd4132b 100644 --- a/tests/loss/test_DINOLoss.py +++ b/tests/loss/test_DINOLoss.py @@ -221,11 +221,11 @@ def test( for param, orig_param in zip( student.parameters(), orig_student.parameters() ): - self.assertTrue(torch.allclose(param, orig_param)) + torch.testing.assert_close(param, orig_param) for param, orig_param in zip( teacher.parameters(), orig_teacher.parameters() ): - self.assertTrue(torch.allclose(param, orig_param)) + torch.testing.assert_close(param, orig_param) def test_all(**kwargs): """Tests all combinations of the input parameters""" diff --git a/tests/loss/test_VICRegLoss.py b/tests/loss/test_VICRegLoss.py index 4787f30b4..3b26f0c00 100644 --- a/tests/loss/test_VICRegLoss.py +++ b/tests/loss/test_VICRegLoss.py @@ -81,7 +81,7 @@ def test_forward__compare_vicregl(self) -> None: loss = VICRegLoss(nu_param=0.5) x0 = torch.randn((2, 10, 32)) x1 = torch.randn((2, 10, 32)) - assert loss(x0, x1).item() == _reference_vicregl_vicreg_loss(x0, x1).item() + torch.testing.assert_close(loss(x0, x1), _reference_vicregl_vicreg_loss(x0, x1)) def _reference_vicreg_loss(