Skip to content

Commit

Permalink
BigtableCreateInstanceOperator & BigtableHook.create_instance Rem…
Browse files Browse the repository at this point in the history
…ove `replica_cluster_id`, `replica_cluster_zone`. (#23251)
  • Loading branch information
eladkal committed Apr 26, 2022
1 parent a9ab02f commit 434ab5a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 37 deletions.
4 changes: 4 additions & 0 deletions airflow/providers/google/CHANGELOG.rst
Expand Up @@ -34,6 +34,10 @@ Breaking changes
For more information, see `Deprecation and sunset <https://developers.google.com/google-ads/api/docs/sunset-dates>`_
and `Upgrading to the newest version <https://developers.google.com/google-ads/api/docs/version-migration>`_

* ``BigtableCreateInstanceOperator`` Remove ``replica_cluster_id``, ``replica_cluster_zone``. Please use ``replica_clusters``.

* ``BigtableHook.create_instance``: Remove ``replica_cluster_id``, ``replica_cluster_zone``. Please use ``replica_clusters``.

* ``GoogleDisplayVideo360CreateReportOperator``: remove ``params``. Please use ``parameters``

* ``FacebookAdsReportToGcsOperator``: remove ``params``. Please use ``parameters``
Expand Down
18 changes: 0 additions & 18 deletions airflow/providers/google/cloud/hooks/bigtable.py
Expand Up @@ -17,7 +17,6 @@
# under the License.
"""This module contains a Google Cloud Bigtable Hook."""
import enum
import warnings
from typing import Dict, List, Optional, Sequence, Union

from google.cloud.bigtable import Client
Expand Down Expand Up @@ -106,8 +105,6 @@ def create_instance(
main_cluster_zone: str,
project_id: str,
replica_clusters: Optional[List[Dict[str, str]]] = None,
replica_cluster_id: Optional[str] = None,
replica_cluster_zone: Optional[str] = None,
instance_display_name: Optional[str] = None,
instance_type: enums.Instance.Type = enums.Instance.Type.TYPE_UNSPECIFIED,
instance_labels: Optional[Dict] = None,
Expand All @@ -128,9 +125,6 @@ def create_instance(
:param replica_clusters: (optional) A list of replica clusters for the new
instance. Each cluster dictionary contains an id and a zone.
Example: [{"id": "replica-1", "zone": "us-west1-a"}]
:param replica_cluster_id: (deprecated) The ID for replica cluster for the new
instance.
:param replica_cluster_zone: (deprecated) The zone for replica cluster.
:param instance_type: (optional) The type of the instance.
:param instance_display_name: (optional) Human-readable name of the instance.
Defaults to ``instance_id``.
Expand Down Expand Up @@ -160,18 +154,6 @@ def create_instance(
if instance_type != enums.Instance.Type.DEVELOPMENT and cluster_nodes:
cluster_kwargs["serve_nodes"] = cluster_nodes
clusters = [instance.cluster(**cluster_kwargs)]
if replica_cluster_id and replica_cluster_zone:
warnings.warn(
"The replica_cluster_id and replica_cluster_zone parameter have been deprecated."
"You should pass the replica_clusters parameter.",
DeprecationWarning,
stacklevel=2,
)
clusters.append(
instance.cluster(
replica_cluster_id, replica_cluster_zone, cluster_nodes, cluster_storage_type
)
)
if replica_clusters:
for replica_cluster in replica_clusters:
if "id" in replica_cluster and "zone" in replica_cluster:
Expand Down
9 changes: 0 additions & 9 deletions airflow/providers/google/cloud/operators/bigtable.py
Expand Up @@ -65,9 +65,6 @@ class BigtableCreateInstanceOperator(BaseOperator, BigtableValidationMixin):
:param replica_clusters: (optional) A list of replica clusters for the new
instance. Each cluster dictionary contains an id and a zone.
Example: [{"id": "replica-1", "zone": "us-west1-a"}]
:param replica_cluster_id: (deprecated) The ID for replica cluster for the new
instance.
:param replica_cluster_zone: (deprecated) The zone for replica cluster.
:param instance_type: (optional) The type of the instance.
:param instance_display_name: (optional) Human-readable name of the instance. Defaults
to ``instance_id``.
Expand Down Expand Up @@ -105,8 +102,6 @@ def __init__(
main_cluster_zone: str,
project_id: Optional[str] = None,
replica_clusters: Optional[List[Dict[str, str]]] = None,
replica_cluster_id: Optional[str] = None,
replica_cluster_zone: Optional[str] = None,
instance_display_name: Optional[str] = None,
instance_type: Optional[enums.Instance.Type] = None,
instance_labels: Optional[Dict] = None,
Expand All @@ -122,8 +117,6 @@ def __init__(
self.main_cluster_id = main_cluster_id
self.main_cluster_zone = main_cluster_zone
self.replica_clusters = replica_clusters
self.replica_cluster_id = replica_cluster_id
self.replica_cluster_zone = replica_cluster_zone
self.instance_display_name = instance_display_name
self.instance_type = instance_type
self.instance_labels = instance_labels
Expand Down Expand Up @@ -156,8 +149,6 @@ def execute(self, context: 'Context') -> None:
main_cluster_id=self.main_cluster_id,
main_cluster_zone=self.main_cluster_zone,
replica_clusters=self.replica_clusters,
replica_cluster_id=self.replica_cluster_id,
replica_cluster_zone=self.replica_cluster_zone,
instance_display_name=self.instance_display_name,
instance_type=self.instance_type,
instance_labels=self.instance_labels,
Expand Down
6 changes: 2 additions & 4 deletions tests/providers/google/cloud/hooks/test_bigtable.py
Expand Up @@ -313,8 +313,7 @@ def test_create_instance_with_one_replica_cluster_production(
instance_id=CBT_INSTANCE,
main_cluster_id=CBT_CLUSTER,
main_cluster_zone=CBT_ZONE,
replica_cluster_id=CBT_REPLICA_CLUSTER_ID,
replica_cluster_zone=CBT_REPLICA_CLUSTER_ZONE,
replica_clusters=[{"id": CBT_REPLICA_CLUSTER_ID, "zone": CBT_REPLICA_CLUSTER_ZONE}],
cluster_nodes=1,
cluster_storage_type=enums.StorageType.SSD,
project_id=GCP_PROJECT_ID_HOOK_UNIT_TEST,
Expand Down Expand Up @@ -357,8 +356,7 @@ def test_create_instance_with_one_replica_cluster_development(
instance_id=CBT_INSTANCE,
main_cluster_id=CBT_CLUSTER,
main_cluster_zone=CBT_ZONE,
replica_cluster_id=CBT_REPLICA_CLUSTER_ID,
replica_cluster_zone=CBT_REPLICA_CLUSTER_ZONE,
replica_clusters=[{"id": CBT_REPLICA_CLUSTER_ID, "zone": CBT_REPLICA_CLUSTER_ZONE}],
cluster_nodes=1,
cluster_storage_type=enums.StorageType.SSD,
project_id=GCP_PROJECT_ID_HOOK_UNIT_TEST,
Expand Down
6 changes: 0 additions & 6 deletions tests/providers/google/cloud/operators/test_bigtable.py
Expand Up @@ -163,8 +163,6 @@ def test_different_error_reraised(self, mock_hook):
main_cluster_zone=CLUSTER_ZONE,
project_id=PROJECT_ID,
replica_clusters=None,
replica_cluster_id=None,
replica_cluster_zone=None,
timeout=None,
)

Expand Down Expand Up @@ -196,8 +194,6 @@ def test_create_instance_that_doesnt_exists(self, mock_hook):
main_cluster_zone=CLUSTER_ZONE,
project_id=PROJECT_ID,
replica_clusters=None,
replica_cluster_id=None,
replica_cluster_zone=None,
timeout=None,
)

Expand Down Expand Up @@ -230,8 +226,6 @@ def test_create_instance_with_replicas_that_doesnt_exists(self, mock_hook):
main_cluster_zone=CLUSTER_ZONE,
project_id=PROJECT_ID,
replica_clusters=REPLICATE_CLUSTERS,
replica_cluster_id=None,
replica_cluster_zone=None,
timeout=None,
)

Expand Down

0 comments on commit 434ab5a

Please sign in to comment.