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

Assets keep their own stac_extensions #1256

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

Conversation

constantinius
Copy link

@constantinius constantinius commented Oct 8, 2023

Related Issue(s):

Description:

This PR aims to make Asset objects more independent, i.e allow to extend them, even if they are not yet inserted into an Item/Collection.

This is achieved by letting assets keep their own stac_extensions list, which is merged with the Items/Collections stac_extension in the respective to_dict function

Other relevant changes:

  • Deprecating validate_owner_has_extension
  • Switching from validate_owner_has_extension to ensure_has_extension in extensions dealing with assets

PR Checklist:

  • pre-commit hooks pass locally
  • 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.

so that they can be extended without being added to an Item.
Deprecating validate_owner_has_extension
Switching from validate_owner_has_extension to ensure_has_extension
in extensions dealing with assets
Extracting a final list of assets in the `to_dict`
function for Items and Collections.
@gadomski gadomski self-requested a review October 9, 2023 15:00
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.

The idea seems reasonable to me, though my inclination is to make the attribute private on an asset, e.g.:

class Asset:
    _stac_extensions: List[str]
    ...

It's not part of the spec, it's a PySTAC implementation detail, so users shouldn't be touching it themselves.

@constantinius
Copy link
Author

765a05f does that.

This makes the extension handling more complex now, though, as we have to introduce a couple of new code paths as we cannot simply treat assets as objects having a stac_extensions: Optional[List[str]].

What would you say?

@gadomski
Copy link
Member

This makes the extension handling more complex now, though, as we have to introduce a couple of new code paths as we cannot simply treat assets as objects having a stac_extensions: Optional[List[str]].

You're right, that is pretty awkward. Maybe _stac_extensions was a bad idea 😬. Let's remove 765a05f for now and keep it at stac_extensions. Thanks for trying that out 🙇🏼.

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.

2 participants