Respect STAC cube:dimensions as source of truth in metadata_from_stac + align tests with dimension policy#867
Conversation
…legacy unit tests fail
soxofaan
left a comment
There was a problem hiding this comment.
just could give this a quick scan to make some notes
…se-correction for Dict to support python3.8 Co-authored-by: Stefaan Lippens <soxofaan@users.noreply.github.com>
|
ready for review @soxofaan |
|
Hi @soxofaan , please let us know if there is something we can do to move on with this PR! |
|
|
||
| # Dimension name resolution policy (STAC cube:dimensions vs openEO defaults) | ||
| @pytest.mark.parametrize( | ||
| ["stac_dict", "expected_dims"], |
There was a problem hiding this comment.
can a STAC 1.1 style test case be added which uses the new 'bands' common metadata and no datacube extension?
Collection metadata example:
https://github.com/radiantearth/stac-spec/blob/master/examples/collection-only/collection.json#L152
Bands spec:
https://github.com/radiantearth/stac-spec/blob/master/commons/common-metadata.md#band-object
jdries
left a comment
There was a problem hiding this comment.
FYI, Stefaan is on holiday
Added one comment myself.
Please also add a changelog entry.
Otherwise I'm inclined to say it looks good, assuming this change mostly preserves existing behaviour. (Biggest worry are collections with faulty datacube extension metadata that would suddenly have a change in behavior.)
Problem
metadata_from_stac()previously injected openEO default dimensions (x,y,t,bands) even when a STAC object already defined dimensions viacube:dimensions.This led to:
Fix
Introduce a clear dimension resolution policy:
If
cube:dimensionsis present→ treat it as the source of truth and preserve dimension names and order.
If
cube:dimensionsis absent→ fall back to openEO defaults (
x,y, optionalt).The metadata parsing logic was refactored accordingly and aligned with PySTAC datacube capabilities.
Testing
Updated existing tests to no longer assume an always-present band dimension.
Added checks verifying:
cube:dimensionsis missing,cube:dimensionsexists,Tests now explicitly enforce the new dimension policy to prevent regressions.
This change makes metadata parsing more STAC-compliant while keeping backward-compatible fallback behavior.
Refer:
https://github.com/destine-datalake-cube/dedl-openeo-coordination/issues/3
Also solves: #743