From 1cf966e1b35e21886ddd6cf551d9f2ed86243b2a Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 15:36:28 -0700 Subject: [PATCH 1/7] Show traceback by default Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 9 ++++++--- flytekit/exceptions/user.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index c31b1e6502..b57d0d1fd4 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -114,9 +114,7 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): """ console = Console() - if verbosity == 0: - console.print(Traceback.from_exception(type(e), e, None)) - elif verbosity == 1: + if verbosity < 2: unwanted_module_names = ["importlib", "click", "rich_click"] click.secho( f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." @@ -124,6 +122,11 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): fg="yellow", ) + if verbosity == 0: + tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__ + new_tb = remove_unwanted_traceback_frames(tb, unwanted_module_names) + console.print(Traceback.from_exception(type(e), e, new_tb)) + elif verbosity == 1: new_tb = remove_unwanted_traceback_frames(e.__traceback__, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity >= 2: diff --git a/flytekit/exceptions/user.py b/flytekit/exceptions/user.py index 3413d172ff..62a1ef636a 100644 --- a/flytekit/exceptions/user.py +++ b/flytekit/exceptions/user.py @@ -172,3 +172,14 @@ class FlyteMissingReturnValueException(FlyteCompilationException): def __str__(self): return f"{self.fn.__name__} function must return a value. Please add a return statement at the end of the function." + + +class FlyteTypeTransformerFailedError(FlyteUserException): + _ERROR_CODE = "USER:TypeTransformerFailedError" + + def __init__(self, transformer_name: str, value: typing.Any): + self.transformer_name = transformer_name + self.value = value + + def __str__(self): + return f"Failed to transform value {self.value} using transformer {self.transformer_name}" From 15d4904200f42466d24d8bfe86ffe984eccc8306 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 15:40:09 -0700 Subject: [PATCH 2/7] lint Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index b57d0d1fd4..c2e33f61f4 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -113,9 +113,9 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): Print the traceback in a nice formatted way if verbose is set to True. """ console = Console() + unwanted_module_names = ["importlib", "click", "rich_click"] if verbosity < 2: - unwanted_module_names = ["importlib", "click", "rich_click"] click.secho( f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." f" For more verbose output, use the flags -vv or -vvv.", From 19ca24f3f3c9fcde8a93f8eb15a94bad395ab928 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 15:41:14 -0700 Subject: [PATCH 3/7] lint Signed-off-by: Kevin Su --- flytekit/exceptions/user.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/flytekit/exceptions/user.py b/flytekit/exceptions/user.py index 62a1ef636a..3413d172ff 100644 --- a/flytekit/exceptions/user.py +++ b/flytekit/exceptions/user.py @@ -172,14 +172,3 @@ class FlyteMissingReturnValueException(FlyteCompilationException): def __str__(self): return f"{self.fn.__name__} function must return a value. Please add a return statement at the end of the function." - - -class FlyteTypeTransformerFailedError(FlyteUserException): - _ERROR_CODE = "USER:TypeTransformerFailedError" - - def __init__(self, transformer_name: str, value: typing.Any): - self.transformer_name = transformer_name - self.value = value - - def __str__(self): - return f"Failed to transform value {self.value} using transformer {self.transformer_name}" From 8cc97377f722b505a4e66bb08f9d8e452a5cb04d Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 16:01:24 -0700 Subject: [PATCH 4/7] remove flytekit Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index c2e33f61f4..0e15a23797 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -115,20 +115,19 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): console = Console() unwanted_module_names = ["importlib", "click", "rich_click"] - if verbosity < 2: - click.secho( - f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." - f" For more verbose output, use the flags -vv or -vvv.", - fg="yellow", - ) - if verbosity == 0: tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__ + unwanted_module_names.append("flytekit") new_tb = remove_unwanted_traceback_frames(tb, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity == 1: new_tb = remove_unwanted_traceback_frames(e.__traceback__, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) + click.secho( + f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." + f" For more verbose output, use the flags -vv or -vvv.", + fg="yellow", + ) elif verbosity >= 2: console.print(Traceback.from_exception(type(e), e, e.__traceback__)) else: From 386b3e553441e872abb2a0cba2089e796b902d33 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 16:11:44 -0700 Subject: [PATCH 5/7] nit Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index 0e15a23797..4fc9f5201b 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -121,13 +121,13 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): new_tb = remove_unwanted_traceback_frames(tb, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity == 1: - new_tb = remove_unwanted_traceback_frames(e.__traceback__, unwanted_module_names) - console.print(Traceback.from_exception(type(e), e, new_tb)) click.secho( f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." f" For more verbose output, use the flags -vv or -vvv.", fg="yellow", ) + new_tb = remove_unwanted_traceback_frames(e.__traceback__, unwanted_module_names) + console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity >= 2: console.print(Traceback.from_exception(type(e), e, e.__traceback__)) else: From c2d888833e3c49e2c44a26a82c4f97f9180b970d Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 16:12:02 -0700 Subject: [PATCH 6/7] nit Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index 4fc9f5201b..11c2d70488 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -126,6 +126,7 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): f" For more verbose output, use the flags -vv or -vvv.", fg="yellow", ) + new_tb = remove_unwanted_traceback_frames(e.__traceback__, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity >= 2: From c98c93a7f72a31ed27e53d7d11e857ac15293453 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 24 Oct 2024 16:12:24 -0700 Subject: [PATCH 7/7] nit Signed-off-by: Kevin Su --- flytekit/clis/sdk_in_container/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index 11c2d70488..9a5fdaa890 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -116,8 +116,8 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): unwanted_module_names = ["importlib", "click", "rich_click"] if verbosity == 0: - tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__ unwanted_module_names.append("flytekit") + tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__ new_tb = remove_unwanted_traceback_frames(tb, unwanted_module_names) console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity == 1: