From 8c25d9c6bc506700baa85bd5f455bc9083b94677 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Mon, 22 Jan 2024 18:21:27 +0800 Subject: [PATCH] docs(google): add deprecation warning to docstring --- .../providers/google/cloud/hooks/gcs.py | 8 ++++++-- .../providers/google/cloud/sensors/gcs.py | 1 + .../providers/google/cloud/triggers/gcs.py | 20 +++++++++++++++---- tests/google/cloud/sensors/test_gcs.py | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/astronomer/providers/google/cloud/hooks/gcs.py b/astronomer/providers/google/cloud/hooks/gcs.py index e1e708952..8a2bc848e 100644 --- a/astronomer/providers/google/cloud/hooks/gcs.py +++ b/astronomer/providers/google/cloud/hooks/gcs.py @@ -13,13 +13,17 @@ class GCSHookAsync(GoogleBaseHookAsync): - """GCSHookAsync run on the trigger worker, inherits from GoogleBaseHookAsync""" + """GCSHookAsync run on the trigger worker, inherits from GoogleBaseHookAsync + + This class is deprecated and will be removed in 2.0.0. + Use :class: `~airflow.providers.google.cloud.hooks.gcs.GCSAsyncHook` instead + """ def __init__(self, **kwargs: Any): warnings.warn( ( "This class is deprecated and will be removed in 2.0.0." - "Use :class: `~airflow.providers.google.cloud.hooks.gcs.GCSAsyncHook` instead" + "Use `airflow.providers.google.cloud.hooks.gcs.GCSAsyncHook` instead" ), DeprecationWarning, stacklevel=2, diff --git a/astronomer/providers/google/cloud/sensors/gcs.py b/astronomer/providers/google/cloud/sensors/gcs.py index bc8335e17..c5901eddc 100644 --- a/astronomer/providers/google/cloud/sensors/gcs.py +++ b/astronomer/providers/google/cloud/sensors/gcs.py @@ -80,6 +80,7 @@ def __init__( ) super().__init__(*args, deferrable=True, **kwargs) + class GCSUploadSessionCompleteSensorAsync(GCSUploadSessionCompleteSensor): """ This class is deprecated. diff --git a/astronomer/providers/google/cloud/triggers/gcs.py b/astronomer/providers/google/cloud/triggers/gcs.py index 4f3545259..ed0cfdb9e 100644 --- a/astronomer/providers/google/cloud/triggers/gcs.py +++ b/astronomer/providers/google/cloud/triggers/gcs.py @@ -17,6 +17,9 @@ class GCSBlobTrigger(BaseTrigger): """ A trigger that fires and it finds the requested file or folder present in the given bucket. + This class is deprecated and will be removed in 2.0.0. + Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSBlobTrigger` instead + :param bucket: the bucket in the google cloud storage where the objects are residing. :param object_name: the file or folder present in the bucket :param google_cloud_conn_id: reference to the Google Connection @@ -34,7 +37,7 @@ def __init__( warnings.warn( ( "This class is deprecated and will be removed in 2.0.0." - "Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSBlobTrigger` instead" + "Use `airflow.providers.google.cloud.triggers.gcs.GCSBlobTrigger` instead" ), DeprecationWarning, stacklevel=2, @@ -102,6 +105,9 @@ class GCSPrefixBlobTrigger(GCSBlobTrigger): A trigger that fires and it looks for all the objects in the given bucket which matches the given prefix if not found sleep for certain interval and checks again. + This class is deprecated and will be removed in 2.0.0. + Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSPrefixBlobTrigger` instead + :param bucket: the bucket in the google cloud storage where the objects are residing. :param prefix: The prefix of the blob_names to match in the Google cloud storage bucket :param google_cloud_conn_id: reference to the Google Connection @@ -119,7 +125,7 @@ def __init__( warnings.warn( ( "This class is deprecated and will be removed in 2.0.0." - "Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSPrefixBlobTrigger` instead" + "Use `airflow.providers.google.cloud.triggers.gcs.GCSPrefixBlobTrigger` instead" ), DeprecationWarning, stacklevel=2, @@ -185,6 +191,9 @@ class GCSUploadSessionTrigger(GCSPrefixBlobTrigger): bucket and returns Trigger Event if the inactivity period has passed with no increase in the number of objects. + This class is deprecated and will be removed in 2.0.0. + Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSUploadSessionTrigger` instead + :param bucket: The Google Cloud Storage bucket where the objects are. expected. :param prefix: The name of the prefix to check in the Google cloud @@ -219,7 +228,7 @@ def __init__( warnings.warn( ( "This class is deprecated and will be removed in 2.0.0." - "Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSUploadSessionTrigger` instead" + "Use `airflow.providers.google.cloud.triggers.gcs.GCSUploadSessionTrigger` instead" ), DeprecationWarning, stacklevel=2, @@ -351,6 +360,9 @@ class GCSCheckBlobUpdateTimeTrigger(BaseTrigger): """ A trigger that makes an async call to GCS to check whether the object is updated in a bucket. + This class is deprecated and will be removed in 2.0.0. + Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSCheckBlobUpdateTimeTrigger` instead + :param bucket: google cloud storage bucket name cloud storage where the objects are residing. :param object_name: the file or folder present in the bucket :param ts: datetime object @@ -371,7 +383,7 @@ def __init__( warnings.warn( ( "This class is deprecated and will be removed in 2.0.0." - "Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSUploadSessionTrigger` instead" + "Use :class: `~airflow.providers.google.cloud.triggers.gcs.GCSCheckBlobUpdateTimeTrigger` instead" ), DeprecationWarning, stacklevel=2, diff --git a/tests/google/cloud/sensors/test_gcs.py b/tests/google/cloud/sensors/test_gcs.py index efb627caa..8b284258c 100644 --- a/tests/google/cloud/sensors/test_gcs.py +++ b/tests/google/cloud/sensors/test_gcs.py @@ -1,4 +1,3 @@ - from airflow.providers.google.cloud.sensors.gcs import ( GCSObjectExistenceSensor, GCSObjectsWithPrefixExistenceSensor, @@ -47,6 +46,7 @@ def test_init(self): assert isinstance(task, GCSObjectsWithPrefixExistenceSensor) assert task.deferrable is True + class TestGCSUploadSessionCompleteSensorAsync: def test_init(self): task = GCSUploadSessionCompleteSensorAsync(