Get rid of pydantic and move data validation to standard dataclasses#2307
Get rid of pydantic and move data validation to standard dataclasses#2307francbartoli wants to merge 7 commits intogeopython:masterfrom
Conversation
f5eec0c to
8e4f144
Compare
|
CI failures are not related to these changes |
|
Its not entirely clear to me how the introduction of PluginContext is coupled this closesly with the removal of pydantic. Furthermore I am not quite sure I understand the intended utility of it - perhaps this is a documentation question. Where / How would this be used? |
That's a very good question @webb-ben, I'm happy to document what's the intended usage downstream indeed |
|
@webb-ben I've added an example about a potential use case for data validation with two variants, one with a default validator (standard library only) and the second with a downstream override ( They are technically independent but share the same design goal: making the plugin system more flexible for downstream projects. In the new example there is a
Again, this is just one of the possible use cases. The pattern would be the same as |
079ad24 to
b4f1e0e
Compare
Overview
This PR aims at removing
pydanticfrom the core dependencies in favor of the standarddataclasseswhile offering the same level of data validation in the codebase. At the same time it improves the extensibility of the plugin system in order to write custom plugins for data validation withpydanticor other external validation libraries.A new
PluginContextdataclass has been added to pass dependencies in the plugin system. Downstream projects/forks can extendPluginContextvia subclassing to integrate a custom validation logic.The change has a minimal footprint on the plugin design because it guarantees backwards compatibility so existing pygeoapi instances can update with zero-risk impact.
Related Issue / discussion
Mainly discussed and agreed during the summit with the ultimate goal to get rid of
pydanticand provide downstream data validation with custom pydantic-based (or similar tools) plugins#1547
#1664
Additional information
A new RFC has been raised to voting about this design change
The plan to achieve the above goal is the following:
load_plugininplugin.pymethod with an optional context based on aPluginContextdataclassBaseProvider,BaseProcessorandBaseManagerfor backwards compatibilityAPIRulesto dataclassTileSetMetadatato dataclassMVTTilesJsonto dataclassPydanticfrom the dependenciesDependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)