Skip to content

Commit 2574094

Browse files
committed
Issue #567 initial fix for broken reduce_temporal after load_stac
1 parent bb04cdc commit 2574094

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
### Fixed
2323

24+
- Initial fix for broken `DataCube.reduce_temporal()` after `load_stac` ([#568](https://github.com/Open-EO/openeo-python-client/pull/568))
25+
2426

2527
## [0.29.0] - 2024-05-03
2628

openeo/metadata.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,5 +581,8 @@ def is_band_asset(asset: pystac.Asset) -> bool:
581581

582582
# TODO: conditionally include band dimension when there was actual indication of band metadata?
583583
band_dimension = BandDimension(name="bands", bands=bands)
584-
metadata = CubeMetadata(dimensions=[band_dimension])
584+
# TODO #567 get actual temporal extent information from metadata (if any)
585+
# TODO #567 is it possible to derive the actual name of temporal dimension that the backend will use?
586+
temporal_dimension = TemporalDimension(name="t", extent=[None, None])
587+
metadata = CubeMetadata(dimensions=[band_dimension, temporal_dimension])
585588
return metadata

tests/rest/test_connection.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,52 @@ def test_load_stac_from_job_empty_result(self, con120, requests_mock):
25552555
}
25562556
}
25572557

2558+
def test_load_stac_reduce_temporal(self, con120, tmp_path):
2559+
# TODO: reusable utility to create/generate a STAC resource for testing
2560+
# (a file, but preferably a URL, but that requires urllib mocking)
2561+
stac_path = tmp_path / "stac.json"
2562+
stac_data = {
2563+
"type": "Collection",
2564+
"id": "test-collection",
2565+
"stac_version": "1.0.0",
2566+
"description": "Test collection",
2567+
"links": [],
2568+
"title": "Test Collection",
2569+
"extent": {
2570+
"spatial": {"bbox": [[-180.0, -90.0, 180.0, 90.0]]},
2571+
"temporal": {"interval": [["2020-01-01T00:00:00Z", "2020-01-10T00:00:00Z"]]},
2572+
},
2573+
"license": "proprietary",
2574+
"summaries": {"eo:bands": [{"name": "B01"}, {"name": "B02"}]},
2575+
}
2576+
stac_path.write_text(json.dumps(stac_data))
2577+
2578+
cube = con120.load_stac(str(stac_path))
2579+
reduced = cube.reduce_temporal("max")
2580+
assert reduced.flat_graph() == {
2581+
"loadstac1": {
2582+
"process_id": "load_stac",
2583+
"arguments": {"url": str(stac_path)},
2584+
},
2585+
"reducedimension1": {
2586+
"process_id": "reduce_dimension",
2587+
"arguments": {
2588+
"data": {"from_node": "loadstac1"},
2589+
"dimension": "t",
2590+
"reducer": {
2591+
"process_graph": {
2592+
"max1": {
2593+
"arguments": {"data": {"from_parameter": "data"}},
2594+
"process_id": "max",
2595+
"result": True,
2596+
}
2597+
}
2598+
},
2599+
},
2600+
"result": True,
2601+
},
2602+
}
2603+
25582604

25592605
@pytest.mark.parametrize(
25602606
"data",

0 commit comments

Comments
 (0)