Skip to content

Commit 37681bc

Browse files
ashbKamil Breguła
andauthored
Auto-apply apply_default decorator (#15667)
* Auto-apply apply_default decorator * Automatically patch warnings stacklevel inside Operator constructors 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) * Don't test provider packges against 2.0 anymore 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 Co-authored-by: Kamil Breguła <kamil.bregula@polidea.com>
1 parent db0e942 commit 37681bc

File tree

333 files changed

+348
-1215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

333 files changed

+348
-1215
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,12 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
553553
env:
554554
USE_AIRFLOW_VERSION: "wheel"
555555
PACKAGE_FORMAT: "wheel"
556-
- name: "Install and test provider packages and airflow on Airflow 2.0 files"
556+
- name: "Install and test provider packages and airflow on Airflow 2.1 files"
557557
run: ./scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh
558558
env:
559-
USE_AIRFLOW_VERSION: "2.0.0"
559+
USE_AIRFLOW_VERSION: "2.1.0"
560560
PACKAGE_FORMAT: "wheel"
561+
if: false
561562

562563
prepare-test-provider-packages-sdist:
563564
timeout-minutes: 40

UPDATING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ https://developers.google.com/style/inclusive-documentation
7171
7272
-->
7373

74+
### `@apply_default` decorator isn't longer necessary
75+
76+
This decorator is now automatically added to all operators via the metaclass on BaseOperator
77+
7478
### Change the configuration options for field masking
7579

7680
We've improved masking for sensitive data in Web UI and logs. As part of it, the following configurations have been changed:

airflow/contrib/operators/adls_to_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def __init__(self, *args, **kwargs):
3939
"""This class is deprecated.
4040
Please use `airflow.providers.google.cloud.transfers.adls_to_gcs.ADLSToGCSOperator`.""",
4141
DeprecationWarning,
42-
stacklevel=3,
42+
stacklevel=2,
4343
)
4444
super().__init__(*args, **kwargs)

airflow/contrib/operators/awsbatch_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):
5353
"""This class is deprecated.
5454
Please use `airflow.providers.amazon.aws.operators.batch.AwsBatchOperator`.""",
5555
DeprecationWarning,
56-
stacklevel=3,
56+
stacklevel=2,
5757
)
5858
super().__init__(*args, **kwargs)
5959

airflow/contrib/operators/bigquery_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ def __init__(self, *args, **kwargs):
5151
"""This class is deprecated.
5252
Please use `airflow.providers.google.cloud.operators.bigquery.BigQueryExecuteQueryOperator`.""",
5353
DeprecationWarning,
54-
stacklevel=3,
54+
stacklevel=2,
5555
)
5656
super().__init__(*args, **kwargs)

airflow/contrib/operators/bigquery_table_delete_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def __init__(self, *args, **kwargs):
3939
"""This class is deprecated.
4040
Please use `airflow.providers.google.cloud.operators.bigquery.BigQueryDeleteTableOperator`.""",
4141
DeprecationWarning,
42-
stacklevel=3,
42+
stacklevel=2,
4343
)
4444
super().__init__(*args, **kwargs)

airflow/contrib/operators/bigquery_to_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def __init__(self, *args, **kwargs):
3939
"""This class is deprecated.
4040
Please use `airflow.providers.google.cloud.transfers.bigquery_to_gcs.BigQueryToGCSOperator`.""",
4141
DeprecationWarning,
42-
stacklevel=3,
42+
stacklevel=2,
4343
)
4444
super().__init__(*args, **kwargs)

airflow/contrib/operators/cassandra_to_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ def __init__(self, *args, **kwargs):
4242
"""This class is deprecated.
4343
Please use `airflow.providers.google.cloud.transfers.cassandra_to_gcs.CassandraToGCSOperator`.""",
4444
DeprecationWarning,
45-
stacklevel=3,
45+
stacklevel=2,
4646
)
4747
super().__init__(*args, **kwargs)

airflow/contrib/operators/dataflow_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, *args, **kwargs):
4343
"""This class is deprecated.
4444
Please use `airflow.providers.google.cloud.operators.dataflow.DataflowCreateJavaJobOperator`.""",
4545
DeprecationWarning,
46-
stacklevel=3,
46+
stacklevel=2,
4747
)
4848
super().__init__(*args, **kwargs)
4949

@@ -60,7 +60,7 @@ def __init__(self, *args, **kwargs):
6060
Please use
6161
`airflow.providers.google.cloud.operators.dataflow.DataflowCreatePythonJobOperator`.""",
6262
DeprecationWarning,
63-
stacklevel=3,
63+
stacklevel=2,
6464
)
6565
super().__init__(*args, **kwargs)
6666

@@ -77,6 +77,6 @@ def __init__(self, *args, **kwargs):
7777
Please use
7878
`airflow.providers.google.cloud.operators.dataflow.DataflowTemplatedJobStartOperator`.""",
7979
DeprecationWarning,
80-
stacklevel=3,
80+
stacklevel=2,
8181
)
8282
super().__init__(*args, **kwargs)

