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

Raise exception when extending object that does not have schema URI #450

Merged
merged 21 commits into from
Jun 17, 2021

Conversation

duckontheweb
Copy link
Contributor

@duckontheweb duckontheweb commented Jun 16, 2021

Related Issue(s):

Description:

Introduces a new ExceptionNotImplemented exception type and raises this when attempting to extend an object that does not include that extension's schema URI in stac_extensions. See the corresponding issue for discussion of how Assets without an owner are handled.

Also adds an add_if_missing boolean option to the *Extension.ext methods that will add the schema URI to the object's stac_extension list if it is missing (see this PR comment for original suggestion).

PR Checklist:

  • Code is formatted (run pre-commit run --all-files)
  • Tests pass (run scripts/test)
  • 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.

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2021

Codecov Report

Merging #450 (5f2296f) into main (7f8e7aa) will increase coverage by 0.51%.
The diff coverage is 93.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #450      +/-   ##
==========================================
+ Coverage   90.80%   91.31%   +0.51%     
==========================================
  Files          40       40              
  Lines        5120     5204      +84     
==========================================
+ Hits         4649     4752     +103     
+ Misses        471      452      -19     
Impacted Files Coverage Δ
pystac/__init__.py 100.00% <ø> (ø)
pystac/extensions/item_assets.py 65.85% <16.66%> (-3.38%) ⬇️
pystac/extensions/datacube.py 62.26% <72.72%> (+5.23%) ⬆️
pystac/extensions/raster.py 90.61% <94.44%> (+0.39%) ⬆️
pystac/errors.py 88.88% <100.00%> (+0.65%) ⬆️
pystac/extensions/base.py 92.45% <100.00%> (+0.78%) ⬆️
pystac/extensions/eo.py 96.69% <100.00%> (+0.09%) ⬆️
pystac/extensions/file.py 95.38% <100.00%> (+0.18%) ⬆️
pystac/extensions/label.py 96.51% <100.00%> (+0.06%) ⬆️
pystac/extensions/pointcloud.py 96.69% <100.00%> (+0.08%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f8e7aa...5f2296f. Read the comment docs.

@duckontheweb
Copy link
Contributor Author

@gadomski @lossyrob Would be good to get your feedback on this draft implementation on the EO extension before I start implementing it on the other extensions.

@lossyrob
Copy link
Member

Seems straightforward to me, +1

Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

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

LGTM

CHANGELOG.md Outdated Show resolved Hide resolved
@duckontheweb duckontheweb force-pushed the change/gh-370-ext-exception branch from 6604ef1 to 8e8cb56 Compare June 16, 2021 18:35
@duckontheweb duckontheweb marked this pull request as ready for review June 17, 2021 01:54
@duckontheweb
Copy link
Contributor Author

@gadomski @lossyrob This is ready for final review. I also added the add_if_missing argument suggested here

@duckontheweb duckontheweb added this to the 1.0.0-rc.1 milestone Jun 17, 2021
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for taking this on, that is a lot of boilerplate to churn through 🙇🏽.

Copy link
Member

@lossyrob lossyrob left a comment

Choose a reason for hiding this comment

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

🚀

@duckontheweb
Copy link
Contributor Author

LGTM. Thanks for taking this on, that is a lot of boilerplate to churn through 🙇🏽.

Yeah, it would be good to look at this at some point to see if we can reduce any of this through inheritance, but I didn't see any easy way here.

@duckontheweb duckontheweb merged commit a729cd2 into stac-utils:main Jun 17, 2021
@duckontheweb duckontheweb deleted the change/gh-370-ext-exception branch June 17, 2021 13:45
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.

Raise exception on attempt to extend object not implementing that extension
4 participants