From Fedora Project Wiki
m (→‎Feedback: Typo fix except→expect)
(completing the change proposal)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Update To Pydantic Version 2 =
= Update To Pydantic Version 2 =


{{Change_Proposal_Banner}}


== Summary ==
== Summary ==


{{package|python-pydantic}}, a Python data validation library, will be updated from 1.10.x to 2.y.x.
{{package|python-pydantic}}, a Python data validation library, will be updated from 1.10.z to 2.y.z.
The Change owners will perform a test rebuild and work with package maintainers
The Change owners will perform a test rebuild and work with package maintainers
and upstreams to port code.
and upstreams to port code.
Line 15: Line 14:


== Current status ==
== Current status ==
[[Category:ChangePageIncomplete]]
[[Category:ChangeAcceptedF40]]
<!-- When your change proposal page is completed and ready for review and announcement -->
<!-- When your change proposal page is completed and ready for review and announcement -->
<!-- remove Category:ChangePageIncomplete and change it to Category:ChangeReadyForWrangler -->
<!-- remove Category:ChangePageIncomplete and change it to Category:ChangeReadyForWrangler -->
Line 25: Line 24:
* Targeted release: [https://docs.fedoraproject.org/en-US/releases/f40/ Fedora Linux 40]
* Targeted release: [https://docs.fedoraproject.org/en-US/releases/f40/ Fedora Linux 40]
* Last updated: <!-- this is an automatic macro — you don't need to change this line -->  {{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}  
* Last updated: <!-- this is an automatic macro — you don't need to change this line -->  {{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}  
* [<will be assigned by the Wrangler> devel thread]
* [https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/GWBHOWDQXSUDYD4NGNSEGU2A6UWGLR37/ Announced]
* [<will be assigned by the Wrangler> Discussions thread]
* [https://discussion.fedoraproject.org/t/f40-change-proposal-update-to-pydantic-version-2-self-contained/92894 Discussion thread]
* FESCo issue: <will be assigned by the Wrangler>
* FESCo issue: [https://pagure.io/fesco/issue/3090 #3090]
* Tracker bug: <will be assigned by the Wrangler>
* Tracker bug: [https://bugzilla.redhat.com/show_bug.cgi?id=2249663 #2249663]
* Release notes tracker: <will be assigned by the Wrangler>
* Release notes tracker: [https://pagure.io/fedora-docs/release-notes/issue/1061 #1061]


== Detailed Description ==
== Detailed Description ==


Pydantic is a Python data validation library.
Pydantic is a Python data validation library.
Recently, upstream released a new major version with many fixes and performance
Recently, upstream released major version 2 with many fixes and performance
improvements but also some breaking API changes.
improvements but also multiple breaking API changes.
The new release relies on {{package|python-pydantic-core}}, which provides the
The new release relies on {{package|python-pydantic-core}}, which provides the
core validation and serialization functionality used by pydantic v2.
core validation and serialization functionality used by pydantic v2.
Line 88: Line 87:
** Test your package to ensure it still builds and functions with pydantic v2
** Test your package to ensure it still builds and functions with pydantic v2
** Help with package reviews
** Help with package reviews
** Review distgit PRs to fix incompatibilities


== Upgrade/compatibility impact ==
== Upgrade/compatibility impact ==
Line 96: Line 96:
== How To Test ==
== How To Test ==


You can preform test builds like this:
You can perform test builds like this:


<pre>
<pre>
Line 127: Line 127:
== Release Notes ==
== Release Notes ==


python3-pydantic was updated from 1.10.x to 2.x.0. Pydantic v2 brings
python3-pydantic was updated from 1.10.z to 2.y.z. Pydantic v2 brings
performance improvements and an API refactoring, amongst other changes.
performance improvements and an API refactoring, amongst other changes.
See upstream's [https://docs.pydantic.dev/latest/migration/ Migration Guide]
See upstream's [https://docs.pydantic.dev/latest/migration/ Migration Guide]
for a full inventory of breaking changes.
for a full inventory of breaking changes.

Latest revision as of 19:52, 14 November 2023

Update To Pydantic Version 2

Summary

python-pydantic, a Python data validation library, will be updated from 1.10.z to 2.y.z. The Change owners will perform a test rebuild and work with package maintainers and upstreams to port code.

Owner

  • Name: Maxwell G; Benjamin Beasley; Python SIG
  • Email: maxwell@gtmx.me; code@musicinmybrain.net; python-devel@lists.fedoraproject.org

Current status

Detailed Description

Pydantic is a Python data validation library. Recently, upstream released major version 2 with many fixes and performance improvements but also multiple breaking API changes. The new release relies on python-pydantic-core, which provides the core validation and serialization functionality used by pydantic v2. pydantic-core is a Rust PyO3 Python extension module.

We will update pydantic to version 2 after making sure dependent packages are accounted for.

Porting strategies

Pydantic v2 contains some breaking API changes that may require porting if packages depend on old functionality. Upstream provides a detailed Migration Guide that describes the breaking API changes.

Projects that are not ready to port to pydantic v2 may use the pydantic.v1 compatibility module which contains a full copy of the old pydantic v1 code. https://github.com/matrix-org/synapse/pull/16332 exemplifies this approach. As shown in the above PR, projects can use conditional imports to import pydantic.v1 if pydantic v2 is in use and otherwise fall back to importing pydantic if pydantic v1 is in use.

Maintaining compatibility for both pydantic v1 and v2 in the same codebase without the compatibility module is possible but may not be practical for larger, more complex usecases. fedrq uses this approach and silences pydantic.PydanticDeprecatedSince20 warnings. Many of these deprecation warnings cannot be resolved without dropping support for pydantic v1.

Feedback

I did not receive much feedback as of yet, but I expect this change to be uncontroversial.

Benefit to Fedora

Fedora will have the latest version of pydantic in its repositories. The new version touts a significant performance boost, amongst other improvements.

Scope

  • Proposal owners:
    • Preform an impact check
    • Make an inventory of failures or packages that have a hard dependency on pydantic v1.
    • Submit distgit PRs and/or file upstream issues to fix incompatibilities in dependent packages
    • Submit new python-pydantic-settings and python-pydantic-extra-types packages for review
    • Wait two weeks for packagers to review PRs. Those that remain compatible with pydantic v1 can be merged immediately.
    • Build pydantic v2 package and any outstanding PRs in a side tag.
  • Other developers:
    • Test your package to ensure it still builds and functions with pydantic v2
    • Help with package reviews
    • Review distgit PRs to fix incompatibilities

Upgrade/compatibility impact

Pydantic version 2 has some breaking API changes. See upstream's Migration Guide.

How To Test

You can perform test builds like this:

$ copr mock-config gotmax23/pydanticv2-testing fedora-rawhide-x86_64 > ~/.config/pydanticv2.cfg
$ fedpkg --release=rawhide mockbuild --root pydanticv2

User Experience

This isn't a particularly user visible change. Users of Python applications that utilize Pydantic should notice a performance improvement.

Dependencies

See https://gtmx.me/Wiki/Fedora/pydantic-v2-update/#lists for a list of dependent packages. The Change owners will work with these packages' maintainers to ensure the packages remain functional with the new pydantic version.

Contingency Plan

  • Contingency mechanism: N/A (not a System Wide Change)
  • Contingency deadline: N/A (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change)

Documentation

See https://gtmx.me/Wiki/Fedora/pydantic-v2-update/ for the current status and notes.

Release Notes

python3-pydantic was updated from 1.10.z to 2.y.z. Pydantic v2 brings performance improvements and an API refactoring, amongst other changes. See upstream's Migration Guide for a full inventory of breaking changes.