Skip to content

Commit 5c046f2

Browse files
_job_splitting: raise error when user specified non-positive tile_size #883
1 parent e987fe3 commit 5c046f2

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

openeo/extra/job_management/_job_splitting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def __init__(self, *, epsg: int, size: float):
122122
if not isinstance(epsg, int):
123123
raise JobSplittingFailure(f"Only integer EPSG codes are supported for tile grid splitting, got {epsg!r}.")
124124
self._epsg = epsg
125+
if size <= 0:
126+
raise JobSplittingFailure(f"Tile size must be positive, got {size!r}.")
125127
self.size = size
126128

127129
@property

tests/extra/job_management/test_job_splitting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def test_constructor_rejects_unknown_epsg(self):
2828
with pytest.raises(JobSplittingFailure, match="Failed to normalize EPSG code"):
2929
_SizeBasedTileGrid(epsg=999999, size=1.0)
3030

31+
@pytest.mark.parametrize("size", [0, -1, -0.5])
32+
def test_constructor_rejects_non_positive_size(self, size):
33+
"""Tile size must be strictly positive."""
34+
with pytest.raises(JobSplittingFailure, match="Tile size must be positive"):
35+
_SizeBasedTileGrid(epsg=4326, size=size)
3136
def test_get_tiles_raises_exception(self):
3237
"""test get_tiles when the input geometry is not a dict or shapely.geometry.Polygon"""
3338
tile_grid = _SizeBasedTileGrid(epsg=4326, size=0.1)

0 commit comments

Comments
 (0)