From d76bcab98fbc8d1f546ed078d4c647733f736e45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:36:50 +0000 Subject: [PATCH 1/3] Bump ruff from 0.7.4 to 0.8.0 in /requirements Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.4 to 0.8.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.4...0.8.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements/style.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/style.txt b/requirements/style.txt index 9f3085bfef..d0eb263ea5 100644 --- a/requirements/style.txt +++ b/requirements/style.txt @@ -1,3 +1,3 @@ # style mypy==1.13.0 -ruff==0.7.4 +ruff==0.8.0 From 345b95be2013ac08e07e0f907fef676c056752a7 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 23 Nov 2024 11:03:14 +0100 Subject: [PATCH 2/3] Sort __all__, remove comments --- hubconf.py | 2 +- torchgeo/datamodules/__init__.py | 56 ++++++------ torchgeo/datasets/__init__.py | 152 +++++++++++++++---------------- torchgeo/models/__init__.py | 49 +++++----- torchgeo/samplers/__init__.py | 13 +-- torchgeo/trainers/__init__.py | 12 +-- 6 files changed, 131 insertions(+), 153 deletions(-) diff --git a/hubconf.py b/hubconf.py index 4ce63b0c7c..9362e05612 100644 --- a/hubconf.py +++ b/hubconf.py @@ -26,8 +26,8 @@ 'resnet50', 'resnet152', 'scalemae_large_patch16', - 'swin_v2_t', 'swin_v2_b', + 'swin_v2_t', 'vit_small_patch16_224', ) diff --git a/torchgeo/datamodules/__init__.py b/torchgeo/datamodules/__init__.py index ae4f029c93..dc9513a652 100644 --- a/torchgeo/datamodules/__init__.py +++ b/torchgeo/datamodules/__init__.py @@ -55,67 +55,63 @@ from .xview import XView2DataModule __all__ = ( - # GeoDataset 'AgriFieldNetDataModule', - 'ChesapeakeCVPRDataModule', - 'IOBenchDataModule', - 'L7IrishDataModule', - 'L8BiomeDataModule', - 'NAIPChesapeakeDataModule', - 'Sentinel2CDLDataModule', - 'Sentinel2EuroCropsDataModule', - 'Sentinel2NCCMDataModule', - 'Sentinel2SouthAmericaSoybeanDataModule', - 'SouthAfricaCropTypeDataModule', - # NonGeoDataset + 'BaseDataModule', 'BigEarthNetDataModule', - 'CaFFeDataModule', + 'COWCCountingDataModule', 'CaBuArDataModule', + 'CaFFeDataModule', 'ChaBuDDataModule', - 'COWCCountingDataModule', + 'ChesapeakeCVPRDataModule', 'DeepGlobeLandCoverDataModule', 'DigitalTyphoonDataModule', 'ETCI2021DataModule', + 'EuroSAT100DataModule', 'EuroSATDataModule', 'EuroSATSpatialDataModule', - 'EuroSAT100DataModule', 'FAIR1MDataModule', 'FieldsOfTheWorldDataModule', 'FireRiskDataModule', - 'GeoNRWDataModule', 'GID15DataModule', + 'GeoDataModule', + 'GeoNRWDataModule', + 'IOBenchDataModule', 'InriaAerialImageLabelingDataModule', - 'LandCoverAIDataModule', - 'LandCoverAI100DataModule', + 'L7IrishDataModule', + 'L8BiomeDataModule', 'LEVIRCDDataModule', 'LEVIRCDPlusDataModule', + 'LandCoverAI100DataModule', + 'LandCoverAIDataModule', 'LoveDADataModule', + 'MisconfigurationException', + 'NAIPChesapeakeDataModule', 'NASAMarineDebrisDataModule', + 'NonGeoDataModule', 'OSCDDataModule', 'Potsdam2DDataModule', 'QuakeSetDataModule', 'RESISC45DataModule', - 'SeasonalContrastS2DataModule', 'SEN12MSDataModule', 'SKIPPDDataModule', - 'So2SatDataModule', - 'SpaceNetBaseDataModule', - 'SpaceNet1DataModule', - 'SpaceNet6DataModule', 'SSL4EOLBenchmarkDataModule', 'SSL4EOLDataModule', 'SSL4EOS12DataModule', + 'SeasonalContrastS2DataModule', + 'Sentinel2CDLDataModule', + 'Sentinel2EuroCropsDataModule', + 'Sentinel2NCCMDataModule', + 'Sentinel2SouthAmericaSoybeanDataModule', + 'So2SatDataModule', + 'SouthAfricaCropTypeDataModule', + 'SpaceNet1DataModule', + 'SpaceNet6DataModule', + 'SpaceNetBaseDataModule', 'SustainBenchCropYieldDataModule', 'TropicalCycloneDataModule', 'UCMercedDataModule', 'USAVarsDataModule', - 'Vaihingen2DDataModule', 'VHR10DataModule', + 'Vaihingen2DDataModule', 'XView2DataModule', - # Base classes - 'BaseDataModule', - 'GeoDataModule', - 'NonGeoDataModule', - # Utilities - 'MisconfigurationException', ) diff --git a/torchgeo/datasets/__init__.py b/torchgeo/datasets/__init__.py index f3b88f6396..3016c3af7e 100644 --- a/torchgeo/datasets/__init__.py +++ b/torchgeo/datasets/__init__.py @@ -147,14 +147,47 @@ from .zuericrop import ZueriCrop __all__ = ( - # GeoDataset + 'ADVANCE', + 'CDL', + 'COWC', + 'DFC2022', + 'ETCI2021', + 'EUDEM', + 'FAIR1M', + 'GBIF', + 'GID15', + 'LEVIRCD', + 'NAIP', + 'NCCM', + 'NLCD', + 'OSCD', + 'PASTIS', + 'PRISMA', + 'RESISC45', + 'SEN12MS', + 'SKIPPD', + 'SSL4EO', + 'SSL4EOL', + 'SSL4EOS12', + 'VHR10', 'AbovegroundLiveWoodyBiomassDensity', 'AgriFieldNet', 'Airphen', 'AsterGDEM', + 'BeninSmallHolderCashews', + 'BigEarthNet', + 'BioMassters', + 'BoundingBox', + 'CMSGlobalMangroveCanopy', + 'COWCCounting', + 'COWCDetection', + 'CV4AKenyaCropType', + 'CaBuAr', + 'CaFFe', 'CanadianBuildingFootprints', - 'CDL', + 'ChaBuD', 'Chesapeake', + 'ChesapeakeCVPR', 'ChesapeakeDC', 'ChesapeakeDE', 'ChesapeakeMD', @@ -162,19 +195,36 @@ 'ChesapeakePA', 'ChesapeakeVA', 'ChesapeakeWV', - 'ChesapeakeCVPR', - 'CMSGlobalMangroveCanopy', + 'CloudCoverDetection', 'CropHarvest', + 'DatasetNotFoundError', + 'DeepGlobeLandCover', + 'DependencyNotFoundError', + 'DigitalTyphoon', 'EDDMapS', + 'EnviroAtlas', 'Esri2020', 'EuroCrops', - 'EUDEM', - 'GBIF', + 'EuroSAT', + 'EuroSAT100', + 'EuroSATSpatial', + 'FieldsOfTheWorld', + 'FireRisk', + 'ForestDamage', + 'GeoDataset', + 'GeoNRW', 'GlobBiomass', + 'IDTReeS', 'INaturalist', 'IOBench', + 'InriaAerialImageLabeling', + 'IntersectionDataset', 'L7Irish', 'L8Biome', + 'LEVIRCDBase', + 'LEVIRCDPlus', + 'LandCoverAI', + 'LandCoverAI100', 'LandCoverAIBase', 'LandCoverAIGeo', 'Landsat', @@ -188,70 +238,32 @@ 'Landsat7', 'Landsat8', 'Landsat9', - 'NAIP', - 'NCCM', - 'NLCD', - 'OpenBuildings', - 'PRISMA', - 'Sentinel', - 'Sentinel1', - 'Sentinel2', - 'SouthAfricaCropType', - 'SouthAmericaSoybean', - # NonGeoDataset - 'ADVANCE', - 'BeninSmallHolderCashews', - 'BigEarthNet', - 'BioMassters', - 'CaBuAr', - 'CaFFe', - 'ChaBuD', - 'CloudCoverDetection', - 'COWC', - 'COWCCounting', - 'COWCDetection', - 'CV4AKenyaCropType', - 'DeepGlobeLandCover', - 'DFC2022', - 'DigitalTyphoon', - 'EnviroAtlas', - 'ETCI2021', - 'EuroSAT', - 'EuroSATSpatial', - 'EuroSAT100', - 'FAIR1M', - 'FieldsOfTheWorld', - 'FireRisk', - 'ForestDamage', - 'GeoNRW', - 'GID15', - 'IDTReeS', - 'InriaAerialImageLabeling', - 'LandCoverAI', - 'LandCoverAI100', - 'LEVIRCD', - 'LEVIRCDBase', - 'LEVIRCDPlus', 'LoveDA', + 'MMEarth', 'MapInWild', 'MillionAID', - 'MMEarth', 'NASAMarineDebris', - 'OSCD', - 'PASTIS', + 'NonGeoClassificationDataset', + 'NonGeoDataset', + 'OpenBuildings', 'PatternNet', 'Potsdam2D', 'QuakeSet', - 'RESISC45', + 'RGBBandsMissingError', + 'RasterDataset', 'ReforesTree', 'RwandaFieldBoundary', + 'SSL4EOLBenchmark', 'SatlasPretrain', - 'SeasonalContrastS2', 'SeasoNet', - 'SEN12MS', - 'SKIPPD', + 'SeasonalContrastS2', + 'Sentinel', + 'Sentinel1', + 'Sentinel2', 'SkyScript', 'So2Sat', + 'SouthAfricaCropType', + 'SouthAmericaSoybean', 'SpaceNet', 'SpaceNet1', 'SpaceNet2', @@ -261,41 +273,23 @@ 'SpaceNet6', 'SpaceNet7', 'SpaceNet8', - 'SSL4EO', - 'SSL4EOLBenchmark', - 'SSL4EOL', - 'SSL4EOS12', 'SustainBenchCropYield', 'TropicalCyclone', 'UCMerced', 'USAVars', + 'UnionDataset', 'Vaihingen2D', - 'VHR10', + 'VectorDataset', 'WesternUSALiveFuelMoisture', 'XView2', 'ZueriCrop', - # Base classes - 'GeoDataset', - 'IntersectionDataset', - 'NonGeoClassificationDataset', - 'NonGeoDataset', - 'RasterDataset', - 'UnionDataset', - 'VectorDataset', - # Utilities - 'BoundingBox', 'concat_samples', 'merge_samples', - 'stack_samples', - 'unbind_samples', - # Splits 'random_bbox_assignment', 'random_bbox_splitting', 'random_grid_cell_assignment', 'roi_split', + 'stack_samples', 'time_series_split', - # Errors - 'DatasetNotFoundError', - 'DependencyNotFoundError', - 'RGBBandsMissingError', + 'unbind_samples', ) diff --git a/torchgeo/models/__init__.py b/torchgeo/models/__init__.py index 791ee821c9..539be67180 100644 --- a/torchgeo/models/__init__.py +++ b/torchgeo/models/__init__.py @@ -32,46 +32,43 @@ from .vit import ViTSmall16_Weights, vit_small_patch16_224 __all__ = ( - # models - 'ChangeMixin', - 'ChangeStar', - 'ChangeStarFarSeg', 'CROMA', - 'CROMABase_Weights', - 'CROMALarge_Weights', - 'croma_base', - 'croma_large', 'DOFA', - 'dofa_small_patch16_224', - 'dofa_base_patch16_224', - 'dofa_large_patch16_224', - 'dofa_huge_patch16_224', - 'FarSeg', 'FCN', - 'FCSiamConc', - 'FCSiamDiff', 'RCF', - 'resnet18', - 'resnet50', - 'resnet152', - 'ScaleMAE', - 'scalemae_large_patch16', - 'swin_v2_t', - 'swin_v2_b', - 'vit_small_patch16_224', - # weights + 'CROMABase_Weights', + 'CROMALarge_Weights', + 'ChangeMixin', + 'ChangeStar', + 'ChangeStarFarSeg', 'DOFABase16_Weights', 'DOFALarge16_Weights', + 'FCSiamConc', + 'FCSiamDiff', + 'FarSeg', 'ResNet18_Weights', 'ResNet50_Weights', 'ResNet152_Weights', + 'ScaleMAE', 'ScaleMAELarge16_Weights', - 'Swin_V2_T_Weights', 'Swin_V2_B_Weights', + 'Swin_V2_T_Weights', 'ViTSmall16_Weights', - # utilities + 'croma_base', + 'croma_large', + 'dofa_base_patch16_224', + 'dofa_huge_patch16_224', + 'dofa_large_patch16_224', + 'dofa_small_patch16_224', 'get_model', 'get_model_weights', 'get_weight', 'list_models', + 'resnet18', + 'resnet50', + 'resnet152', + 'scalemae_large_patch16', + 'swin_v2_b', + 'swin_v2_t', + 'vit_small_patch16_224', ) diff --git a/torchgeo/samplers/__init__.py b/torchgeo/samplers/__init__.py index ba995c9c78..e9cad8a8f8 100644 --- a/torchgeo/samplers/__init__.py +++ b/torchgeo/samplers/__init__.py @@ -9,18 +9,13 @@ from .utils import get_random_bounding_box, tile_to_chips __all__ = ( - # Samplers + 'BatchGeoSampler', + 'GeoSampler', 'GridGeoSampler', 'PreChippedGeoSampler', - 'RandomGeoSampler', - # Batch samplers 'RandomBatchGeoSampler', - # Base classes - 'GeoSampler', - 'BatchGeoSampler', - # Utilities + 'RandomGeoSampler', + 'Units', 'get_random_bounding_box', 'tile_to_chips', - # Constants - 'Units', ) diff --git a/torchgeo/trainers/__init__.py b/torchgeo/trainers/__init__.py index be4fb4a03d..ee69bff002 100644 --- a/torchgeo/trainers/__init__.py +++ b/torchgeo/trainers/__init__.py @@ -14,19 +14,15 @@ from .simclr import SimCLRTask __all__ = ( - # Supervised + 'BYOLTask', + 'BaseTask', 'ClassificationTask', + 'IOBenchTask', + 'MoCoTask', 'MultiLabelClassificationTask', 'ObjectDetectionTask', 'PixelwiseRegressionTask', 'RegressionTask', 'SemanticSegmentationTask', - # Self-supervised - 'BYOLTask', - 'MoCoTask', 'SimCLRTask', - # Base classes - 'BaseTask', - # Other - 'IOBenchTask', ) From e884ba2beb12bcd858ca6cb1901a4719aa9b37e2 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 23 Nov 2024 11:09:15 +0100 Subject: [PATCH 3/3] Bump minimum ruff, fix formatting --- .pre-commit-config.yaml | 2 +- experiments/ssl4eo/download_ssl4eo.py | 2 +- pyproject.toml | 6 +++--- torchgeo/models/scale_mae.py | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61e7d2a538..e09d665c3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.8.0 hooks: - id: ruff types_or: diff --git a/experiments/ssl4eo/download_ssl4eo.py b/experiments/ssl4eo/download_ssl4eo.py index 6cc7015111..283e6e39c8 100755 --- a/experiments/ssl4eo/download_ssl4eo.py +++ b/experiments/ssl4eo/download_ssl4eo.py @@ -520,7 +520,7 @@ def worker(idx: int) -> None: print(f'Downloaded {count} images in {time.time() - start_time:.3f}s.') else: if args.debug: - print('no suitable image for location %d.' % (idx)) + print(f'no suitable image for location {idx}.') # add to existing checked locations with open(ext_path, 'a') as f: diff --git a/pyproject.toml b/pyproject.toml index f01e4933f4..3541689f5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,8 +115,8 @@ docs = [ style = [ # mypy 0.900+ required for pyproject.toml support "mypy>=0.900", - # ruff 0.2+ required for [ruff.lint] - "ruff>=0.2", + # ruff 0.8+ required for removal of ANN101, ANN102 + "ruff>=0.8", ] tests = [ # nbmake 1.3.3+ required for variable mocking @@ -298,7 +298,7 @@ skip-magic-trailing-comma = true [tool.ruff.lint] extend-select = ["ANN", "D", "I", "RUF", "UP"] -ignore = ["ANN101", "ANN102", "ANN401"] +ignore = ["ANN401"] [tool.ruff.lint.per-file-ignores] "docs/**" = ["ANN", "D"] diff --git a/torchgeo/models/scale_mae.py b/torchgeo/models/scale_mae.py index fed06e0f49..7dd689e0f1 100644 --- a/torchgeo/models/scale_mae.py +++ b/torchgeo/models/scale_mae.py @@ -163,8 +163,7 @@ def interpolate_pos_embed( # class_token and dist_token are kept unchanged if orig_size != new_size: print( - 'Interpolating positional embeddings from %dx%d to %dx%d' - % (orig_size, orig_size, new_size, new_size) + f'Interpolating positional embeddings from {orig_size}x{orig_size} to {new_size}x{new_size}' ) extra_tokens = pos_embed_checkpoint[:, :num_extra_tokens] # only the position tokens are interpolated