Skip to content

Conversation

pjonsson
Copy link
Contributor

@pjonsson pjonsson commented Mar 29, 2025

Reason for this pull request

GridSpec is only used for type
checking, so only import it for
type checking to avoid triggering
deprecation warnings.

Refs #1716

Proposed changes

  • Closes #xxxx

  • Tests added / passed

  • Fully documented, including docs/about/whats_new.rst for all changes


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

GridSpec is only used for type
checking, so only import it for
type checking to avoid triggering
deprecation warnings.

Refs opendatacube#1716
@pjonsson pjonsson force-pushed the fix-gridspec-warning branch from 03d092c to b05b839 Compare March 29, 2025 13:49
Copy link

codecov bot commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.44%. Comparing base (99e36dc) to head (b05b839).
Report is 477 commits behind head on develop.

Files with missing lines Patch % Lines
datacube/api/core.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1745      +/-   ##
===========================================
- Coverage    85.45%   85.44%   -0.01%     
===========================================
  Files          148      148              
  Lines        15513    15516       +3     
===========================================
+ Hits         13256    13258       +2     
- Misses        2257     2258       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pjonsson
Copy link
Contributor Author

The failing lint is fixed by #1744, no idea why readthedocs fails on this one.

Copy link
Member

@omad omad left a comment

Choose a reason for hiding this comment

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

This works... however a tidier fix would be importing from odc-geo. That way there won't be anything to change when we do remove GridSpec from datacube-core.

from odc.geo.gridspec import GridSpec

@omad
Copy link
Member

omad commented Apr 1, 2025

The deprecation warning should give more explicit instructions, rather than vaguely pointing at odc-geo.

@pjonsson
Copy link
Contributor Author

pjonsson commented Apr 1, 2025

This works... however a tidier fix would be importing from odc-geo. That way there won't be anything to change when we do remove GridSpec from datacube-core.

That changes the interface in this file from expecting a GridSpec from this package to expecting a GridSpec from odc-geo.

I'm not against modernizing the API, but that kind of change (which could break type checking of datacube-core users) feels like something that should have been a part of 1.9.0, not something that appears in 1.9.3.

@omad
Copy link
Member

omad commented Apr 1, 2025

After creation the two different GridSpec classes are compatible. Maybe even identical.

I don't see it as changing an interface. It's updating the documentation of the interface, which I think is fine to do in a minor release.

That said, this will work fine as well and can be updated when GridSpec is removed here.

@omad omad merged commit 0a257e1 into opendatacube:develop Apr 1, 2025
17 of 19 checks passed
@pjonsson pjonsson deleted the fix-gridspec-warning branch April 1, 2025 10:40
@pjonsson
Copy link
Contributor Author

pjonsson commented Apr 1, 2025

After creation the two different GridSpec classes are compatible. Maybe even identical.

How hard would it be to make the datacube-core class into a thin wrapper over the odc-geo class? That would save nearly 200 lines of code in this package, and reduce the risk that the classes are different in any major ways.

Why is the deprecation message for Product.grid_spec() talking about the "Grid workflow"? Even if the GridSpec class in datacube is deprecated, I don't see a reason the grid_spec method couldn't return a odc-geo GridSpec like the deprecation message suggests, but doing that isn't going to be useful if all users have migrated away from using the grid_spec method after switching to 1.9 and getting deprecation messages about it.

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.

2 participants