diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2962cf28..a58c081b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: debug-statements - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" + rev: "v4.0.0-alpha.4" hooks: - id: prettier exclude: "tests/(test_stats|test_project)/" @@ -26,12 +26,12 @@ repos: language_version: python3 - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.1.6" + rev: "v0.1.7" hooks: - id: ruff - repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.0 + rev: 1.7.1 hooks: - id: nbqa-black - id: nbqa-ruff diff --git a/CHANGELOG.md b/CHANGELOG.md index b2449bad..896c6652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,20 @@ +## [Version 1.7.3] - 2023-12-11 + +- Fix bug with versions of `sentinelhub-py >= 3.10.0` due to bad version string comparison. +- Adjust rounding of statistics for vector data. + + ## [Version 1.7.2] - 2023-11-28 - Fix pipeline-chain execution when using CLI + ## [Version 1.7.1] - 2023-11-23 - Fixed `eogrow-validate` command when validating pipeline chains that use variables. - Restricted version of `typing_extensions` + ## [Version 1.7.0] - 2023-11-22 With this release we push `eo-grow` towards a more `ray` centered execution model. diff --git a/eogrow/__init__.py b/eogrow/__init__.py index 0d7b6bff..6bf6c2c2 100644 --- a/eogrow/__init__.py +++ b/eogrow/__init__.py @@ -1,3 +1,3 @@ """The main module of the eo-grow package.""" -__version__ = "1.7.2" +__version__ = "1.7.3" diff --git a/eogrow/core/storage.py b/eogrow/core/storage.py index d6b42b2d..465ceeaf 100644 --- a/eogrow/core/storage.py +++ b/eogrow/core/storage.py @@ -7,7 +7,6 @@ import fs from pydantic import BaseSettings, Field -import sentinelhub from eolearn.core.utils.fs import get_aws_credentials, get_filesystem, is_s3_path from sentinelhub import SHConfig @@ -65,7 +64,7 @@ def __init__(self, config: Schema): def _prepare_sh_config(self) -> SHConfig: """Prepares an instance of `SHConfig` containing AWS credentials. In case given AWS profile doesn't exist it will show a warning and return a config without AWS credentials.""" - sh_config = SHConfig(hide_credentials=True) if sentinelhub.__version__ < "3.9.0" else SHConfig() + sh_config = SHConfig() if self.is_on_s3() and self.config.aws_profile: sh_config = get_aws_credentials(aws_profile=self.config.aws_profile, config=sh_config) diff --git a/eogrow/utils/testing.py b/eogrow/utils/testing.py index ca870cd0..f2ab44ba 100644 --- a/eogrow/utils/testing.py +++ b/eogrow/utils/testing.py @@ -8,6 +8,7 @@ import os from collections import defaultdict from dataclasses import dataclass +from functools import partial from typing import Any, Iterable, cast import fs @@ -189,10 +190,13 @@ def _get_coords_sample(geom: Polygon | MultiPolygon | Any) -> list[tuple[float, if len(gdf): subsample: gpd.GeoDataFrame = gdf.sample(min(len(gdf), config.num_random_values), random_state=42) subsample["centroid"] = subsample.centroid.apply(_rounder) - subsample["area"] = subsample.area.apply(_prepare_value, dtype=np.float64) + subsample["area"] = subsample.area subsample["geometry_type"] = subsample.geometry.geom_type subsample["some_coords"] = subsample.geometry.apply(_get_coords_sample) + for col in subsample.select_dtypes(include="number").columns.values: + subsample[col] = subsample[col].apply(partial(_prepare_value, dtype=subsample[col].dtype)) + subsample_json_string = subsample.drop(columns="geometry").to_json(orient="index", date_format="iso") stats["random_rows"] = json.loads(subsample_json_string) diff --git a/pyproject.toml b/pyproject.toml index 8669fcee..052e5dd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ dependencies = [ "python-rapidjson", "rasterio", "ray[default]", - "sentinelhub>=3.6.2", + "sentinelhub>=3.9.0", "shapely>=1.8.0", "typing-extensions>=4.5.0", ] diff --git a/tests/pipelines/test_byoc.py b/tests/pipelines/test_byoc.py index 4a54f854..c73e9081 100644 --- a/tests/pipelines/test_byoc.py +++ b/tests/pipelines/test_byoc.py @@ -33,7 +33,9 @@ @pytest.fixture(name="configured_requests_mock") def request_mock_setup(requests_mock): requests_mock.get(url="/latest/dynamic/instance-identity/document", real_http=True) # logging - requests_mock.post(url="/oauth/token", real_http=True) + requests_mock.post( + url="https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token", real_http=True + ) # creating a new collection requests_mock.post(url="/api/v1/byoc/collections", response_list=[{"json": {"data": {"id": "mock-collection"}}}]) @@ -79,7 +81,7 @@ def test_timeless_byoc(config_and_stats_paths, preparation_config, config, confi pipeline, requests = run_byoc_pipeline(config_path, configured_requests_mock) auth_request = requests.pop(0) - assert auth_request.url == "https://services.sentinel-hub.com/oauth/token" + assert auth_request.url == "https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token" creation_request = requests.pop(0) assert creation_request.url == "https://services.sentinel-hub.com/api/v1/byoc/collections" @@ -111,7 +113,7 @@ def test_temporal_byoc(config_and_stats_paths, preparation_config, config, confi pipeline, requests = run_byoc_pipeline(config_path, configured_requests_mock) auth_request = requests.pop(0) - assert auth_request.url == "https://services.sentinel-hub.com/oauth/token" + assert auth_request.url == "https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token" creation_request = requests.pop(0) assert creation_request.url == "https://services.sentinel-hub.com/api/v1/byoc/collections" @@ -124,12 +126,41 @@ def test_temporal_byoc(config_and_stats_paths, preparation_config, config, confi assert check_request.method == "GET" timestamps = [ - "2019-01-04T07:48:37Z", - "2019-01-24T07:48:39Z", - "2019-02-13T07:48:39Z", - "2019-02-18T07:48:36Z", - "2019-02-23T07:49:38Z", - "2019-03-05T07:55:53Z", + "2018-01-19T07:42:27Z", + "2018-02-28T07:46:50Z", + "2018-03-05T07:38:03Z", + "2018-03-25T07:44:17Z", + "2018-04-09T07:38:40Z", + "2018-04-19T07:43:26Z", + "2018-04-24T07:46:03Z", + "2018-05-09T07:36:10Z", + "2018-05-19T07:45:29Z", + "2018-06-08T07:43:25Z", + "2018-06-13T07:43:56Z", + "2018-06-18T07:42:58Z", + "2018-06-23T07:46:07Z", + "2018-06-28T07:45:41Z", + "2018-07-03T07:36:13Z", + "2018-07-08T07:42:00Z", + "2018-07-13T07:44:13Z", + "2018-08-02T07:36:12Z", + "2018-08-07T07:41:24Z", + "2018-08-17T07:47:30Z", + "2018-08-22T07:45:09Z", + "2018-08-27T07:39:47Z", + "2018-09-01T07:36:10Z", + "2018-09-06T07:40:44Z", + "2018-09-11T07:44:09Z", + "2018-09-16T07:41:35Z", + "2018-09-21T07:46:13Z", + "2018-09-26T07:47:11Z", + "2018-10-01T07:37:17Z", + "2018-10-21T07:39:34Z", + "2018-10-31T07:41:47Z", + "2018-11-10T07:48:34Z", + "2018-11-20T07:48:33Z", + "2018-12-15T07:48:33Z", + "2018-12-30T07:48:33Z", ] for tile_request in requests: assert tile_request.url == "https://services.sentinel-hub.com/api/v1/byoc/collections/mock-collection/tiles" diff --git a/tests/test_config_files/byoc/prepare_bands_data.json b/tests/test_config_files/byoc/prepare_bands_data.json index 2453bfb3..2aea9b62 100644 --- a/tests/test_config_files/byoc/prepare_bands_data.json +++ b/tests/test_config_files/byoc/prepare_bands_data.json @@ -6,7 +6,7 @@ "maps": "maps/BANDS-S2-L1C" } }, - "input_folder_key": "data_2019", + "input_folder_key": "data", "output_folder_key": "maps", "feature": ["data", "BANDS-S2-L1C"], "map_dtype": "float32",