From 50ec31441cc1114bccfdeb13bb7092d25f2d147a Mon Sep 17 00:00:00 2001 From: eladkal <45845474+eladkal@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:55:58 +0300 Subject: [PATCH] `BigtableCreateInstanceOperator` & `BigtableHook.create_instance` Remove `replica_cluster_id`, `replica_cluster_zone`. --- airflow/providers/google/CHANGELOG.rst | 4 ++++ .../providers/google/cloud/hooks/bigtable.py | 18 ------------------ .../google/cloud/operators/bigtable.py | 9 --------- .../google/cloud/hooks/test_bigtable.py | 6 ++---- .../google/cloud/operators/test_bigtable.py | 6 ------ 5 files changed, 6 insertions(+), 37 deletions(-) diff --git a/airflow/providers/google/CHANGELOG.rst b/airflow/providers/google/CHANGELOG.rst index 9cb29093ec936..3a573e7bd3406 100644 --- a/airflow/providers/google/CHANGELOG.rst +++ b/airflow/providers/google/CHANGELOG.rst @@ -34,6 +34,10 @@ Breaking changes For more information, see `Deprecation and sunset `_ and `Upgrading to the newest version `_ +* ``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`` diff --git a/airflow/providers/google/cloud/hooks/bigtable.py b/airflow/providers/google/cloud/hooks/bigtable.py index 1feccd37f3a27..e43e03f6fcf5e 100644 --- a/airflow/providers/google/cloud/hooks/bigtable.py +++ b/airflow/providers/google/cloud/hooks/bigtable.py @@ -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 @@ -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, @@ -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``. @@ -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: diff --git a/airflow/providers/google/cloud/operators/bigtable.py b/airflow/providers/google/cloud/operators/bigtable.py index 7520a655ca285..c763db375fc27 100644 --- a/airflow/providers/google/cloud/operators/bigtable.py +++ b/airflow/providers/google/cloud/operators/bigtable.py @@ -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``. @@ -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, @@ -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 @@ -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, diff --git a/tests/providers/google/cloud/hooks/test_bigtable.py b/tests/providers/google/cloud/hooks/test_bigtable.py index 797e62bdf6fcd..86a54494ee6f8 100644 --- a/tests/providers/google/cloud/hooks/test_bigtable.py +++ b/tests/providers/google/cloud/hooks/test_bigtable.py @@ -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, @@ -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, diff --git a/tests/providers/google/cloud/operators/test_bigtable.py b/tests/providers/google/cloud/operators/test_bigtable.py index 0a3bf31ad5869..27293d901e12b 100644 --- a/tests/providers/google/cloud/operators/test_bigtable.py +++ b/tests/providers/google/cloud/operators/test_bigtable.py @@ -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, ) @@ -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, ) @@ -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, )