[RFC] Archive stac-pydantic #1252
Replies: 5 comments 18 replies
-
I believe the main benefit of this library is the nice integration with other libraries using Pydantic such as FastAPI including the libraries mentioned above. However, it is not a requirement. When working on the PR using pydantic 2, I was hoping to get better performance out of stac-pydantic. After testing this now, this doesn't proof to be true. See screenshot of benchmark test, comparing
As STAC evolves it will remain a burden to keep this library up to date. Since there is a significant overlap between this library and pystac and this library also seems to be much slower, archiving it might make sense. |
Beta Was this translation helpful? Give feedback.
-
One use case for me is writing extensions for item and collection properties that enforce a strict controlled vocabulary, sometimes with hundreds of allowed values. Using pydantic, this can be done programmatically with under 100 lines of code. The equivalent json schema generated by pydantic has around 14,000 lines. Also, real world metadata is often messy, and pydantic offers mechanisms to beat it into shape before feeding it into catalog items. In other words, pydantic does not only validate, it also parses, and this is really valuable. All this to say that pydantic models might not be strictly necessary for vanilla STAC objects, but they are handy for extensions. |
Beta Was this translation helpful? Give feedback.
-
Although I like the running discussion, and I've no real position to stac-pydantic keep-it-or-remove-it, I want to highlight that this is a blocker for moving onto pydantic 2. Why is not possible to merge the fix for stac-pydantic, then later (after proper discussion that, at that point, can take months without bringing problems to nobody) it can be removed as a dependency, or not. |
Beta Was this translation helpful? Give feedback.
-
Thinking out loud: stac-pydantic reimplements the JSON specifications as Pydantic models. It would be great if we were able to dynamically generate and extend such a model at runtime instead of having to define fields explicitly in code. This would made the package obsolete. I imagine something like this: Item = BaseModel.from_json_schema("https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/item-spec/json-schema/item.json")
Item.add_schema_extension("https://raw.githubusercontent.com/stac-extensions/raster/v1.1.0/json-schema/schema.json")
my_item = Item(id = ..., properties= {...}, ...) Pydantic has a |
Beta Was this translation helpful? Give feedback.
-
Coming back to this, it appears that stac-pydantic has been re-vitalized and is well-cared for, so I"m going to close this RFC as resolved in favor of NO. |
Beta Was this translation helpful? Give feedback.
-
Summary
stac-pydantic is a Python package that provides pydantic models for STAC objects. Its main purpose is to provide:
(De)serialization is also implemented in pystac, and validation is provided by the specification json schemas coupled with jsonschema validators, including the one in pystac. stac-pydantic doesn't provide any significant additional value to the ecosystem, and therefore should be archived to reduce "what package should I use" confusion.
Implementation
Drawbacks
Some libraries, most notably stac-fastapi, stac-fastapi-pgstac, and stac-fastapi-sqlalchemy, depend on stac-pydantic, though that dependency can be problematic (see stac-utils/stac-fastapi#588). While archiving stac-pydantic does not break any current software, since the PyPI releases won't change, it does mean that and dependent libraries will need to migrate away from stac-pydantic if they continue to evolve.
Rationale and alternatives
We could bring stac-pydantic up-to-date (e.g. via stac-utils/stac-pydantic#127), but that doesn't solve the problem of stac-pydantic and pystac overlapping considerably.
Beta Was this translation helpful? Give feedback.
All reactions