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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Item assets #1476

wants to merge 5 commits into from

Conversation

jsignell
Copy link
Member

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 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 81.87135% with 31 lines in your changes missing coverage. Please review.

Project coverage is 90.94%. Comparing base (3efd9dd) to head (dd88fe5).

Files with missing lines Patch % Lines
pystac/item_assets.py 83.33% 14 Missing and 1 partial ⚠️
pystac/collection.py 46.15% 7 Missing ⚠️
pystac/extensions/datacube.py 75.00% 0 Missing and 1 partial ⚠️
pystac/extensions/eo.py 83.33% 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 ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1476      +/-   ##
==========================================
- Coverage   91.17%   90.94%   -0.24%     
==========================================
  Files          52       53       +1     
  Lines        7251     7275      +24     
  Branches      875      880       +5     
==========================================
+ Hits         6611     6616       +5     
- Misses        460      479      +19     
  Partials      180      180              

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


🚨 Try these New Features:

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
1 participant