Skip to content

Commit

Permalink
Dataproc : remove location in favor of region (#23250)
Browse files Browse the repository at this point in the history
  • Loading branch information
eladkal committed Apr 26, 2022
1 parent b4c88f8 commit 5ca1f3b
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 639 deletions.
19 changes: 19 additions & 0 deletions airflow/providers/google/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ Breaking changes

* ``PubSubPullSensor``: Remove ``return_immediately``

* ``DataprocJobSensor``: Remove ``location``. Please use ``region``.

* ``DataprocCreateWorkflowTemplateOperator``: Remove ``location``. Please use ``region``.

* ``DataprocCreateClusterOperator``: Remove ``location``. Please use ``region``.

* ``DataprocSubmitJobOperator``: Remove ``location``. Please use ``region``.

* ``DataprocHook``: Remove ``location`` parameter. Please use ``region``.
affected functions are:
``cancel_job``, ``create_workflow_template``, ``get_batch_client``,
``get_cluster_client``, ``get_job``, ``get_job_client``, ``get_template_client``,
``instantiate_inline_workflow_template``, ``instantiate_workflow_template``,
``submit_job``, ``update_cluster``,``wait_for_job``

* ``DataprocHook``: order of parameters in ``wait_for_job`` function has changed.

* ``DataprocSubmitJobOperator``: order of parameters has changed.

6.8.0
.....

Expand Down
165 changes: 18 additions & 147 deletions airflow/providers/google/cloud/hooks/dataproc.py

Large diffs are not rendered by default.

45 changes: 3 additions & 42 deletions airflow/providers/google/cloud/operators/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,6 @@ class DataprocCreateWorkflowTemplateOperator(BaseOperator):
:param project_id: Optional. The ID of the Google Cloud project the cluster belongs to.
:param region: Required. The Cloud Dataproc region in which to handle the request.
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
:param template: The Dataproc workflow template to create. If a dict is provided,
it must be of the same form as the protobuf message WorkflowTemplate.
:param retry: A retry object used to retry requests. If ``None`` is specified, requests will not be
Expand All @@ -1530,27 +1529,15 @@ def __init__(
self,
*,
template: Dict,
region: Optional[str] = None,
region: str,
project_id: Optional[str] = None,
location: Optional[str] = None,
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
gcp_conn_id: str = "google_cloud_default",
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
):
if region is None:
if location is not None:
warnings.warn(
"Parameter `location` will be deprecated. "
"Please provide value through `region` parameter instead.",
DeprecationWarning,
stacklevel=2,
)
region = location
else:
raise TypeError("missing 1 required keyword argument: 'region'")
super().__init__(**kwargs)
self.region = region
self.template = template
Expand Down Expand Up @@ -1775,7 +1762,6 @@ class DataprocSubmitJobOperator(BaseOperator):
:param project_id: Optional. The ID of the Google Cloud project that the job belongs to.
:param region: Required. The Cloud Dataproc region in which to handle the request.
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
:param job: Required. The job resource.
If a dict is provided, it must be of the same form as the protobuf message
:class:`~google.cloud.dataproc_v1.types.Job`
Expand Down Expand Up @@ -1813,9 +1799,8 @@ def __init__(
self,
*,
job: Dict,
region: str,
project_id: Optional[str] = None,
region: Optional[str] = None,
location: Optional[str] = None,
request_id: Optional[str] = None,
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: Optional[float] = None,
Expand All @@ -1827,17 +1812,6 @@ def __init__(
wait_timeout: Optional[int] = None,
**kwargs,
) -> None:
if region is None:
if location is not None:
warnings.warn(
"Parameter `location` will be deprecated. "
"Please provide value through `region` parameter instead.",
DeprecationWarning,
stacklevel=2,
)
region = location
else:
raise TypeError("missing 1 required keyword argument: 'region'")
super().__init__(**kwargs)
self.project_id = project_id
self.region = region
Expand Down Expand Up @@ -1894,7 +1868,6 @@ class DataprocUpdateClusterOperator(BaseOperator):
:param region: Required. The Cloud Dataproc region in which to handle the request.
:param project_id: Optional. The ID of the Google Cloud project the cluster belongs to.
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
:param cluster_name: Required. The cluster name.
:param cluster: Required. The changes to the cluster.
Expand Down Expand Up @@ -1946,8 +1919,7 @@ def __init__(
cluster: Union[Dict, Cluster],
update_mask: Union[Dict, FieldMask],
graceful_decommission_timeout: Union[Dict, Duration],
region: Optional[str] = None,
location: Optional[str] = None,
region: str,
request_id: Optional[str] = None,
project_id: Optional[str] = None,
retry: Union[Retry, _MethodDefault] = DEFAULT,
Expand All @@ -1957,17 +1929,6 @@ def __init__(
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
):
if region is None:
if location is not None:
warnings.warn(
"Parameter `location` will be deprecated. "
"Please provide value through `region` parameter instead.",
DeprecationWarning,
stacklevel=2,
)
region = location
else:
raise TypeError("missing 1 required keyword argument: 'region'")
super().__init__(**kwargs)
self.project_id = project_id
self.region = region
Expand Down
16 changes: 1 addition & 15 deletions airflow/providers/google/cloud/sensors/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""This module contains a Dataproc Job sensor."""
# pylint: disable=C0302
import time
import warnings
from typing import TYPE_CHECKING, Optional, Sequence

from google.api_core.exceptions import ServerError
Expand All @@ -40,7 +39,6 @@ class DataprocJobSensor(BaseSensorOperator):
:param region: Required. The Cloud Dataproc region in which to handle the request. (templated)
:param project_id: The ID of the google cloud project in which
to create the cluster. (templated)
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request. (templated)
:param gcp_conn_id: The connection ID to use connecting to Google Cloud Platform.
:param wait_timeout: How many seconds wait for job to be ready.
"""
Expand All @@ -52,24 +50,12 @@ def __init__(
self,
*,
dataproc_job_id: str,
region: Optional[str] = None,
region: str,
project_id: Optional[str] = None,
location: Optional[str] = None,
gcp_conn_id: str = 'google_cloud_default',
wait_timeout: Optional[int] = None,
**kwargs,
) -> None:
if region is None:
if location is not None:
warnings.warn(
"Parameter `location` will be deprecated. "
"Please provide value through `region` parameter instead.",
DeprecationWarning,
stacklevel=2,
)
region = location
else:
raise TypeError("missing 1 required keyword argument: 'region'")
super().__init__(**kwargs)
self.project_id = project_id
self.gcp_conn_id = gcp_conn_id
Expand Down

0 comments on commit 5ca1f3b

Please sign in to comment.