Skip to content

Improve error logging when invoking custom handler methods #164

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

Merged
merged 5 commits into from
Mar 15, 2024
Merged
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
8 changes: 8 additions & 0 deletions src/sagemaker_inference/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import absolute_import

import importlib
import logging
import traceback

try:
Expand Down Expand Up @@ -56,6 +57,8 @@ def find_spec(module_name):
from sagemaker_inference.default_inference_handler import DefaultInferenceHandler
from sagemaker_inference.errors import BaseInferenceToolkitError, GenericInferenceToolkitError

logger = logging.getLogger()


class Transformer(object):
"""Represents the execution workflow for handling inference requests
Expand Down Expand Up @@ -98,6 +101,11 @@ def handle_error(context, inference_exception, trace):
Returns:
str: The error message and stacktrace from the exception.
"""
logger.error(
"Transform failed for model: %s. Error traceback: %s",
context.model_name,
trace.splitlines()
)
context.set_response_status(
code=inference_exception.status_code,
phrase=utils.remove_crlf(inference_exception.phrase),
Expand Down