Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python 3.10 #2559

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.11', '3.12', '3.13']
steps:
- name: Clone repo
uses: actions/[email protected]
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
id: setup-python
uses: actions/[email protected]
with:
python-version: '3.10'
python-version: '3.11'
- name: Cache dependencies
uses: actions/[email protected]
id: cache
Expand Down
65 changes: 32 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
name = "torchgeo"
description = "TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
license = {file = "LICENSE"}
authors = [
{name = "Adam J. Stewart", email = "[email protected]"},
Expand All @@ -29,7 +29,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand All @@ -39,8 +38,8 @@ classifiers = [
dependencies = [
# einops 0.3+ required for einops.repeat
"einops>=0.3",
# fiona 1.8.21+ required for Python 3.10 wheels
"fiona>=1.8.21",
# fiona 1.8.22+ required for Python 3.11 wheels
"fiona>=1.8.22",
# kornia 0.7.4+ required for AugmentationSequential support for unknown keys
"kornia>=0.7.4",
# lightly 1.4.5+ required for LARS optimizer
Expand All @@ -51,53 +50,53 @@ dependencies = [
# lightning 2.3 contains known bugs related to YAML parsing
# https://github.com/Lightning-AI/pytorch-lightning/issues/19977
"lightning[pytorch-extra]>=2,!=2.3.*,!=2.5.0",
# matplotlib 3.5+ required for Python 3.10 wheels
"matplotlib>=3.5",
# numpy 1.21.2+ required by Python 3.10 wheels
"numpy>=1.21.2",
# pandas 1.3.3+ required for Python 3.10 wheels
"pandas>=1.3.3",
# pillow 8.4+ required for Python 3.10 wheels
"pillow>=8.4",
# pyproj 3.3+ required for Python 3.10 wheels
"pyproj>=3.3",
# rasterio 1.3+ required for Python 3.10 wheels
# matplotlib 3.6+ required for Python 3.11 wheels
"matplotlib>=3.6",
# numpy 1.23.2+ required by Python 3.11 wheels
"numpy>=1.23.2",
# pandas 1.5+ required for Python 3.11 wheels
"pandas>=1.5",
# pillow 9.2+ required for Python 3.11 wheels
"pillow>=9.2",
# pyproj 3.4+ required for Python 3.11 wheels
"pyproj>=3.4",
# rasterio 1.3.3+ required for Python 3.11 wheels
# rasterio 1.4.0-1.4.2 lack support for merging WarpedVRT objects
# https://github.com/rasterio/rasterio/issues/3196
"rasterio>=1.3,!=1.4.0,!=1.4.1,!=1.4.2",
# rtree 1+ required for Python 3.10 wheels
"rtree>=1",
"rasterio>=1.3.3,!=1.4.0,!=1.4.1,!=1.4.2",
# rtree 1.0.1+ required for Python 3.11 wheels
"rtree>=1.0.1",
# segmentation-models-pytorch 0.2+ required for smp.losses module
"segmentation-models-pytorch>=0.2",
# shapely 1.8+ required for Python 3.10 wheels
"shapely>=1.8",
# shapely 1.8.5+ required for Python 3.11 wheels
"shapely>=1.8.5",
# timm 0.4.12 required by segmentation-models-pytorch
"timm>=0.4.12",
# torch 1.13+ required by torchvision
"torch>=1.13",
# torch 2+ required for Python 3.11 wheels
"torch>=2",
# torchmetrics 0.10+ required for binary/multiclass/multilabel classification metrics
"torchmetrics>=0.10",
# torchvision 0.14+ required for torchvision.models.swin_v2_b
"torchvision>=0.14",
# torchvision 0.15.1+ required for Python 3.11 wheels
"torchvision>=0.15.1",
]
dynamic = ["version"]

[project.optional-dependencies]
datasets = [
# h5py 3.6+ required for Python 3.10 wheels
"h5py>=3.6",
# h5py 3.8+ required for Python 3.11 wheels
"h5py>=3.8",
# laspy 2+ required for laspy.read
"laspy>=2",
# opencv-python 4.5.4+ required for Python 3.10 wheels
"opencv-python>=4.5.4",
# opencv-python 4.5.5+ required for Python 3.11 wheels
"opencv-python>=4.5.5",
# pandas 2+ required for parquet extra
"pandas[parquet]>=2",
# pycocotools 2.0.7+ required for wheels
# pycocotools 2.0.7+ required for Python 3.11 wheels
"pycocotools>=2.0.7",
# scikit-image 0.19+ required for Python 3.10 wheels
"scikit-image>=0.19",
# scipy 1.7.2+ required for Python 3.10 wheels
"scipy>=1.7.2",
# scikit-image 0.20+ required for Python 3.11 wheels
"scikit-image>=0.20",
# scipy 1.9.2+ required for Python 3.11 wheels
"scipy>=1.9.2",
]
docs = [
# ipywidgets 7+ required by nbsphinx
Expand Down
30 changes: 15 additions & 15 deletions requirements/min-reqs.old
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ setuptools==61.0.0

# install
einops==0.3.0
fiona==1.8.21
fiona==1.8.22
kornia==0.7.4
lightly==1.4.5
lightning[pytorch-extra]==2.0.0
matplotlib==3.5.0
numpy==1.21.2
pandas==1.3.3
pillow==8.4.0
pyproj==3.3.0
rasterio==1.3.0.post1
rtree==1.0.0
matplotlib==3.6.0
numpy==1.23.2
pandas==1.5.0
pillow==9.2.0
pyproj==3.4.0
rasterio==1.3.3
rtree==1.0.1
segmentation-models-pytorch==0.2.0
shapely==1.8.0
shapely==1.8.5
timm==0.4.12
torch==1.13.0
torch==2.0.0
torchmetrics==0.10.0
torchvision==0.14.0
torchvision==0.15.1

# datasets
h5py==3.6.0
h5py==3.8.0
laspy==2.0.0
opencv-python==4.5.4.58
opencv-python==4.5.5.64
pycocotools==2.0.7
pyarrow==15.0.0 # Remove when we upgrade min version of pandas to `pandas[parquet]>=2`
scikit-image==0.19.0
scipy==1.7.2
scikit-image==0.20.0
scipy==1.9.2

# tests
pytest==7.3.0
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from torchgeo.datasets import ADVANCE, DatasetNotFoundError

pytest.importorskip('scipy', minversion='1.7.2')
pytest.importorskip('scipy', minversion='1.9.2')


class TestADVANCE:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_cabuar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from torchgeo.datasets import CaBuAr, DatasetNotFoundError

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestCaBuAr:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_chabud.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from torchgeo.datasets import ChaBuD, DatasetNotFoundError

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestChaBuD:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_cropharvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from torchgeo.datasets import CropHarvest, DatasetNotFoundError

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestCropHarvest:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_digital_typhoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from torchgeo.datasets import DatasetNotFoundError, DigitalTyphoon

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestDigitalTyphoon:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_landcoverai.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_plot(self, dataset: LandCoverAIGeo) -> None:


class TestLandCoverAI:
pytest.importorskip('cv2', minversion='4.5.4')
pytest.importorskip('cv2', minversion='4.5.5')

@pytest.fixture(
params=product([LandCoverAI100, LandCoverAI], ['train', 'val', 'test'])
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_mmearth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from torchgeo.datasets import DatasetNotFoundError, MMEarth

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')

data_dir_dict = {
'MMEarth': os.path.join('tests', 'data', 'mmearth', 'data_1M_v001'),
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_quakeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from torchgeo.datasets import DatasetNotFoundError, QuakeSet

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestQuakeSet:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_skippd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchgeo.datasets import SKIPPD, DatasetNotFoundError

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestSKIPPD:
Expand Down
6 changes: 2 additions & 4 deletions tests/datasets/test_so2sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from torchgeo.datasets import DatasetNotFoundError, RGBBandsMissingError, So2Sat

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestSo2Sat:
Expand Down Expand Up @@ -43,9 +43,7 @@ def test_len(self, dataset: So2Sat) -> None:
assert len(dataset) == 2

def test_out_of_bounds(self, dataset: So2Sat) -> None:
# h5py at version 2.10.0 raises a ValueError instead of an IndexError so we
# check for both here
with pytest.raises((IndexError, ValueError)):
with pytest.raises(IndexError):
dataset[2]

def test_invalid_split(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_vhr10.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_not_downloaded(self, tmp_path: Path) -> None:
VHR10(tmp_path)

def test_plot(self, dataset: VHR10) -> None:
pytest.importorskip('skimage', minversion='0.19')
pytest.importorskip('skimage', minversion='0.20')
x = dataset[1].copy()
dataset.plot(x, suptitle='Test')
plt.close()
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_zuericrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from torchgeo.datasets import DatasetNotFoundError, RGBBandsMissingError, ZueriCrop

pytest.importorskip('h5py', minversion='3.6')
pytest.importorskip('h5py', minversion='3.8')


class TestZueriCrop:
Expand Down
6 changes: 1 addition & 5 deletions torchgeo/datasets/cyclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ def _load_image(self, image_id: str) -> Tensor:
filename = os.path.join(self.root, self.split, f'{image_id}.jpg')
with Image.open(filename) as img:
if img.height != self.size or img.width != self.size:
# Moved in PIL 9.1.0
try:
resample = Image.Resampling.BILINEAR
except AttributeError:
resample = Image.BILINEAR # type: ignore[attr-defined]
resample = Image.Resampling.BILINEAR
img = img.resize(size=(self.size, self.size), resample=resample)
array: np.typing.NDArray[np.int_] = np.array(img.convert('RGB'))
tensor = torch.from_numpy(array)
Expand Down
7 changes: 1 addition & 6 deletions torchgeo/datasets/satlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,6 @@ def _load_image(
row: Web Mercator row.
directories: Directories that may contain the image.
"""
# Moved in PIL 9.1.0
try:
resample = Image.Resampling.BILINEAR
except AttributeError:
resample = Image.BILINEAR # type: ignore[attr-defined]

# Find directories that match image product
good_directories: list[str] = []
for directory in directories:
Expand All @@ -659,6 +653,7 @@ def _load_image(
sample[f'time_{image}'] = torch.tensor(time)

# Load all bands
resample = Image.Resampling.BILINEAR
channels = []
for band in self.bands[image]:
path = os.path.join(self.root, image, directory, band, f'{col}_{row}.png')
Expand Down
6 changes: 1 addition & 5 deletions torchgeo/datasets/seco.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ def _load_patch(self, root: Path, subdir: Path) -> Tensor:
# slowdown here from converting to/from a PIL Image just to resize.
# https://gist.github.com/calebrob6/748045ac8d844154067b2eefa47de92f
pil_image = Image.fromarray(band_data)
# Moved in PIL 9.1.0
try:
resample = Image.Resampling.BILINEAR
except AttributeError:
resample = Image.BILINEAR # type: ignore[attr-defined]
resample = Image.Resampling.BILINEAR
band_data = np.array(
pil_image.resize((264, 264), resample=resample)
)
Expand Down
6 changes: 1 addition & 5 deletions torchgeo/trainers/moco.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from torch.optim.lr_scheduler import (
CosineAnnealingLR,
LinearLR,
LRScheduler,
MultiStepLR,
SequentialLR,
)
Expand All @@ -34,11 +35,6 @@
from . import utils
from .base import BaseTask

try:
from torch.optim.lr_scheduler import LRScheduler
except ImportError:
from torch.optim.lr_scheduler import _LRScheduler as LRScheduler


def moco_augmentations(
version: int, size: int, weights: Tensor
Expand Down