From 59a75887a618f52ebc1f798bf98626e553bce0aa Mon Sep 17 00:00:00 2001 From: Daniel Gafni Date: Tue, 14 Jan 2025 17:36:42 +0200 Subject: [PATCH] [dagster-aws] move WaiterConfig to a new shared Pipes client utils module (#27008) ## Summary & Motivation Will need this type in a few Pipes clients going forward ## How I Tested These Changes this is a refactor, existing tests --- .../dagster_aws/pipes/clients/ecs.py | 18 ++---------------- .../dagster_aws/pipes/clients/utils.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/ecs.py b/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/ecs.py index 33e56afae3704..96830f474b4d4 100644 --- a/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/ecs.py +++ b/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/ecs.py @@ -1,5 +1,5 @@ from pprint import pformat -from typing import TYPE_CHECKING, Any, Optional, TypedDict, Union, cast +from typing import TYPE_CHECKING, Any, Optional, Union, cast import boto3 import botocore @@ -17,8 +17,8 @@ PipesMessageReader, ) from dagster._core.pipes.utils import PipesEnvContextInjector, open_pipes_session -from typing_extensions import NotRequired +from dagster_aws.pipes.clients.utils import WaiterConfig from dagster_aws.pipes.message_readers import PipesCloudWatchLogReader, PipesCloudWatchMessageReader if TYPE_CHECKING: @@ -30,20 +30,6 @@ ) -class WaiterConfig(TypedDict): - """A WaiterConfig representing the configuration of the waiter. - - Args: - Delay (NotRequired[int]): The amount of time in seconds to wait between attempts. Defaults to 6. - MaxAttempts (NotRequired[int]): The maximum number of attempts to be made. Defaults to 1000000 - By default the waiter is configured to wait up to 70 days (waiter_delay*waiter_max_attempts). - See `Boto3 API Documentation `_ - """ - - Delay: NotRequired[int] - MaxAttempts: NotRequired[int] - - @experimental class PipesECSClient(PipesClient, TreatAsResourceParam): """A pipes client for running AWS ECS tasks. diff --git a/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/utils.py b/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/utils.py index 32313b3440577..209948d0065dd 100644 --- a/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/utils.py +++ b/python_modules/libraries/dagster-aws/dagster_aws/pipes/clients/utils.py @@ -1,6 +1,7 @@ -from typing import TYPE_CHECKING, cast +from typing import TYPE_CHECKING, TypedDict, cast from dagster._core.pipes.utils import PipesSession +from typing_extensions import NotRequired if TYPE_CHECKING: from mypy_boto3_emr.type_defs import ConfigurationUnionTypeDef @@ -70,3 +71,17 @@ def emr_inject_pipes_env_vars( ) return configurations + + +class WaiterConfig(TypedDict): + """A WaiterConfig representing the configuration of the waiter. + + Args: + Delay (NotRequired[int]): The amount of time in seconds to wait between attempts. Defaults to 6. + MaxAttempts (NotRequired[int]): The maximum number of attempts to be made. Defaults to 1000000 + By default the waiter is configured to wait up to 70 days (waiter_delay*waiter_max_attempts). + See `Boto3 API Documentation `_ + """ + + Delay: NotRequired[int] + MaxAttempts: NotRequired[int]