From 68e2186cde489e9b23cda3ea1852fafac1c48634 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 10:38:59 -0700 Subject: [PATCH 01/15] 0.3.0 release --- torchgeo/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchgeo/__init__.py b/torchgeo/__init__.py index b7c78f30320..05a38b5a00a 100644 --- a/torchgeo/__init__.py +++ b/torchgeo/__init__.py @@ -11,4 +11,4 @@ """ __author__ = "Adam J. Stewart" -__version__ = "0.3.0.dev0" +__version__ = "0.3.0" From 5da727c55d18b6b4354a45055466b9792a40bb78 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 10:51:17 -0700 Subject: [PATCH 02/15] Slightly different distutils deprecation warning --- .github/workflows/release.yaml | 3 --- pyproject.toml | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 15f0c54c17c..72f416ed1f9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,7 +19,6 @@ jobs: python-version: '3.10' - name: Install pip dependencies run: | - pip install --pre 'rasterio>=1.0.16' pip install .[tests] pip list - name: Run pytest checks @@ -36,7 +35,6 @@ jobs: python-version: '3.10' - name: Install pip dependencies run: | - pip install --pre 'rasterio>=1.0.16' pip install .[datasets,tests] pip list - name: Run integration checks @@ -53,7 +51,6 @@ jobs: python-version: '3.10' - name: Install pip dependencies run: | - pip install --pre 'rasterio>=1.0.16' pip install .[datasets,docs,tests] pip list - name: Run notebook checks diff --git a/pyproject.toml b/pyproject.toml index 33ae8ba5a21..ec12afb68ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ filterwarnings = [ # https://github.com/pytorch/pytorch/issues/72906 # https://github.com/pytorch/pytorch/pull/69823 "ignore:distutils Version classes are deprecated. Use packaging.version instead:DeprecationWarning:torch.utils.tensorboard", + "ignore:The distutils package is deprecated and slated for removal in Python 3.12:DeprecationWarning:torch.utils.tensorboard", # https://github.com/PyTorchLightning/pytorch-lightning/issues/13256 # https://github.com/PyTorchLightning/pytorch-lightning/pull/13261 "ignore:torch.distributed._sharded_tensor will be deprecated:DeprecationWarning:torch.distributed._sharded_tensor", From 1ae004ea1d95fa926054e0bf34d4021011c9c52a Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 11:44:04 -0700 Subject: [PATCH 03/15] Fix release tests --- pyproject.toml | 2 ++ tests/datasets/test_openbuildings.py | 3 +-- tests/test_train.py | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ec12afb68ba..e72fa60a5f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,6 +79,8 @@ filterwarnings = [ "ignore:Named tensors and all their associated APIs are an experimental feature and subject to change:UserWarning:torch.nn.functional", # https://github.com/tensorflow/tensorboard/issues/5798 "ignore:Call to deprecated create function:DeprecationWarning:tensorboard.compat.proto", + # https://github.com/treebeardtech/nbmake/issues/68 + "ignore:The (fspath: py.path.local) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin", # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS diff --git a/tests/datasets/test_openbuildings.py b/tests/datasets/test_openbuildings.py index 02a14f1e125..a745d19432f 100644 --- a/tests/datasets/test_openbuildings.py +++ b/tests/datasets/test_openbuildings.py @@ -9,7 +9,6 @@ from typing import Any import matplotlib.pyplot as plt -import pandas as pd import pytest import torch import torch.nn as nn @@ -24,7 +23,7 @@ UnionDataset, ) -pytest.importorskip("pandas", minversion="0.23.2") +pd = pytest.importorskip("pandas", minversion="0.23.2") class TestOpenBuildings: diff --git a/tests/test_train.py b/tests/test_train.py index 8d392b99ac2..eca609d1806 100644 --- a/tests/test_train.py +++ b/tests/test_train.py @@ -69,8 +69,10 @@ def test_overwrite_experiment_dir(tmp_path: Path) -> None: "program.data_dir=" + data_dir, "program.log_dir=" + str(log_dir), "experiment.task=cyclone", + "experiment.datamodule.root_dir=" + data_dir, "program.overwrite=True", "trainer.fast_dev_run=1", + "trainer.gpus=0", ] ps = subprocess.run(args, capture_output=True, check=True) assert re.search( @@ -123,8 +125,11 @@ def test_config_file(tmp_path: Path) -> None: experiment: name: test task: cyclone + datamodule: + root_dir: {data_dir} trainer: fast_dev_run: true + gpus: 0 """ ) args = [sys.executable, "train.py", "config_file=" + str(config_file)] From 6f1f79b54c4f4fc5456e1946764861b17c211d0d Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 11:48:27 -0700 Subject: [PATCH 04/15] Escape regex in warning ignore --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e72fa60a5f6..2436f88379e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ filterwarnings = [ # https://github.com/tensorflow/tensorboard/issues/5798 "ignore:Call to deprecated create function:DeprecationWarning:tensorboard.compat.proto", # https://github.com/treebeardtech/nbmake/issues/68 - "ignore:The (fspath: py.path.local) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin", + "ignore:The \(fspath: py.path.local\) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin", # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS From 7917ee30a94667f552e862d74d31a233674e12c0 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 11:54:22 -0700 Subject: [PATCH 05/15] Escape characters require literal strings --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2436f88379e..3d0e247f629 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ filterwarnings = [ # https://github.com/tensorflow/tensorboard/issues/5798 "ignore:Call to deprecated create function:DeprecationWarning:tensorboard.compat.proto", # https://github.com/treebeardtech/nbmake/issues/68 - "ignore:The \(fspath: py.path.local\) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin", + 'ignore:The \(fspath: py.path.local\) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin', # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS From 0601aec8e6458adc362997dac01be13256003685 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 12:04:11 -0700 Subject: [PATCH 06/15] Colon was problematic --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3d0e247f629..e9d94476425 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ filterwarnings = [ # https://github.com/tensorflow/tensorboard/issues/5798 "ignore:Call to deprecated create function:DeprecationWarning:tensorboard.compat.proto", # https://github.com/treebeardtech/nbmake/issues/68 - 'ignore:The \(fspath: py.path.local\) argument to NotebookFile is deprecated:pytest.PytestRemovedIn8Warning:nbmake.pytest_plugin', + "ignore:The (fspath. py.path.local) argument to NotebookFile is deprecated:pytest.PytestDeprecationWarning:nbmake.pytest_plugin", # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS From f8b3723ea927712859fe6ce0fd8e25d13b751b85 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 12:48:09 -0700 Subject: [PATCH 07/15] Re-escape regex patterns --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e9d94476425..7fb0324c083 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ filterwarnings = [ # https://github.com/tensorflow/tensorboard/issues/5798 "ignore:Call to deprecated create function:DeprecationWarning:tensorboard.compat.proto", # https://github.com/treebeardtech/nbmake/issues/68 - "ignore:The (fspath. py.path.local) argument to NotebookFile is deprecated:pytest.PytestDeprecationWarning:nbmake.pytest_plugin", + 'ignore:The \(fspath. py.path.local\) argument to NotebookFile is deprecated:pytest.PytestDeprecationWarning:nbmake.pytest_plugin', # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS From d810355118e151a392a85c00e4a00ad9c869c6a1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 12:55:25 -0700 Subject: [PATCH 08/15] Fix tests without optional dependencies --- tests/datamodules/test_usavars.py | 1 + tests/datasets/test_landcoverai.py | 1 + tests/datasets/test_reforestree.py | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/datamodules/test_usavars.py b/tests/datamodules/test_usavars.py index f8813261d6d..f083ce709d3 100644 --- a/tests/datamodules/test_usavars.py +++ b/tests/datamodules/test_usavars.py @@ -12,6 +12,7 @@ class TestUSAVarsDataModule: @pytest.fixture() def datamodule(self, request: SubRequest) -> USAVarsDataModule: + pytest.importorskip("pandas", minversion="0.23.2") root = os.path.join("tests", "data", "usavars") batch_size = 1 num_workers = 0 diff --git a/tests/datasets/test_landcoverai.py b/tests/datasets/test_landcoverai.py index 3893afb78ff..fa70ba38efc 100644 --- a/tests/datasets/test_landcoverai.py +++ b/tests/datasets/test_landcoverai.py @@ -26,6 +26,7 @@ class TestLandCoverAI: def dataset( self, monkeypatch: MonkeyPatch, tmp_path: Path, request: SubRequest ) -> LandCoverAI: + pytest.importorskip("cv2", minversion="3.4.2.17") monkeypatch.setattr(torchgeo.datasets.landcoverai, "download_url", download_url) md5 = "ff8998857cc8511f644d3f7d0f3688d0" monkeypatch.setattr(LandCoverAI, "md5", md5) diff --git a/tests/datasets/test_reforestree.py b/tests/datasets/test_reforestree.py index 1337cfb18c3..cf06580a57b 100644 --- a/tests/datasets/test_reforestree.py +++ b/tests/datasets/test_reforestree.py @@ -24,6 +24,7 @@ def download_url(url: str, root: str, *args: str) -> None: class TestReforesTree: @pytest.fixture def dataset(self, monkeypatch: MonkeyPatch, tmp_path: Path) -> ReforesTree: + pytest.importorskip("pandas", minversion="0.23.2") monkeypatch.setattr(torchgeo.datasets.utils, "download_url", download_url) data_dir = os.path.join("tests", "data", "reforestree") From 47b83f9a2a7498bef12ba6b03ac9ef2cc2d13f1c Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 13:03:46 -0700 Subject: [PATCH 09/15] Fix tests without optional dependencies --- tests/datasets/test_landcoverai.py | 1 + tests/datasets/test_reforestree.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/datasets/test_landcoverai.py b/tests/datasets/test_landcoverai.py index fa70ba38efc..e8e64680ef0 100644 --- a/tests/datasets/test_landcoverai.py +++ b/tests/datasets/test_landcoverai.py @@ -57,6 +57,7 @@ def test_already_extracted(self, dataset: LandCoverAI) -> None: LandCoverAI(root=dataset.root, download=True) def test_already_downloaded(self, monkeypatch: MonkeyPatch, tmp_path: Path) -> None: + pytest.importorskip("cv2", minversion="3.4.2.17") sha256 = "ecec8e871faf1bbd8ca525ca95ddc1c1f5213f40afb94599884bd85f990ebd6b" monkeypatch.setattr(LandCoverAI, "sha256", sha256) url = os.path.join("tests", "data", "landcoverai", "landcover.ai.v1.zip") diff --git a/tests/datasets/test_reforestree.py b/tests/datasets/test_reforestree.py index cf06580a57b..a558393afa6 100644 --- a/tests/datasets/test_reforestree.py +++ b/tests/datasets/test_reforestree.py @@ -79,6 +79,7 @@ def test_len(self, dataset: ReforesTree) -> None: assert len(dataset) == 2 def test_not_extracted(self, tmp_path: Path) -> None: + pytest.importorskip("pandas", minversion="0.23.2") url = os.path.join("tests", "data", "reforestree", "reforesTree.zip") shutil.copy(url, tmp_path) ReforesTree(root=str(tmp_path)) From 333c6176e1552972bd7ff91253021f2dfbcc1554 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 13:09:32 -0700 Subject: [PATCH 10/15] Try older nbmake --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 91e314c1e1b..c9ac935a53f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -122,7 +122,7 @@ tests = # mypy 0.900+ required for pyproject.toml support mypy>=0.900,<=0.961 # nbmake 0.1+ required to fix path_source bug - nbmake>=0.1,<2 + nbmake>=0.1,<1.3 # pytest 6.1.2+ required by nbmake pytest>=6.1.2,<8 # pytest-cov 2.4+ required for pytest --cov flags From 539dce2cbcf1374f5a06a54bfb5e5182264ceaff Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 13:12:46 -0700 Subject: [PATCH 11/15] Try older nbmake --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index c9ac935a53f..17d473eb384 100644 --- a/setup.cfg +++ b/setup.cfg @@ -122,7 +122,7 @@ tests = # mypy 0.900+ required for pyproject.toml support mypy>=0.900,<=0.961 # nbmake 0.1+ required to fix path_source bug - nbmake>=0.1,<1.3 + nbmake>=0.1,<1.2 # pytest 6.1.2+ required by nbmake pytest>=6.1.2,<8 # pytest-cov 2.4+ required for pytest --cov flags From 9714169c338496b0baf0e580b4efe5b46d7ba3d6 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 15:19:36 -0700 Subject: [PATCH 12/15] Try explicitly passing key --- docs/tutorials/trainers.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/trainers.ipynb b/docs/tutorials/trainers.ipynb index e7e115e8aae..71ab97b9cd1 100644 --- a/docs/tutorials/trainers.ipynb +++ b/docs/tutorials/trainers.ipynb @@ -119,7 +119,7 @@ "outputs": [], "source": [ "# Set this to your API key (available for free at https://mlhub.earth/)\n", - "RADIANT_EARTH_API_KEY = \"\"" + "MLHUB_API_KEY = os.environ[\"MLHUB_API_KEY\"]" ] }, { @@ -136,7 +136,7 @@ " seed=1337,\n", " batch_size=64,\n", " num_workers=6,\n", - " api_key=RADIANT_EARTH_API_KEY,\n", + " api_key=MLHUB_API_KEY,\n", ")" ] }, From a8ed695d7ec083d45e73201783fe9718ddec748b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 15:35:07 -0700 Subject: [PATCH 13/15] Black fixes --- docs/tutorials/trainers.ipynb | 6 +----- requirements/tests.txt | 2 +- setup.cfg | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/trainers.ipynb b/docs/tutorials/trainers.ipynb index 71ab97b9cd1..bc36aabdfdc 100644 --- a/docs/tutorials/trainers.ipynb +++ b/docs/tutorials/trainers.ipynb @@ -132,11 +132,7 @@ "data_dir = os.path.join(tempfile.gettempdir(), \"cyclone_data\")\n", "\n", "datamodule = CycloneDataModule(\n", - " root_dir=data_dir,\n", - " seed=1337,\n", - " batch_size=64,\n", - " num_workers=6,\n", - " api_key=MLHUB_API_KEY,\n", + " root_dir=data_dir, seed=1337, batch_size=64, num_workers=6, api_key=MLHUB_API_KEY\n", ")" ] }, diff --git a/requirements/tests.txt b/requirements/tests.txt index c00bc6aae05..8bdfda0a902 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ # tests mypy==0.961 -nbmake==1.3.0 +nbmake==1.1 pytest==7.1.2 pytest-cov==3.0.0 diff --git a/setup.cfg b/setup.cfg index 17d473eb384..07fc8f308b4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -120,8 +120,10 @@ style = pyupgrade>=1.24,<3 tests = # mypy 0.900+ required for pyproject.toml support - mypy>=0.900,<=0.961 + mypy>=0.900,<0.962 # nbmake 0.1+ required to fix path_source bug + # nbmake 1.2+ is buggy: + # https://github.com/treebeardtech/nbmake/issues/71 nbmake>=0.1,<1.2 # pytest 6.1.2+ required by nbmake pytest>=6.1.2,<8 From de525c0d18a5ece13e63c379e5366181adfbfe8b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 17:24:30 -0700 Subject: [PATCH 14/15] Document when parameters were added --- requirements/tests.txt | 2 +- torchgeo/datasets/eurosat.py | 2 ++ torchgeo/datasets/so2sat.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index 8bdfda0a902..c00bc6aae05 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ # tests mypy==0.961 -nbmake==1.1 +nbmake==1.3.0 pytest==7.1.2 pytest-cov==3.0.0 diff --git a/torchgeo/datasets/eurosat.py b/torchgeo/datasets/eurosat.py index 0fba561fdd5..a1d74e08a21 100644 --- a/torchgeo/datasets/eurosat.py +++ b/torchgeo/datasets/eurosat.py @@ -129,6 +129,8 @@ def __init__( RuntimeError: if ``download=False`` and data is not found, or checksums don't match + .. versionadded:: 0.3 + The *bands* parameter. """ self.root = root self.transforms = transforms diff --git a/torchgeo/datasets/so2sat.py b/torchgeo/datasets/so2sat.py index 4a1c1a3de2e..4d9d1065ed0 100644 --- a/torchgeo/datasets/so2sat.py +++ b/torchgeo/datasets/so2sat.py @@ -150,6 +150,9 @@ def __init__( Raises: AssertionError: if ``split`` argument is invalid RuntimeError: if data is not found in ``root``, or checksums don't match + + .. versionadded:: 0.3 + The *bands* parameter. """ try: import h5py # noqa: F401 From cc553c4bb5a47ef5608059501eb4edd4d65c0eb1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 20:16:06 -0700 Subject: [PATCH 15/15] Document more changes --- torchgeo/trainers/segmentation.py | 3 +++ torchgeo/transforms/indices.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/torchgeo/trainers/segmentation.py b/torchgeo/trainers/segmentation.py index a47d659c98a..375f5207bc4 100644 --- a/torchgeo/trainers/segmentation.py +++ b/torchgeo/trainers/segmentation.py @@ -82,6 +82,9 @@ def __init__(self, **kwargs: Any) -> None: Raises: ValueError: if kwargs arguments are invalid + + .. versionchanged:: 0.3 + The *ignore_zeros* parameter was renamed to *ignore_index*. """ super().__init__() diff --git a/torchgeo/transforms/indices.py b/torchgeo/transforms/indices.py index ef373ab2860..9344dda6e6c 100644 --- a/torchgeo/transforms/indices.py +++ b/torchgeo/transforms/indices.py @@ -213,6 +213,8 @@ class AppendSWI(AppendNormalizedDifferenceIndex): If you use this index in your research, please cite the following paper: * https://doi.org/10.3390/w13121647 + + .. versionadded:: 0.3 """ def __init__(self, index_red: int, index_swir: int) -> None: @@ -237,6 +239,8 @@ class AppendGNDVI(AppendNormalizedDifferenceIndex): If you use this index in your research, please cite the following paper: * https://doi.org/10.2134/agronj2001.933583x + + .. versionadded:: 0.3 """ def __init__(self, index_nir: int, index_green: int) -> None: