From 36768fca787ff6e10e386cdf06d9a5b2d130be56 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 20:52:06 +0200 Subject: [PATCH 1/7] 0.5.0 release --- torchgeo/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchgeo/__init__.py b/torchgeo/__init__.py index f09454f830d..36c456170d2 100644 --- a/torchgeo/__init__.py +++ b/torchgeo/__init__.py @@ -11,4 +11,4 @@ """ __author__ = "Adam J. Stewart" -__version__ = "0.5.0.dev0" +__version__ = "0.5.0" From 5df8a66af01dc34547e230dcb36785df24fd64d8 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 21:50:50 +0200 Subject: [PATCH 2/7] Fix caching hash --- .github/workflows/release.yaml | 6 +++--- .github/workflows/tutorials.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ea4ae2634ae..f5095fd38da 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,7 +22,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} + key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} - name: Install pip dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install .[tests] @@ -48,7 +48,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} + key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} - name: Install pip dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install .[datasets,tests] @@ -74,7 +74,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} + key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} - name: Install pip dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install .[docs,tests] planetary_computer pystac diff --git a/.github/workflows/tutorials.yaml b/.github/workflows/tutorials.yaml index d94b77db83c..cc575eab1f4 100644 --- a/.github/workflows/tutorials.yaml +++ b/.github/workflows/tutorials.yaml @@ -26,7 +26,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} + key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} - name: Install pip dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install .[docs,tests] planetary_computer pystac From e3b3544234202129a5f4f3d02561da1fe736aade Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 22:16:21 +0200 Subject: [PATCH 3/7] Warnings not raised because not final layer --- tests/trainers/test_moco.py | 24 ++++++++++-------------- tests/trainers/test_simclr.py | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/trainers/test_moco.py b/tests/trainers/test_moco.py index 8657777aa32..a4d19fc98f2 100644 --- a/tests/trainers/test_moco.py +++ b/tests/trainers/test_moco.py @@ -128,20 +128,16 @@ def test_weight_str(self, mocked_weights: WeightsEnum) -> None: @pytest.mark.slow def test_weight_enum_download(self, weights: WeightsEnum) -> None: - match = "num classes .* != num classes in pretrained model" - with pytest.warns(UserWarning, match=match): - MoCoTask( - model=weights.meta["model"], - weights=weights, - in_channels=weights.meta["in_chans"], - ) + MoCoTask( + model=weights.meta["model"], + weights=weights, + in_channels=weights.meta["in_chans"], + ) @pytest.mark.slow def test_weight_str_download(self, weights: WeightsEnum) -> None: - match = "num classes .* != num classes in pretrained model" - with pytest.warns(UserWarning, match=match): - MoCoTask( - model=weights.meta["model"], - weights=str(weights), - in_channels=weights.meta["in_chans"], - ) + MoCoTask( + model=weights.meta["model"], + weights=str(weights), + in_channels=weights.meta["in_chans"], + ) diff --git a/tests/trainers/test_simclr.py b/tests/trainers/test_simclr.py index c7d841a8751..b7629cb3654 100644 --- a/tests/trainers/test_simclr.py +++ b/tests/trainers/test_simclr.py @@ -126,20 +126,16 @@ def test_weight_str(self, mocked_weights: WeightsEnum) -> None: @pytest.mark.slow def test_weight_enum_download(self, weights: WeightsEnum) -> None: - match = "num classes .* != num classes in pretrained model" - with pytest.warns(UserWarning, match=match): - SimCLRTask( - model=weights.meta["model"], - weights=weights, - in_channels=weights.meta["in_chans"], - ) + SimCLRTask( + model=weights.meta["model"], + weights=weights, + in_channels=weights.meta["in_chans"], + ) @pytest.mark.slow def test_weight_str_download(self, weights: WeightsEnum) -> None: - match = "num classes .* != num classes in pretrained model" - with pytest.warns(UserWarning, match=match): - SimCLRTask( - model=weights.meta["model"], - weights=str(weights), - in_channels=weights.meta["in_chans"], - ) + SimCLRTask( + model=weights.meta["model"], + weights=str(weights), + in_channels=weights.meta["in_chans"], + ) From da9783ff4c6ceb71ce564447cc39e0d7d7c16267 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 22:25:31 +0200 Subject: [PATCH 4/7] Skip tests that require optional deps --- tests/datasets/test_advance.py | 1 + tests/datasets/test_skippd.py | 3 +++ tests/trainers/test_detection.py | 4 ++++ tests/trainers/test_regression.py | 3 +++ 4 files changed, 11 insertions(+) diff --git a/tests/datasets/test_advance.py b/tests/datasets/test_advance.py index abbffbf47c5..9da0976e3ab 100644 --- a/tests/datasets/test_advance.py +++ b/tests/datasets/test_advance.py @@ -81,6 +81,7 @@ def test_mock_missing_module( dataset[0] def test_plot(self, dataset: ADVANCE) -> None: + pytest.importorskip("scipy", minversion="1.6.2") x = dataset[0].copy() dataset.plot(x, suptitle="Test") plt.close() diff --git a/tests/datasets/test_skippd.py b/tests/datasets/test_skippd.py index cc6aebe2cf9..389f376aa39 100644 --- a/tests/datasets/test_skippd.py +++ b/tests/datasets/test_skippd.py @@ -19,6 +19,9 @@ from torchgeo.datasets import SKIPPD +pytest.importorskip("h5py", minversion="3") + + def download_url(url: str, root: str, *args: str, **kwargs: str) -> None: shutil.copy(url, root) diff --git a/tests/trainers/test_detection.py b/tests/trainers/test_detection.py index a4e84277b4b..ef02a6b38fe 100644 --- a/tests/trainers/test_detection.py +++ b/tests/trainers/test_detection.py @@ -18,6 +18,10 @@ from torchgeo.trainers import ObjectDetectionTask +# MAP metric requires pycocotools to be installed +pytest.importorskip("pycocotools") + + class PredictObjectDetectionDataModule(NASAMarineDebrisDataModule): def setup(self, stage: str) -> None: self.predict_dataset = NASAMarineDebris(**self.kwargs) diff --git a/tests/trainers/test_regression.py b/tests/trainers/test_regression.py index 74c773e9ceb..3f13df0737e 100644 --- a/tests/trainers/test_regression.py +++ b/tests/trainers/test_regression.py @@ -66,6 +66,9 @@ def create_model(*args: Any, **kwargs: Any) -> Module: def test_trainer( self, monkeypatch: MonkeyPatch, name: str, fast_dev_run: bool ) -> None: + if name == "skippd": + pytest.importorskip("h5py", minversion="3") + config = os.path.join("tests", "conf", name + ".yaml") monkeypatch.setattr(timm, "create_model", self.create_model) From ee72322567a2331425593d6a9730738946ba0c5e Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 22:26:57 +0200 Subject: [PATCH 5/7] Isort fixes --- tests/datasets/test_skippd.py | 1 - tests/trainers/test_detection.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/datasets/test_skippd.py b/tests/datasets/test_skippd.py index 389f376aa39..838f4d67032 100644 --- a/tests/datasets/test_skippd.py +++ b/tests/datasets/test_skippd.py @@ -18,7 +18,6 @@ import torchgeo.datasets.utils from torchgeo.datasets import SKIPPD - pytest.importorskip("h5py", minversion="3") diff --git a/tests/trainers/test_detection.py b/tests/trainers/test_detection.py index ef02a6b38fe..a05e1820dbf 100644 --- a/tests/trainers/test_detection.py +++ b/tests/trainers/test_detection.py @@ -17,7 +17,6 @@ from torchgeo.main import main from torchgeo.trainers import ObjectDetectionTask - # MAP metric requires pycocotools to be installed pytest.importorskip("pycocotools") From cb3abe5b1c9adb4fbfee9bfcec8106d32898b378 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 23:13:09 +0200 Subject: [PATCH 6/7] Fix? ChesapeakeCVPR tests --- torchgeo/datamodules/chesapeake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchgeo/datamodules/chesapeake.py b/torchgeo/datamodules/chesapeake.py index f1d2418dffe..604c0d7e3ec 100644 --- a/torchgeo/datamodules/chesapeake.py +++ b/torchgeo/datamodules/chesapeake.py @@ -93,7 +93,7 @@ def __init__( """ # This is a rough estimate of how large of a patch we will need to sample in # EPSG:3857 in order to guarantee a large enough patch in the local CRS. - self.original_patch_size = patch_size * 2 + self.original_patch_size = patch_size * 3 kwargs["transforms"] = _Transform(K.CenterCrop(patch_size)) super().__init__( From fe546bf160a02acf6275b3f97c1ecd94fec81490 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 30 Sep 2023 23:18:38 +0200 Subject: [PATCH 7/7] Hack to avoid GeoDataset bug --- docs/tutorials/getting_started.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tutorials/getting_started.ipynb b/docs/tutorials/getting_started.ipynb index 826bcd0abc6..bfae62e29a7 100644 --- a/docs/tutorials/getting_started.ipynb +++ b/docs/tutorials/getting_started.ipynb @@ -189,6 +189,7 @@ "outputs": [], "source": [ "chesapeake_root = os.path.join(tempfile.gettempdir(), \"chesapeake\")\n", + "os.makedirs(chesapeake_root, exist_ok=True)\n", "chesapeake = ChesapeakeDE(chesapeake_root, crs=naip.crs, res=naip.res, download=True)" ] },