Skip to content

Conversation

@uranusjr
Copy link
Member

@uranusjr uranusjr commented Jul 5, 2023

Fix #32311 eventually. For CI only at the moment.

uranusjr added 2 commits July 5, 2023 14:05
This is a temporary measure to work around dependencies pinning
Pydantic to 1.8.x. Will remove this once we fixed all the 2.x
incompatibilities.
@boring-cyborg boring-cyborg bot added area:dev-tools area:production-image Production image improvements and fixes labels Jul 5, 2023
@uranusjr
Copy link
Member Author

uranusjr commented Jul 6, 2023

Hey, the CI passes.

If I can get some reviews to ensure the changes are OK, I’ll add a commit to remove the build script hack so this is merge-able.

@uranusjr uranusjr marked this pull request as ready for review July 6, 2023 09:20
@uranusjr uranusjr added area:dependencies Issues related to dependencies problems and removed area:production-image Production image improvements and fixes area:dev-tools labels Jul 6, 2023
dag_id: str
queued_at: Optional[datetime]
execution_date: DateTime
execution_date: datetime
Copy link
Member

Choose a reason for hiding this comment

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

Ah... So Pydantic just got more "picky" about those. Cool.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think they basically switch from isinstance to type identity check, probably for performance concerns (we have similar designs in our own serialisation code). The old behaviour can be brought back with a flag, but this doesn’t need that.

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.

Pending the pydantic>2 hack removal.

@potiuk potiuk merged commit 9cb463e into apache:main Jul 7, 2023
@eladkal eladkal added this to the Airflow 2.6.4 milestone Jul 8, 2023
# Limit Pydantic to <2.0.0 because it breaks Kubernetes tests and building providers
# This limit should be removed after https://github.com/apache/airflow/issues/32311 is fixed
pydantic>=1.10.0,<2.0.0
pydantic>=1.10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Started to see

Unknown warnings generated:

/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:261:Valid config keys have changed in V2: * 'orm_mode' has been renamed to 'from_attributes'
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:210:Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.2/migration/
/usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:261:Valid config keys have changed in V2: * 'orm_mode' has been renamed to 'from_attributes'

ERROR! There were 8 warnings generated during the import

Example:

https://github.com/apache/airflow/actions/runs/5494206967/jobs/10012899407?pr=32441#step:11:1600

Copy link
Contributor

Choose a reason for hiding this comment

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

#32444 will handle it

@uranusjr uranusjr deleted the pydantic-2-support branch July 10, 2023 08:36
@eladkal eladkal modified the milestones: Airflow 2.6.4, Airflow 2.7.0 Aug 1, 2023
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 2, 2023
@lmrlyv
Copy link

lmrlyv commented Aug 18, 2023

Hi, @potiuk!

I'm interested in finding out when the next release is expected to be made available. Having support for Pydantic 2 would be highly beneficial.

@potiuk
Copy link
Member

potiuk commented Aug 18, 2023

I'm interested in finding out when the next release is expected to be made available. Having support for Pydantic 2 would be highly beneficial.

Why? Could you explain why ?

Airlfow 2.7.0 is being released today as we speak (working on it). But in constraints Pydantic is still < 2 - because some of our dependencies limit us, But we have no requiments, and if you are not using any provider that limits pydantic through their dependencies, you might attempt to upgrade and see if it works for you. But you will need to test it and make sure it works.

@lmrlyv
Copy link

lmrlyv commented Aug 18, 2023

I'm interested in finding out when the next release is expected to be made available. Having support for Pydantic 2 would be highly beneficial.

Why? Could you explain why ?

Airlfow 2.7.0 is being released today as we speak (working on it). But in constraints Pydantic is still < 2 - because some of our dependencies limit us, But we have no requiments, and if you are not using any provider that limits pydantic through their dependencies, you might attempt to upgrade and see if it works for you. But you will need to test it and make sure it works.

If you're asking about the reasons for using Pydantic v2, I'd highlight its significant speed improvement of 5-50 times, along with its enhanced stability and flexibility when compared to v1 (according to its release notes).

Regarding why we are waiting for this release, it's because we encountered an error (although I don't remember the details now) while attempting to deploy our airflow (v2.6.3) project that relies on Pydantic v2 models into a Kubernetes cluster. There was an open issue in this repo, and this pull request is expected to address and resolve that problem.

@potiuk
Copy link
Member

potiuk commented Aug 18, 2023

If you're asking about the reasons for using Pydantic v2, I'd highlight its significant speed improvement of 5-50 times, along with its enhanced stability and flexibility when compared to v1 (according to its release notes).

We are hardly using Pydantic, so improvements would be mariginal, but yes I am very well aware of it, just for "Airflow" it is not highly benefitial (yet). It might be in the future as we have plans for using Pydantic for internal API.

Regarding why we are waiting for this release, it's because we encountered an error (although I don't remember the details now) while attempting to deploy our airflow (v2.6.3) project that relies on Pydantic v2 models into a Kubernetes cluster. There was an open issue in this repo, and this pull request is expected to address and resolve that problem.

Just checked: 2.7.0 stil has no support for Pydantic:

# We limit Pydantic to <2.0.0 until we can upgrade - there are limitation for Pydantic in AWS provider
# dependency (aws-sam-translator) - also we need to change orm-mode to from_attributes in definitions
# of the ORM models. See for the previous attempt https://github.com/apache/airflow/pull/33220
pydantic>=1.10.0,<2.0.0

That was likely an overlook as part of the problem with orm-mode at least is solved. So you will have to wait for 2.7.1

@potiuk
Copy link
Member

potiuk commented Aug 18, 2023

I added limitation removal and scheduled it for 2.7.1 #33507 - seems that the aws-sam-translator removed the limitation last week and are going to be released in a week or two, which should be good as then our CI will test it automatically and we will produce constraints with Pydantic 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dependencies Issues related to dependencies problems 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.

Pydantic 2.0.0 support for Airflow

6 participants