Skip to content

Accept the use of async predict methods #1565

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

Closed
wants to merge 3 commits into from

Conversation

RobertLucian
Copy link
Member

@RobertLucian RobertLucian commented Nov 17, 2020

This fixes the issue when a request has the content type set to multipart/form-data and a file is uploaded (i.e. when making a request of this kind curl <api-endpoint> -X POST -H "Content-Type: multipart/form-data" -F "iris=@sample.json").

This is because reading a form file requires the call of an async method read, which cannot be called unless the predict method of the predictor is an async method too, which in turn, means, the backend method must be an async function as well.

Here's an example of how to read a file using forms (scroll to the bottom of the page): https://www.starlette.io/requests/.

Edit

This is no longer required because the file can just be retrieved from the payload.file attribute, which is already a tempfile.SpooledTemporaryFile object. As shown in #1566. That being said, this PR might still be of interest to those that use async functions.


checklist:

  • run make test and make lint
  • test manually (i.e. build/push all images, restart operator, and re-deploy APIs)

@RobertLucian RobertLucian added the bug Something isn't working label Nov 17, 2020
@RobertLucian RobertLucian requested a review from deliahu November 17, 2020 21:13
@deliahu deliahu mentioned this pull request Nov 26, 2020
@deliahu deliahu deleted the fix/form-data-request branch April 19, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant