Skip to content

Auto-apply apply_default decorator #15667

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

Merged
merged 9 commits into from
May 7, 2021

Conversation

ashb
Copy link
Member

@ashb ashb commented May 5, 2021

Continuation of, and closes #15044


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.

@boring-cyborg boring-cyborg bot added area:core-operators Operators, Sensors and hooks within Core Airflow area:providers provider:amazon AWS/Amazon - related issues labels May 5, 2021
@github-actions
Copy link

github-actions bot commented May 5, 2021

The Workflow run is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.

@github-actions
Copy link

github-actions bot commented May 5, 2021

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

github-actions bot commented May 5, 2021

The Workflow run is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.

@github-actions
Copy link

github-actions bot commented May 5, 2021

The Workflow run is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.

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.

As discussed on slack. We cannot do that, because we continue releasing providers from master, so the failure of that tests is precisely what should happen.

We have the following options:

  1. Wait with merging it to just before we cut the branch for 2.1 release (i.e. before we release 2.1rc) - with ~2 weeks release timeline
  2. Have a separate branch for providers-only release where we could cherry-pick provider's changes
  3. Refactor code automatically for provider release process.

I think option 1) sounds like easiest to do (and it has very little drawbacks, the PR will simply have to be rebased periodically + removal of a new @apply_defaults.

@ashb
Copy link
Member Author

ashb commented May 5, 2021

That's why I'm picking that this now, as it's what we are days away 2.1 release, and I was thinking that the small window of not being able to release providers was okay.

@potiuk
Copy link
Member

potiuk commented May 5, 2021

Yeah. If it's 'days' then we can do option 2) cut the branch where we can cherry-pick any provider changes where we could relase providers from by cherry-picking if needed - just before merging this one, and yeah, in this case we can disable the "2.0" build and enable it back pointing to 2.1.0 right after the rc1 for 2.1.0 gets released. We'd then have to add >=2.1.0rc1 for all priovider -> airflow dependencies.

but I think it would be OK to do it when we are sure rc1 is going to be released "shortly" :)

@ashb ashb force-pushed the AIRFLOW-6829-metaclass branch 4 times, most recently from c7e915e to 04f072a Compare May 6, 2021 15:28
@github-actions
Copy link

github-actions bot commented May 6, 2021

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

github-actions bot commented May 6, 2021

The Workflow run is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.

Kamil Breguła and others added 8 commits May 7, 2021 12:03
This makes two changes to make the apply_defaults transparent to
warnings:

1. It removes `__call__` from the Metaclass (which added one frame)
2. It "patches" warnings.warn _in the function scope_ to automatically
   adjust the stacklevel

The reason for this is that now that apply_defaults is called
"magically" from the Metaclass we're adding extra frames to the
callstack. By locally patching warnings like this it means that user
code doesn't have to be aware of what we've done.

(I wish Python had a native way of handling this case as it crops up all
the time. Perhaps I should submit a PEP for it with a better design)
Since we have changed the dep to need Airflow 2.1, testing against 2.0
no longer makes any sense.

And since 2.1 is not yet out, we have disabled this specific step for
now
@ashb ashb force-pushed the AIRFLOW-6829-metaclass branch from 20f9c11 to f375d07 Compare May 7, 2021 11:04
@ashb
Copy link
Member Author

ashb commented May 7, 2021

@potiuk Happy to merge this now?

@potiuk
Copy link
Member

potiuk commented May 7, 2021

Absolutely. I will branch-off any changes in providers in case we need to release them with 2.0 compatibility.

@ashb ashb requested review from turbaszek and XD-DENG as code owners May 7, 2021 12:33
@ashb ashb merged commit 37681bc into apache:master May 7, 2021
@ashb ashb deleted the AIRFLOW-6829-metaclass branch May 7, 2021 16:28
@eladkal eladkal mentioned this pull request May 11, 2021
jmelot added a commit to jmelot/airflow that referenced this pull request May 11, 2021
jmelot added a commit to jmelot/airflow that referenced this pull request May 17, 2021
potiuk added a commit to potiuk/airflow that referenced this pull request May 25, 2021
The GCSToLocalFilesystemOperator in Google Provider <=3.0.0 had wrong
import for apply_defaults. It used

`from airflow.sensors.base_sensor_operator import apply_defaults`

instead of

`from airflow.utils.decorators import apply_defaults`

When we removed apply_defaults in apache#15667, the base_sensor_operator
import was removed as well which made the GCSToLocalFilestystemOperator
stops working in 2.1.0

Fixes: apache#16035
potiuk added a commit that referenced this pull request May 27, 2021
The GCSToLocalFilesystemOperator in Google Provider <=3.0.0 had wrong
import for apply_defaults. It used

`from airflow.sensors.base_sensor_operator import apply_defaults`

instead of

`from airflow.utils.decorators import apply_defaults`

When we removed apply_defaults in #15667, the base_sensor_operator
import was removed as well which made the GCSToLocalFilestystemOperator
stops working in 2.1.0

Fixes: #16035
jhtimmins pushed a commit to astronomer/airflow that referenced this pull request Jun 3, 2021
The GCSToLocalFilesystemOperator in Google Provider <=3.0.0 had wrong
import for apply_defaults. It used

`from airflow.sensors.base_sensor_operator import apply_defaults`

instead of

`from airflow.utils.decorators import apply_defaults`

When we removed apply_defaults in apache#15667, the base_sensor_operator
import was removed as well which made the GCSToLocalFilestystemOperator
stops working in 2.1.0

Fixes: apache#16035
(cherry picked from commit 0f8f66e)
ashb pushed a commit that referenced this pull request Jun 22, 2021
The GCSToLocalFilesystemOperator in Google Provider <=3.0.0 had wrong
import for apply_defaults. It used

`from airflow.sensors.base_sensor_operator import apply_defaults`

instead of

`from airflow.utils.decorators import apply_defaults`

When we removed apply_defaults in #15667, the base_sensor_operator
import was removed as well which made the GCSToLocalFilestystemOperator
stops working in 2.1.0

Fixes: #16035
(cherry picked from commit 0f8f66e)
@dstaple
Copy link
Contributor

dstaple commented Apr 12, 2023

I noticed that @apply_defaults is deprecated but it was left with the following comment: "Make it still be a wrapper to keep the previous behaviour of an extra stack frame"
https://github.com/apache/airflow/blob/2.5.3/airflow/utils/decorators.py#L52-L54

It seems to me the number of scenarios where this will make a difference is relatively limited, but considering you chose to do it this way, I'm wondering if there are situations where a user cannot expect to simply remove the @apply_defaults decorator to resolve this DeprecationWarning?

@potiuk
Copy link
Member

potiuk commented Apr 12, 2023

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow area:providers full tests needed We need to run full set of tests for this PR to merge provider:amazon AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants