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

Refrain from passing encoding to the SQL engine in SQLAlchemy v2 #37545

Merged
merged 6 commits into from
Feb 21, 2024
Merged

Refrain from passing encoding to the SQL engine in SQLAlchemy v2 #37545

merged 6 commits into from
Feb 21, 2024

Conversation

Dev-iL
Copy link
Contributor

@Dev-iL Dev-iL commented Feb 19, 2024

This PR fixes 1 error and 1 warning related to SQLAlchemy v2 ("SQLA2"), as well as an unrelated documentation hyperlink issue.
See motivation for changes here: #28723 (comment)
related: #28723

Note that while the added unit tests pass on SQLA1, one of them fails with SQLA2, and will require additional future modifications before that version could be adopted:

ERROR test_orm_event_handlers.py::test_setup_event_handlers_no_warnings - sqlalchemy.exc.ArgumentError: Type annotation for "TaskInstance.dag_model" can't be correctly interpreted for Annotated Declarative Table form.  ORM annotations should normally make use of the ``Mapped[]`` generic ...

^ 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 Feb 19, 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

@Dev-iL
Copy link
Contributor Author

Dev-iL commented Feb 19, 2024

@potiuk Pinging as promised.

tests/utils/test_orm_event_handlers.py Outdated Show resolved Hide resolved
tests/utils/test_orm_event_handlers.py Outdated Show resolved Hide resolved
tests/utils/test_orm_event_handlers.py Outdated Show resolved Hide resolved
airflow/settings.py Outdated Show resolved Hide resolved
airflow/settings.py Outdated Show resolved Hide resolved
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.

Appproved - with a potential NIT

@uranusjr
Copy link
Member

Eh this is not what I suggested, I want the SQLA v1 check to go into airflow.utils.sqlalchemy, and the others kept as-is.

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.

Agree with @uranusjr -> we should move it to airflow.uitls.sqlalchemy

@Dev-iL
Copy link
Contributor Author

Dev-iL commented Feb 20, 2024

@uranusjr @potiuk I moved the methods as suggested. Please resolve threads and approve if acceptable.

@potiuk
Copy link
Member

potiuk commented Feb 20, 2024

LGTM. @uranusjr ?

@Dev-iL
Copy link
Contributor Author

Dev-iL commented Feb 20, 2024

Can someone please explain the build failure to me? I don't know what to do about it.

@Taragolis
Copy link
Contributor

This error is expected, regression of #37524
Every PR now have this error, except the PRs which do not require to run LatestBoto ci tests

@potiuk
Copy link
Member

potiuk commented Feb 20, 2024

Well - it was you who proposed to do something common between pydantic and sqlachemy so you expanded scope and discussions yourself, so yes it took longer and had more twists.

I thinl up until then there was only one extra suggestion from TP so that you move things to sqlalchemy. If you need exact instructions here it is:

  • do not make DRY code between Pydantic and sqlalchemy and pydantic at all. You can have separate PR for that f you want
  • move the code to check sqlalchemy to utils.sqlalchemy

And yes, it happens and is expected. Sometimes small prs takes days or weeks and you will get different twists along the way and people looking at what you propose will have different opinions. And sometimes it get few iterations.

@Dev-iL
Copy link
Contributor Author

Dev-iL commented Feb 20, 2024

As of the latest changes (submitted a few hours ago), both of the points you mentioned are implemented. Is it acceptable to resolve the threads (assuming the changes were implemented, of course; I'm just used to letting the reviewer "close the loop")?

@Dev-iL
Copy link
Contributor Author

Dev-iL commented Feb 21, 2024

...merge?

@potiuk potiuk merged commit 70348de into apache:main Feb 21, 2024
59 checks passed
Copy link

boring-cyborg bot commented Feb 21, 2024

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

sunank200 pushed a commit to astronomer/airflow that referenced this pull request Feb 21, 2024
…pache#37545)

* Fix broken hyperlink to Dockerfile.ci

* Fix typo, add PY311 to main init's exports

* Add util for checking package versions

* Refrain from passing `encoding` to the SQL engine in SQLAlchemy v2

* Fix an SQLA2 deprecation warning

* Addressing PR comments
abhishekbhakat pushed a commit to abhishekbhakat/my_airflow that referenced this pull request Mar 5, 2024
…pache#37545)

* Fix broken hyperlink to Dockerfile.ci

* Fix typo, add PY311 to main init's exports

* Add util for checking package versions

* Refrain from passing `encoding` to the SQL engine in SQLAlchemy v2

* Fix an SQLA2 deprecation warning

* Addressing PR comments
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Mar 6, 2024
@ephraimbuddy ephraimbuddy added this to the Airflow 2.9.0 milestone Mar 6, 2024
@potiuk potiuk modified the milestones: Airflow 2.9.0, Airflow 2.8.4 Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants