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

Support upto 4D array as REST input payload. #6

Merged
merged 5 commits into from
Dec 3, 2021

Conversation

ScrapCodes
Copy link
Contributor

closes #5

@ScrapCodes
Copy link
Contributor Author

@pvaneck Please take a look !

@pvaneck
Copy link
Member

pvaneck commented Nov 11, 2021

Thanks @ScrapCodes , I will test this out soon. Currently having issues with my workstation I need to resolve. I'm not entirely sure why the lint job is suddenly failing with that Running error: context loading failed: no go files to analyze error. That will need to be looked into.

@njhill Would be great to have your eyes on this, too. :)

@njhill njhill self-requested a review November 11, 2021 03:16
@ScrapCodes
Copy link
Contributor Author

@pvaneck and @njhill thanks for taking a look, I have sent another PR to fix the CI. #7

@njhill
Copy link
Member

njhill commented Nov 11, 2021

Thanks @ScrapCodes. I think there should be a way we can streamline this and support arbitrary dimensions without having to deal with them as separate cases. I updated some experiments I was making before and can push that to a different branch to illustrate.

W.r.t. to test cases, I think we want to just have a set of raw json request payload examples along with the expected protobuf equivalent, and a bunch of raw protobuf response payload examples along with the expected REST equivalent. Just testing more cases end-to-end would be more valuable and simpler imo for this than more granular tests.

@njhill
Copy link
Member

njhill commented Nov 11, 2021

@ScrapCodes @pvaneck here's my proposed approach: https://github.com/kserve/rest-proxy/compare/main...njhill:dimensions?expand=1. It does not yet handle string / BYTES values though - I think there's some ambiguity in the spec around how BYTES values should/can be represented within the data array(s) so needs a bit more investigation.

@ScrapCodes
Copy link
Contributor Author

Thanks @njhill, tests are not exactly as you had asked. Please take a look!

For handling BYTES in json, are you considering base64 encoding?

@njhill
Copy link
Member

njhill commented Nov 16, 2021

Thanks @ScrapCodes the tests are going in the right direction but I would suggest the following:

  • Start with full REST request payload rather than just individual tensors, and test using the CustomJSONPb.NewDecoder func:
out = &gw.ModelInferRequest{}
err := CustomJsonPb{}.NewDecoder(...).Decode(out)
// verify contents of out
  • No need to duplicate the verification logic in separate functions, just put the jsons in an array and have the test func iterate over that to test each
  • No need to diff individual fields of the target protobuf struct, can just compare the entire struct
  • We should also test the response path in a similar way, i.e. CustomJSONPb.Marshal

For BYTES as mentioned I think the spec is currently ambiguous (to me at least). For example if strings are used then how should the encoding be determined. Also it's not clear how the byte lengths should be encoded when flattening. One option is to say that they must all be the same length and add a dimension to the shape for this. If their lengths can vary however then something extra is needed, like a corresponding integer tensor to hold them.

Previously I looked into how MLServer handles these kinds of inputs for some clues but do not recall the details now. Maybe you could look into that?

@njhill
Copy link
Member

njhill commented Dec 1, 2021

@ScrapCodes @pvaneck any thoughts/update on this? We should aim to get it in for the release right?

@pvaneck
Copy link
Member

pvaneck commented Dec 2, 2021

@njhill Yep, this should definitely be in the next release. I believe @ScrapCodes is currently finalizing the tests, then we can hopefully get this merged in. I think BYTES can be handled in a separate PR. I remember looking at some of MLServer's BYTES string tests and base64 tests before, but yea, this needs some more investigation for how we should handle it here.

@ScrapCodes ScrapCodes force-pushed the n-dim-input branch 2 times, most recently from 353aebe to f96a742 Compare December 2, 2021 12:04
@ScrapCodes ScrapCodes force-pushed the n-dim-input branch 2 times, most recently from b182d0d to ec54e3e Compare December 2, 2021 14:22
proxy/marshaler_test.go Outdated Show resolved Hide resolved
proxy/marshaler_test.go Outdated Show resolved Hide resolved
@ScrapCodes
Copy link
Contributor Author

@njhill thanks for taking a look, hope this is close to what we expect. Code looks cleaner and should perform faster thanks to you.

Copy link
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ScrapCodes, lgtm

@njhill
Copy link
Member

njhill commented Dec 3, 2021

Thanks @pvaneck, I opened an issue #8 for this.

Also I noticed that the files in this repo don't have the apache license/copyright headers, do you know if these are needed?

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ScrapCodes

@pvaneck
Copy link
Member

pvaneck commented Dec 3, 2021

@njhill Ah, yea, they should be added. I can do that real quick.

@pvaneck pvaneck merged commit 0541722 into kserve:main Dec 3, 2021
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 N-dimensional data arrays as input in the request data array
3 participants