-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Add Airflow specific warning classes #25799
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t read everything
airflow/exceptions.py
Outdated
@@ -338,3 +338,17 @@ class TaskDeferralError(AirflowException): | |||
|
|||
class PodReconciliationError(AirflowException): | |||
"""Raised when an error is encountered while trying to merge pod configs.""" | |||
|
|||
|
|||
class RemoveInAirflow3DeprecationWarning(DeprecationWarning): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.python.org/3/library/warnings.html
DeprecationWarning | Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by code in main). |
---|---|
FutureWarning | Base category for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python. |
-- | -- |
PendingDeprecationWarning | Base category for warnings about features that will be deprecated in the future (ignored by default). |
-- | -- |
Should we make this baseclass be FutureWarning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We consider Airflow users as Python developers not end users don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PendingDeprecationWarning
s and DeprecationWarning
s are filtered out by default. I think subclassing from FutureWarning
would make them more visible to Airflow DAG authors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, we may not want this to be immediately visible to DAG authors, because at this point we should still assume that we will only have 2.x releases.
Subclassing from DeprecationWarning (or PendingDeprecationWarning) might actually be the right call here until we have concrete plans for Airflow 3.0. PEP-0387:
If an API is being removed, simply warn whenever it is entered. DeprecationWarning is the usual warning category to use, but PendingDeprecationWarning may be used in special cases where the old and new versions of the API will coexist for many releases [2].
(emphasis mine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We explicitly enable the Deprecation warnings coming from airflow following https://peps.python.org/pep-0565/#recommended-filter-settings-for-interactive-shells
See airflow.configuration.py
:
if not sys.warnoptions:
warnings.filterwarnings(action='default', category=DeprecationWarning, module='airflow')
warnings.filterwarnings(action='default', category=PendingDeprecationWarning, module='airflow')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why #1285 "turned on" both DeprecationWarning and PendingDeprecationWarning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was 6 years ago :) 5 Apr 2016
:). I am afraid no commiters who are active now were even around :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to comment here, but i'm obsessed with DeprecationWarning recently because i couldn't find mine 😂 :
https://apache-airflow.slack.com/archives/CSS36QQS1/p1661974104498239
Comment: We COULD potentially do the same approach as with common.sql and introduce 'apache-airflow-providers-common-provider` and add the AirflowProviderDeprecationWarning. If the package is very small, we can keep it as a way to add functionality that is common to all providers. And we could replace the provider's warnings even now. |
Should we add a pre-commit to check automatically if there are no "standard" warnings in Airflow code? I think it should be as easy as using |
We can but to be honest I think it has very little value. With the new provider governance module there is no reason to keep deprecations for so long. We can remove them really fast even in a follow up release with is 1 month window and cherry pick features to earlier releases. |
Added |
Adding `RemoveInAirflow3DeprecationWarning` and `AirflowProviderDeprecationWarning` Closes: apache#22356
Adding
RemoveInAirflow3DeprecationWarning
RemovedInAirflow3Warning
andAirflowProviderDeprecationWarning
RemovedInAirflow3Warning
- modifying all occurrences ofDeprecationWarning
in core to the new class.AirflowProviderDeprecationWarning
- only adding the class. We can not yet replace warnings in providers. This will be useful when minimum provider version would be on Airflow 2.4 (or the release of this PR)Regarding
contrib
folder due to the discussion of [DISCUSS] Move "contrib" and all old classes to a separate package in mailing list I left all classes untouched they will still produceDeprecationWarning
Closes: #22356
Todo:
contrib
)PendingDeprecationWarning
in the code basebut I'm not sure if we have that distinction? Should we also haveRemovedInAirflow3Warning
?Providers: Replaced all
PendingDeprecationWarning
withDeprecationWarning
Core: Replaced all
PendingDeprecationWarning
withRemovedInAirflow3Warning
^ 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.