From 3910d9ab2ae17e9f91a356394e82d4c60e9c3fa6 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 11:52:34 +0200 Subject: [PATCH 01/11] 0.6.0 release --- torchgeo/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchgeo/__init__.py b/torchgeo/__init__.py index 5574da2f7e..8b36139d83 100644 --- a/torchgeo/__init__.py +++ b/torchgeo/__init__.py @@ -11,4 +11,4 @@ """ __author__ = 'Adam J. Stewart' -__version__ = '0.6.0.dev0' +__version__ = '0.6.0' From ef63bcf0f87b11cc89406fbbcd117468cdfd6ecf Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 12:18:57 +0200 Subject: [PATCH 02/11] Fix versionadded --- torchgeo/datamodules/digital_typhoon.py | 5 ++++- torchgeo/datamodules/geonrw.py | 2 +- torchgeo/datasets/levircd.py | 2 -- torchgeo/trainers/byol.py | 4 ++-- torchgeo/trainers/segmentation.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/torchgeo/datamodules/digital_typhoon.py b/torchgeo/datamodules/digital_typhoon.py index 11874aba8d..ce799bf3d5 100644 --- a/torchgeo/datamodules/digital_typhoon.py +++ b/torchgeo/datamodules/digital_typhoon.py @@ -16,7 +16,10 @@ class DigitalTyphoonDataModule(NonGeoDataModule): - """Digital Typhoon Data Module.""" + """Digital Typhoon Data Module. + + .. versionadded:: 0.6 + """ valid_split_types = ('time', 'typhoon_id') diff --git a/torchgeo/datamodules/geonrw.py b/torchgeo/datamodules/geonrw.py index 8540b8276c..c67753673a 100644 --- a/torchgeo/datamodules/geonrw.py +++ b/torchgeo/datamodules/geonrw.py @@ -21,7 +21,7 @@ class GeoNRWDataModule(NonGeoDataModule): Implements 80/20 train/val splits based on city locations. See :func:`setup` for more details. - .. versionadded: 0.6 + .. versionadded:: 0.6 """ def __init__( diff --git a/torchgeo/datasets/levircd.py b/torchgeo/datasets/levircd.py index e664365ab2..fdff569dc1 100644 --- a/torchgeo/datasets/levircd.py +++ b/torchgeo/datasets/levircd.py @@ -329,8 +329,6 @@ class LEVIRCDPlus(LEVIRCDBase): If you use this dataset in your research, please cite the following paper: * https://arxiv.org/abs/2107.09244 - - .. versionchanged:: 0.6 """ url = 'https://drive.google.com/file/d/1JamSsxiytXdzAIk6VDVWfc-OsX-81U81' diff --git a/torchgeo/trainers/byol.py b/torchgeo/trainers/byol.py index 38aac522b9..6cd4f50f8c 100644 --- a/torchgeo/trainers/byol.py +++ b/torchgeo/trainers/byol.py @@ -122,8 +122,8 @@ class BackboneWrapper(nn.Module): * The output of the encoding layer is passed through the projection head * The forward call returns the output of the projection head - .. versionchanged 0.4: Name changed from *EncoderWrapper* to - *BackboneWrapper*. + .. versionchanged:: 0.4 + Name changed from *EncoderWrapper* to *BackboneWrapper*. """ def __init__( diff --git a/torchgeo/trainers/segmentation.py b/torchgeo/trainers/segmentation.py index afd7152100..9eccda2f0f 100644 --- a/torchgeo/trainers/segmentation.py +++ b/torchgeo/trainers/segmentation.py @@ -77,7 +77,7 @@ class and used with 'ce' loss. were renamed to *model*, *backbone*, and *weights*. .. versionadded:: 0.5 - The *class_weights*, *freeze_backbone*, and *freeze_decoder* parameters. + The *class_weights*, *freeze_backbone*, and *freeze_decoder* parameters. .. versionchanged:: 0.5 The *weights* parameter now supports WeightEnums and checkpoint paths. @@ -85,7 +85,7 @@ class and used with 'ce' loss. *lr* and *patience*. .. versionchanged:: 0.6 - The *ignore_index* parameter now works for jaccard loss. + The *ignore_index* parameter now works for jaccard loss. """ self.weights = weights super().__init__(ignore='weights') From e856d4395d43fdb8f5e0cff8c85700e62c7245de Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 12:56:05 +0200 Subject: [PATCH 03/11] Update docs on ruff --- docs/user/contributing.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user/contributing.rst b/docs/user/contributing.rst index 91b8b4d3ab..2d5b173cc1 100644 --- a/docs/user/contributing.rst +++ b/docs/user/contributing.rst @@ -88,7 +88,7 @@ These tests require `pytest `_ and `pytest-c Linters ------- -In order to remain `PEP-8 `_ compliant and maintain a high-quality codebase, we use a couple of linting tools: +In order to remain `PEP-8 `_ compliant and maintain a high-quality codebase, we use a few linting tools: * `ruff `_ for code formatting * `mypy `_ for static type analysis @@ -98,8 +98,8 @@ These tools should be used from the root of the project to ensure that our confi .. code-block:: console - $ ruff check $ ruff format + $ ruff check Mypy won't fix your code for you, but will warn you about potential issues with your code: @@ -164,7 +164,7 @@ The resulting HTML files can be found in ``_build/html``. Open ``index.html`` in Tutorials --------- -TorchGeo has a number of tutorials included in the documentation that can be run in `Google Colab `_. These Jupyter notebooks are tested before each release to make sure that they still run properly. To test these locally, install `pytest `_ and `nbmake `_ and run: +TorchGeo has a number of tutorials included in the documentation that can be run in `Lightning Studios `_ and `Google Colab `_. These Jupyter notebooks are tested before each release to make sure that they still run properly. To test these locally, install `pytest `_ and `nbmake `_ and run: .. code-block:: console From 7a924d54f2dc0570259e2e86abf22ad13a9a76e3 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 12:56:18 +0200 Subject: [PATCH 04/11] EuroCrops: consistent citation message --- torchgeo/datasets/eurocrops.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/torchgeo/datasets/eurocrops.py b/torchgeo/datasets/eurocrops.py index cb5bb2a5bc..d2087e4b38 100644 --- a/torchgeo/datasets/eurocrops.py +++ b/torchgeo/datasets/eurocrops.py @@ -31,8 +31,9 @@ class EuroCrops(VectorDataset): is tagged with a "EC_hcat_n" attribute indicating the harmonized crop name grown within the polygon in the year associated with the shapefile. - If you use this dataset in your research, please follow the citation guidelines at - https://github.com/maja601/EuroCrops#reference. + If you use this dataset in your research, please follow the citation guidelines at: + + * https://github.com/maja601/EuroCrops#reference. .. versionadded:: 0.6 """ From 3f49e898be7a2d19f43cb00fecccbb06331753d5 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 12:56:35 +0200 Subject: [PATCH 05/11] Attempt to remove fully qualified type hints --- docs/conf.py | 6 +++--- pyproject.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index ec721bfff9..037b9016b1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,9 +50,8 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build'] -# Sphinx 3.0+ required for: -# autodoc_typehints_description_target = "documented" -needs_sphinx = '4.0' +# Sphinx 4.4+ required for autodoc_typehints_format +needs_sphinx = '4.4' nitpicky = True nitpick_ignore = [ @@ -106,6 +105,7 @@ autodoc_member_order = 'bysource' autodoc_typehints = 'description' autodoc_typehints_description_target = 'documented' +autodoc_typehints_format = 'short' # sphinx.ext.intersphinx intersphinx_mapping = { diff --git a/pyproject.toml b/pyproject.toml index 97d326961d..ec82ffd28d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,10 +103,10 @@ docs = [ "nbsphinx>=0.8.5", # release versions missing files, must install from master "pytorch-sphinx-theme", - # sphinx 4+ required for autodoc_typehints_description_target = documented + # sphinx 4.4+ required for autodoc_typehints_format # sphinx 6+ is incompatible with pytorch-sphinx-theme # https://github.com/pytorch/pytorch_sphinx_theme/issues/175 - "sphinx>=4,<6", + "sphinx>=4.4,<6", ] style = [ # mypy 0.900+ required for pyproject.toml support From ba9a99162061b28c48c42be75ba37392ecca5376 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 13:21:24 +0200 Subject: [PATCH 06/11] Silence test warnings --- pyproject.toml | 2 ++ torchgeo/datasets/digital_typhoon.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ec82ffd28d..60580b8ba8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -226,12 +226,14 @@ filterwarnings = [ "ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning", "ignore:pkg_resources is deprecated as an API.:DeprecationWarning:lightning_utilities.core.imports", "ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated:DeprecationWarning:jsonargparse", + "ignore:`ModuleAvailableCache` is a special case of `RequirementCache`.:DeprecationWarning:lightning.fabric.plugins.environments.xla", # https://github.com/pytorch/pytorch/issues/110549 "ignore:allow_ops_in_compiled_graph failed to import torch:ImportWarning:einops", # https://github.com/rr-/docstring_parser/pull/82 "ignore:ast.* is deprecated and will be removed in Python 3.14:DeprecationWarning:docstring_parser.attrdoc", # https://github.com/python/cpython/pull/102953 "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchgeo.datasets.utils", + "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchvision.datasets.utils", # https://github.com/kornia/kornia/pull/2967 "ignore:`torch.cuda.amp.custom_fwd\\(args...\\)` is deprecated.:FutureWarning:kornia.feature.lightglue", # https://github.com/kornia/kornia/pull/2981 diff --git a/torchgeo/datasets/digital_typhoon.py b/torchgeo/datasets/digital_typhoon.py index 42bb4caa1b..0e62e2603f 100644 --- a/torchgeo/datasets/digital_typhoon.py +++ b/torchgeo/datasets/digital_typhoon.py @@ -5,7 +5,6 @@ import glob import os -import tarfile from collections.abc import Callable, Sequence from typing import Any, ClassVar, TypedDict @@ -17,7 +16,13 @@ from .errors import DatasetNotFoundError from .geo import NonGeoDataset -from .utils import Path, download_url, lazy_import, percentile_normalization +from .utils import ( + Path, + download_url, + extract_archive, + lazy_import, + percentile_normalization, +) class _SampleSequenceDict(TypedDict): @@ -404,10 +409,7 @@ def _extract(self) -> None: """Extract the dataset.""" # Extract tarball for suffix in self.md5sums.keys(): - with tarfile.open( - os.path.join(self.root, f'{self.data_root}.tar.gz{suffix}') - ) as tar: - tar.extractall(path=self.root) + extract_archive(os.path.join(self.root, f'{self.data_root}.tar.gz{suffix}')) def plot( self, From a5cacd5336717923aa435eb0deb1ac84dd730d52 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 30 Aug 2024 13:31:44 +0200 Subject: [PATCH 07/11] Undo digital typhoon changes --- torchgeo/datasets/digital_typhoon.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/torchgeo/datasets/digital_typhoon.py b/torchgeo/datasets/digital_typhoon.py index 0e62e2603f..42bb4caa1b 100644 --- a/torchgeo/datasets/digital_typhoon.py +++ b/torchgeo/datasets/digital_typhoon.py @@ -5,6 +5,7 @@ import glob import os +import tarfile from collections.abc import Callable, Sequence from typing import Any, ClassVar, TypedDict @@ -16,13 +17,7 @@ from .errors import DatasetNotFoundError from .geo import NonGeoDataset -from .utils import ( - Path, - download_url, - extract_archive, - lazy_import, - percentile_normalization, -) +from .utils import Path, download_url, lazy_import, percentile_normalization class _SampleSequenceDict(TypedDict): @@ -409,7 +404,10 @@ def _extract(self) -> None: """Extract the dataset.""" # Extract tarball for suffix in self.md5sums.keys(): - extract_archive(os.path.join(self.root, f'{self.data_root}.tar.gz{suffix}')) + with tarfile.open( + os.path.join(self.root, f'{self.data_root}.tar.gz{suffix}') + ) as tar: + tar.extractall(path=self.root) def plot( self, From 03b72d860e301864696f7e4ee3603db471b36f63 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 31 Aug 2024 13:01:11 +0200 Subject: [PATCH 08/11] Undo sphinx req changes --- docs/conf.py | 5 ++--- pyproject.toml | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 037b9016b1..4078970c2e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,8 +50,8 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build'] -# Sphinx 4.4+ required for autodoc_typehints_format -needs_sphinx = '4.4' +# Sphinx 4.0+ required for autodoc_typehints_description_traget +needs_sphinx = '4.0' nitpicky = True nitpick_ignore = [ @@ -105,7 +105,6 @@ autodoc_member_order = 'bysource' autodoc_typehints = 'description' autodoc_typehints_description_target = 'documented' -autodoc_typehints_format = 'short' # sphinx.ext.intersphinx intersphinx_mapping = { diff --git a/pyproject.toml b/pyproject.toml index 60580b8ba8..3a2c2319ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,10 +103,10 @@ docs = [ "nbsphinx>=0.8.5", # release versions missing files, must install from master "pytorch-sphinx-theme", - # sphinx 4.4+ required for autodoc_typehints_format + # sphinx 4+ required for autodoc_typehints_description_target # sphinx 6+ is incompatible with pytorch-sphinx-theme # https://github.com/pytorch/pytorch_sphinx_theme/issues/175 - "sphinx>=4.4,<6", + "sphinx>=4,<6", ] style = [ # mypy 0.900+ required for pyproject.toml support @@ -233,6 +233,7 @@ filterwarnings = [ "ignore:ast.* is deprecated and will be removed in Python 3.14:DeprecationWarning:docstring_parser.attrdoc", # https://github.com/python/cpython/pull/102953 "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchgeo.datasets.utils", + "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchgeo.datasets.digital_typhoon", "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchvision.datasets.utils", # https://github.com/kornia/kornia/pull/2967 "ignore:`torch.cuda.amp.custom_fwd\\(args...\\)` is deprecated.:FutureWarning:kornia.feature.lightglue", From 8b32988d29b04c0bc3b1a8fd12fd762769c3c9d7 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 31 Aug 2024 14:37:53 +0200 Subject: [PATCH 09/11] Automatically delete downloaded models after successful tests to avoid OOM --- tests/conftest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 7d622c3977..4d5a43c810 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +from pathlib import Path from typing import Any import pytest @@ -16,3 +17,8 @@ def load(*args: Any, progress: bool = False, **kwargs: Any) -> Any: @pytest.fixture def load_state_dict_from_url(monkeypatch: MonkeyPatch) -> None: monkeypatch.setattr(torchvision.models._api, 'load_state_dict_from_url', load) + + +@pytest.fixture(autouse=True) +def torch_hub(tmp_path: Path) -> None: + torch.hub.set_dir(tmp_path) From 1ccca664d9890d1d0924be2a0fcec941f6f588bf Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 31 Aug 2024 14:55:54 +0200 Subject: [PATCH 10/11] Silence mypy warning --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 4d5a43c810..1f5c09a8bb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -21,4 +21,4 @@ def load_state_dict_from_url(monkeypatch: MonkeyPatch) -> None: @pytest.fixture(autouse=True) def torch_hub(tmp_path: Path) -> None: - torch.hub.set_dir(tmp_path) + torch.hub.set_dir(tmp_path) # type: ignore[no-untyped-call] From 7500ee20f651e889e4028ae897d245b4ad9ef82e Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 1 Sep 2024 11:50:44 +0200 Subject: [PATCH 11/11] Skip dependabot in auto-generated release notes --- .github/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release.yml b/.github/release.yml index 76caf0a585..8ca5b59679 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -1,7 +1,7 @@ changelog: exclude: authors: - - dependabot[bot] + - app/dependabot categories: - title: Backwards-incompatible changes labels: