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

Consistent way of checking Airflow version in providers #44686

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Dec 5, 2024

This PR introduces consistent way of checking version of Airflow
by Airflow providers. So far there were about 6 different ways on
how Providers checked for Airflow version - this PR aims to unify
this approach for now and in the future - at least until minimum
version of Airflow set to 2.11 where we are likely to introduce
a simpler check via #44607. Until then all providers are going
to have version_references.py module copied in their sources
that they will be importing the constants from.

This PR also adds pre-commit that checks if the
version_compat.py module is imported from local package copy
or maybe from another provider or test code - both causing
unneeded dependencies from the provider - to another package or
to test code respectively.


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

@potiuk potiuk force-pushed the version-constants-in-template branch 4 times, most recently from 55672b3 to de351db Compare December 5, 2024 10:16
@kacpermuda
Copy link
Contributor

Great idea, thanks Jarek !

@potiuk potiuk force-pushed the version-constants-in-template branch from de351db to 9720404 Compare December 5, 2024 11:11
@potiuk potiuk force-pushed the version-constants-in-template branch from 3e3291f to b78485c Compare December 7, 2024 20:59
@potiuk potiuk requested review from Copilot and ashb December 7, 2024 21:03

Choose a reason for hiding this comment

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

Copilot reviewed 145 out of 160 changed files in this pull request and generated no suggestions.

Files not reviewed (15)
  • contributing-docs/08_static_code_checks.rst: Language not supported
  • contributing-docs/testing/unit_tests.rst: Language not supported
  • dev/breeze/doc/images/output_static-checks.txt: Language not supported
  • providers/src/airflow/providers/MANAGING_PROVIDERS_LIFECYCLE.rst: Language not supported
  • providers/src/airflow/providers/amazon/version_compat.py: Evaluated as low risk
  • providers/src/airflow/providers/common/compat/version_compat.py: Evaluated as low risk
  • providers/src/airflow/providers/cncf/kubernetes/version_compat.py: Evaluated as low risk
  • providers/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py: Evaluated as low risk
  • .pre-commit-config.yaml: Evaluated as low risk
  • providers/src/airflow/providers/amazon/aws/utils/init.py: Evaluated as low risk
  • providers/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py: Evaluated as low risk
  • providers/src/airflow/providers/common/io/xcom/backend.py: Evaluated as low risk
  • providers/src/airflow/providers/amazon/aws/hooks/redshift_sql.py: Evaluated as low risk
  • providers/src/airflow/providers/common/compat/lineage/hook.py: Evaluated as low risk
  • providers/src/airflow/providers/common/compat/assets/init.py: Evaluated as low risk
Comments skipped due to low confidence (1)

providers/src/airflow/providers/amazon/aws/auth_manager/aws_auth_manager.py:42

  • The variable name AIRFLOW_V_2_9_PLUS is clear and consistent with the naming convention used in the PR.
from airflow.providers.amazon.version_compat import AIRFLOW_V_2_9_PLUS
@ashb
Copy link
Member

ashb commented Dec 7, 2024

Thanks very much for making these changes Jarek

@potiuk potiuk force-pushed the version-constants-in-template branch 2 times, most recently from 3bd4327 to 22b6bb2 Compare December 8, 2024 07:57
Copy link
Member

@gopidesupavan gopidesupavan left a comment

Choose a reason for hiding this comment

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

Nice, thanks jarek for the updates and it looks like ruff analyze graph playing nice role.

Great suggestion Ash :)

potiuk added a commit to potiuk/airflow that referenced this pull request Dec 8, 2024
This is extracted out of apache#44686 - pre-requisite for consistency
check and consistency change to always use version_compat embedded in
providers and avoid mistakes with importing the compat from tests
in the providers code.

This is purely extraction of constants that use to be in compat module
to version_compat - which will make it easy to write the pre-commit
to check if version_compat from tests_modules is used accidentally.
@potiuk
Copy link
Member Author

potiuk commented Dec 8, 2024

I think this one should be green. I also extracted out the pure refactor of test version constants to "version_compat" module - that will make this one much smaller (and makes it way easier to see if version_compat is used properly in the ruff analyze graph json output - #44770. If we merge #44770, this one will be much easier to review

@potiuk potiuk force-pushed the version-constants-in-template branch from 22b6bb2 to ce0297a Compare December 8, 2024 08:22
potiuk added a commit to potiuk/airflow that referenced this pull request Dec 8, 2024
This is extracted out of apache#44686 - pre-requisite for consistency
check and consistency change to always use version_compat embedded in
providers and avoid mistakes with importing the compat from tests
in the providers code.

This is purely extraction of constants that use to be in compat module
to version_compat - which will make it easy to write the pre-commit
to check if version_compat from tests_modules is used accidentally.
@potiuk potiuk force-pushed the version-constants-in-template branch from ce0297a to 3e006ab Compare December 8, 2024 11:57
potiuk added a commit to potiuk/airflow that referenced this pull request Dec 8, 2024
This is extracted out of apache#44686 - pre-requisite for consistency
check and consistency change to always use version_compat embedded in
providers and avoid mistakes with importing the compat from tests
in the providers code.

This is purely extraction of constants that use to be in compat module
to version_compat - which will make it easy to write the pre-commit
to check if version_compat from tests_modules is used accidentally.
@potiuk potiuk force-pushed the version-constants-in-template branch from 3e006ab to 4572c77 Compare December 8, 2024 12:16
potiuk added a commit that referenced this pull request Dec 8, 2024
…4774)

This is extracted out of #44686 - pre-requisite for consistency
check and consistency change to always use version_compat embedded in
providers and avoid mistakes with importing the compat from tests
in the providers code.

This is purely extraction of constants that use to be in compat module
to version_compat - which will make it easy to write the pre-commit
to check if version_compat from tests_modules is used accidentally.
This PR introduces consistent way of checking version of Airflow
by Airflow providers. So far there were about 6 different ways on
how Providers checked for Airflow version - this PR aims to unify
this approach for now and in the future - at least until minimum
version of Airflow set to 2.11 where we are likely to introduce
a simpler check via apache#44607. Until then all providers are going
to have `version_references.py` module copied in their sources
that they will be importing the constants from.

This PR also adds pre-commit that checks if the
``version_compat.py`` module is imported from local package copy
or maybe from another provider or test code - both causing
unneeded dependencies from the provider - to another package or
to test code respectively.
@potiuk potiuk force-pushed the version-constants-in-template branch from 4572c77 to f0d76a5 Compare December 8, 2024 16:13
@potiuk
Copy link
Member Author

potiuk commented Dec 8, 2024

Rebased after merging #44774 - this should be now much easier to review :)

@potiuk
Copy link
Member Author

potiuk commented Dec 10, 2024

Merging it as is then. We can always iterate on it later.

@potiuk potiuk merged commit 490b5e8 into apache:main Dec 10, 2024
97 checks passed
@potiuk potiuk deleted the version-constants-in-template branch December 10, 2024 07:35
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
…ache#44774)

This is extracted out of apache#44686 - pre-requisite for consistency
check and consistency change to always use version_compat embedded in
providers and avoid mistakes with importing the compat from tests
in the providers code.

This is purely extraction of constants that use to be in compat module
to version_compat - which will make it easy to write the pre-commit
to check if version_compat from tests_modules is used accidentally.
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
This PR introduces consistent way of checking version of Airflow
by Airflow providers. So far there were about 6 different ways on
how Providers checked for Airflow version - this PR aims to unify
this approach for now and in the future - at least until minimum
version of Airflow set to 2.11 where we are likely to introduce
a simpler check via apache#44607. Until then all providers are going
to have `version_references.py` module copied in their sources
that they will be importing the constants from.

This PR also adds pre-commit that checks if the
``version_compat.py`` module is imported from local package copy
or maybe from another provider or test code - both causing
unneeded dependencies from the provider - to another package or
to test code respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants