From 3f4a5973ded3931504e36b8ad6b9c4c525147ac8 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 23 Dec 2024 03:59:39 -0700 Subject: [PATCH 1/5] fix: drivers have been separated out of the gdal conda --- environment.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index d8bb0f83..d3284d1a 100644 --- a/environment.yml +++ b/environment.yml @@ -3,8 +3,8 @@ channels: - conda-forge - defaults dependencies: - - conda-forge::gdal>=3.3 + - conda-forge::gdal>=3.10 - conda-forge::geos>=3.3 - conda-forge::rasterio>=1.3 - - conda-forge::libstdcxx-ng # gdal dependency. Make sure it's from the same channel as gdal - - conda-forge::libarchive # gdal dependency. Make sure it's from the same channel as gdal + - conda-forge::libgdal-hdf5 + - conda-forge::libgdal-jp2openjpeg From d8be77d07a00cf6cf23c16f279570ed834bf9cf7 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 23 Dec 2024 04:04:42 -0700 Subject: [PATCH 2/5] fix: bump min python to 3.10 --- .github/workflows/continuous-integration.yml | 8 ++++---- docs/index.rst | 2 +- pyproject.toml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bdd4e7e2..ad079281 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12", "3.13"] defaults: run: shell: bash -l {0} @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12", "3.13"] defaults: run: shell: bash -l {0} @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12", "3.13"] defaults: run: shell: bash -l {0} @@ -73,7 +73,7 @@ jobs: continue-on-error: true strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12", "3.13"] defaults: run: shell: bash -l {0} diff --git a/docs/index.rst b/docs/index.rst index 688c9864..8a556cc5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ See the `stactools-packages website `_ and Requirements ============ -* `Python 3.8 or greater `_ +* `Python 3.10 or greater `_ STAC version support ==================== diff --git a/pyproject.toml b/pyproject.toml index de7ed700..27373c93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,12 +12,12 @@ keywords = ["pystac", "imagery", "raster", "catalog", "STAC"] classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] -requires-python = ">=3.8" +requires-python = ">=3.10" dependencies = [ "antimeridian>=0.2.6", "click>=8.1.3", From dc72be8207fc8d4f164f2425540b51d2504c0c22 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 23 Dec 2024 04:15:29 -0700 Subject: [PATCH 3/5] fix: reformat, remove tests that check behavior of other libs --- pyproject.toml | 4 +- scripts/rewrite_test_data.py | 6 +- src/stactools/cli/cli.py | 1 + src/stactools/cli/commands/add.py | 1 + src/stactools/cli/commands/add_asset.py | 1 + src/stactools/cli/commands/add_raster.py | 1 + src/stactools/cli/commands/copy.py | 1 + src/stactools/cli/commands/create.py | 1 + src/stactools/cli/commands/layout.py | 1 + src/stactools/cli/commands/merge.py | 1 + src/stactools/cli/commands/migrate.py | 1 + src/stactools/cli/commands/summary.py | 2 +- src/stactools/cli/commands/update_geometry.py | 1 + src/stactools/cli/commands/version.py | 1 + src/stactools/core/add.py | 1 + src/stactools/core/add_asset.py | 1 + src/stactools/core/create.py | 3 +- src/stactools/core/geometry.py | 3 +- src/stactools/core/io/__init__.py | 1 + src/stactools/core/io/xml.py | 1 + src/stactools/core/layout.py | 1 + src/stactools/core/merge.py | 1 + src/stactools/core/utils/convert.py | 1 + src/stactools/core/utils/raster_footprint.py | 1 + src/stactools/testing/cli.py | 2 + tests/cli/commands/test_add.py | 2 +- tests/cli/commands/test_add_asset.py | 2 +- tests/cli/commands/test_add_raster.py | 2 +- tests/cli/commands/test_copy.py | 2 +- tests/cli/commands/test_create.py | 2 +- tests/cli/commands/test_info.py | 1 + tests/cli/commands/test_lint.py | 10 +- tests/cli/commands/test_merge.py | 2 +- tests/cli/commands/test_migrate.py | 2 +- tests/cli/commands/test_summary.py | 2 +- tests/cli/commands/test_update_extent.py | 2 +- tests/cli/commands/test_update_geometry.py | 2 +- tests/cli/commands/test_validate.py | 2 +- tests/cli/commands/test_version.py | 3 +- tests/core/test_add_asset.py | 2 +- tests/core/test_add_raster.py | 1 + tests/core/test_create.py | 2 +- tests/core/test_io.py | 1 + tests/core/test_projection.py | 1 + tests/core/utils/test_antimeridian.py | 208 +----------------- tests/core/utils/test_convert.py | 2 +- tests/core/utils/test_raster_footprint.py | 2 +- tests/core/utils/test_round.py | 2 +- 48 files changed, 54 insertions(+), 242 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 27373c93..2286066b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ dev = [ "pytest-cov~=3.0", "pytest~=7.3", "requests>=2.27.1", - "ruff==0.0.265", + "ruff~=0.8.0", "types-certifi~=2021.10.8", "types-orjson~=3.6", "types-python-dateutil~=2.8", @@ -82,7 +82,7 @@ version = { attr = "stactools.core.__version__" } [tool.ruff] line-length = 88 -select = ["E", "F", "I"] +lint.select = ["E", "F", "I"] [tool.mypy] mypy_path = "src" diff --git a/scripts/rewrite_test_data.py b/scripts/rewrite_test_data.py index 90baa5f4..9f2e44ef 100755 --- a/scripts/rewrite_test_data.py +++ b/scripts/rewrite_test_data.py @@ -37,9 +37,9 @@ def remap_property(item: Item, before: str, after: str) -> None: for i, interval in enumerate(collection.extent.temporal.intervals): for j, datetime in enumerate(interval): if datetime: - collection.extent.temporal.intervals[i][ - j - ] = datetime.astimezone(UTC) + collection.extent.temporal.intervals[i][j] = ( + datetime.astimezone(UTC) + ) if object.STAC_OBJECT_TYPE == "Feature": item = cast(Item, object) diff --git a/src/stactools/cli/cli.py b/src/stactools/cli/cli.py index ab219ca6..0f4a7a19 100644 --- a/src/stactools/cli/cli.py +++ b/src/stactools/cli/cli.py @@ -2,6 +2,7 @@ from typing import Union import click + from stactools.cli import registry diff --git a/src/stactools/cli/commands/add.py b/src/stactools/cli/commands/add.py index ccd9bc8b..967baa39 100644 --- a/src/stactools/cli/commands/add.py +++ b/src/stactools/cli/commands/add.py @@ -2,6 +2,7 @@ import click from pystac import Catalog, Item, read_file + from stactools.core import add_item diff --git a/src/stactools/cli/commands/add_asset.py b/src/stactools/cli/commands/add_asset.py index 4cfdbc7d..e1318df6 100644 --- a/src/stactools/cli/commands/add_asset.py +++ b/src/stactools/cli/commands/add_asset.py @@ -3,6 +3,7 @@ import click import pystac import pystac.utils + from stactools.core import add_asset diff --git a/src/stactools/cli/commands/add_raster.py b/src/stactools/cli/commands/add_raster.py index e50bcd66..fadf593b 100644 --- a/src/stactools/cli/commands/add_raster.py +++ b/src/stactools/cli/commands/add_raster.py @@ -1,5 +1,6 @@ import click import pystac + from stactools.core import add_raster_to_item diff --git a/src/stactools/cli/commands/copy.py b/src/stactools/cli/commands/copy.py index 01bc22b4..4c3a7074 100644 --- a/src/stactools/cli/commands/copy.py +++ b/src/stactools/cli/commands/copy.py @@ -3,6 +3,7 @@ import click import pystac from pystac.utils import make_absolute_href + from stactools.core.copy import copy_catalog, move_all_assets diff --git a/src/stactools/cli/commands/create.py b/src/stactools/cli/commands/create.py index 31919f1d..dcf852d1 100644 --- a/src/stactools/cli/commands/create.py +++ b/src/stactools/cli/commands/create.py @@ -3,6 +3,7 @@ from typing import List import click + from stactools.core import create diff --git a/src/stactools/cli/commands/layout.py b/src/stactools/cli/commands/layout.py index ed81535c..f9490422 100644 --- a/src/stactools/cli/commands/layout.py +++ b/src/stactools/cli/commands/layout.py @@ -1,5 +1,6 @@ import click import pystac + from stactools.core import layout_catalog diff --git a/src/stactools/cli/commands/merge.py b/src/stactools/cli/commands/merge.py index b487c3af..b837b1a6 100644 --- a/src/stactools/cli/commands/merge.py +++ b/src/stactools/cli/commands/merge.py @@ -2,6 +2,7 @@ import click import pystac + from stactools.core import merge_all_items diff --git a/src/stactools/cli/commands/migrate.py b/src/stactools/cli/commands/migrate.py index 21818132..156b9731 100644 --- a/src/stactools/cli/commands/migrate.py +++ b/src/stactools/cli/commands/migrate.py @@ -1,5 +1,6 @@ import click import pystac + from stactools.core import migrate_object diff --git a/src/stactools/cli/commands/summary.py b/src/stactools/cli/commands/summary.py index 9d036052..7b8d8529 100644 --- a/src/stactools/cli/commands/summary.py +++ b/src/stactools/cli/commands/summary.py @@ -9,7 +9,7 @@ def format_summary(summary: Dict[str, Any], indent: int = 4) -> str: out = "" for var in summary: - if type(summary[var]) == dict: + if summary[var] is dict: out += var + ": \n" + " " * indent + str(summary[var]) + "\n" else: out += var + ": " + str(summary[var]) + "\n" diff --git a/src/stactools/cli/commands/update_geometry.py b/src/stactools/cli/commands/update_geometry.py index db645799..f5464b42 100644 --- a/src/stactools/cli/commands/update_geometry.py +++ b/src/stactools/cli/commands/update_geometry.py @@ -3,6 +3,7 @@ import click from click import Command, Group from pystac import Item + from stactools.core.utils import raster_footprint diff --git a/src/stactools/cli/commands/version.py b/src/stactools/cli/commands/version.py index 1afff46f..735743e0 100644 --- a/src/stactools/cli/commands/version.py +++ b/src/stactools/cli/commands/version.py @@ -2,6 +2,7 @@ from click import echo from click.core import Command, Group from pystac.version import get_stac_version + from stactools.core import __version__ diff --git a/src/stactools/core/add.py b/src/stactools/core/add.py index 30ca94a7..a9da2450 100644 --- a/src/stactools/core/add.py +++ b/src/stactools/core/add.py @@ -4,6 +4,7 @@ from pystac import Catalog, Collection, Item from pystac.layout import BestPracticesLayoutStrategy + from stactools.core.copy import move_assets as do_move_assets diff --git a/src/stactools/core/add_asset.py b/src/stactools/core/add_asset.py index 41b24859..55f3781e 100644 --- a/src/stactools/core/add_asset.py +++ b/src/stactools/core/add_asset.py @@ -4,6 +4,7 @@ from pystac import Asset, Collection, Item from pystac.utils import is_absolute_href, make_relative_href + from stactools.core.copy import move_asset_file logger = logging.getLogger(__name__) diff --git a/src/stactools/core/create.py b/src/stactools/core/create.py index a21ebad2..7c25228a 100644 --- a/src/stactools/core/create.py +++ b/src/stactools/core/create.py @@ -4,10 +4,11 @@ import rasterio import shapely.geometry -import stactools.core.projection from pystac import Asset, Item from pystac.extensions.projection import ProjectionExtension +import stactools.core.projection + from .io import ReadHrefModifier diff --git a/src/stactools/core/geometry.py b/src/stactools/core/geometry.py index 773c1549..4d96ecef 100644 --- a/src/stactools/core/geometry.py +++ b/src/stactools/core/geometry.py @@ -46,5 +46,4 @@ class GeoInterface(Protocol): extract geometries from objects. """ - def __geo_interface__(self) -> Dict[str, Any]: - ... + def __geo_interface__(self) -> Dict[str, Any]: ... diff --git a/src/stactools/core/io/__init__.py b/src/stactools/core/io/__init__.py index b9eb6cdd..2168fb4a 100644 --- a/src/stactools/core/io/__init__.py +++ b/src/stactools/core/io/__init__.py @@ -6,6 +6,7 @@ import fsspec from pystac.link import HREF from pystac.stac_io import StacIO + from stactools.core import utils ReadHrefModifier = Callable[[str], str] diff --git a/src/stactools/core/io/xml.py b/src/stactools/core/io/xml.py index 584a4360..b2dcb8ec 100644 --- a/src/stactools/core/io/xml.py +++ b/src/stactools/core/io/xml.py @@ -3,6 +3,7 @@ from lxml import etree from lxml.etree import _Element as lxmlElement + from stactools.core.io import ReadHrefModifier, read_text diff --git a/src/stactools/core/layout.py b/src/stactools/core/layout.py index 9a586df9..7c57fb2a 100644 --- a/src/stactools/core/layout.py +++ b/src/stactools/core/layout.py @@ -2,6 +2,7 @@ from pystac import Catalog from pystac.layout import TemplateLayoutStrategy + from stactools.core import move_all_assets diff --git a/src/stactools/core/merge.py b/src/stactools/core/merge.py index e8f3bf53..0b262936 100644 --- a/src/stactools/core/merge.py +++ b/src/stactools/core/merge.py @@ -5,6 +5,7 @@ from pystac.layout import BestPracticesLayoutStrategy from pystac.utils import is_absolute_href, make_relative_href from shapely.geometry import mapping, shape + from stactools.core.copy import copy_catalog, move_asset_file from stactools.core.copy import move_assets as do_move_assets diff --git a/src/stactools/core/utils/convert.py b/src/stactools/core/utils/convert.py index 5a2b12ac..2d5911aa 100644 --- a/src/stactools/core/utils/convert.py +++ b/src/stactools/core/utils/convert.py @@ -6,6 +6,7 @@ import rasterio import rasterio.shutil from rasterio.errors import DriverRegistrationError + from stactools.core import utils DEFAULT_PROFILE = { diff --git a/src/stactools/core/utils/raster_footprint.py b/src/stactools/core/utils/raster_footprint.py index c0e1e539..ea78f89b 100644 --- a/src/stactools/core/utils/raster_footprint.py +++ b/src/stactools/core/utils/raster_footprint.py @@ -17,6 +17,7 @@ from shapely.geometry.multipolygon import MultiPolygon from shapely.geometry.polygon import Polygon, orient from shapely.ops import unary_union + from stactools.core.geometry import mutual_intersection from ..projection import reproject_shape diff --git a/src/stactools/testing/cli.py b/src/stactools/testing/cli.py index 63d37081..6ebfd0e8 100644 --- a/src/stactools/testing/cli.py +++ b/src/stactools/testing/cli.py @@ -1,10 +1,12 @@ """CLI for test data maintenance and generation.""" + import logging import os import shutil from tempfile import TemporaryDirectory import click + from stactools.core.utils.subprocess import call logger = logging.getLogger(__name__) diff --git a/tests/cli/commands/test_add.py b/tests/cli/commands/test_add.py index ae668456..ae267539 100644 --- a/tests/cli/commands/test_add.py +++ b/tests/cli/commands/test_add.py @@ -2,8 +2,8 @@ import pystac.utils import pytest from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_add_asset.py b/tests/cli/commands/test_add_asset.py index 2d8231a5..ae473a75 100644 --- a/tests/cli/commands/test_add_asset.py +++ b/tests/cli/commands/test_add_asset.py @@ -3,8 +3,8 @@ import pystac import pystac.utils from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_add_raster.py b/tests/cli/commands/test_add_raster.py index 016f3b2a..862950d7 100644 --- a/tests/cli/commands/test_add_raster.py +++ b/tests/cli/commands/test_add_raster.py @@ -1,8 +1,8 @@ import pystac import pystac.utils from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests.conftest import expected_json diff --git a/tests/cli/commands/test_copy.py b/tests/cli/commands/test_copy.py index 84ff0ca6..510e9b6a 100644 --- a/tests/cli/commands/test_copy.py +++ b/tests/cli/commands/test_copy.py @@ -4,8 +4,8 @@ import pystac import pystac.utils from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_create.py b/tests/cli/commands/test_create.py index 6ad45388..d764e4fa 100644 --- a/tests/cli/commands/test_create.py +++ b/tests/cli/commands/test_create.py @@ -1,8 +1,8 @@ import json from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_info.py b/tests/cli/commands/test_info.py index 57ac5c32..36ce9671 100644 --- a/tests/cli/commands/test_info.py +++ b/tests/cli/commands/test_info.py @@ -1,5 +1,6 @@ import pystac from click.testing import CliRunner + from stactools.cli.cli import cli diff --git a/tests/cli/commands/test_lint.py b/tests/cli/commands/test_lint.py index 3b8cae9e..3a1e08a2 100644 --- a/tests/cli/commands/test_lint.py +++ b/tests/cli/commands/test_lint.py @@ -1,20 +1,12 @@ import pytest from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data pytest.importorskip("stac_check") -def test_valid_item() -> None: - path = test_data.get_path("data-files/linting/20201211_223832_cs2.json") - - runner = CliRunner() - result = runner.invoke(cli, ["lint", path]) - assert result.exit_code == 0 - - def test_invalid_item() -> None: path = test_data.get_path("data-files/linting/core-item.json") diff --git a/tests/cli/commands/test_merge.py b/tests/cli/commands/test_merge.py index 9a5455b9..479e354a 100644 --- a/tests/cli/commands/test_merge.py +++ b/tests/cli/commands/test_merge.py @@ -5,9 +5,9 @@ import pystac import pytest from click.testing import CliRunner + from stactools.cli.cli import cli from stactools.core import move_all_assets - from tests import test_data diff --git a/tests/cli/commands/test_migrate.py b/tests/cli/commands/test_migrate.py index 010c3ec9..bfb8d1e7 100644 --- a/tests/cli/commands/test_migrate.py +++ b/tests/cli/commands/test_migrate.py @@ -4,8 +4,8 @@ import pystac import pytest from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_summary.py b/tests/cli/commands/test_summary.py index c8d2283d..324b2203 100644 --- a/tests/cli/commands/test_summary.py +++ b/tests/cli/commands/test_summary.py @@ -1,6 +1,6 @@ from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_update_extent.py b/tests/cli/commands/test_update_extent.py index fcce4fca..3e26fde1 100644 --- a/tests/cli/commands/test_update_extent.py +++ b/tests/cli/commands/test_update_extent.py @@ -1,6 +1,6 @@ from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_update_geometry.py b/tests/cli/commands/test_update_geometry.py index 005923a1..84cfa2ef 100644 --- a/tests/cli/commands/test_update_geometry.py +++ b/tests/cli/commands/test_update_geometry.py @@ -2,8 +2,8 @@ from pathlib import Path from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data diff --git a/tests/cli/commands/test_validate.py b/tests/cli/commands/test_validate.py index 9fc66426..707aa228 100644 --- a/tests/cli/commands/test_validate.py +++ b/tests/cli/commands/test_validate.py @@ -1,7 +1,7 @@ import pytest from click.testing import CliRunner -from stactools.cli.cli import cli +from stactools.cli.cli import cli from tests import test_data pytest.importorskip("stac_validator") diff --git a/tests/cli/commands/test_version.py b/tests/cli/commands/test_version.py index 273b3920..e5d92ba0 100644 --- a/tests/cli/commands/test_version.py +++ b/tests/cli/commands/test_version.py @@ -1,6 +1,7 @@ import pystac -import stactools from click.testing import CliRunner + +import stactools from stactools.cli.cli import cli from stactools.core.utils.subprocess import call diff --git a/tests/core/test_add_asset.py b/tests/core/test_add_asset.py index 76824ba3..92ec7551 100644 --- a/tests/core/test_add_asset.py +++ b/tests/core/test_add_asset.py @@ -4,8 +4,8 @@ import pystac import pytest -from stactools.core import add_asset, add_asset_to_item +from stactools.core import add_asset, add_asset_to_item from tests import test_data diff --git a/tests/core/test_add_raster.py b/tests/core/test_add_raster.py index 293e162e..cf9ab1c7 100644 --- a/tests/core/test_add_raster.py +++ b/tests/core/test_add_raster.py @@ -7,6 +7,7 @@ import rasterio from rasterio.crs import CRS from rasterio.transform import Affine + from stactools.core import create from stactools.core.add_raster import add_raster_to_item diff --git a/tests/core/test_create.py b/tests/core/test_create.py index dc699918..332acdb9 100644 --- a/tests/core/test_create.py +++ b/tests/core/test_create.py @@ -3,8 +3,8 @@ import pytest from pystac.extensions.projection import ProjectionExtension -from stactools.core import create +from stactools.core import create from tests import test_data diff --git a/tests/core/test_io.py b/tests/core/test_io.py index ee516c44..f8c65b17 100644 --- a/tests/core/test_io.py +++ b/tests/core/test_io.py @@ -3,6 +3,7 @@ from unittest.mock import create_autospec, patch import pystac + import stactools.core.io from stactools.core import use_fsspec diff --git a/tests/core/test_projection.py b/tests/core/test_projection.py index 445bb4c9..db311245 100644 --- a/tests/core/test_projection.py +++ b/tests/core/test_projection.py @@ -1,4 +1,5 @@ from shapely.geometry import Point + from stactools.core import projection diff --git a/tests/core/utils/test_antimeridian.py b/tests/core/utils/test_antimeridian.py index fe31cf07..6ae25537 100644 --- a/tests/core/utils/test_antimeridian.py +++ b/tests/core/utils/test_antimeridian.py @@ -4,45 +4,8 @@ import shapely.geometry from pystac import Item from shapely.geometry import MultiPolygon, Polygon -from stactools.core.utils import antimeridian - - -def test_antimeridian_split() -> None: - # From https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.9 - canonical = Polygon(((170, 40), (-170, 40), (-170, 50), (170, 50), (170, 40))) - with pytest.warns(DeprecationWarning): - split = antimeridian.split(canonical) - assert split - expected = MultiPolygon( - ( - shapely.geometry.box(170, 40, 180, 50), - shapely.geometry.box(-180, 40, -170, 50), - ), - ) - for actual, expected in zip(split.geoms, expected.geoms): - assert actual.exterior.is_ccw - assert actual.equals(expected) - doesnt_cross = Polygon(((170, 40), (170, 50), (180, 50), (180, 40), (170, 40))) - with pytest.warns(DeprecationWarning): - split = antimeridian.split(doesnt_cross) - assert split is None - - canonical_other_way = Polygon( - ((-170, 40), (-170, 50), (170, 50), (170, 40), (-170, 40)), - ) - with pytest.warns(DeprecationWarning): - split = antimeridian.split(canonical_other_way) - assert split - expected = MultiPolygon( - ( - shapely.geometry.box(-180, 40, -170, 50), - shapely.geometry.box(170, 40, 180, 50), - ), - ) - for actual, expected in zip(split.geoms, expected.geoms): - assert actual.exterior.is_ccw - assert actual.equals(expected), f"actual={actual}, expected={expected}" +from stactools.core.utils import antimeridian def test_antimeridian_normalize() -> None: @@ -87,139 +50,6 @@ def test_antimeridian_normalize_easterly() -> None: assert normalized.equals(expected), f"actual={normalized}, expected={expected}" -def test_item_fix_antimeridian_split() -> None: - canonical = Polygon(((170, 40), (-170, 40), (-170, 50), (170, 50), (170, 40))) - item = Item( - "an-id", - geometry=shapely.geometry.mapping(canonical), - bbox=canonical.bounds, - datetime=datetime.datetime.now(), - properties={}, - ) - fix = antimeridian.fix_item(item, antimeridian.Strategy.SPLIT) - expected = MultiPolygon( - ( - shapely.geometry.box(170, 40, 180, 50), - shapely.geometry.box(-180, 40, -170, 50), - ), - ) - for actual, expected in zip( - shapely.geometry.shape(fix.geometry).geoms, - expected.geoms, - ): - assert actual.equals(expected) - assert fix.bbox == [170.0, 40.0, -170.0, 50.0] - - # https://github.com/stac-utils/stactools/issues/431 - item.geometry = { - "type": "MultiPolygon", - "coordinates": [ - [ - [ - [180.0, 71.05915991175688], - [179.9010750820252, 71.06541838862726], - [179.33609176796372, 71.09933099986762], - [178.94212273834066, 71.12173675373532], - [178.8438129745677, 70.9444458447684], - [178.752152818998, 70.76646311814699], - [178.65805412647518, 70.58865453189631], - [178.56519747139944, 70.41081414405018], - [178.47354940789182, 70.23294268101853], - [178.3830776723032, 70.0550408551604], - [178.29375108586135, 69.87710927076108], - [178.20553958576738, 69.69914858383564], - [178.11841414688843, 69.52115944285417], - [177.94089921353645, 69.16547224310027], - [177.84841186280488, 68.98789251198602], - [177.6811017579393, 68.63180788289334], - [177.59856429364814, 68.45374564350413], - [177.5170097254968, 68.27565414719149], - [177.35557827100007, 67.91945640451053], - [177.27786157853095, 67.74121946580148], - [177.2008812187222, 67.5629645683486], - [177.04801561874308, 67.20647273987551], - [176.999842641033, 67.08652173541694], - [177.33004216473563, 67.06599963683973], - [177.80402381607067, 67.0350911283458], - [178.2797509869322, 67.00256994873874], - [178.75469524409255, 66.96859439018418], - [179.22826647862672, 66.9332058638613], - [179.69748316523564, 66.89664359586376], - [180.0, 66.87210508518304], - [180.0, 71.05915991175688], - ] - ], - [ - [ - [-180.0, 71.05915991175688], - [-180.0, 66.87210508518304], - [-179.8356900497663, 66.85877716089777], - [-179.3711345161936, 66.81960857957779], - [-178.90872065703624, 66.77913696435182], - [-178.44665752494657, 66.73720767705268], - [-177.98865515860075, 66.69416388262516], - [-177.52780114205189, 66.6493554890298], - [-177.07275963647132, 66.6036210941224], - [-176.60787845770125, 66.55536115330877], - [-176.1601824748328, 66.50739485114256], - [-175.70001915807038, 66.4565657047866], - [-175.2469931583778, 66.40499213010705], - [-174.7964900612594, 66.35218457280217], - [-174.34347993447946, 66.29754039236374], - [-173.93806864778026, 66.24724531349037], - [-173.84461372118676, 66.36429279141416], - [-173.71659543892704, 66.53996608675018], - [-173.56903550480715, 66.7133044234658], - [-173.42527581962764, 66.88723670581788], - [-173.13377948252224, 67.23496576919374], - [-172.9861602177385, 67.40878187666635], - [-172.83662520799953, 67.58248608985471], - [-172.68512898875264, 67.75607579888592], - [-172.53162554562746, 67.92954828162647], - [-172.3760685337871, 68.10290084143905], - [-172.2184100683418, 68.27613086321372], - [-172.05860098199193, 68.44923546830157], - [-171.89659058995878, 68.6222117159503], - [-171.73232652538707, 68.79505671303144], - [-171.5657549702618, 68.96776730324396], - [-171.39682036750511, 69.14034030642564], - [-171.2254655001628, 69.31277236817284], - [-171.0516311905371, 69.48506019171748], - [-170.87525658150514, 69.65720018398522], - [-170.6962788340423, 69.82918868566634], - [-170.51463300157428, 70.00102201028209], - [-170.33062092998924, 70.17235288521945], - [-170.8013714414895, 70.22969914468295], - [-171.32505679115005, 70.2915919758267], - [-171.85186730974112, 70.35195515326475], - [-172.3817527878377, 70.41077446610994], - [-172.9146602469648, 70.46803605371709], - [-173.45053416371871, 70.52372627412625], - [-173.98931653005684, 70.5778316447626], - [-174.53094682771086, 70.6303388535604], - [-175.07536190589843, 70.68123489897708], - [-175.62249600000058, 70.73050710549359], - [-176.17228091814727, 70.77814294613066], - [-176.72464582082006, 70.82413036939441], - [-177.2795175859301, 70.86845740126327], - [-177.83682058594974, 70.91111247989673], - [-178.39647668879172, 70.95208453426882], - [-178.96676234549457, 70.99192936610521], - [-179.53562414647374, 71.02978121124382], - [-180.0, 71.05915991175688], - ] - ], - ], - } - fix = antimeridian.fix_item(item, antimeridian.Strategy.SPLIT) - assert fix.bbox == [ - 176.999842641033, - 66.24724531349037, - -170.33062092998924, - 71.12173675373532, - ] - - def test_item_fix_antimeridian_normalize() -> None: canonical = Polygon(((170, 40), (170, 50), (-170, 50), (-170, 40), (170, 40))) item = Item( @@ -254,39 +84,3 @@ def test_item_fix_antimeridian_multipolygon_ok() -> None: antimeridian.fix_item(item, antimeridian.Strategy.SPLIT) with pytest.warns(DeprecationWarning): antimeridian.fix_item(item, antimeridian.Strategy.NORMALIZE) - - -def test_antimeridian_multipolygon() -> None: - multi_polygon = MultiPolygon( - [ - Polygon(((170, 40), (-170, 40), (-170, 42), (170, 42), (170, 40))), - Polygon(((170, 48), (-170, 48), (-170, 50), (170, 50), (170, 48))), - ], - ) - with pytest.warns(DeprecationWarning): - split = antimeridian.split_multipolygon(multi_polygon) - assert split - expected = MultiPolygon( - ( - shapely.geometry.box(170, 40, 180, 42), - shapely.geometry.box(-180, 40, -170, 42), - shapely.geometry.box(170, 48, 180, 50), - shapely.geometry.box(-180, 48, -170, 50), - ), - ) - for actual, expected in zip(split.geoms, expected.geoms): - assert actual.exterior.is_ccw - assert actual.equals(expected), f"actual={actual}, expected={expected}" - - with pytest.warns(DeprecationWarning): - normalized = antimeridian.normalize_multipolygon(multi_polygon) - assert normalized - expected = MultiPolygon( - ( - Polygon(((170, 40), (170, 42), (190, 42), (190, 40), (170, 40))), - Polygon(((170, 48), (170, 50), (190, 50), (190, 48), (170, 48))), - ), - ) - for actual, expected in zip(normalized.geoms, expected.geoms): - assert actual.exterior.is_ccw - assert actual.equals(expected), f"actual={actual}, expected={expected}" diff --git a/tests/core/utils/test_convert.py b/tests/core/utils/test_convert.py index 86d363e8..ac761ed1 100644 --- a/tests/core/utils/test_convert.py +++ b/tests/core/utils/test_convert.py @@ -1,9 +1,9 @@ from pathlib import Path import rasterio + from stactools.core import utils from stactools.core.utils.convert import cogify, cogify_subdatasets - from tests import test_data diff --git a/tests/core/utils/test_raster_footprint.py b/tests/core/utils/test_raster_footprint.py index 86581498..0b2c9515 100644 --- a/tests/core/utils/test_raster_footprint.py +++ b/tests/core/utils/test_raster_footprint.py @@ -4,6 +4,7 @@ from shapely.geometry import shape from shapely.geometry.multipolygon import MultiPolygon from shapely.geometry.polygon import Polygon, orient + from stactools.core import use_fsspec from stactools.core.utils.raster_footprint import ( FootprintMergeStrategy, @@ -14,7 +15,6 @@ densify_reproject_simplify, update_geometry_from_asset_footprint, ) - from tests import test_data diff --git a/tests/core/utils/test_round.py b/tests/core/utils/test_round.py index 3224225d..32023c47 100644 --- a/tests/core/utils/test_round.py +++ b/tests/core/utils/test_round.py @@ -1,8 +1,8 @@ from typing import Any, Iterable, Iterator from pystac import Collection, Item -from stactools.core.utils.round import recursive_round, round_coordinates +from stactools.core.utils.round import recursive_round, round_coordinates from tests import test_data From 8866c1b374209aa1e980e4fffd88e9b4cc9e8b16 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 23 Dec 2024 04:18:48 -0700 Subject: [PATCH 4/5] feat: update pre-commit --- .pre-commit-config.yaml | 10 +++++----- src/stactools/core/add_raster.py | 5 ++++- src/stactools/core/utils/raster_footprint.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b30a7c1..2f3fb5c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,26 +3,26 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.265 + rev: v0.8.4 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.3.0 hooks: - id: codespell args: [--ignore-words=.codespellignore] types_or: [jupyter, markdown, python, shell] - repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 + rev: v1.1.2 hooks: - id: doc8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.14.0 hooks: - id: mypy # TODO lint test and scripts too diff --git a/src/stactools/core/add_raster.py b/src/stactools/core/add_raster.py index 01570b20..57559fae 100644 --- a/src/stactools/core/add_raster.py +++ b/src/stactools/core/add_raster.py @@ -69,7 +69,10 @@ def _read_bands(href: str, statistics: bool, histogram: bool) -> List[RasterBand data, range=(minimum, maximum), bins=BINS ) band.histogram = Histogram.create( - BINS, minimum, maximum, hist_data.tolist() + BINS, + minimum, + maximum, + hist_data.tolist(), # type: ignore ) bands.append(band) return bands diff --git a/src/stactools/core/utils/raster_footprint.py b/src/stactools/core/utils/raster_footprint.py index ea78f89b..9ef14f84 100644 --- a/src/stactools/core/utils/raster_footprint.py +++ b/src/stactools/core/utils/raster_footprint.py @@ -292,7 +292,7 @@ def data_mask(self) -> npt.NDArray[np.uint8]: mask[~np.isnan(self.data_array)] = 1 else: mask[self.data_array != self.no_data] = 1 - mask = np.sum(mask, axis=0, dtype=np.uint8) + mask = np.sum(mask, axis=0, dtype=np.uint8) # type: ignore mask[mask > 0] = 1 else: mask = np.full(shape, 1, dtype=np.uint8) From 197da6d4e8af1089d72411616aeecce3f3381db2 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 23 Dec 2024 04:28:29 -0700 Subject: [PATCH 5/5] fix: remove more broken stuff --- .github/workflows/continuous-integration.yml | 17 --------------- README.md | 6 ----- docker/cibuild | 23 -------------------- scripts/cibuild | 23 -------------------- 4 files changed, 69 deletions(-) delete mode 100755 docker/cibuild delete mode 100755 scripts/cibuild diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ad079281..d027bffa 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -88,23 +88,6 @@ jobs: run: pip install -U --pre pystac rasterio --no-binary rasterio - name: Run tests run: scripts/test - codecov: - name: Codecov - needs: - - standard - - extra-requires - - minimum-versions - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Execute linters and test suites - run: ./docker/cibuild - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - fail_ci_if_error: false docker: name: Docker needs: diff --git a/README.md b/README.md index 15a97a57..623cecca 100644 --- a/README.md +++ b/README.md @@ -162,12 +162,6 @@ Once the container is built, you can run the `scripts/` scripts inside a docker docker/console ``` -A complete build and test can be run with: - -```sh -docker/cibuild -``` - In scenarios where you want to run scripts in `docker/` but don't want to run the build, images can be downloaded via the `pull` script: ```sh diff --git a/docker/cibuild b/docker/cibuild deleted file mode 100755 index 6e8e9fb8..00000000 --- a/docker/cibuild +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -e - -if [[ -n "${STACTOOLS_DEBUG}" ]]; then - set -x -fi - -source $(dirname "$0")/env - -function usage() { - echo -n \ - "Usage: $(basename "$0") -Runs CI in the docker dev container. -" -} - -if [ "${BASH_SOURCE[0]}" = "${0}" ]; then - ./docker/build - docker run --rm \ - --entrypoint scripts/cibuild \ - $DOCKER_REGISTRY/$DOCKER_ORG/$DOCKER_REPO:$DOCKER_TAG_DEV -fi diff --git a/scripts/cibuild b/scripts/cibuild deleted file mode 100755 index c6378539..00000000 --- a/scripts/cibuild +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -e - -if [[ -n "${CI}" ]]; then - set -x -fi - -function usage() { - echo -n \ - "Usage: $(basename "$0") -Execute project linters and test suites in CI. -" -} - -if [ "${BASH_SOURCE[0]}" = "${0}" ]; then - if [ "${1:-}" = "--help" ]; then - usage - else - ./scripts/update - ./scripts/test - fi -fi