bentoml / BentoML

The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
https://bentoml.com
Apache License 2.0
7.13k stars 791 forks source link

bug: from_sample factory for bentoml.io.PandasDataFrame doesnt work #3169

Closed subramaniam20jan closed 1 year ago

subramaniam20jan commented 2 years ago

Describe the bug

There seems to be an obvious bug here, where the dtype is set to a boolean and then checked here to not be boolean. I tried to circumvent this issue by skipping this factory but couldnt get it to work either.

Simply running the example code here, should be able to hit the issue

To reproduce

Contents of service.py

import pandas as pd
import bentoml
from bentoml.io import PandasDataFrame
arr = [[1,2,3]]
input_spec = PandasDataFrame.from_sample(pd.DataFrame(arr))

svc = bentoml.Service("test")

@svc.api(input=input_spec, output=PandasDataFrame())
def predict(inputs: pd.DataFrame) -> pd.DataFrame:
  return pd.DataFrame([[1]])

Expected behavior

Returns a single static prediction.

Instead throws an error:

Traceback (most recent call last):
  File "/home/subu/.local/lib/python3.10/site-packages/bentoml/_internal/server/http_app.py", line 298, in api_func
    input_data = await api.input.from_http_request(request)
  File "/home/subu/.local/lib/python3.10/site-packages/bentoml/_internal/io_descriptors/pandas.py", line 378, in from_http_request
    assert not isinstance(self._dtype, bool)
AssertionError

Environment

bentoml: 1.0.7 python: 3.10

aarnphm commented 1 year ago

Can you try again with 1.0.10? We recently updated the from_sample implementation and see if you still encounter this bug.

Note that the example from the docstring for from_sample is a foobar example.

sobayed commented 1 year ago

I'm encountering the same issue with 1.0.10. See here for the respective line.

Related issue: https://github.com/bentoml/BentoML/issues/3086

aarnphm commented 1 year ago

Hi there again. I have tested this with the latest version and I didn't encounter the error. Feel free to reopen this if it stills come up.