Skip to content

Commit 40add26

Browse files
authored
Remove almost all references to airflow.contrib (#9559)
1 parent ae171f2 commit 40add26

11 files changed

Lines changed: 22 additions & 26 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ repos:
6969
- --fuzzy-match-generates-todo
7070
- id: insert-license
7171
name: Add license for all JINJA template files
72-
files: "^airflow/www/templates/.*\\.html$|^docs/templates/.*\\.html$|^airflow/contrib/plugins/\
73-
metastore_browser/templates/.*\\.html$|.*\\.jinja2"
72+
files: "^airflow/www/templates/.*\\.html$|^docs/templates/.*\\.html$.*\\.jinja2"
7473
exclude: ^\.github/.*$
7574
args:
7675
- --comment-style
@@ -296,7 +295,6 @@ metastore_browser/templates/.*\\.html$|.*\\.jinja2"
296295
^airflow/operators/.*$|
297296
^airflow/sensors/.*$|
298297
^airflow/providers/.*$|
299-
^airflow/contrib/.*$|
300298
^backport_packages/.*$
301299
- id: base-operator
302300
language: pygrep
@@ -309,8 +307,7 @@ metastore_browser/templates/.*\\.html$|.*\\.jinja2"
309307
^airflow/hooks/.*$|
310308
^airflow/operators/.*$|
311309
^airflow/sensors/.*$|
312-
^airflow/providers/.*\.py$|
313-
^airflow/contrib/.*\.py$
310+
^airflow/providers/.*\.py$
314311
- id: provide-create-sessions
315312
language: pygrep
316313
name: To avoid import cycles make sure provide_session and create_session are imported from

airflow/contrib/operators/gcp_dlp_operator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
class CloudDLPDeleteDlpJobOperator(CloudDLPDeleteDLPJobOperator):
4545
"""
4646
This class is deprecated.
47-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPDeleteDLPJobOperator`.
47+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPDeleteDLPJobOperator`.
4848
"""
4949

5050
def __init__(self, *args, **kwargs):
5151
warnings.warn(
5252
"""This class is deprecated.
53-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPDeleteDLPJobOperator`.""",
53+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPDeleteDLPJobOperator`.""",
5454

5555
DeprecationWarning, stacklevel=3
5656
)
@@ -60,13 +60,13 @@ def __init__(self, *args, **kwargs):
6060
class CloudDLPGetDlpJobOperator(CloudDLPGetDLPJobOperator):
6161
"""
6262
This class is deprecated.
63-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPGetDLPJobOperator`.
63+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPGetDLPJobOperator`.
6464
"""
6565

6666
def __init__(self, *args, **kwargs):
6767
warnings.warn(
6868
"""This class is deprecated.
69-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPGetDLPJobOperator`.""",
69+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPGetDLPJobOperator`.""",
7070
DeprecationWarning, stacklevel=3
7171
)
7272
super().__init__(*args, **kwargs)
@@ -75,13 +75,13 @@ def __init__(self, *args, **kwargs):
7575
class CloudDLPGetJobTripperOperator(CloudDLPGetDLPJobTriggerOperator):
7676
"""
7777
This class is deprecated.
78-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPGetDLPJobTriggerOperator`.
78+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPGetDLPJobTriggerOperator`.
7979
"""
8080

8181
def __init__(self, *args, **kwargs):
8282
warnings.warn(
8383
"""This class is deprecated.
84-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPGetDLPJobTriggerOperator`.""",
84+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPGetDLPJobTriggerOperator`.""",
8585
DeprecationWarning, stacklevel=3
8686
)
8787
super().__init__(*args, **kwargs)
@@ -90,13 +90,13 @@ def __init__(self, *args, **kwargs):
9090
class CloudDLPListDlpJobsOperator(CloudDLPListDLPJobsOperator):
9191
"""
9292
This class is deprecated.
93-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPListDLPJobsOperator`.
93+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPListDLPJobsOperator`.
9494
"""
9595

9696
def __init__(self, *args, **kwargs):
9797
warnings.warn(
9898
"""This class is deprecated.
99-
Please use `airflow.contrib.operators.gcp_dlp_operator.CloudDLPListDLPJobsOperator`.""",
99+
Please use `airflow.providers.google.cloud.operators.dlp.CloudDLPListDLPJobsOperator`.""",
100100
DeprecationWarning, stacklevel=3
101101
)
102102
super().__init__(*args, **kwargs)

airflow/providers/amazon/aws/hooks/sagemaker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ def get_log_conn(self):
250250
def log_stream(self, log_group, stream_name, start_time=0, skip=0):
251251
"""
252252
This method is deprecated.
253-
Please use :py:meth:`airflow.contrib.hooks.AwsLogsHook.get_log_events` instead.
253+
Please use
254+
:py:meth:`airflow.providers.amazon.aws.hooks.logs.AwsLogsHook.get_log_events` instead.
254255
"""
255256
warnings.warn("Method `log_stream` has been deprecated. "
256-
"Please use `airflow.contrib.hooks.AwsLogsHook.get_log_events` instead.",
257+
"Please use "
258+
"`airflow.providers.amazon.aws.hooks.logs.AwsLogsHook.get_log_events` instead.",
257259
category=DeprecationWarning,
258260
stacklevel=2)
259261

airflow/providers/google/cloud/hooks/vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def create_reference_image(
385385
) -> str:
386386
"""
387387
For the documentation see:
388-
:py:class:`~airflow.contrib.operators.gcp_vision_operator.CloudVisionReferenceImageCreateOperator`
388+
:py:class:`~airflow.providers.google.cloud.operators.vision.CloudVisionCreateReferenceImageOperator`
389389
"""
390390
client = self.get_conn()
391391
self.log.info('Creating ReferenceImage')

airflow/providers/google/cloud/transfers/s3_to_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def execute(self, context):
214214
return files
215215

216216
# Following functionality may be better suited in
217-
# airflow/contrib/hooks/gcs.py
217+
# airflow/providers/google/cloud/hooks/gcs.py
218218
@staticmethod
219219
def _gcs_object_is_directory(bucket):
220220
_, blob = _parse_gcs_url(bucket)

airflow/providers/google/cloud/utils/mlengine_prediction_summary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
The summary will have an additional key, 'count', to represent the
3737
total number of instances, so the keys shouldn't include 'count'.
3838
# Usage example:
39+
from airflow.providers.google.cloud.operators.dataflow import DataflowCreatePythonJobOperator
3940
def get_metric_fn():
4041
import math # all imports must be outside of the function to be passed.
4142
def metric_fn(inst):
@@ -48,7 +49,7 @@ def metric_fn(inst):
4849
return (log_loss, squared_err)
4950
return metric_fn
5051
metric_fn_encoded = base64.b64encode(dill.dumps(get_metric_fn(), recurse=True))
51-
airflow.contrib.operators.DataFlowPythonOperator(
52+
DataflowCreatePythonJobOperator(
5253
task_id="summary-prediction",
5354
py_options=["-m"],
5455
py_file="airflow.providers.google.cloud.utils.mlengine_prediction_summary",

docs/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,6 @@
500500
# A list of patterns to ignore when finding files
501501
autoapi_ignore = [
502502
'*/airflow/kubernetes/kubernetes_request_factory/*',
503-
'*/airflow/contrib/sensors/*',
504-
'*/airflow/contrib/hooks/*',
505-
'*/airflow/contrib/operators/*',
506503
'*/_internal*',
507504
'*/node_modules/*',
508505
'*/migrations/*',

docs/exts/docroles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def template_field_role(app,
7575
7676
Sample usage::
7777
78-
:template-fields:
79-
`airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeSentimentOperator`
78+
:template-fields:`airflow.operators.bash.BashOperator`
8079
8180
For further information look at:
8281

docs/operators-and-hooks-ref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ All hooks are based on :class:`airflow.providers.yandex.hooks.yandex.YandexCloud
10901090

10911091
.. note::
10921092
You can learn how to use Yandex.Cloud integrations by analyzing the
1093-
`example DAG <https://github.com/apache/airflow/tree/master/airflow/contrib/example_dags/example_yandexcloud_dataproc.py>`_
1093+
`example DAG <https://github.com/apache/airflow/blob/master/airflow/providers/yandex/example_dags/example_yandexcloud_dataproc.py>`_
10941094

10951095
Service operators and hooks
10961096
'''''''''''''''''''''''''''

tests/providers/ftp/hooks/test_ftp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import unittest
2121
from unittest import mock
2222

23-
from airflow.contrib.hooks import ftp_hook as fh
23+
from airflow.providers.ftp.hooks import ftp as fh
2424

2525

2626
class TestFTPHook(unittest.TestCase):

0 commit comments

Comments
 (0)