Closed ALee008 closed 2 years ago
Hi @ALee008, I believe that this is the expected behaviour to use pydantic to convert the payload to json. We are currently working on documentation on this behaviour. I will try to get back to you ASAP after discussing with the team.
P/S: I believe this https://github.com/bentoml/BentoML/commit/e85d3697f946219c7d5853c093d7cf14dc1f1a82#diff-dc32bfb232459ae49509822c85ca5b705e1e92764f5db50364674db397ea0ba5R172-R173 updates the behaviour of pydantic model, which is included in rc0 releases.
Hi @ALee008, the behaviour has been fixed in #2578 and merged on main. We will work on better documents this behaviour.
@aarnphm , much appreciated! Thank you guys for your quick responses. You are doing great work!
Describe the bug When using JSON() descriptor with a pydantic model I expect a pydantic model object to be passed as parameter to the decorated function, a dictionary is returned instead. This seems to be an issue in RC0 because it was working in the latest alpha release 1.0.0a7.
To Reproduce
Expected behavior
dummy
is a pydantic model which has the attributedict
.Environment:
Additional context In
venv/Lib/site-packages/bentoml/_internal/io_descriptors/json.py
I tested a change in row 177 by removing the.dict()
method call. See my inline comment below. This solved this particular issue.