Skip to content

Commit

Permalink
Correct typo in GCSObjectsWtihPrefixExistenceSensor (#14179)
Browse files Browse the repository at this point in the history
Rename GCSObjectsWtihPrefixExistenceSensor to GCSObjectsWithPrefixExistenceSensor
  • Loading branch information
morrme committed Feb 12, 2021
1 parent 6dc6339 commit e3bcaa3
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion UPDATING.md
Expand Up @@ -1262,7 +1262,7 @@ The following table shows changes in import paths.
|airflow.contrib.sensors.gcp_transfer_sensor.GCPTransferServiceWaitForJobStatusSensor |airflow.providers.google.cloud.sensors.cloud_storage_transfer_service.DataTransferServiceJobStatusSensor |
|airflow.contrib.sensors.gcs_sensor.GoogleCloudStorageObjectSensor |airflow.providers.google.cloud.sensors.gcs.GCSObjectExistenceSensor |
|airflow.contrib.sensors.gcs_sensor.GoogleCloudStorageObjectUpdatedSensor |airflow.providers.google.cloud.sensors.gcs.GCSObjectUpdateSensor |
|airflow.contrib.sensors.gcs_sensor.GoogleCloudStoragePrefixSensor |airflow.providers.google.cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor |
|airflow.contrib.sensors.gcs_sensor.GoogleCloudStoragePrefixSensor |airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor |
|airflow.contrib.sensors.gcs_sensor.GoogleCloudStorageUploadSessionCompleteSensor |airflow.providers.google.cloud.sensors.gcs.GCSUploadSessionCompleteSensor |
|airflow.contrib.sensors.pubsub_sensor.PubSubPullSensor |airflow.providers.google.cloud.sensors.pubsub.PubSubPullSensor |

Expand Down
8 changes: 4 additions & 4 deletions airflow/contrib/sensors/gcs_sensor.py
Expand Up @@ -21,7 +21,7 @@

from airflow.providers.google.cloud.sensors.gcs import (
GCSObjectExistenceSensor,
GCSObjectsWtihPrefixExistenceSensor,
GCSObjectsWithPrefixExistenceSensor,
GCSObjectUpdateSensor,
GCSUploadSessionCompleteSensor,
)
Expand Down Expand Up @@ -65,16 +65,16 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class GoogleCloudStoragePrefixSensor(GCSObjectsWtihPrefixExistenceSensor):
class GoogleCloudStoragePrefixSensor(GCSObjectsWithPrefixExistenceSensor):
"""
This class is deprecated.
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor`.
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"""This class is deprecated.
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor`.""",
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor`.""",
DeprecationWarning,
stacklevel=3,
)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/BACKPORT_PROVIDER_README.md
Expand Up @@ -605,7 +605,7 @@ in [Naming conventions for provider packages](https://github.com/apache/airflow/
| [cloud.sensors.cloud_storage_transfer_service.CloudDataTransferServiceJobStatusSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py) | [contrib.sensors.gcp_transfer_sensor.GCPTransferServiceWaitForJobStatusSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcp_transfer_sensor.py) |
| [cloud.sensors.gcs.GCSObjectExistenceSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/gcs.py) | [contrib.sensors.gcs_sensor.GoogleCloudStorageObjectSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcs_sensor.py) |
| [cloud.sensors.gcs.GCSObjectUpdateSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/gcs.py) | [contrib.sensors.gcs_sensor.GoogleCloudStorageObjectUpdatedSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcs_sensor.py) |
| [cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/gcs.py) | [contrib.sensors.gcs_sensor.GoogleCloudStoragePrefixSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcs_sensor.py) |
| [cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/gcs.py) | [contrib.sensors.gcs_sensor.GoogleCloudStoragePrefixSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcs_sensor.py) |
| [cloud.sensors.gcs.GCSUploadSessionCompleteSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/gcs.py) | [contrib.sensors.gcs_sensor.GoogleCloudStorageUploadSessionCompleteSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/gcs_sensor.py) |
| [cloud.sensors.pubsub.PubSubPullSensor](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/sensors/pubsub.py) | [contrib.sensors.pubsub_sensor.PubSubPullSensor](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/sensors/pubsub_sensor.py) |

Expand Down
19 changes: 18 additions & 1 deletion airflow/providers/google/cloud/sensors/gcs.py
Expand Up @@ -18,6 +18,7 @@
"""This module contains Google Cloud Storage sensors."""

import os
import warnings
from datetime import datetime
from typing import Callable, List, Optional, Sequence, Set, Union

Expand Down Expand Up @@ -167,7 +168,7 @@ def poke(self, context: dict) -> bool:
return hook.is_updated_after(self.bucket, self.object, self.ts_func(context))


class GCSObjectsWtihPrefixExistenceSensor(BaseSensorOperator):
class GCSObjectsWithPrefixExistenceSensor(BaseSensorOperator):
"""
Checks for the existence of GCS objects at a given prefix, passing matches via XCom.
Expand Down Expand Up @@ -239,6 +240,22 @@ def execute(self, context: dict) -> List[str]:
return self._matches


class GCSObjectsWtihPrefixExistenceSensor(GCSObjectsWithPrefixExistenceSensor):
"""
This class is deprecated.
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"""This class is deprecated.
Please use `airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor`.""",
DeprecationWarning,
stacklevel=3,
)
super().__init__(*args, **kwargs)


def get_time():
"""
This is just a wrapper of datetime.datetime.now to simplify mocking in the
Expand Down
1 change: 1 addition & 0 deletions tests/always/test_project_structure.py
Expand Up @@ -220,6 +220,7 @@ class TestGoogleProviderProjectStructure(unittest.TestCase):
'airflow.providers.google.cloud.operators.compute.ComputeEngineBaseOperator',
'airflow.providers.google.cloud.sensors.gcs.GCSObjectExistenceSensor',
'airflow.providers.google.cloud.sensors.gcs.GCSObjectUpdateSensor',
'airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor',
'airflow.providers.google.cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor',
'airflow.providers.google.cloud.sensors.gcs.GCSUploadSessionCompleteSensor',
}
Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated_classes.py
Expand Up @@ -1416,7 +1416,7 @@
"airflow.contrib.sensors.gcs_sensor.GoogleCloudStorageObjectUpdatedSensor",
),
(
"airflow.providers.google.cloud.sensors.gcs.GCSObjectsWtihPrefixExistenceSensor",
"airflow.providers.google.cloud.sensors.gcs.GCSObjectsWithPrefixExistenceSensor",
"airflow.contrib.sensors.gcs_sensor.GoogleCloudStoragePrefixSensor",
),
(
Expand Down
10 changes: 5 additions & 5 deletions tests/providers/google/cloud/sensors/test_gcs.py
Expand Up @@ -25,7 +25,7 @@
from airflow.models.dag import DAG, AirflowException
from airflow.providers.google.cloud.sensors.gcs import (
GCSObjectExistenceSensor,
GCSObjectsWtihPrefixExistenceSensor,
GCSObjectsWithPrefixExistenceSensor,
GCSObjectUpdateSensor,
GCSUploadSessionCompleteSensor,
ts_function,
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_should_pass_argument_to_hook(self, mock_hook):
class TestGoogleCloudStoragePrefixSensor(TestCase):
@mock.patch("airflow.providers.google.cloud.sensors.gcs.GCSHook")
def test_should_pass_arguments_to_hook(self, mock_hook):
task = GCSObjectsWtihPrefixExistenceSensor(
task = GCSObjectsWithPrefixExistenceSensor(
task_id="task-id",
bucket=TEST_BUCKET,
prefix=TEST_PREFIX,
Expand All @@ -152,7 +152,7 @@ def test_should_pass_arguments_to_hook(self, mock_hook):

@mock.patch("airflow.providers.google.cloud.sensors.gcs.GCSHook")
def test_should_return_false_on_empty_list(self, mock_hook):
task = GCSObjectsWtihPrefixExistenceSensor(
task = GCSObjectsWithPrefixExistenceSensor(
task_id="task-id",
bucket=TEST_BUCKET,
prefix=TEST_PREFIX,
Expand All @@ -166,7 +166,7 @@ def test_should_return_false_on_empty_list(self, mock_hook):

@mock.patch('airflow.providers.google.cloud.sensors.gcs.GCSHook')
def test_execute(self, mock_hook):
task = GCSObjectsWtihPrefixExistenceSensor(
task = GCSObjectsWithPrefixExistenceSensor(
task_id="task-id",
bucket=TEST_BUCKET,
prefix=TEST_PREFIX,
Expand All @@ -190,7 +190,7 @@ def test_execute(self, mock_hook):

@mock.patch('airflow.providers.google.cloud.sensors.gcs.GCSHook')
def test_execute_timeout(self, mock_hook):
task = GCSObjectsWtihPrefixExistenceSensor(
task = GCSObjectsWithPrefixExistenceSensor(
task_id="task-id", bucket=TEST_BUCKET, prefix=TEST_PREFIX, poke_interval=0, timeout=1
)
mock_hook.return_value.list.return_value = []
Expand Down

0 comments on commit e3bcaa3

Please sign in to comment.