Skip to content

Commit 470b2a7

Browse files
ratb3rtmik-laj
authored andcommitted
[AIRFLOW-5741] Move Cloud Natural Language to providers (#6421)
1 parent bd3aeb2 commit 470b2a7

File tree

14 files changed

+63
-56
lines changed

14 files changed

+63
-56
lines changed

UPDATING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ The following table shows changes in import paths.
221221
|airflow.contrib.hooks.gcp_function_hook.GcfHook |airflow.gcp.hooks.functions.CloudFunctionsHook |
222222
|airflow.contrib.hooks.gcp_kms_hook.GoogleCloudKMSHook |airflow.gcp.hooks.kms.GoogleCloudKMSHook |
223223
|airflow.contrib.hooks.gcp_mlengine_hook.MLEngineHook |airflow.gcp.hooks.mlengine.MLEngineHook |
224-
|airflow.contrib.hooks.gcp_natural_language_hook.CloudNaturalLanguageHook |airflow.gcp.hooks.natural_language.CloudNaturalLanguageHook |
224+
|airflow.contrib.hooks.gcp_natural_language_hook.CloudNaturalLanguageHook |airflow.providers.google.cloud.hooks.natural_language.CloudNaturalLanguageHook |
225225
|airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook |airflow.gcp.hooks.pubsub.PubSubHook |
226226
|airflow.contrib.hooks.gcp_spanner_hook.CloudSpannerHook |airflow.gcp.hooks.spanner.SpannerHook |
227227
|airflow.contrib.hooks.gcp_speech_to_text_hook.GCPSpeechToTextHook |airflow.gcp.hooks.speech_to_text.GCPSpeechToTextHook |
@@ -315,10 +315,10 @@ The following table shows changes in import paths.
315315
|airflow.contrib.operators.gcp_dlp_operator.CloudDLPUpdateStoredInfoTypeOperator |airflow.gcp.operators.dlp.CloudDLPUpdateStoredInfoTypeOperator |
316316
|airflow.contrib.operators.gcp_function_operator.GcfFunctionDeleteOperator |airflow.gcp.operators.functions.GcfFunctionDeleteOperator |
317317
|airflow.contrib.operators.gcp_function_operator.GcfFunctionDeployOperator |airflow.gcp.operators.functions.GcfFunctionDeployOperator |
318-
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeEntitiesOperator |airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator |
319-
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeEntitySentimentOperator |airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitySentimentOperator |
320-
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeSentimentOperator |airflow.gcp.operators.natural_language.CloudLanguageAnalyzeSentimentOperator |
321-
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageClassifyTextOperator |airflow.gcp.operators.natural_language.CloudLanguageClassifyTextOperator |
318+
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeEntitiesOperator |airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator |
319+
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeEntitySentimentOperator |airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitySentimentOperator |
320+
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageAnalyzeSentimentOperator |airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeSentimentOperator |
321+
|airflow.contrib.operators.gcp_natural_language_operator.CloudLanguageClassifyTextOperator |airflow.providers.google.cloud.operators.natural_language.CloudLanguageClassifyTextOperator |
322322
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeleteOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDatabaseDeleteOperator |
323323
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeployOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDatabaseDeployOperator |
324324
|airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseQueryOperator |airflow.gcp.operators.spanner.CloudSpannerInstanceDatabaseQueryOperator |

airflow/contrib/hooks/gcp_natural_language_hook.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919
"""
20-
This module is deprecated. Please use `airflow.gcp.hooks.natural_language`.
20+
This module is deprecated. Please use `airflow.providers.google.cloud.hooks.natural_language`.
2121
"""
2222

2323
import warnings
2424

2525
# pylint: disable=unused-import
26-
from airflow.gcp.hooks.natural_language import CloudNaturalLanguageHook # noqa
26+
from airflow.providers.google.cloud.hooks.natural_language import CloudNaturalLanguageHook # noqa
2727

2828
warnings.warn(
29-
"This module is deprecated. Please use `airflow.gcp.hooks.natural_language`",
29+
"This module is deprecated. Please use `airflow.providers.google.cloud.hooks.natural_language`",
3030
DeprecationWarning, stacklevel=2
3131
)

airflow/contrib/operators/gcp_natural_language_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919
"""
20-
This module is deprecated. Please use `airflow.gcp.operators.natural_language`.
20+
This module is deprecated. Please use `airflow.providers.google.cloud.operators.natural_language`.
2121
"""
2222

2323
import warnings
2424

2525
# pylint: disable=unused-import
26-
from airflow.gcp.operators.natural_language import ( # noqa
26+
from airflow.providers.google.cloud.operators.natural_language import ( # noqa
2727
CloudLanguageAnalyzeEntitiesOperator, CloudLanguageAnalyzeEntitySentimentOperator,
2828
CloudLanguageAnalyzeSentimentOperator, CloudLanguageClassifyTextOperator,
2929
)
3030

3131
warnings.warn(
32-
"This module is deprecated. Please use `airflow.gcp.operators.natural_language`",
32+
"This module is deprecated. Please use `airflow.providers.google.cloud.operators.natural_language`",
3333
DeprecationWarning, stacklevel=2
3434
)

airflow/gcp/example_dags/example_natural_language.py renamed to airflow/providers/google/cloud/example_dags/example_natural_language.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525

2626
import airflow
2727
from airflow import models
28-
from airflow.gcp.operators.natural_language import (
28+
from airflow.operators.bash_operator import BashOperator
29+
from airflow.providers.google.cloud.operators.natural_language import (
2930
CloudLanguageAnalyzeEntitiesOperator, CloudLanguageAnalyzeEntitySentimentOperator,
3031
CloudLanguageAnalyzeSentimentOperator, CloudLanguageClassifyTextOperator,
3132
)
32-
from airflow.operators.bash_operator import BashOperator
3333

3434
# [START howto_operator_gcp_natural_language_document_text]
35-
TEXT = """
36-
Airflow is a platform to programmatically author, schedule and monitor workflows.
35+
TEXT = """Airflow is a platform to programmatically author, schedule and monitor workflows.
3736
3837
Use Airflow to author workflows as Directed Acyclic Graphs (DAGs) of tasks. The Airflow scheduler executes
3938
your tasks on an array of workers while following the specified dependencies. Rich command line utilities

airflow/gcp/operators/natural_language.py renamed to airflow/providers/google/cloud/operators/natural_language.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
from google.cloud.language_v1.types import Document
2727
from google.protobuf.json_format import MessageToDict
2828

29-
from airflow.gcp.hooks.natural_language import CloudNaturalLanguageHook
3029
from airflow.models import BaseOperator
30+
from airflow.providers.google.cloud.hooks.natural_language import CloudNaturalLanguageHook
3131

3232
MetaData = Sequence[Tuple[str, str]]
3333

docs/autoapi_templates/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ All operators are in the following packages:
8080

8181
airflow/providers/google/marketing_platform/operators/index
8282

83+
airflow/providers/google/cloud/operators/index
84+
8385
airflow/providers/google/marketing_platform/sensors/index
8486

8587

@@ -110,6 +112,8 @@ All hooks are in the following packages:
110112

111113
airflow/providers/google/marketing_platform/hooks/index
112114

115+
airflow/providers/google/cloud/hooks/index
116+
113117

114118
Executors
115119
---------

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@
217217
'_api/airflow/providers/google/cloud/example_dags',
218218
'_api/airflow/providers/google/marketing_platform/index.rst',
219219
'_api/airflow/providers/google/marketing_platform/example_dags',
220+
'_api/airflow/providers/google/cloud/index.rst',
221+
'_api/airflow/providers/google/cloud/example_dags',
220222
'autoapi_templates',
221223
'howto/operator/gcp/_partials',
222224
]

docs/howto/operator/gcp/natural_language.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ representing text.
4848

4949
Here is an example of document with text provided as a string:
5050

51-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
51+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
5252
:language: python
5353
:start-after: [START howto_operator_gcp_natural_language_document_text]
5454
:end-before: [END howto_operator_gcp_natural_language_document_text]
5555

5656
In addition to supplying string, a document can refer to content stored in Google Cloud Storage.
5757

58-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
58+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
5959
:language: python
6060
:start-after: [START howto_operator_gcp_natural_language_document_gcs]
6161
:end-before: [END howto_operator_gcp_natural_language_document_gcs]
@@ -68,20 +68,20 @@ Analyzing Entities
6868
Entity Analysis inspects the given text for known entities (proper nouns such as
6969
public figures, landmarks, etc.), and returns information about those entities.
7070
Entity analysis is performed with the
71-
:class:`~airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator` operator.
71+
:class:`~airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator` operator.
7272

73-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
73+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
7474
:language: python
7575
:dedent: 4
7676
:start-after: [START howto_operator_gcp_natural_language_analyze_entities]
7777
:end-before: [END howto_operator_gcp_natural_language_analyze_entities]
7878

7979
You can use :ref:`Jinja templating <jinja-templating>` with
80-
:template-fields:`airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator`
80+
:template-fields:`airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator`
8181
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
8282
to be used by other operators.
8383

84-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
84+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
8585
:language: python
8686
:dedent: 4
8787
:start-after: [START howto_operator_gcp_natural_language_analyze_entities_result]
@@ -95,21 +95,21 @@ Analyzing Entity Sentiment
9595
Sentiment Analysis inspects the given text and identifies the prevailing
9696
emotional opinion within the text, especially to determine a writer's attitude
9797
as positive, negative, or neutral. Sentiment analysis is performed through
98-
the :class:`~airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitySentimentOperator`
98+
the :class:`~airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitySentimentOperator`
9999
operator.
100100

101-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
101+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
102102
:language: python
103103
:dedent: 4
104104
:start-after: [START howto_operator_gcp_natural_language_analyze_entity_sentiment]
105105
:end-before: [END howto_operator_gcp_natural_language_analyze_entity_sentiment]
106106

107107
You can use :ref:`Jinja templating <jinja-templating>` with
108-
:template-fields:`airflow.gcp.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator`
108+
:template-fields:`airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeEntitiesOperator`
109109
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
110110
to be used by other operators.
111111

112-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
112+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
113113
:language: python
114114
:dedent: 4
115115
:start-after: [START howto_operator_gcp_natural_language_analyze_entity_sentiment_result]
@@ -124,21 +124,21 @@ Sentiment Analysis inspects the given text and identifies the prevailing
124124
emotional opinion within the text, especially to determine a writer's
125125
attitude as positive, negative, or neutral. Sentiment analysis is performed
126126
through the
127-
:class:`~airflow.gcp.operators.natural_language.CloudLanguageAnalyzeSentimentOperator`
127+
:class:`~airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeSentimentOperator`
128128
operator.
129129

130-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
130+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
131131
:language: python
132132
:dedent: 4
133133
:start-after: [START howto_operator_gcp_natural_language_analyze_sentiment]
134134
:end-before: [END howto_operator_gcp_natural_language_analyze_sentiment]
135135

136136
You can use :ref:`Jinja templating <jinja-templating>` with
137-
:template-fields:`airflow.gcp.operators.natural_language.CloudLanguageAnalyzeSentimentOperator`
137+
:template-fields:`airflow.providers.google.cloud.operators.natural_language.CloudLanguageAnalyzeSentimentOperator`
138138
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
139139
to be used by other operators.
140140

141-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
141+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
142142
:language: python
143143
:dedent: 4
144144
:start-after: [START howto_operator_gcp_natural_language_analyze_sentiment_result]
@@ -152,21 +152,21 @@ Classifying Content
152152
Content Classification analyzes a document and returns a list of content
153153
categories that apply to the text found in the document. To classify the
154154
content in a document, use the
155-
:class:`~airflow.gcp.operators.natural_language.CloudLanguageClassifyTextOperator`
155+
:class:`~airflow.providers.google.cloud.operators.natural_language.CloudLanguageClassifyTextOperator`
156156
operator.
157157

158-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
158+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
159159
:language: python
160160
:dedent: 4
161161
:start-after: [START howto_operator_gcp_natural_language_analyze_classify_text]
162162
:end-before: [END howto_operator_gcp_natural_language_analyze_classify_text]
163163

164164
You can use :ref:`Jinja templating <jinja-templating>` with
165-
:template-fields:`airflow.gcp.operators.natural_language.CloudLanguageClassifyTextOperator`
165+
:template-fields:`airflow.providers.google.cloud.operators.natural_language.CloudLanguageClassifyTextOperator`
166166
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
167167
to be used by other operators.
168168

169-
.. exampleinclude:: ../../../../airflow/gcp/example_dags/example_natural_language.py
169+
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_natural_language.py
170170
:language: python
171171
:dedent: 4
172172
:start-after: [START howto_operator_gcp_natural_language_analyze_classify_text_result]

docs/operators-and-hooks-ref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ These integrations allow you to perform various operations within the Google Clo
601601

602602
* - `Natural Language <https://cloud.google.com/natural-language/>`__
603603
- :doc:`How to use <howto/operator/gcp/natural_language>`
604-
- :mod:`airflow.gcp.hooks.natural_language`
605-
- :mod:`airflow.gcp.operators.natural_language`
604+
- :mod:`airflow.providers.google.cloud.hooks.natural_language`
605+
- :mod:`airflow.providers.google.cloud.operators.natural_language`
606606
-
607607

608608
* - `Cloud Pub/Sub <https://cloud.google.com/pubsub/>`__

0 commit comments

Comments
 (0)