geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
459 stars 250 forks source link

Compatibility with Pydantic >= 2 through pydantic.v1 #1663

Open SarahG-579462 opened 1 month ago

SarahG-579462 commented 1 month ago

Overview

Recently, pygeoapi's pydantic was downgraded from 2.0-compatible to pydantic < 1. This removed compatibility with two of our libraries, xscen and xclim, for climate data processing, due to intake-esm's current requirement on pydantic > 2

Because we require these in the use of our pygeoapi process plugins, this change forced us to use either very outdated versions of xscen (and thus xarray, pandas, xclim, etc.), or a very outdated version of pygeoapi.

Thankfully, a simple fix is available by the use of pydantic 2's backwards-compatible pydantic.v1 module.

It is not entirely clear to me why pydantic was downgraded, the best explanation I can see in the discussion was due to "versionitis". I was, however, able to run all tests with the latest version of pydantic installed in this fashion. The way this PR is written, if pydantic >= 2 is not available on the operating system in question, everything will continue as-is.

Related Issue / discussion

Pydantic issues:

1573

1341

1584

Additional information

Dependency policy (RFC2)

(It follows RFC2 as far as I understand, as it allows backwards compatibility with pydantic < 2)

Updates to public demo

No breaking changes shuold ensue as a result of this PR, since it is backwards compatible. I am not entirely sure how to test this demo server, help would be appreciated here.

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

SarahG-579462 commented 1 month ago

Note: I had to change one of the github actions, since docker images do not allow capital letters, and the repository for our organisation is "Ouranosinc". Feel free to discard this change, if needed.

tomkralidis commented 1 month ago

To add, it would be valuable to have pygeoapi.models.pydantic that covers the try/except in one place and have the rest of code import from pygeoapi.models.pydantic