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

Improve error message for get signed url failure #2679

Merged
merged 1 commit into from
Aug 20, 2024
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 flytekit/clients/friendly.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def get_upload_signed_url(
)
)
except Exception as e:
raise RuntimeError(f"Failed to get signed url for {filename}, reason: {e}")
raise RuntimeError(f"Failed to get signed url for {filename}.") from e

def get_download_signed_url(
self, native_url: str, expires_in: datetime.timedelta = None
Expand Down
4 changes: 3 additions & 1 deletion flytekit/clients/grpc_utils/wrap_exception_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import grpc

from flytekit.exceptions.base import FlyteException
from flytekit.exceptions.system import FlyteSystemException
from flytekit.exceptions.system import FlyteSystemException, FlyteSystemUnavailableException
from flytekit.exceptions.user import (
FlyteAuthenticationException,
FlyteEntityAlreadyExistsException,
Expand All @@ -28,6 +28,8 @@ def _raise_if_exc(request: typing.Any, e: Union[grpc.Call, grpc.Future]):
raise FlyteEntityNotExistException() from e
elif e.code() == grpc.StatusCode.INVALID_ARGUMENT:
raise FlyteInvalidInputException(request) from e
elif e.code() == grpc.StatusCode.UNAVAILABLE:
raise FlyteSystemUnavailableException() from e
raise FlyteSystemException() from e

def intercept_unary_unary(self, continuation, client_call_details, request):
Expand Down
8 changes: 4 additions & 4 deletions flytekit/clis/sdk_in_container/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def pretty_print_grpc_error(e: grpc.RpcError):
"""
if isinstance(e, grpc._channel._InactiveRpcError): # noqa
click.secho(f"RPC Failed, with Status: {e.code()}", fg="red", bold=True)
click.secho(f"\tdetails: {e.details()}", fg="magenta", bold=True)
click.secho(f"\tDetails: {e.details()}", fg="magenta", bold=True)
return


Expand Down Expand Up @@ -113,7 +113,6 @@ 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()
tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think showing all the stack trace is better, not just the e.cause.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a few examples of the before and after this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before:
Screenshot 2024-08-17 at 1 51 45 AM

after:
Screenshot 2024-08-17 at 1 52 17 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyflyte -vv register flyte-example/getting_started.py


if verbosity == 0:
console.print(Traceback.from_exception(type(e), e, None))
Expand All @@ -124,10 +123,11 @@ 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(tb, unwanted_module_names)

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, tb))
console.print(Traceback.from_exception(type(e), e, e.__traceback__))
else:
raise ValueError(f"Verbosity level must be between 0 and 2. Got {verbosity}")

Expand Down
7 changes: 7 additions & 0 deletions flytekit/exceptions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ class FlyteSystemException(_base_exceptions.FlyteRecoverableException):
_ERROR_CODE = "SYSTEM:Unknown"


class FlyteSystemUnavailableException(FlyteSystemException):
_ERROR_CODE = "SYSTEM:Unavailable"

def __str__(self):
return "Flyte cluster is currently unavailable. Please make sure the cluster is up and running."


class FlyteNotImplementedException(FlyteSystemException, NotImplementedError):
_ERROR_CODE = "SYSTEM:NotImplemented"

Expand Down
Loading