From 5fc8a3a2864dbbfc15faab3acf6afaa524adf584 Mon Sep 17 00:00:00 2001 From: Alexander Streed Date: Fri, 15 Mar 2024 08:14:57 -0500 Subject: [PATCH] Deprecate `ECSTask` block (#395) --- prefect_aws/ecs.py | 19 ++++++++++++++++++- requirements.txt | 2 +- tests/test_ecs.py | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/prefect_aws/ecs.py b/prefect_aws/ecs.py index 6368748f..b0227bf6 100644 --- a/prefect_aws/ecs.py +++ b/prefect_aws/ecs.py @@ -1,4 +1,11 @@ """ +DEPRECATION WARNING: + +This module is deprecated as of March 2024 and will not be available after September 2024. +It has been replaced by the ECS worker, which offers enhanced functionality and better performance. + +For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/. + Integrations with the Amazon Elastic Container Service. Examples: @@ -102,7 +109,8 @@ ], ) ``` -""" +""" # noqa + import copy import difflib import json @@ -118,6 +126,7 @@ import yaml from anyio.abc import TaskStatus from jsonpointer import JsonPointerException +from prefect._internal.compatibility.deprecated import deprecated_class from prefect.blocks.core import BlockNotSavedError from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound from prefect.infrastructure.base import Infrastructure, InfrastructureResult @@ -205,6 +214,14 @@ def _pretty_diff(d1: dict, d2: dict) -> str: ) +@deprecated_class( + start_date="Mar 2024", + help=( + "Use the ECS worker instead." + " Refer to the upgrade guide for more information:" + " https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/." + ), +) class ECSTask(Infrastructure): """ Run a command as an ECS task. diff --git a/requirements.txt b/requirements.txt index e5cfb0b0..4a764f81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ boto3>=1.24.53 botocore>=1.27.53 mypy_boto3_s3>=1.24.94 mypy_boto3_secretsmanager>=1.26.49 -prefect>=2.14.10 +prefect>=2.16.4 tenacity>=8.0.0 \ No newline at end of file diff --git a/tests/test_ecs.py b/tests/test_ecs.py index a81c446b..6c429e9f 100644 --- a/tests/test_ecs.py +++ b/tests/test_ecs.py @@ -12,6 +12,7 @@ from botocore.exceptions import ClientError from moto import mock_ec2, mock_ecs, mock_logs from moto.ec2.utils import generate_instance_identity_document +from prefect._internal.compatibility.deprecated import PrefectDeprecationWarning from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound from prefect.logging.configuration import setup_logging from prefect.server.schemas.core import Deployment, Flow, FlowRun @@ -35,6 +36,20 @@ parse_task_identifier, ) + +def test_ecs_task_emits_deprecation_warning(): + with pytest.warns( + PrefectDeprecationWarning, + match=( + "prefect_aws.ecs.ECSTask has been deprecated." + " It will not be available after Sep 2024." + " Use the ECS worker instead." + " Refer to the upgrade guide for more information" + ), + ): + ECSTask() + + setup_logging()