airflow/contrib/operators/dataproc_operator.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, *args, **kwargs):
5252
"""This class is deprecated.
5353
Please use `airflow.providers.google.cloud.operators.dataproc.DataprocCreateClusterOperator`.""",
5454
DeprecationWarning,
55-
stacklevel=3,
55+
stacklevel=2,
5656
)
5757
super().__init__(*args, **kwargs)
5858

@@ -68,7 +68,7 @@ def __init__(self, *args, **kwargs):
6868
"""This class is deprecated.
6969
Please use `airflow.providers.google.cloud.operators.dataproc.DataprocDeleteClusterOperator`.""",
7070
DeprecationWarning,
71-
stacklevel=3,
71+
stacklevel=2,
7272
)
7373
super().__init__(*args, **kwargs)
7474

@@ -84,7 +84,7 @@ def __init__(self, *args, **kwargs):
8484
"""This class is deprecated.
8585
Please use `airflow.providers.google.cloud.operators.dataproc.DataprocScaleClusterOperator`.""",
8686
DeprecationWarning,
87-
stacklevel=3,
87+
stacklevel=2,
8888
)
8989
super().__init__(*args, **kwargs)
9090

@@ -101,7 +101,7 @@ def __init__(self, *args, **kwargs):
101101
Please use
102102
`airflow.providers.google.cloud.operators.dataproc.DataprocSubmitHadoopJobOperator`.""",
103103
DeprecationWarning,
104-
stacklevel=3,
104+
stacklevel=2,
105105
)
106106
super().__init__(*args, **kwargs)
107107

@@ -118,7 +118,7 @@ def __init__(self, *args, **kwargs):
118118
Please use
119119
`airflow.providers.google.cloud.operators.dataproc.DataprocSubmitHiveJobOperator`.""",
120120
DeprecationWarning,
121-
stacklevel=3,
121+
stacklevel=2,
122122
)
123123
super().__init__(*args, **kwargs)
124124

@@ -134,7 +134,7 @@ def __init__(self, *args, **kwargs):
134134
"""This class is deprecated.
135135
Please use `airflow.providers.google.cloud.operators.dataproc.DataprocJobBaseOperator`.""",
136136
DeprecationWarning,
137-
stacklevel=3,
137+
stacklevel=2,
138138
)
139139
super().__init__(*args, **kwargs)
140140

@@ -150,7 +150,7 @@ def __init__(self, *args, **kwargs):
150150
"""This class is deprecated.
151151
Please use `airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPigJobOperator`.""",
152152
DeprecationWarning,
153-
stacklevel=3,
153+
stacklevel=2,
154154
)
155155
super().__init__(*args, **kwargs)
156156

@@ -167,7 +167,7 @@ def __init__(self, *args, **kwargs):
167167
Please use
168168
`airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPySparkJobOperator`.""",
169169
DeprecationWarning,
170-
stacklevel=3,
170+
stacklevel=2,
171171
)
172172
super().__init__(*args, **kwargs)
173173

@@ -184,7 +184,7 @@ def __init__(self, *args, **kwargs):
184184
Please use
185185
`airflow.providers.google.cloud.operators.dataproc.DataprocSubmitSparkJobOperator`.""",
186186
DeprecationWarning,
187-
stacklevel=3,
187+
stacklevel=2,
188188
)
189189
super().__init__(*args, **kwargs)
190190

@@ -201,7 +201,7 @@ def __init__(self, *args, **kwargs):
201201
Please use
202202
`airflow.providers.google.cloud.operators.dataproc.DataprocSubmitSparkSqlJobOperator`.""",
203203
DeprecationWarning,
204-
stacklevel=3,
204+
stacklevel=2,
205205
)
206206
super().__init__(*args, **kwargs)
207207

@@ -220,7 +220,7 @@ def __init__(self, *args, **kwargs):
220220
`airflow.providers.google.cloud.operators.dataproc
221221
.DataprocInstantiateInlineWorkflowTemplateOperator`.""",
222222
DeprecationWarning,
223-
stacklevel=3,
223+
stacklevel=2,
224224
)
225225
super().__init__(*args, **kwargs)
226226

@@ -239,6 +239,6 @@ def __init__(self, *args, **kwargs):
239239
`airflow.providers.google.cloud.operators.dataproc
240240
.DataprocInstantiateWorkflowTemplateOperator`.""",
241241
DeprecationWarning,
242-
stacklevel=3,
242+
stacklevel=2,
243243
)
244244
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)