diff --git a/.github/workflows/check_example_nbs.yml b/.github/workflows/check_example_nbs.yml index 11a297738..f51133bed 100644 --- a/.github/workflows/check_example_nbs.yml +++ b/.github/workflows/check_example_nbs.yml @@ -21,7 +21,7 @@ jobs: - name: Set Up Python uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: 3.8 - name: Set Up Environment run: | make install-uv reset-venv diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ed15a6ff..b7579d7c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ["3.7", "3.12"] + python: ["3.8", "3.12"] steps: - name: Checkout Code @@ -51,8 +51,8 @@ jobs: make install-uv reset-venv source .venv/bin/activate make install-pinned-extras-${{ matrix.python }} - - name: Run Pytest (Python 3.7) - if: matrix.python == '3.7' + - name: Run Pytest (Python 3.8) + if: matrix.python == '3.8' run: | source .venv/bin/activate export LIGHTLY_SERVER_LOCATION="localhost:-1" diff --git a/.github/workflows/test_code_format.yml b/.github/workflows/test_code_format.yml index 99ce19ba2..79df95458 100644 --- a/.github/workflows/test_code_format.yml +++ b/.github/workflows/test_code_format.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ["3.7", "3.12"] + python: ["3.8", "3.12"] steps: - name: Checkout Code uses: actions/checkout@v4 diff --git a/.github/workflows/test_minimal_deps.yml b/.github/workflows/test_minimal_deps.yml index 6c272e7e6..bd5279a45 100644 --- a/.github/workflows/test_minimal_deps.yml +++ b/.github/workflows/test_minimal_deps.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ["3.7"] + python: ["3.8"] dependencies: ["minimal", "minimal-extras"] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test_setup.yml b/.github/workflows/test_setup.yml index ec8cb2fa5..43031b6de 100644 --- a/.github/workflows/test_setup.yml +++ b/.github/workflows/test_setup.yml @@ -40,7 +40,7 @@ jobs: - name: Set Up Python uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: 3.8 - name: Set Up Environment run: | make install-uv reset-venv diff --git a/.github/workflows/tests_unmocked.yml b/.github/workflows/tests_unmocked.yml index cd17a3544..4c7c680e9 100644 --- a/.github/workflows/tests_unmocked.yml +++ b/.github/workflows/tests_unmocked.yml @@ -17,7 +17,7 @@ jobs: - name: Set Up Python uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: 3.8 cache: pip cache-dependency-path: | pyproject.toml diff --git a/.readthedocs.yml b/.readthedocs.yml index f909f3164..6583e0deb 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -15,7 +15,7 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 + version: 3.8 install: - method: pip path: . diff --git a/Makefile b/Makefile index bcc17a5d3..10ad259dd 100644 --- a/Makefile +++ b/Makefile @@ -206,8 +206,8 @@ else endif # Install package with pinned extras for specific Python versions used in CI. -.PHONY: install-pinned-extras-3.7 install-pinned-extras-3.12 -install-pinned-extras-3.7: install-pinned-extras-no-video +.PHONY: install-pinned-extras-3.8 install-pinned-extras-3.12 +install-pinned-extras-3.8: install-pinned-extras-no-video install-pinned-extras-3.12: install-av-system-deps install-pinned-extras # Install package with the latest dependencies. diff --git a/README.md b/README.md index 1629fb860..b0e0308c9 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Community and partner projects: ## Quick Start -Lightly requires **Python 3.7+**. We recommend installing Lightly in a **Linux** or **OSX** environment. Python 3.13 is not yet supported, as PyTorch itself lacks Python 3.13 compatibility. +Lightly requires **Python 3.8+**. We recommend installing Lightly in a **Linux** or **OSX** environment. Python 3.13 is not yet supported, as PyTorch itself lacks Python 3.13 compatibility. ### Dependencies diff --git a/docs/source/getting_started/install.rst b/docs/source/getting_started/install.rst index c840c319d..f154d4160 100644 --- a/docs/source/getting_started/install.rst +++ b/docs/source/getting_started/install.rst @@ -4,7 +4,7 @@ Installation Supported Python versions ------------------------- -Lightly\ **SSL** requires Python 3.7+. We recommend installing Lightly\ **SSL** in a Linux or OSX environment. +Lightly\ **SSL** requires Python 3.8+. We recommend installing Lightly\ **SSL** in a Linux or OSX environment. .. _rst-installing: diff --git a/lightly/loss/lejepa_loss.py b/lightly/loss/lejepa_loss.py index 53bc3114e..80059ac43 100644 --- a/lightly/loss/lejepa_loss.py +++ b/lightly/loss/lejepa_loss.py @@ -1,5 +1,7 @@ """LeJEPA loss functions and regularizers.""" +from typing import cast + import torch from torch import Tensor, nn from torch import distributed as torch_dist @@ -202,7 +204,10 @@ def _compute_cf_error_at_each_frequency( cos_mean = cos_sum / num_samples sin_mean = sin_sum / num_samples phi = self.phi.to(dtype=x_t.dtype) - return (cos_mean - phi).square() + sin_mean.square() # type: ignore[operator] + return cast( + Tensor, + (cos_mean - phi).square() + sin_mean.square(), # type: ignore[operator] + ) def _integrate_via_trapezoidal_rule( self, @@ -212,7 +217,7 @@ def _integrate_via_trapezoidal_rule( """Integrate the error over frequency using trapezoidal weights.""" weights = self.weights.to(dtype=err_per_frequency.dtype) statistic = (err_per_frequency @ weights) * num_samples # type: ignore[operator] - return statistic.mean() + return cast(Tensor, statistic.mean()) def forward(self, proj: Tensor) -> Tensor: """Compute the SIGReg loss for a batch of projections. diff --git a/lightly/utils/lars.py b/lightly/utils/lars.py index 44bf43e7b..bd50ebd7a 100644 --- a/lightly/utils/lars.py +++ b/lightly/utils/lars.py @@ -101,7 +101,7 @@ def __setstate__(self, state: Dict[str, Any]) -> None: for group in self.param_groups: group.setdefault("nesterov", False) - # Type ignore for overloads is required for Python 3.7. + # PyTorch's version-dependent overloads do not match these signatures. @overload # type: ignore[override] def step(self, closure: None = None) -> None: ... diff --git a/pyproject.toml b/pyproject.toml index a77aeffb8..015821679 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name="lightly" -requires-python = ">=3.6" +requires-python = ">=3.8" authors = [ {name = "Lightly Team", email = "team@lightly.ai"}, ] @@ -26,8 +26,6 @@ classifiers = [ "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -103,7 +101,7 @@ openapi = [ "aenum>=3.1.11" ] timm = ["timm>=0.9.9"] -video = ["av>=8.0.3; python_version>='3.8'"] +video = ["av>=12.0.0; python_version>='3.8'"] matplotlib = ["matplotlib>=3"] @@ -135,7 +133,7 @@ lightly = ["lightly/cli/config/*.yaml"] [tool.ruff] line-length = 88 -target-version = "py37" +target-version = "py38" extend-exclude = ["lightly/openapi_generated"] [tool.ruff.lint]