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

Item assets #1476

Merged
merged 14 commits into from
Jan 6, 2025
Merged

Item assets #1476

merged 14 commits into from
Jan 6, 2025

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Nov 19, 2024

Related Issue(s):

Description:

>>> import pystac
>>> 
>>> collection = pystac.Collection.from_file("./tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json")
>>> collection.item_assets
{'thumbnail': <pystac.item_assets.ItemAssetDefinition at 0x72aea0420750>,
 'metadata': <pystac.item_assets.ItemAssetDefinition at 0x72aea017dc90>,
 'B5': <pystac.item_assets.ItemAssetDefinition at 0x72aea017efd0>,
 'B6': <pystac.item_assets.ItemAssetDefinition at 0x72aea016d5d0>,
 'B7': <pystac.item_assets.ItemAssetDefinition at 0x72aea016e050>,
 'B8': <pystac.item_assets.ItemAssetDefinition at 0x72aea016da90>}
>>> collection.item_assets["thumbnail"].title
'Thumbnail'
>>> collection.item_assets["thumbnail"].title = "fake"
>>> collection.item_assets["thumbnail"].title
'fake'
>>> collection.item_assets["B4"] = {
    'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
    'eo:bands': [{'name': 'B4', 'common_name': 'red'}]
}
>>>collection.item_assets["B4"].owner == collection
True

Notes:
This approach is a little wonky, but it is a backwards compatible change. Shown here (a688988) passing with no test changes.

TODO:

  • Add deprecation warning when accessing the ItemAssetsExtension class. I think the simplest approach will be to warn when instantiating that class.
  • Add tests/docs demonstrating new access patterns.

PR Checklist:

  • Pre-commit hooks and tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 94.59459% with 10 lines in your changes missing coverage. Please review.

Project coverage is 91.31%. Comparing base (f15e3f6) to head (38e6662).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pystac/collection.py 84.61% 1 Missing and 1 partial ⚠️
pystac/extensions/datacube.py 75.00% 0 Missing and 1 partial ⚠️
pystac/extensions/pointcloud.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/projection.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/sar.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/sat.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/storage.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/table.py 75.00% 0 Missing and 1 partial ⚠️
pystac/extensions/view.py 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1476      +/-   ##
==========================================
+ Coverage   91.17%   91.31%   +0.13%     
==========================================
  Files          52       53       +1     
  Lines        7253     7286      +33     
  Branches      877      883       +6     
==========================================
+ Hits         6613     6653      +40     
+ Misses        460      453       -7     
  Partials      180      180              

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

@jsignell jsignell marked this pull request as ready for review January 3, 2025 21:23
@gadomski gadomski self-requested a review January 3, 2025 21:43
pystac/extensions/item_assets.py Outdated Show resolved Hide resolved
@jsignell jsignell added this pull request to the merge queue Jan 6, 2025
Merged via the queue into stac-utils:main with commit 43cfdec Jan 6, 2025
23 checks passed
@jsignell jsignell deleted the item-assets branch January 6, 2025 15:07
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.

Deprecate item_assets extension and move into collection core
2 participants