Skip to content

Commit

Permalink
Prepare for release (#528)
Browse files Browse the repository at this point in the history
* update version and changelog

* fix failing test

* update pre-commit hooks

* fixed doc version
  • Loading branch information
zigaLuksic committed Apr 24, 2024
1 parent dd27e36 commit 13a71ab
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 112 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: requirements-txt-fixer
Expand All @@ -13,18 +13,18 @@ repos:
- id: debug-statements

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.4.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.11"
rev: "v0.4.1"
hooks:
- id: ruff

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
rev: 1.8.5
hooks:
- id: nbqa-black
- id: nbqa-ruff
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [Version 3.10.2] - 2024-24-04

- Added `max_retries` parameter to `SHConfig` class. It controls how many times the client will attempt to re-download before raising `OutOfRequestsException`. It is set to `None` by default, in which case it never stops trying. Contributed by @Regan-Koopmans.


## [Version 3.10.1] - 2024-01-10

- Improved documentation for Copernicus Data Space Ecosystem.
Expand Down
16 changes: 9 additions & 7 deletions examples/fis_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,15 @@
"\n",
"geometry1 = Geometry(Polygon([(-5.13, 48), (-5.23, 48.09), (-5.13, 48.17), (-5.03, 48.08), (-5.13, 48)]), CRS.WGS84)\n",
"geometry2 = Geometry(\n",
" Polygon([\n",
" (1292344.0, 5205055.5),\n",
" (1301479.5, 5195920.0),\n",
" (1310615.0, 5205055.5),\n",
" (1301479.5, 5214191.0),\n",
" (1292344.0, 5205055.5),\n",
" ]),\n",
" Polygon(\n",
" [\n",
" (1292344.0, 5205055.5),\n",
" (1301479.5, 5195920.0),\n",
" (1310615.0, 5205055.5),\n",
" (1301479.5, 5214191.0),\n",
" (1292344.0, 5205055.5),\n",
" ]\n",
" ),\n",
" CRS.POP_WEB,\n",
")"
]
Expand Down
16 changes: 9 additions & 7 deletions examples/process_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,15 @@
"request_raw_dict = {\n",
" \"input\": {\n",
" \"bounds\": {\"properties\": {\"crs\": betsiboka_bbox.crs.opengis_string}, \"bbox\": list(betsiboka_bbox)},\n",
" \"data\": [{\n",
" \"type\": \"S2L1C\",\n",
" \"dataFilter\": {\n",
" \"timeRange\": {\"from\": \"2020-06-01T00:00:00Z\", \"to\": \"2020-06-30T00:00:00Z\"},\n",
" \"mosaickingOrder\": \"leastCC\",\n",
" },\n",
" }],\n",
" \"data\": [\n",
" {\n",
" \"type\": \"S2L1C\",\n",
" \"dataFilter\": {\n",
" \"timeRange\": {\"from\": \"2020-06-01T00:00:00Z\", \"to\": \"2020-06-30T00:00:00Z\"},\n",
" \"mosaickingOrder\": \"leastCC\",\n",
" },\n",
" }\n",
" ],\n",
" },\n",
" \"output\": {\n",
" \"width\": betsiboka_size[0],\n",
Expand Down
16 changes: 9 additions & 7 deletions examples/process_request_cdse.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,15 @@
"request_raw_dict = {\n",
" \"input\": {\n",
" \"bounds\": {\"properties\": {\"crs\": betsiboka_bbox.crs.opengis_string}, \"bbox\": list(betsiboka_bbox)},\n",
" \"data\": [{\n",
" \"type\": \"S2L1C\",\n",
" \"dataFilter\": {\n",
" \"timeRange\": {\"from\": \"2020-06-01T00:00:00Z\", \"to\": \"2020-06-30T00:00:00Z\"},\n",
" \"mosaickingOrder\": \"leastCC\",\n",
" },\n",
" }],\n",
" \"data\": [\n",
" {\n",
" \"type\": \"S2L1C\",\n",
" \"dataFilter\": {\n",
" \"timeRange\": {\"from\": \"2020-06-01T00:00:00Z\", \"to\": \"2020-06-30T00:00:00Z\"},\n",
" \"mosaickingOrder\": \"leastCC\",\n",
" },\n",
" }\n",
" ],\n",
" },\n",
" \"output\": {\n",
" \"width\": betsiboka_size[0],\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ docs = [
"matplotlib",
"nbsphinx",
"sphinx==7.1.2",
"sphinx_mdinclude",
"sphinx_mdinclude==0.5.4", # version fixed because 0.6.0 didnt work at release time of 3.10.2
"sphinx_rtd_theme==1.3.0",
]
dev = [
Expand Down
2 changes: 1 addition & 1 deletion sentinelhub/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of the sentinelhub package."""

__version__ = "3.10.1"
__version__ = "3.10.2"
12 changes: 7 additions & 5 deletions sentinelhub/api/base_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ def _get_base_url(self) -> str:
settings from config object. In case different collections have different restrictions then
`SHConfig.sh_base_url` breaks the tie in case it matches one of the data collection URLs.
"""
data_collection_urls = tuple({
input_data_dict.service_url.rstrip("/")
for input_data_dict in self.payload["input"]["data"]
if isinstance(input_data_dict, InputDataDict) and input_data_dict.service_url is not None
})
data_collection_urls = tuple(
{
input_data_dict.service_url.rstrip("/")
for input_data_dict in self.payload["input"]["data"]
if isinstance(input_data_dict, InputDataDict) and input_data_dict.service_url is not None
}
)
config_base_url = self.config.sh_base_url.rstrip("/")

if not data_collection_urls:
Expand Down
24 changes: 13 additions & 11 deletions sentinelhub/api/batch/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,19 @@ def output(
:param kwargs: Any other arguments to be added to a dictionary of parameters
:return: A dictionary of output parameters
"""
return remove_undefined({
"defaultTilePath": default_tile_path,
"overwrite": overwrite,
"skipExisting": skip_existing,
"cogOutput": cog_output,
"cogParameters": cog_parameters,
"createCollection": create_collection,
"collectionId": collection_id,
"responses": responses,
**kwargs,
})
return remove_undefined(
{
"defaultTilePath": default_tile_path,
"overwrite": overwrite,
"skipExisting": skip_existing,
"cogOutput": cog_output,
"cogParameters": cog_parameters,
"createCollection": create_collection,
"collectionId": collection_id,
"responses": responses,
**kwargs,
}
)

def iter_tiling_grids(self, **kwargs: Any) -> SentinelHubFeatureIterator:
"""An iterator over tiling grids
Expand Down
12 changes: 7 additions & 5 deletions sentinelhub/api/byoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ def update_tile(self, collection: CollectionType, tile: TileType) -> Json:
headers = {"Content-Type": MimeType.JSON.get_string()}

_tile = self._to_dict(tile)
updates = remove_undefined({
"path": _tile["path"],
"coverGeometry": _tile.get("coverGeometry"),
"sensingTime": _tile.get("sensingTime"),
})
updates = remove_undefined(
{
"path": _tile["path"],
"coverGeometry": _tile.get("coverGeometry"),
"sensingTime": _tile.get("sensingTime"),
}
)

return self.client.get_json(
url=url, request_type=RequestType.PUT, post_values=updates, headers=headers, use_session=True
Expand Down
30 changes: 16 additions & 14 deletions sentinelhub/api/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,22 @@ def search(
if geometry and geometry.crs is not CRS.WGS84:
geometry = geometry.transform(CRS.WGS84)

payload = remove_undefined({
"collections": [collection_id],
"datetime": f"{start_time}/{end_time}" if time else None,
"bbox": list(bbox) if bbox else None,
"intersects": geometry.get_geojson(with_crs=False) if geometry else None,
"ids": ids,
"filter": self._prepare_filters(filter, collection, filter_lang),
"filter-lang": filter_lang,
"filter-crs": filter_crs,
"fields": fields,
"distinct": distinct,
"limit": limit,
**kwargs,
})
payload = remove_undefined(
{
"collections": [collection_id],
"datetime": f"{start_time}/{end_time}" if time else None,
"bbox": list(bbox) if bbox else None,
"intersects": geometry.get_geojson(with_crs=False) if geometry else None,
"ids": ids,
"filter": self._prepare_filters(filter, collection, filter_lang),
"filter-lang": filter_lang,
"filter-crs": filter_crs,
"fields": fields,
"distinct": distinct,
"limit": limit,
**kwargs,
}
)

return CatalogSearchIterator(self.client, url, payload)

Expand Down
2 changes: 1 addition & 1 deletion sentinelhub/data_collections_bands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Contains information about data collections used by SH """
"""Contains information about data collections used by SH"""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion sentinelhub/download/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def new_download_func(self: Self, request: DownloadRequest) -> T:


def retry_temporary_errors(
download_func: Callable[[SelfWithConfig, DownloadRequest], T]
download_func: Callable[[SelfWithConfig, DownloadRequest], T],
) -> Callable[[SelfWithConfig, DownloadRequest], T]:
"""Decorator function for handling server and connection errors"""
backoff_coefficient = 3
Expand Down
2 changes: 1 addition & 1 deletion sentinelhub/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _to_tuple(cls, bbox: BBoxInputType) -> tuple[float, float, float, float]:

@staticmethod
def _tuple_from_list_or_tuple(
bbox: tuple[float, float, float, float] | tuple[tuple[float, float], tuple[float, float]]
bbox: tuple[float, float, float, float] | tuple[tuple[float, float], tuple[float, float]],
) -> tuple[float, float, float, float]:
"""Converts a list or tuple representation of a bbox into a flat tuple representation.
Expand Down
28 changes: 15 additions & 13 deletions tests/api/batch/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,23 @@ def test_create_and_run_batch_request(batch_client: SentinelHubBatch, requests_m
request_id = "mocked-id"
requests_mock.post(
"/api/v1/batch/process",
[{
"json": {
"id": request_id,
"processRequest": {
"input": {
"bounds": {
"bbox": list(bbox),
"properties": {"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"},
[
{
"json": {
"id": request_id,
"processRequest": {
"input": {
"bounds": {
"bbox": list(bbox),
"properties": {"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"},
}
}
}
},
"tileCount": 42,
"status": "CREATED",
},
"tileCount": 42,
"status": "CREATED",
}
}
}],
],
)

batch_request = batch_client.create(
Expand Down
34 changes: 19 additions & 15 deletions tests/api/test_byoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ def collection_fixture() -> JsonDict:
"maxMetersPerPixel": 800.0,
"extent": {
"type": "Polygon",
"coordinates": [[
[13.293347498, 45.366449953],
[13.293347498, 46.897693758],
[16.575424424, 46.897693758],
[16.575424424, 45.366449953],
[13.293347498, 45.366449953],
]],
"coordinates": [
[
[13.293347498, 45.366449953],
[13.293347498, 46.897693758],
[16.575424424, 46.897693758],
[16.575424424, 45.366449953],
[13.293347498, 45.366449953],
]
],
},
"hasSensingTimes": "NO",
},
Expand Down Expand Up @@ -79,15 +81,17 @@ def tile_fixture() -> JsonDict:
"coverGeometry": {
"crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::32633"}},
"type": "MultiPolygon",
"coordinates": [(
"coordinates": [
(
(369999.99998228427, 5025000.000464492),
(620000.000010147, 5025000.000464773),
(620000.000012391, 5195000.000585059),
(369999.9999783558, 5195000.00058473),
(369999.99998228427, 5025000.000464492),
),
)],
(
(369999.99998228427, 5025000.000464492),
(620000.000010147, 5025000.000464773),
(620000.000012391, 5195000.000585059),
(369999.9999783558, 5195000.00058473),
(369999.99998228427, 5025000.000464492),
),
)
],
},
"created": "2020-06-22T12:33:36.081000Z",
"sensingTime": None,
Expand Down
16 changes: 9 additions & 7 deletions tests/api/test_fis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@

BBOX = BBox([14.00, 45.00, 14.03, 45.03], crs=CRS.WGS84)
GEOMETRY1 = Geometry(
Polygon([
(465888.877326859, 5079639.436138632),
(465885.3413983975, 5079641.524618266),
(465882.9542217017, 5079647.166043535),
(465888.8780175466, 5079668.703676634),
(465888.877326859, 5079639.436138632),
]),
Polygon(
[
(465888.877326859, 5079639.436138632),
(465885.3413983975, 5079641.524618266),
(465882.9542217017, 5079647.166043535),
(465888.8780175466, 5079668.703676634),
(465888.877326859, 5079639.436138632),
]
),
CRS(32633),
)
GEOMETRY2 = Geometry("POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))", CRS.WGS84)
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_ogc.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ def collect_data(self, request: OgcRequest) -> list:
result_len=1,
img_min=0.0,
img_max=1.0,
img_mean=0.34803,
img_mean=0.34748,
img_median=0.02383,
img_std=0.46208,
img_std=0.46185,
tile_num=2,
),
OgcTestCase(
Expand Down
3 changes: 1 addition & 2 deletions tests/api/test_process.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Tests for the Process API requests
"""
"""Tests for the Process API requests"""

from __future__ import annotations

Expand Down
3 changes: 1 addition & 2 deletions tests/api/test_process_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Tests for the Async Process API requests
"""
"""Tests for the Async Process API requests"""

import datetime as dt

Expand Down
Loading

0 comments on commit 13a71ab

Please sign in to comment.