-
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
Standardize deprecations in providers [part1] #36876
Standardize deprecations in providers [part1] #36876
Conversation
65f3f55
to
e0d415b
Compare
49dcdbf
to
b535619
Compare
b535619
to
add3083
Compare
I don't have time to look through this large PR in detail at the moment. But I love the goals of documentation and standardization! +1 |
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.
Nice! @dstandish - I guess we could connect it with #31830
add3083
to
1a45198
Compare
@potiuk I already prepared a POC for the custom decorator itself in #36952 . @dstandish check it out, maybe it will help detecting the things that should be removed in specific versions of the providers |
Its important to detect but we must make sure the mechanisem doesnt force our hands. |
Sure, we can still not provide that information on purpose and leave it blank and then work that in the detection mechanism. |
e2d33a1
to
3555acb
Compare
Hey, is there anything else that i can do to make this PR merged? Pinging those who at least saw it 😄 @eladkal @potiuk @o-nikolas |
I am good for it - @dstandish ? What do you think? |
3555acb
to
3b0cd12
Compare
3b0cd12
to
7f82962
Compare
Seems we just replace warnings.warn with deprecated decorator, seems fine, to me |
TLDR;
I propose standardizing our approach to deprecating elements in the Airflow codebase, aiming for improved readability and easier automated parsing. I propose adopting a structured approach, potentially enforceable through the CI process, for handling deprecations in Airflow. This would involve primarily using decorators for the deprecation process. This PR serves as an introduction and first step. The whole process will probably take couple of PR's.
I encourage everyone to share their thoughts and feedback on this proposal.
Genesis
The genesis of this proposal stems from my attempt to compile a comprehensive documentation of all deprecations in Airflow. The lack of a standardized process for deprecation made it challenging to track and document these changes effectively.
Problem
Currently, deprecation in Airflow relies mainly on the content of warning messages, making it less accessible for automated discovery. The typical process includes:
__init__
, detailing the deprecation. The @deprecated decorator is rarely applied to the class.schedule
from "@once" to "@single"), a DeprecationWarning is raised with a detailed message in the function/method.The current practice of raising a DeprecationWarning in the
__init__
or a function in Airflow makes it unclear what exactly is being deprecated, whether it's the class, function, a specific argument, or a particular argument value.Proposed solution
I propose adopting a structured approach, potentially enforceable through the CI process, for handling deprecations in Airflow. This would involve primarily using decorators for the deprecation process. We could develop new decorators or utilize existing ones, similar to those in the TensorFlow codebase. These could be housed in a dedicated module, such as
airflow/deprecation.py
.By implementing our own decorators, we can standardize the information provided during deprecation, allowing us to specify details using separate keyword arguments instead of embedding everything within a message.
Demo
Instead of this:
We could have:
Challenges
I'm uncertain if we can entirely remove explicit calls to
warnings.warn
. For instance, in cases where complex logic determines if a provided argument value is deprecated, especially with complex objects or nested structures, usingwarnings.warn
directly might still be the most effective method of notification. It remains to be seen if a decorator can neatly handle such scenarios.Please share any potential drawbacks of this approach in the comments.
Future possibilities / work plan
We adopt the following steps for deprecating components in Airflow:
arg
,arg_values
etc., to replace current warnings within function bodies and include these in the documentation.Further considerations for future development:
Feel free to suggest additional ideas or improvements.
Mentioning @potiuk , as we talked about it on the Slack. Feel free to tag others who might be interested in contributing their thoughts.
^ 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.