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

[python] log exception stacktrace for exceptions in python, improve r… #2142

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

siddvenk
Copy link
Contributor

@siddvenk siddvenk commented Jul 2, 2024

…eturned error message on KeyErrors during parse input

Two changes:

  1. Log the stacktrace for exceptions. In some cases where we log in the except blocks, we don't log any details about the exception/stacktrace making it hard to debug and understand what went wrong.
  2. Improve both the logging and error message for Parse input failures.

Prior to this change, for a parse input failure we would log:

INFO  PyProcess W-267-0a3e93accd53998-stdout: [1,0]<stdout>:Parse input failed: 0

And return to the client:

{'error': "'prompt'", 'code': 424}

Now, for a parse input failure we will log:

INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:Input Parsing failed. Ensure that the request payload is valid. Invalid Request Property: 'prompt'
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:Traceback (most recent call last):
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:  File "/tmp/.djl.ai/python/0.29.0-SNAPSHOT/djl_python/utils.py", line 68, in parse_input_with_formatter
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:    _inputs, _param, is_client_side_batch[i] = _parse_inputs_params(
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:  File "/tmp/.djl.ai/python/0.29.0-SNAPSHOT/djl_python/utils.py", line 117, in _parse_inputs_params
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:    _inputs, _param = parse_3p_request(
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:  File "/tmp/.djl.ai/python/0.29.0-SNAPSHOT/djl_python/three_p/three_p_utils.py", line 24, in parse_3p_request
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:    _inputs = input_map.pop("prompt")
INFO  PyProcess W-9340-model-stdout: [1,3]<stdout>:KeyError: 'prompt'

And return to the client:

{'error': "Input Parsing failed. Ensure that the request payload is valid. Invalid Request Property: 'prompt'", 'code': 424}

@siddvenk siddvenk requested review from zachgk, frankfliu and a team as code owners July 2, 2024 23:49
…eturned error message on KeyErrors during parse input
@siddvenk siddvenk force-pushed the py-log-exception branch from f9d8b95 to 932f8ae Compare July 3, 2024 00:31
@siddvenk siddvenk merged commit 4fd4f0c into deepjavalibrary:master Jul 3, 2024
9 checks passed
@siddvenk siddvenk deleted the py-log-exception branch July 3, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants