Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Pydantic v2 #35551

Merged
merged 2 commits into from Nov 22, 2023
Merged

Upgrade to Pydantic v2 #35551

merged 2 commits into from Nov 22, 2023

Conversation

sinwoobang
Copy link
Contributor

@sinwoobang sinwoobang commented Nov 9, 2023

This PR removes deprecated features from Pydantic v1 in preparation for the upcoming major release. The focus is on eliminating elements that are no longer supported in v2 or later, as outlined in the migration guide.

  • Use ConfigDict instead of Config
  • Drop compatibility for v1

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Copy link

boring-cyborg bot commented Nov 9, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE! We only want to remove it when we know some important packages that are used by Airflow have already moved to Pydantic v2 . See this comment #34081 (comment) where we had to bring Pydantic 1 back after removing it (becasue Great Expections had not supported Pydantic v2)

@sinwoobang : Can you please take on the task on reviewing Great Expectations and possibly finding out the state of Pydantic v2 among important data engineering libraries? I am pretty sure someone somewhere did such a research - and maybe keeps the list updated - or maybe it can be asked in Pydantic discussion list.

potiuk added a commit to potiuk/airflow that referenced this pull request Nov 9, 2023
As a follow-up after apache#35511 it turned out that we have THREE
tests which are named Test_BranchDecoratedOperator - because they
were copied originally from the "Python" one - there is a Python,
ExternalPython and PythonVirtualenv tests :).

The apache#35551 only added timeout in one of them - and in the least
problematic one at that (Python). This PR also adds it in the
other tests and renames the tests classes to distinguish between
the different tests (to more easily see which one failed).
potiuk added a commit that referenced this pull request Nov 9, 2023
As a follow-up after #35511 it turned out that we have THREE
tests which are named Test_BranchDecoratedOperator - because they
were copied originally from the "Python" one - there is a Python,
ExternalPython and PythonVirtualenv tests :).

The #35551 only added timeout in one of them - and in the least
problematic one at that (Python). This PR also adds it in the
other tests and renames the tests classes to distinguish between
the different tests (to more easily see which one failed).
@sinwoobang
Copy link
Contributor Author

@potiuk Thank you for the review. I looked around Great Expectations as per your request. Pydantic V2 has been supported on Great Expectations since 8th Sep according to this commit great-expectations/great_expectations@091fc1d, whereas the PR - bringing back Pydantic V1 compatibility - was created on 5th Sep.

Facts

  • Great Expectations has supported Pydantic V2 from the release 0.17.15 published on 8th Sep.
  • However, Great Expectations still supports Pydantic from v1.10.8
    • requirements.txt says that v1.9.2 is the min version, which is NOT true.
    • A maintainer confirms that v1.10.8 is the actual min version.

romsharon98 pushed a commit to romsharon98/airflow that referenced this pull request Nov 10, 2023
As a follow-up after apache#35511 it turned out that we have THREE
tests which are named Test_BranchDecoratedOperator - because they
were copied originally from the "Python" one - there is a Python,
ExternalPython and PythonVirtualenv tests :).

The apache#35551 only added timeout in one of them - and in the least
problematic one at that (Python). This PR also adds it in the
other tests and renames the tests classes to distinguish between
the different tests (to more easily see which one failed).
@potiuk
Copy link
Member

potiuk commented Nov 22, 2023

I think it's about to time to resurrect that one. We are nearing 2.8.0 releease and I think it's good idea to move to Pydanticv2 only. Will you work on it @sinwoobang ?

@sinwoobang
Copy link
Contributor Author

@potiuk I would be glad to do it. I will let you know after I take a look around the code again. Would you have any cautions or things I need to know?

@potiuk
Copy link
Member

potiuk commented Nov 22, 2023

Nope. You've already checked great expectations and 5 months passed and Pydantic is already at 2.5 - there is no particular reason to stick to v1 any more.

@potiuk
Copy link
Member

potiuk commented Nov 22, 2023

But let me know If I can help in any way.

@sinwoobang sinwoobang marked this pull request as ready for review November 22, 2023 09:56
@sinwoobang sinwoobang changed the title Remove Deprecated Features from Pydantic v1 Upgrade to Pydantic v2 Nov 22, 2023
@sinwoobang
Copy link
Contributor Author

sinwoobang commented Nov 22, 2023

@potiuk I bumped the Pydantic version to v2.3.0, referring to the previous PRs (#34081, #33956).

@potiuk potiuk merged commit 172f573 into apache:main Nov 22, 2023
72 checks passed
Copy link

boring-cyborg bot commented Nov 22, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@potiuk
Copy link
Member

potiuk commented Nov 22, 2023

Looks good :)

@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Nov 23, 2023
ephraimbuddy pushed a commit that referenced this pull request Nov 23, 2023
* Replace deprecated Config with ConfigDict

* Drop Pydantic v1 compatibility as bumping it to 2.3.0
ephraimbuddy pushed a commit that referenced this pull request Nov 26, 2023
* Replace deprecated Config with ConfigDict

* Drop Pydantic v1 compatibility as bumping it to 2.3.0
tatiana pushed a commit to astronomer/astronomer-cosmos that referenced this pull request Jan 3, 2024
[Airflow's upgraded to Pydantic 2.0
(!!)](apache/airflow#35551), so this removes the
restriction on Cosmos to ensure it's compatible.
ykuc pushed a commit to ykuc/astronomer-cosmos that referenced this pull request Jan 11, 2024
[Airflow's upgraded to Pydantic 2.0
(!!)](apache/airflow#35551), so this removes the
restriction on Cosmos to ensure it's compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:serialization type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants