Skip to content

Fix proj extension regression.#253

Merged
SpacemanPaul merged 3 commits intodevelopfrom
item-proj-fix
Jan 15, 2026
Merged

Fix proj extension regression.#253
SpacemanPaul merged 3 commits intodevelopfrom
item-proj-fix

Conversation

@SpacemanPaul
Copy link
Copy Markdown
Contributor

@SpacemanPaul SpacemanPaul commented Jan 7, 2026

Closes #251

Based closely on code provided by @lukesdm

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 7, 2026

@github-actions github-actions Bot temporarily deployed to pull request January 7, 2026 23:03 Inactive
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.60%. Comparing base (d6b648b) to head (3aeb137).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #253      +/-   ##
===========================================
+ Coverage    89.56%   89.60%   +0.03%     
===========================================
  Files            9        9              
  Lines         1380     1385       +5     
===========================================
+ Hits          1236     1241       +5     
  Misses         144      144              

☔ 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.

@github-actions github-actions Bot temporarily deployed to pull request January 7, 2026 23:04 Inactive
Ariana-B
Ariana-B previously approved these changes Jan 8, 2026
Comment thread odc/stac/_mdtools.py
Comment thread odc/stac/_mdtools.py Outdated
and data_assets
and not any(has_proj_data(a) for a in data_assets.values())
):
has_proj = False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should has_proj still be True if there are no data_assets?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Does it matter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm really not sure, but the mismatch between having has_proj = True for an item with the proj ext and no assets but has_proj = False for an item with the proj extension but no proj data in the assets struck me as a little odd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See how has_proj is used in _parse_item() below in this file:

  has_proj = False if template.has_proj is False else has_proj_ext(item)

expects that template.has_proj (set by the code here) can be different.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And we need to set it to False so the band2grid method gets called by _parse_item.

Comment thread odc/stac/_mdtools.py Outdated
Comment thread tests/test_mdtools.py
@SpacemanPaul SpacemanPaul requested a review from Ariana-B January 8, 2026 22:57
@SpacemanPaul SpacemanPaul dismissed Ariana-B’s stale review January 8, 2026 23:13

AS discussed, this PR needs more attention.

Based closely on code provided by @lukesdm
@github-actions github-actions Bot temporarily deployed to pull request January 14, 2026 05:26 Inactive
@SpacemanPaul SpacemanPaul mentioned this pull request Jan 14, 2026
Comment thread odc/stac/_mdtools.py
):
_, band2grid = compute_eo3_grids(data_assets)
else:
band2grid = band2grid_from_gsd(data_assets)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The double if-statements with almost the same condition seems convoluted. Shouldn't has_proj = False be in this block instead of the separate if-statement on lines 677-684?

If the value of has_proj is important after having taken this branch, I'm guessing the RHS could be some boolean expression (has_proj = has_proj and ..).

Copy link
Copy Markdown
Contributor Author

@SpacemanPaul SpacemanPaul Jan 14, 2026

Choose a reason for hiding this comment

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

Oops - IIRC I intended the code at 687-692 to replace the code at 677-684.

(The intent was to keep the logical choice of eo3 grids vs gsd grids, but leave the has_proj value unmodified in RasterCollectionMetadata.)

That explains why I didn't have to modify the test in that commit - I thought that was odd.

But I can see why that idea doesn't work now.

@github-actions github-actions Bot temporarily deployed to pull request January 15, 2026 01:57 Inactive
Comment thread odc/stac/_mdtools.py
Comment on lines +519 to +523
if len(data_bands) == 0 and check_proj:
# If no data bands found with check_proj=True, fallback to check_proj=False
# This handles items that declare proj extension at item level but don't have
# per-asset proj data (shape/transform)
data_bands = dicttoolz.itemfilter(lambda kv: _keep(kv, False), item.assets)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this block still necessary? I thought the new check_proj definition took care of this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think so? It's the fallback if nothing is found with check_proj=True.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your comment says, "This handles items that declare proj extension at item level but don't have per-asset proj data", but check_proj will already be false for those items, so I think it's redundant.

Copy link
Copy Markdown
Contributor Author

@SpacemanPaul SpacemanPaul Jan 15, 2026

Choose a reason for hiding this comment

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

Hmm... Well removing it breaks the tests, so it's definitely doing something.

@SpacemanPaul SpacemanPaul merged commit 0d025fa into develop Jan 15, 2026
24 checks passed
@SpacemanPaul SpacemanPaul deleted the item-proj-fix branch January 15, 2026 03:36
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.

empty dataset assets for OpenLandMap STAC data in odc.stac>0.4.0

3 participants