Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility fix for passing odc-geo GeoBoxes to dc.load(like=...) #1551

Merged
merged 12 commits into from
Mar 26, 2024

Conversation

robbibt
Copy link
Contributor

@robbibt robbibt commented Feb 16, 2024

Reason for this pull request

Support users passing odc.geo GeoBoxes to datacube.load(like=...). For more details, see #1549.

Temporary fix until odc-geo is officially integrated in version 1.9.

Proposed changes

If the passed object is not a Datacube-style Geobox but has a odc-geo ".compat" attribute, try using that ".compat" method to convert the odc-geo style GeoBox to a datacube-style GeoBox.

(I deliberately didn't use a check for whether it was the object was a odc.geo.geobox.Geobox object because I didn't know if we wanted to add odc-geo to the package dependencies yet - happy to change to that though if you'd prefer!)


📚 Documentation preview 📚: https://datacube-core--1551.org.readthedocs.build/en/1551/

@robbibt robbibt changed the title Compatibility fix for odc-geo GeoBoxes to close #1549 Compatibility fix for passing odc-geo GeoBoxes to dc.load(like=...) Feb 16, 2024
@robbibt robbibt marked this pull request as ready for review February 16, 2024 05:04
Copy link
Contributor

@SpacemanPaul SpacemanPaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Robbi - would be good to have a test though.

It should be reasonably easy to write a test without installing odc-geo - because of the way you wrote it you could just pass in a mock with an ODC-GEO GeoBox as the compat attribute.

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.79%. Comparing base (47b8d09) to head (f67f1c2).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1551   +/-   ##
========================================
  Coverage    91.79%   91.79%           
========================================
  Files          132      132           
  Lines        14631    14633    +2     
========================================
+ Hits         13430    13432    +2     
  Misses        1201     1201           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

datacube/api/core.py Outdated Show resolved Hide resolved
@robbibt
Copy link
Contributor Author

robbibt commented Mar 26, 2024

@SpacemanPaul Let me know what you think about this approach - I couldn't get MagicMock to work without infinite recursion errors, so went with making a fake class instead.

@SpacemanPaul SpacemanPaul self-requested a review March 26, 2024 23:02
Copy link
Contributor

@SpacemanPaul SpacemanPaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks Robbi (and Kirill)

@robbibt robbibt merged commit fa58d90 into develop Mar 26, 2024
31 checks passed
@robbibt robbibt deleted the odc_geobox_compat branch March 26, 2024 23:30
@SpacemanPaul SpacemanPaul mentioned this pull request Apr 9, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot pass odc.geo GeoBoxes to dc.load
3 participants