From b406b576603734f9795117d95e9664e3aa0e2145 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 22 Nov 2023 18:55:24 -0500 Subject: [PATCH] MAINT Remove wrapt dependency (#1973) * MAINT Remove wrapt dependency Signed-off-by: Thomas J. Fan * MAINT Removes wrapt dependency from requirements Signed-off-by: Thomas J. Fan --------- Signed-off-by: Thomas J. Fan --- dev-requirements.txt | 1 - doc-requirements.txt | 1 - flytekit/exceptions/scopes.py | 21 +++++++++++++++---- setup.py | 1 - .../workflows/requirements.txt | 1 - 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 59b2aa462fe..8a00c9588fc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -556,7 +556,6 @@ wheel==0.41.3 wrapt==1.15.0 # via # aiobotocore - # flytekit # tensorflow yarl==1.9.2 # via aiohttp diff --git a/doc-requirements.txt b/doc-requirements.txt index 99bc5159004..5336cfe0d3a 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -1434,7 +1434,6 @@ wrapt==1.15.0 # via # aiobotocore # astroid - # flytekit # pandera # tensorflow xarray==2023.8.0 diff --git a/flytekit/exceptions/scopes.py b/flytekit/exceptions/scopes.py index bdfb2ba1821..f0a0f02189a 100644 --- a/flytekit/exceptions/scopes.py +++ b/flytekit/exceptions/scopes.py @@ -1,8 +1,7 @@ +from functools import wraps as _wraps from sys import exc_info as _exc_info from traceback import format_tb as _format_tb -from wrapt import decorator as _decorator - from flytekit.exceptions import base as _base_exceptions from flytekit.exceptions import system as _system_exceptions from flytekit.exceptions import user as _user_exceptions @@ -134,8 +133,22 @@ def _is_base_context(): return _CONTEXT_STACK[-2] == _NULL_CONTEXT +def _decorator(outer_f): + """Decorate a function with signature func(wrapped, args, kwargs).""" + + @_wraps(outer_f) + def inner_decorator(inner_f): + @_wraps(inner_f) + def f(*args, **kwargs): + return outer_f(inner_f, args, kwargs) + + return f + + return inner_decorator + + @_decorator -def system_entry_point(wrapped, instance, args, kwargs): +def system_entry_point(wrapped, args, kwargs): """ The reason these two (see the user one below) decorators exist is to categorize non-Flyte exceptions at arbitrary locations. For example, while there is a separate ecosystem of Flyte-defined user and system exceptions @@ -178,7 +191,7 @@ def system_entry_point(wrapped, instance, args, kwargs): @_decorator -def user_entry_point(wrapped, instance, args, kwargs): +def user_entry_point(wrapped, args, kwargs): """ See the comment for the system_entry_point above as well. diff --git a/setup.py b/setup.py index 171250cef4f..fc8e9716708 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,6 @@ "typing_extensions", "urllib3>=1.22,<2.0.0", "wheel>=0.30.0,<1.0.0", - "wrapt>=1.0.0,<2.0.0", ], extras_require=extras_require, scripts=[ diff --git a/tests/flytekit/integration/remote/mock_flyte_repo/workflows/requirements.txt b/tests/flytekit/integration/remote/mock_flyte_repo/workflows/requirements.txt index 2519e945f0a..08cc1491610 100644 --- a/tests/flytekit/integration/remote/mock_flyte_repo/workflows/requirements.txt +++ b/tests/flytekit/integration/remote/mock_flyte_repo/workflows/requirements.txt @@ -348,7 +348,6 @@ wrapt==1.15.0 # via # aiobotocore # deprecated - # flytekit yarl==1.9.2 # via aiohttp zipp==3.16.2