From 76139f60df21644c1498e39ac6a8be508115638c Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 10 Jul 2022 22:30:48 -0700 Subject: [PATCH] 0.3.0 release (#664) * 0.3.0 release * Slightly different distutils deprecation warning * Fix release tests * Escape regex in warning ignore * Escape characters require literal strings * Colon was problematic * Re-escape regex patterns * Fix tests without optional dependencies * Fix tests without optional dependencies * Try older nbmake * Try older nbmake * Try explicitly passing key * Black fixes * Document when parameters were added * Document more changes --- .github/workflows/release.yaml | 3 --- docs/tutorials/trainers.ipynb | 8 ++------ pyproject.toml | 3 +++ setup.cfg | 6 ++++-- tests/datamodules/test_usavars.py | 1 + tests/datasets/test_landcoverai.py | 2 ++ tests/datasets/test_openbuildings.py | 3 +-- tests/datasets/test_reforestree.py | 2 ++ tests/test_train.py | 5 +++++ torchgeo/__init__.py | 2 +- torchgeo/datasets/eurosat.py | 2 ++ torchgeo/datasets/so2sat.py | 3 +++ torchgeo/trainers/segmentation.py | 3 +++ torchgeo/transforms/indices.py | 4 ++++ 14 files changed, 33 insertions(+), 14 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/docs/tutorials/trainers.ipynb b/docs/tutorials/trainers.ipynb index e7e115e8aae..bc36aabdfdc 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\"]" ] }, { @@ -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=RADIANT_EARTH_API_KEY,\n", + " root_dir=data_dir, seed=1337, batch_size=64, num_workers=6, api_key=MLHUB_API_KEY\n", ")" ] }, diff --git a/pyproject.toml b/pyproject.toml index 33ae8ba5a21..7fb0324c083 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", @@ -78,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.PytestDeprecationWarning:nbmake.pytest_plugin', # Expected warnings # pytorch-lightning warns us about using num_workers=0, but it's faster on macOS diff --git a/setup.cfg b/setup.cfg index 91e314c1e1b..07fc8f308b4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -120,9 +120,11 @@ 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>=0.1,<2 + # 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 # pytest-cov 2.4+ required for pytest --cov flags 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..e8e64680ef0 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) @@ -56,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_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/datasets/test_reforestree.py b/tests/datasets/test_reforestree.py index 1337cfb18c3..a558393afa6 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") @@ -78,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)) 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)] 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" 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 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: