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

Sqlalchemy dependency update #38066

Closed

Conversation

amindadgar
Copy link

Updating executemany_mode for supporting sqlalchemy>=2.0.0
Trying to resolve the issue #38064


^ 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.

- Adding the executemany_mode support of sqlalchemy==2.0.0
sqlalchemy dependency version update.
Copy link

boring-cyborg bot commented Mar 12, 2024

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 Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.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: [email protected]
    Slack: https://s.apache.org/airflow-slack

@Taragolis
Copy link
Contributor

airflow/pyproject.toml

Lines 136 to 139 in 7213fc5

# We use some deprecated features of sqlalchemy 2.0 and we should replace them before we can upgrade
# See https://sqlalche.me/e/b8d9 for details of deprecated features
# you can set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.
# The issue tracking it is https://github.com/apache/airflow/issues/28723

And we also have a FAB (Flask APP Builder) which also limited by sqlaclhemy < 1.5

@amindadgar
Copy link
Author

@Taragolis Thanks for your checking. So I see two options

  1. Wait for FAB library to update their dependency or
  2. To contribute to their library

Is there another easy way we could follow?

@potiuk
Copy link
Member

potiuk commented Mar 12, 2024

@Taragolis Thanks for your checking. So I see two options

  1. Wait for FAB library to update their dependency or
  2. To contribute to their library

Is there another easy way we could follow?

Generally this is the only way to follow. We need somoene (for example you, but can be anyone) to follow up and close all the issues internally (fix all deprecations etc) and nag (or help as you mentioned) everyone who is a blocker to upgrade, and then update all the dependencies (or wait until somoene else does it). Or just wait until they do - this will happen eventually even without you nagging them.

Another option of course is to replace the dependencies with others to do the same when we see no option for them to upgrade quickly.

All this is for example what happened when we just added Python 3.12. This one took 5 months till Python 3.12 was released and finally we got it merged yesterday.

I think a good start (and this is something you could do if you want to make it more progressing) is to create a separate issue named "Sqlalchemy 3 upgrade" where you will track down and list with

  • checkmarks

all the things that need to happen - and then link (and mark as duplicate) all the issues that refer to it - including the #38064

That would be a very good way to contribute to make that happen eventually. You are most welcome to do that and take a leadership on nagging others and maybe making PRs to fix thins internally.

@Taragolis
Copy link
Contributor

It might be good to change default value for execute many for PG, because seems like it didn't change for a long time, and it only valid in SA 1.3, SA 1.4 look like silently fallback to valid value, in SA 2.0+ it is invalid

@@ -273,7 +273,7 @@ def configure_orm(disable_connection_pool=False, pool_class=None):

DEFAULT_ENGINE_ARGS = {
"postgresql": {
"executemany_mode": "values",
"executemany_mode": "values_only",
Copy link
Member

Choose a reason for hiding this comment

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

Does 1.4 support values_only?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, values even not listed in allowed values in 1.4.
But as I could understand the values -> values_plus_batch

sqlalchemy/sqlalchemy#5401

Copy link
Member

@uranusjr uranusjr Mar 13, 2024

Choose a reason for hiding this comment

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

In that case maybe we don't need to raise the lower version bound, and can make the version range >=1.4.36,<2.1.0 instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh... I miss this change. Yeah we definitely should keep support of SA 1.4 as much as possible, not all providers could work with SA 2.0

But also I'm not sure that we need to add support SA 2.0, because I'm not totally sure that Airflow could work with it properly.

Copy link
Author

Choose a reason for hiding this comment

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

Ahhh... I miss this change. Yeah we definitely should keep support of SA 1.4 as much as possible, not all providers could work with SA 2.0

But also I'm not sure that we need to add support SA 2.0, because I'm not totally sure that Airflow could work with it properly.

Agreed. The FAB library you mentioned earlier is required to update their SA. I'll have a quick look on what is needed to update that dependency.

Copy link
Member

@potiuk potiuk Mar 20, 2024

Choose a reason for hiding this comment

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

FAB is being migrated in #38319 to 4.4.1 -but still sqlalchemy is < 1.5 there.

@amindadgar
Copy link
Author

@Taragolis Thanks for your checking. So I see two options

  1. Wait for FAB library to update their dependency or
  2. To contribute to their library

Is there another easy way we could follow?

Generally this is the only way to follow. We need somoene (for example you, but can be anyone) to follow up and close all the issues internally (fix all deprecations etc) and nag (or help as you mentioned) everyone who is a blocker to upgrade, and then update all the dependencies (or wait until somoene else does it). Or just wait until they do - this will happen eventually even without you nagging them.

Another option of course is to replace the dependencies with others to do the same when we see no option for them to upgrade quickly.

All this is for example what happened when we just added Python 3.12. This one took 5 months till Python 3.12 was released and finally we got it merged yesterday.

I think a good start (and this is something you could do if you want to make it more progressing) is to create a separate issue named "Sqlalchemy 3 upgrade" where you will track down and list with

  • checkmarks

all the things that need to happen - and then link (and mark as duplicate) all the issues that refer to it - including the #38064

That would be a very good way to contribute to make that happen eventually. You are most welcome to do that and take a leadership on nagging others and maybe making PRs to fix thins internally.

Thanks for your detailed response. I would love to contribute to this project but unfortunately, I'm very busy with another open source project. Special thanks to @Taragolis for taking the lead on this PR. I see the questions are answered by Taragolis, but if there's any more input required from me, please don't hesitate to ask :)

Copy link

github-actions bot commented May 5, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label May 5, 2024
@Taragolis
Copy link
Contributor

Already fixed in #38362

@Taragolis Taragolis closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale PRs per the .github/workflows/stale.yml policy file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants