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

For generators returned from predict, coerce results to a string #477

Open
squidarth opened this issue Jul 26, 2023 · 0 comments
Open

For generators returned from predict, coerce results to a string #477

squidarth opened this issue Jul 26, 2023 · 0 comments

Comments

@squidarth
Copy link
Collaborator

Describe the bug

If right now, in your predict function, your return a generator that yields non-string values, these values will not get streamed to a client. In fact, the client will just receive an empty response.

def predict(payload: Dict):
    def inner():
        for i in range(5):
              yield i
     return inner()

To Reproduce
Steps to reproduce the behavior:

Expected behavior

Since pretty much any python object responds to str(), we should just coerce the user's results to a string. This will be much more predictable & clearer to the user when they've done something they haven't intended, as opposed to seeing an empty response.

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.

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