opendatacube / datacube-core

Open Data Cube analyses continental scale Earth Observation data through time
http://www.opendatacube.org
Apache License 2.0
509 stars 177 forks source link

Ensure eo3 datasets read directly from another index can be indexed directly into a new index #1591

Closed SpacemanPaul closed 4 months ago

SpacemanPaul commented 4 months ago

Reason for this pull request

On indexing an eo3 dataset, the prep_eo3() method is called, which generates the extent and grid_spatial sections from the grids already defined, and adds those new sections into the dataset metadata for storage, and also rewrites lineage metadata into a new format.

If dataset metadata is copied directly from an existing ODC index, this "preparation" is already applied, and calling prep_eo3() on the dataset again fails with an ugly error.

Proposed changes

Modify the prep_eo3() function so that it is idempotent. E.g. after this PR:

prep_eo3(doc, **kwargs) == prep_eo3(prep_eo3(doc, **kwargs), **kwargs)

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.43%. Comparing base (e69ff50) to head (325bb12). Report is 35 commits behind head on develop-1.9.

Files with missing lines Patch % Lines
datacube/index/eo3.py 91.66% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop-1.9 #1591 +/- ## =============================================== - Coverage 85.44% 85.43% -0.01% =============================================== Files 140 140 Lines 15479 15487 +8 =============================================== + Hits 13226 13232 +6 - Misses 2253 2255 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

SpacemanPaul commented 4 months ago

Worth noting that I have no idea what the point of rewriting lineage like this actually is.