Skip to content

Docs on adding extensions is misleading or incomplete #602

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

Closed
alexgleith opened this issue Aug 12, 2021 · 6 comments
Closed

Docs on adding extensions is misleading or incomplete #602

alexgleith opened this issue Aug 12, 2021 · 6 comments
Assignees
Labels
documentation Issues related to PySTAC documentation
Milestone

Comments

@alexgleith
Copy link

alexgleith commented Aug 12, 2021

The Extensions docs say that to add an extension you do:

import pystac
from pystac.extensions.eo import EOExtension

item = Item(...)  # See docs for creating an Item
eo_ext = EOExtension.ext(item)

But in practice you need to do:

EOExtension.add_to(item)
eo = EOExtension.ext(item)

Is this intended, and if yes, can we tweak the docs please?

@duckontheweb
Copy link
Contributor

Thank for raising this @alexgleith.

The behavior of raising an exception if the Item does not already contain the schema URI is intended (see this PR comment in stactools for some background).

Those docs assumed that the Item already has the EO extension schema URI in its stac_extensions list, but we should definitely make it more clear that you need to use either EOExtension.add_to(item) or eo_ext = EOExtension.ext(item, add_if_missing=True) to add the extensions to an Item that does not already implement it.

@duckontheweb duckontheweb added the documentation Issues related to PySTAC documentation label Aug 12, 2021
@alexgleith
Copy link
Author

Is there a good reason why that doesn't default to true?

@gadomski
Copy link
Member

stac-utils/stactools#113 (comment) has some discussion about why it's not automatic, but basically we wanted to force folks to be explicit about adding any new extension schema urls so we didn't, e.g., mutate the object in question (by adding an extension schema url) when a person was treating the object as "read-only".

@alexgleith
Copy link
Author

Hmm, I can see the logic here for when dealing with an existing item.

I reckon the docs should cover it better still. Maybe I need to read them again to see if I missed it somewhere!

@duckontheweb
Copy link
Contributor

@alexgleith I opened #701 to try to clarify this better in the Concepts docs. Let me know if you think that covers it.

@duckontheweb
Copy link
Contributor

Closed via #701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues related to PySTAC documentation
Projects
None yet
Development

No branches or pull requests

3 participants