-
Notifications
You must be signed in to change notification settings - Fork 183
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
Schema enforcement error when using PandasCodec
inference request
#1625
Comments
I have also had this issue, and it's unclear from the docs if this is intended or not. There is a disclaimer about this in the Numpy Array section of the docs, but it is not present in the Pandas DataFrame section just after it, and the presented JSON Payload has other errors that make it unreliable for determining what the correct value should be (I have an MR out for that docs change at #1679) |
We've merged in a contribution in #1751 that should fix this. If you're able to use MLServer from |
@jesse-c I just had a chance to test this with the new changes. TL;DR is that this works! But not quite in the way I expected it to, and I didn't think it would when I first serialized the new request. Expand for more.Using the same code snippet, the inference request looked the same with both the MLServer 1.5.0 release, and the current state of import pandas as pd
import mlserver.grpc.converters as converters
from mlserver.codecs import PandasCodec
example_dict = {
"input1": [132.6454, 131.315],
"input2": [2.78412, 1.315],
"input3": [12.9, 35.6687]
}
data = pd.DataFrame(example_dict)
inference_request = PandasCodec.encode_request(data, inject_batch=True)
grpc_inference_request = converters.ModelInferRequestConverter.from_types(inference_request,
model_name=model_name, model_version=None)
inference_request.inputs Output: [RequestInput(name='input1', shape=[2, 1], datatype='FP64', parameters=None, data=TensorData(__root__=[132.6454, 131.315])),
RequestInput(name='input2', shape=[2, 1], datatype='FP64', parameters=None, data=TensorData(__root__=[2.78412, 1.315])),
RequestInput(name='input3', shape=[2, 1], datatype='FP64', parameters=None, data=TensorData(__root__=[12.9, 35.6687]))] In 1.5.0, this would result in an error when trying to send it to the inference server, so I would have to amend the code snippet above to add two short lines to reshape the inputs: inference_request = PandasCodec.encode_request(data, inject_batch=True)
for i in inference_request.inputs:
i.shape = [i.shape[0]] Which would yield a request that looked like this: [RequestInput(name='input1', shape=[2], datatype='FP64', parameters=None, data=TensorData(root=[132.6454, 131.315])),
RequestInput(name='input2', shape=[2], datatype='FP64', parameters=None, data=TensorData(root=[2.78412, 1.315])),
RequestInput(name='input3', shape=[2], datatype='FP64', parameters=None, data=TensorData(root=[12.9, 35.6687]))] And that version of the request would work in 1.5.0. With the new changes on This change is a welcome one for sure, since it removes the need for those workaround lines in code that might have to handle multiple request types! But I wasn't sure it was going to work when I noticed that my requests looked the same as they did before, so that might be beneficial to mention in release notes somewhere. Thank you for this! |
Hi!
My goal is to serve a mlflow model with a signature via mlserver and observed some issue with the signature enforcement and the request generated by
PandasCodec
.I followed the example from https://mlserver.readthedocs.io/en/latest/examples/mlflow/README.html
The model signature in the example is inferred by
and logged to mlflow via:
model serving is done with mlserver
I can test the inference via the given plain json example
However, if I create the inference request using
PandasCodec
like thisI get the following error response:
and mlserver shows the following stack trace:
I had a look on the difference between the plain json schema and the resulting
PandasCodec
schema. It seems that theshape
attribute for the input is different:plain json example
PandasCodec
resultThe
shape
is[1]
in the plain json example and[1,1]
in the resultingPandasCodec
request.I fixed the shape information and tested it successfully with:
Version Infos:
Is there any issue in the generated
shape
information generated byPandasCodec
or have I missed something?Thanks a lot for any help!
The text was updated successfully, but these errors were encountered: