Skip to content

Support multiple types of responses in predict() #915

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

Conversation

RobertLucian
Copy link
Member

@RobertLucian RobertLucian commented Mar 26, 2020

Closes #913.


checklist:

  • run make test and make lint
  • test manually (i.e. build/push all images, restart operator, and re-deploy APIs)
  • update docs and add any new files to summary.md (view in gitbook after merging)

i.e. cortex.lib.exceptions.UserRuntimeException: error: consider passing a bytes object or a custom starlette.response object instead: Object of type 'DataFrame' is not JSON serializable: runtime exception
@RobertLucian RobertLucian changed the title Feature/extended response content Support multiple types of responses in predict() Mar 26, 2020
@RobertLucian
Copy link
Member Author

What has to be kept in mind in the back of the mind is that with this method, other protocols for pickle can be used too: 1, 2, 3, and 4 (with the exclusion of 5). 5 cannot be used because the serving container is still based on Python 3.6.x).

Anyhow, the speedup over protocol 0 (in my experiments) is this:

  • Protocol 1: ~0.5x speedup.
  • Protocol 2: ~0.5x speedup.
  • Protocol 3: ~3x speedup.
  • Protocol 4: ~3x speedup.
  • Protocol 5: ~6x speedup - but is not accessible yet.

So assuming protocol 4, which is 3 times as fast as protocol 0, and no json.dumps for it, the serialization process for a ~27 MB DataFrame takes about 58 ms. That's a very good improvement over the 820 ms using protocol 0 & dumps.json. And even much better if it weren't for pickle (aka using df.to_dict and json.dumps): ~8000 ms.

@vishalbollu vishalbollu self-requested a review March 28, 2020 00:39
@deliahu deliahu merged commit 63f3787 into cortexlabs:master Mar 29, 2020
@RobertLucian RobertLucian deleted the feature/extended-response-content branch March 29, 2020 13:40
@RobertLucian RobertLucian mentioned this pull request Apr 30, 2020
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.

Support byte string return values from predict()
3 participants