You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried following the examples to use the new structured types and IODescriptor protocols. From the documentation here, it seems like I'm doing things correctly: https://docs.bentoml.org/en/latest/guides/iotypes.html#validate-data . However, I can't seem to get a demo working.
The failure is at the client level.
To reproduce
The service looks like the following. To reproduce, start the server using bentoml serve *:service and then run the client.
I expect the service to echo the dataframes. Instead I get the following error when running the client. There is no error for the server.
Traceback (most recent call last):
File "/Users/aloukian/Documents/ffdtg/notebooks/bentify/repro.py", line 7, in <module>classInput(BaseModel):
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 182, in __new__
complete_model_class(
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 491, in complete_model_class
schema =cls.__get_pydantic_core_schema__(cls, handler)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/main.py", line 578, in __get_pydantic_core_schema__return __handler(__source)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
schema =self._handler(__source_type)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 468, in generate_schema
schema =self._generate_schema(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 700, in _generate_schema
schema =self._post_process_generated_schema(self._generate_schema_inner(obj))
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 722, in _generate_schema_innerreturnself._model_schema(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 541, in _model_schema
{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 541, in <dictcomp>
{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 886, in _generate_md_field_schema
common_field =self._common_field_schema(name, field_info, decorators)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 951, in _common_field_schema
schema =self._apply_annotations(
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 1654, in _apply_annotations
schema = get_inner_schema(source_type)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
schema =self._handler(__source_type)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 1635, in inner_handler
schema =self._generate_schema(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 700, in _generate_schema
schema =self._post_process_generated_schema(self._generate_schema_inner(obj))
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 727, in _generate_schema_innerreturnself.match_type(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 814, in match_typereturnself._unknown_type_schema(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 366, in _unknown_type_schemaraise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'pandas.core.frame.DataFrame'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.
For further information visit https://errors.pydantic.dev/2.5/u/schema-for-unknown-type
If instead I try using Annotated with schemas, ie change the type definitions to
I run into another exception related to JSONSerialization. It looks like the encode functions aren't being triggered.
Traceback (most recent call last):
File "/Users/aloukian/Documents/ffdtg/notebooks/bentify/repro.py", line 39, in <module>
value = client.echo_df(df1=data)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/_bentoml_impl/client/base.py", line 36, in methodreturnself.call(name, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/_bentoml_impl/client/http.py", line 320, in callreturnself._call(endpoint, args, kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/_bentoml_impl/client/http.py", line 391, in _call
req =self._build_request(endpoint, args, kwargs, headers or {})
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/_bentoml_impl/client/http.py", line 230, in _build_request
content=self.serde.serialize(kwargs),
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/site-packages/_bentoml_impl/serde.py", line 64, in serializereturn json.dumps(obj).encode("utf-8")
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/json/__init__.py", line 231, in dumpsreturn _default_encoder.encode(obj)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/json/encoder.py", line 199, in encode
chunks =self.iterencode(o, _one_shot=True)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/json/encoder.py", line 257, in iterencodereturn _iterencode(o, 0)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ffdtg-dev/lib/python3.10/json/encoder.py", line 179, in defaultraiseTypeError(f'Object of type {o.__class__.__name__}'TypeError: Object of type DataFrame is not JSON serializable
Describe the bug
I tried following the examples to use the new structured types and IODescriptor protocols. From the documentation here, it seems like I'm doing things correctly: https://docs.bentoml.org/en/latest/guides/iotypes.html#validate-data . However, I can't seem to get a demo working.
The failure is at the client level.
To reproduce
The service looks like the following. To reproduce, start the server using
bentoml serve *:service
and then run the client.Expected behavior
I expect the service to echo the dataframes. Instead I get the following error when running the client. There is no error for the server.
If instead I try using
Annotated
with schemas, ie change the type definitions toI run into another exception related to JSONSerialization. It looks like the encode functions aren't being triggered.
Environment
Environment variable
System information
bentoml
: 1.2.1python
: 3.10.13platform
: macOS-14.1.1-arm64-arm-64bituid_gid
: 501:20conda
: 23.3.1in_conda_env
: Trueconda_packages
pip_packages
The text was updated successfully, but these errors were encountered: