Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated modules from Amazon provider package #25609

Merged
merged 6 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_athena_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.athena import AWSAthenaHook # noqa
from airflow.providers.amazon.aws.hooks.athena import AthenaHook as AWSAthenaHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.athena`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_datasync_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.datasync import AWSDataSyncHook # noqa
from airflow.providers.amazon.aws.hooks.datasync import DataSyncHook as AWSDataSyncHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.datasync`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_dynamodb_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.dynamodb import AwsDynamoDBHook # noqa
from airflow.providers.amazon.aws.hooks.dynamodb import DynamoDBHook as AwsDynamoDBHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.dynamodb`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_firehose_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.kinesis import AwsFirehoseHook # noqa
from airflow.providers.amazon.aws.hooks.kinesis import FirehoseHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.kinesis`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_glue_catalog_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.glue_catalog import AwsGlueCatalogHook # noqa
from airflow.providers.amazon.aws.hooks.glue_catalog import GlueCatalogHook as AwsGlueCatalogHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.glue_catalog`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_lambda_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.lambda_function import AwsLambdaHook # noqa
from airflow.providers.amazon.aws.hooks.lambda_function import LambdaHook as AwsLambdaHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.lambda_function`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/hooks/aws_sns_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings

from airflow.providers.amazon.aws.hooks.sns import AwsSnsHook # noqa
from airflow.providers.amazon.aws.hooks.sns import SnsHook as AwsSnsHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.sns`.",
Expand Down
2 changes: 1 addition & 1 deletion airflow/contrib/operators/aws_athena_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings

from airflow.providers.amazon.aws.operators.athena import AWSAthenaOperator # noqa
from airflow.providers.amazon.aws.operators.athena import AthenaOperator as AWSAthenaOperator # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.operators.athena`.",
Expand Down
29 changes: 5 additions & 24 deletions airflow/contrib/operators/awsbatch_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@

import warnings

from airflow.providers.amazon.aws.hooks.batch_client import AwsBatchProtocol
from airflow.providers.amazon.aws.operators.batch import AwsBatchOperator
from airflow.typing_compat import Protocol, runtime_checkable
from airflow.providers.amazon.aws.hooks.batch_client import BatchProtocol # noqa
from airflow.providers.amazon.aws.operators.batch import BatchOperator

warnings.warn(
"This module is deprecated. "
Expand All @@ -41,35 +40,17 @@
)


class AWSBatchOperator(AwsBatchOperator):
class AWSBatchOperator(BatchOperator):
"""
This class is deprecated. Please use
`airflow.providers.amazon.aws.operators.batch.AwsBatchOperator`.
`airflow.providers.amazon.aws.operators.batch.BatchOperator`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"""This class is deprecated.
Please use `airflow.providers.amazon.aws.operators.batch.AwsBatchOperator`.""",
Please use `airflow.providers.amazon.aws.operators.batch.BatchOperator`.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


@runtime_checkable
class BatchProtocol(AwsBatchProtocol, Protocol):
"""
This class is deprecated. Please use
`airflow.providers.amazon.aws.hooks.batch_client.AwsBatchProtocol`.
"""

# A Protocol cannot be instantiated

def __new__(cls, *args, **kwargs):
warnings.warn(
"""This class is deprecated.
Please use `airflow.providers.amazon.aws.hooks.batch_client.AwsBatchProtocol`.""",
DeprecationWarning,
stacklevel=2,
)
7 changes: 4 additions & 3 deletions airflow/contrib/operators/ecs_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import warnings

from airflow.providers.amazon.aws.operators.ecs import ECSOperator, ECSProtocol

__all__ = ["ECSOperator", "ECSProtocol"]
from airflow.providers.amazon.aws.operators.ecs import ( # noqa
EcsOperator as ECSOperator,
EcsProtocol as ECSProtocol,
)

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.operators.ecs`.",
Expand Down
4 changes: 3 additions & 1 deletion airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

import warnings

from airflow.providers.amazon.aws.sensors.glue_catalog_partition import AwsGlueCatalogPartitionSensor # noqa
from airflow.providers.amazon.aws.sensors.glue_catalog_partition import ( # noqa
GlueCatalogPartitionSensor as AwsGlueCatalogPartitionSensor,
)

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.glue_catalog_partition`.",
Expand Down
17 changes: 0 additions & 17 deletions airflow/providers/amazon/aws/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#
# Note: Any AirflowException raised is expected to cause the TaskInstance
# to be marked in an ERROR state
import warnings


class EcsTaskFailToStart(Exception):
Expand All @@ -42,19 +41,3 @@ def __init__(self, failures: list, message: str):

def __reduce__(self):
return EcsOperatorError, (self.failures, self.message)


class ECSOperatorError(EcsOperatorError):
"""
This class is deprecated.
Please use :class:`airflow.providers.amazon.aws.exceptions.EcsOperatorError`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This class is deprecated. "
"Please use `airflow.providers.amazon.aws.exceptions.EcsOperatorError`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
16 changes: 0 additions & 16 deletions airflow/providers/amazon/aws/hooks/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

PageIterator
"""
import warnings
from time import sleep
from typing import Any, Dict, Optional

Expand Down Expand Up @@ -252,18 +251,3 @@ def stop_query(self, query_execution_id: str) -> Dict:
:return: dict
"""
return self.get_conn().stop_query_execution(QueryExecutionId=query_execution_id)


class AWSAthenaHook(AthenaHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.athena.AthenaHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. Please use `airflow.providers.amazon.aws.hooks.athena.AthenaHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
20 changes: 2 additions & 18 deletions airflow/providers/amazon/aws/hooks/base_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,11 @@ def get_session(self, region_name: Optional[str] = None) -> boto3.session.Sessio

def get_client_type(
self,
client_type: Optional[str] = None,
region_name: Optional[str] = None,
config: Optional[Config] = None,
) -> boto3.client:
"""Get the underlying boto3 client using boto3 session"""
if client_type:
warnings.warn(
"client_type is deprecated. Set client_type from class attribute.",
DeprecationWarning,
stacklevel=2,
)
else:
client_type = self.client_type
client_type = self.client_type

# No AWS Operators use the config argument to this method.
# Keep backward compatibility with other users who might use it
Expand All @@ -464,19 +456,11 @@ def get_client_type(

def get_resource_type(
self,
resource_type: Optional[str] = None,
region_name: Optional[str] = None,
config: Optional[Config] = None,
) -> boto3.resource:
"""Get the underlying boto3 resource using boto3 session"""
if resource_type:
warnings.warn(
"resource_type is deprecated. Set resource_type from class attribute.",
DeprecationWarning,
stacklevel=2,
)
else:
resource_type = self.resource_type
resource_type = self.resource_type

# No AWS Operators use the config argument to this method.
# Keep backward compatibility with other users who might use it
Expand Down
33 changes: 0 additions & 33 deletions airflow/providers/amazon/aws/hooks/batch_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
- http://boto3.readthedocs.io/en/latest/reference/services/batch.html
- https://docs.aws.amazon.com/batch/latest/APIReference/Welcome.html
"""
import warnings
from random import uniform
from time import sleep
from typing import Dict, List, Optional, Union
Expand Down Expand Up @@ -551,35 +550,3 @@ def exp(tries):
delay = 1 + pow(tries * 0.6, 2)
delay = min(max_interval, delay)
return uniform(delay / 3, delay)


class AwsBatchProtocol(BatchProtocol, Protocol):
"""
This class is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchProtocol`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This class is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchProtocol`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class AwsBatchClientHook(BatchClientHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchClientHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchClientHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
17 changes: 0 additions & 17 deletions airflow/providers/amazon/aws/hooks/batch_waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import json
import sys
import warnings
from copy import deepcopy
from pathlib import Path
from typing import Dict, List, Optional, Union
Expand Down Expand Up @@ -227,19 +226,3 @@ def wait_for_job(self, job_id: str, delay: Union[int, float, None] = None) -> No

except (botocore.exceptions.ClientError, botocore.exceptions.WaiterError) as err:
raise AirflowException(err)


class AwsBatchWaitersHook(BatchWaitersHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchWaitersHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.batch.BatchWaitersHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
17 changes: 0 additions & 17 deletions airflow/providers/amazon/aws/hooks/cloud_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# under the License.

"""This module contains AWS CloudFormation Hook"""
import warnings
from typing import Optional, Union

from boto3 import client, resource
Expand Down Expand Up @@ -75,19 +74,3 @@ def delete_stack(self, stack_name: str, cloudformation_parameters: Optional[dict
if 'StackName' not in cloudformation_parameters:
cloudformation_parameters['StackName'] = stack_name
self.get_conn().delete_stack(**cloudformation_parameters)


class AWSCloudFormationHook(CloudFormationHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.cloud_formation.CloudFormationHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.cloud_formation.CloudFormationHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
16 changes: 0 additions & 16 deletions airflow/providers/amazon/aws/hooks/datasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""Interact with AWS DataSync, using the AWS ``boto3`` library."""

import time
import warnings
from typing import List, Optional

from airflow.exceptions import AirflowBadRequest, AirflowException, AirflowTaskTimeout
Expand Down Expand Up @@ -316,18 +315,3 @@ def wait_for_task_execution(self, task_execution_arn: str, max_iterations: int =
if iterations <= 0:
raise AirflowTaskTimeout("Max iterations exceeded!")
raise AirflowException(f"Unknown status: {status}") # Should never happen


class AWSDataSyncHook(DataSyncHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.datasync.DataSyncHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. Please use `airflow.providers.amazon.aws.hooks.datasync.DataSyncHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
17 changes: 0 additions & 17 deletions airflow/providers/amazon/aws/hooks/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


"""This module contains the AWS DynamoDB hook"""
import warnings
from typing import Iterable, List, Optional

from airflow.exceptions import AirflowException
Expand Down Expand Up @@ -58,19 +57,3 @@ def write_batch_data(self, items: Iterable) -> bool:
return True
except Exception as general_error:
raise AirflowException(f"Failed to insert items in dynamodb, error: {str(general_error)}")


class AwsDynamoDBHook(DynamoDBHook):
"""
This class is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.dynamodb.DynamoDBHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This class is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.dynamodb.DynamoDBHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
Loading