Skip to content

Commit 0864778

Browse files
Update clients to latest protobuf changes (#55)
1 parent b5b5827 commit 0864778

13 files changed

Lines changed: 197 additions & 44 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.61.0] - 2026-09-04
11+
1012
### Added
1113

1214
- `tilebox-grpc`: Add runtime and execution environment metadata to all API requests using the `Tilebox-Client` header.
15+
- `tilebox-datasets`: Add explicit `filter_contains_geometry` and `geometry_contains_filter` spatial query modes,
16+
deprecated the legacy `contains` mode which is an alias for `filter_contains_geometry`.
17+
- `tilebox-workflows`: Add task ID filters to job log and span queries and severity filters to job log queries.
18+
- `tilebox-workflows`: Allow querying jobs without specifying a temporal extent.
1319

1420
### Fixed
1521

@@ -489,7 +495,8 @@ the first client that does not cache data (since it's already on the local file
489495
- Released under the [MIT](https://opensource.org/license/mit) license.
490496
- Released packages: `tilebox-datasets`, `tilebox-workflows`, `tilebox-storage`, `tilebox-grpc`
491497

492-
[Unreleased]: https://github.com/tilebox/tilebox-python/compare/v0.60.0...HEAD
498+
[Unreleased]: https://github.com/tilebox/tilebox-python/compare/v0.61.0...HEAD
499+
[0.61.0]: https://github.com/tilebox/tilebox-python/compare/v0.60.0...v0.61.0
493500
[0.60.0]: https://github.com/tilebox/tilebox-python/compare/v0.59.0...v0.60.0
494501
[0.59.0]: https://github.com/tilebox/tilebox-python/compare/v0.58.0...v0.59.0
495502
[0.58.0]: https://github.com/tilebox/tilebox-python/compare/v0.57.0...v0.58.0

‎tilebox-datasets/tests/data/data_access.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ def spatial_filter_likes(draw: DrawFn) -> Geometry | SpatialFilterDict:
2626
return geometry
2727

2828
# return a dict
29-
mode: SpatialFilterMode | Literal["intersects", "contains"] | None = draw(
30-
sampled_from(["intersects", "contains"]), sampled_from(SpatialFilterMode) | none()
29+
mode: SpatialFilterMode | Literal["intersects", "filter_contains_geometry", "geometry_contains_filter"] | None = (
30+
draw(
31+
sampled_from(["intersects", "filter_contains_geometry", "geometry_contains_filter"]),
32+
sampled_from(SpatialFilterMode) | none(),
33+
)
3134
)
3235
coordinate_system: SpatialCoordinateSystem | Literal["cartesian", "spherical"] | None = draw(
3336
sampled_from(["cartesian", "spherical"]), sampled_from(SpatialCoordinateSystem) | none()

‎tilebox-datasets/tests/data/test_data_access.py‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import pytest
55
from hypothesis import given
6-
from shapely import Geometry
6+
from shapely import Geometry, box
77

88
from tests.data.data_access import query_filters, spatial_filter_likes, spatial_filters
9-
from tilebox.datasets.data.data_access import QueryFilters, SpatialFilter, SpatialFilterDict
9+
from tilebox.datasets.data.data_access import QueryFilters, SpatialFilter, SpatialFilterDict, SpatialFilterMode
1010
from tilebox.datasets.datasets.v1 import data_access_pb2
1111
from tilebox.datasets.query import TimeInterval, field
1212
from tilebox.datasets.query.id_interval import IDInterval
@@ -37,6 +37,25 @@ def test_parse_spatial_filter_like(spatial_filter_like: Geometry | SpatialFilter
3737
assert spatial_filter.coordinate_system is not None
3838

3939

40+
def test_contains_spatial_filter_mode_is_deprecated() -> None:
41+
with pytest.warns(DeprecationWarning, match='Use "filter_contains_geometry" instead'):
42+
spatial_filter = SpatialFilter.parse({"geometry": box(0, 0, 1, 1), "mode": "contains"})
43+
44+
assert spatial_filter.mode is SpatialFilterMode.FILTER_CONTAINS_GEOMETRY
45+
46+
47+
@pytest.mark.parametrize(
48+
("mode", "wire_mode"),
49+
[
50+
(SpatialFilterMode.FILTER_CONTAINS_GEOMETRY, data_access_pb2.SPATIAL_FILTER_MODE_FILTER_CONTAINS_GEOMETRY),
51+
(SpatialFilterMode.GEOMETRY_CONTAINS_FILTER, data_access_pb2.SPATIAL_FILTER_MODE_GEOMETRY_CONTAINS_FILTER),
52+
],
53+
)
54+
def test_directional_spatial_filter_modes(mode: SpatialFilterMode, wire_mode: int) -> None:
55+
message = SpatialFilter(box(0, 0, 1, 1), mode).to_message()
56+
assert message.mode == wire_mode
57+
58+
4059
@given(query_filters())
4160
def test_query_filters_to_message_and_back(q: QueryFilters) -> None:
4261
assert QueryFilters.from_message(q.to_message()) == q

‎tilebox-datasets/tilebox/datasets/aio/dataset.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ async def query(
464464
spatial_extent: The spatial extent to query data in. (Optional)
465465
Expected to be either a shapely geometry, or a dict with the following keys:
466466
- geometry: The geometry to query by. Must be a shapely.Polygon, shapely.MultiPolygon or shapely.Point.
467-
- mode: The spatial filter mode to use. Can be one of "intersects" or "contains".
468-
Defaults to "intersects".
467+
- mode: The spatial filter mode to use. Can be one of "intersects", "filter_contains_geometry", or
468+
"geometry_contains_filter". Defaults to "intersects".
469469
- coordinate_system: The coordinate system to use for performing geometry calculations. Can be one
470470
of "cartesian" or "spherical".
471471
Only supported for spatiotemporal datasets. Will raise an error if used for other dataset types.
472-
All datapoints whose geometry intersects the given spatial extent will be returned.
472+
Datapoints matching the selected spatial filter mode will be returned.
473473
skip_data: Whether to skip the actual data of the datapoint. If True, only datapoint metadata is returned.
474474
show_progress: Whether to show a progress bar while loading the data.
475475
If a callable is specified it is used as callback to report progress percentages.

‎tilebox-datasets/tilebox/datasets/data/data_access.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dataclasses import dataclass
22
from enum import Enum
33
from typing import Literal, TypeAlias, TypedDict
4+
from warnings import warn
45

56
from shapely import Geometry, from_wkb, to_wkb
67

@@ -15,7 +16,8 @@
1516

1617
class SpatialFilterMode(Enum):
1718
INTERSECTS = data_access_pb2.SPATIAL_FILTER_MODE_INTERSECTS
18-
CONTAINS = data_access_pb2.SPATIAL_FILTER_MODE_CONTAINS
19+
FILTER_CONTAINS_GEOMETRY = data_access_pb2.SPATIAL_FILTER_MODE_FILTER_CONTAINS_GEOMETRY
20+
GEOMETRY_CONTAINS_FILTER = data_access_pb2.SPATIAL_FILTER_MODE_GEOMETRY_CONTAINS_FILTER
1921

2022

2123
_filter_modes_from_string = {mode.name.lower(): mode for mode in SpatialFilterMode}
@@ -33,7 +35,10 @@ class SpatialCoordinateSystem(Enum):
3335

3436
class SpatialFilterDict(TypedDict):
3537
geometry: Geometry
36-
mode: NotRequired[SpatialFilterMode | Literal["intersects", "contains"]]
38+
# "contains" is deprecated and retained only for backwards compatibility.
39+
mode: NotRequired[
40+
SpatialFilterMode | Literal["intersects", "filter_contains_geometry", "geometry_contains_filter", "contains"]
41+
]
3742
coordinate_system: NotRequired[SpatialCoordinateSystem | Literal["cartesian", "spherical"]]
3843

3944

@@ -49,8 +54,8 @@ class SpatialFilter:
4954
5055
Args:
5156
geometry: The spatial geometry to filter by (e.g. a polygon)
52-
mode: The spatial filter mode to use. Can be one of "intersects" or "contains".
53-
Defaults to "intersects".
57+
mode: The spatial filter mode to use. Can be one of "intersects", "filter_contains_geometry", or
58+
"geometry_contains_filter". Defaults to "intersects".
5459
crs: The coordinate system to use for performing geometry calculations. Can be one
5560
of "cartesian" or "spherical".
5661
"""
@@ -92,6 +97,13 @@ def parse(cls, spatial_filter_like: SpatialFilterLike) -> "SpatialFilter":
9297
if isinstance(spatial_filter_like, dict):
9398
mode = spatial_filter_like.get("mode", None)
9499
if isinstance(mode, str):
100+
if mode.lower() == "contains":
101+
warn(
102+
'The spatial filter mode "contains" is deprecated. Use "filter_contains_geometry" instead.',
103+
DeprecationWarning,
104+
stacklevel=2,
105+
)
106+
mode = "filter_contains_geometry"
95107
mode = _filter_modes_from_string.get(mode.lower())
96108
coordinate_system = spatial_filter_like.get("coordinate_system", None)
97109
if isinstance(coordinate_system, str):

‎tilebox-datasets/tilebox/datasets/datasets/v1/data_access_pb2.py‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)