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

Streaming -- validate user's responses #576

Open
squidarth opened this issue Aug 16, 2023 · 0 comments
Open

Streaming -- validate user's responses #576

squidarth opened this issue Aug 16, 2023 · 0 comments
Assignees

Comments

@squidarth
Copy link
Collaborator

Describe the bug

If the user yields some complex object that is not bytes or string in a generator response, it can lead to strange errors. For instance, if you yield a numpy array, you get this exception:

Aug 16 6:14:28pm
Exception while reading stream response: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Traceback (most recent call last):
  File "/app/model_wrapper.py", line 249, in write_response_to_queue
    async for chunk in generator:
  File "/app/model_wrapper.py", line 351, in _convert_generator_to_async
    if chunk == FINAL_GENERATOR_VALUE:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

To Reproduce

Yield a numpy array from a generator returned from the predict method.

Expected behavior

We should throw exception if the user yields something that isn't bytes or a string.

Screenshots/Logs
If applicable, add screenshots or logs to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. macOS]
  • Environment versions [e.g. python versions, framework/package versions]
  • Truss version [e.g. 22]

Additional context
Add any other context about the problem here.

@squidarth squidarth self-assigned this Aug 16, 2023
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

No branches or pull requests

1 participant