Conversation
* dynamically creates new extension class that inherits
from the pydantic_model
* interact with extension purely via the `obj.ext.{name}.` api
* use `apply` to update the fields on an extension
There was a problem hiding this comment.
I love (love love love) being able to auto-gen extensions from the JSON schema. This is a big enough win to justify lots of other pain, IMO.
I have a thought, not fully formed, that we could break extensions out of the pystac Python package entirely for v2. I'm thinking about namespace package plugins (probably in pystac.extensions): https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-namespace-packages. We could maintain "core" extensions in the pystac repo but in their own Python packages (e.g. pystac-projection or pystac-extension-projection). This would allow us to version the plugins separately (maybe even keep extension code versions matching their latest-supported jsonschema verision?). This would make it easier for folks to contribute extensions ... they could just publish their own Python package and it would be auto-detected by our plugin mechanism, if present.
|
Extensions are now separate from core pystac as of #1650 |
Related Issue(s):
Description:
Lays out a vision for STAC Extension classes in pystac v2. The goal is to improve the user experience of working with pystac objects that include stac extension fields while making it dramatically easier to write and maintain the stac extension classes.
With this PR you would start with a pydantic model which can be autogenerated from the jsonschema and then tweaked a bit or written by hand. Then you just decorate the model with a special method called
register_extensionand add an import toextensions/__init__.py.Once you have done those steps the user can access the fields (and there is type hinting) like:
There are also some helper functions on
item.ext.eofor instance to get the related extension url fromstac_extensions:or to remove the given extension from
stac_extensions:To add a bunch of new extension fields the idea is that you would do something like:
Ongoing work:
register_extensionmechanismremovemethod?PR Checklist:
pre-commit run --all-files)pytest)