-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Adjust built-in base_aws methods to avoid Deprecation warnings #19725
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
Adjust built-in base_aws methods to avoid Deprecation warnings #19725
Conversation
@potiuk what are the Airflow policies around removing parameters after depreciation? At a minimum we could drop the warning to INFO or DEBUG, but I would want to make sure any changes meet the community's backwards compatibility standards for DAGs. |
|
@potiuk I'd ask you 😛 Basically the same thing John said. I've seen some deprecation warning in other places in the provider packages as well. It looks like these were flagged for deprecation a couple months ago in 867e930 What's Airflow's policy on this? How long do we support something after a deprecation warning is pushed? I presume it's there until the next major version of the provider package? If they were flagged as deprecated without an actual plan to follow though with removing them, then I guess that's an Issue to tack onto the list? |
|
Yeah feel free to raise it on the list :). I think we have no "hard" rules defined for the providers - except the SamVer which tell that you MAY introduce breaaking change (i.e. drop parameters) when you release major upgrade. So technically, we could drop those deprecated parameters with any MAJOR release of provider. However I am of a position that not everything that can be done - should be. I think keeping backwards compatibility is extremely important - and except stuff that we HAVE have as backwards incompatibility, I think we should drop something only when we have very good reason - i.e. when it slows us down on releasing something or when it costs a lot to maintain it. In vast majority of cases I see no reason for dropping a parameter if it is just renaming and keeping old one for backwards compatibility, This has very little benefit (two lines of code less) but can potentially wreak havoc for an unsuspecting user. So my approach is: We should drop any such deprecated parameters when we "have to" (because we have good reason) not when we "can" However this is a different case @dimon222 talks about (please confirm @dimon222) From what @dimon222 understand says is that deprecation warnings are raised accidentaly whenever there is a legitimate use of the Operator and it cannot be avoided. Usually when you have such depracation there should be an easy way to change your use of it and deprecation warning should disappear. I do not know that much about the the operator and it's parameter to judge it - but I find the
As I wrote - I do not know much about the reasons for deprecating client_type - but if we answer the three questions above, we should be able to decide if deprecation should really be there. Also @eladkal maybe you can chime in here? |
|
@potiuk In general, I see no problem in any kind of refactoring if there's a legitimate reason for that. In our current scenario, however, we see that So the middleground I'm proposing here is:
|
It was missed
This is probably the better solution as #17987 solves a real problem so apparently it's just incomplete. |
|
Just to clarify @eladkal - you think the proposed change is ok :) ? I am about to start preparing the providers release so we should merge that one I guess ? Sorry i have been swamped a bit recently and had no tone to look in detail |
The current PR doesnt solve the issue. It just hide warnning. The solution is doing a small refactor as suggested so get_client_type(IAM) is not needed. To my understanding this is what @dimon222 is going to do? (Then we dont need to bump major version) |
Works for me! @dimon222 - I will be releasing providers later this week, so If you could make the change before and we could merge it before, that would be awesome! |
|
Done, up for another review. |
Skip argument Co-authored-by: Tzu-ping Chung <[email protected]>
Skip argument Co-authored-by: Tzu-ping Chung <[email protected]>
|
Applied review corrections + modified all identified references with my basic search. Please verify the new corrections. |
eladkal
left a comment
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.
LGTM.
Wonder if some unit tests can be added?
|
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease. |
|
These are all already covered by tests (and working), but this removes depretion warnings emitted by them. Do you mean tests on not emitting deprecation warnings? That might be a good thing to do globally (IIRC there’s a pytest flag for that). |
yep - to avoid problems like we have here. If we had something like that I would have handle it in the first PR. but yeah that is out of scope here |
|
Splitting the testing issue to #19788. |
|
Awesome work, congrats on your first merged pull request! |
|
Arrgh! I misclicked the merge. Submitting a fix to the test failures now… |
|
Trying to fix this in #19789 |
apache#19725)" This reverts commit 4be0414.
…e#19725) Co-authored-by: Tzu-ping Chung <[email protected]>
What is this?
This PR is to help with consequences of 867e930 (#17987)
Currently out of the box base_aws implementation is going to show warnings whenever connection cache is invoked (that is potentially always when you use any AWS-based resource in Airflow like S3 as storage for logging or sensors)
Why?
Newly added warning for deprecation is shown every time anyone is passing
not Nonevalueclient_typetoget_client_typemethod. Same is happening withnot Nonevalueresource_typebeing passed toget_resource_type.While this new deprecation warning might have been created with good intentions, the out of the box calls to mentioned methods weren't modified accordingly (missed during review?), so right now Airflow is barking on its own code for deprecation on any AWS-hook based component.
Condition 1:
airflow/airflow/providers/amazon/aws/hooks/base_aws.py
Lines 444 to 449 in aa2cb55
Calls:
airflow/airflow/providers/amazon/aws/hooks/base_aws.py
Lines 493 to 494 in aa2cb55
airflow/airflow/providers/amazon/aws/hooks/base_aws.py
Lines 541 to 542 in aa2cb55
(for
iamcall please read the notes on the very end of this PR message)Condition 2:
airflow/airflow/providers/amazon/aws/hooks/base_aws.py
Lines 469 to 474 in aa2cb55
Calls:
airflow/airflow/providers/amazon/aws/hooks/base_aws.py
Lines 495 to 496 in aa2cb55
Now, to mitigate this I took next approach: I pass temporarily None in mentioned arguments until the code is refactored to get rid of entire argument in method (I assume somewhen in the future?).
Few notes: