temporalio / samples-python

Samples for working with the Temporal Python SDK
MIT License
120 stars 53 forks source link

[Bug] pydantic_encoder -> jsonable_encoder #136

Closed rakesh-163 closed 1 month ago

rakesh-163 commented 1 month ago

What are you really trying to do?

I was trying to use the encoder example here:

https://github.com/temporalio/samples-python/tree/a0b2cdf4b0eef905776fba9b1a2805357b8b473e/pydantic_converter

Describe the bug

In the new versions, the converter was not working as advertised.

I had to modify the import of pydantic_encoder:

from pydantic.json import pydantic_encoder

to

from fastapi.encoders import jsonable_encoder

As show here:

https://fastapi.tiangolo.com/tutorial/encoder/#using-the-jsonable_encoder

--

I think it is a bug. But I am not a 100% to be honest if there is something else going on that I am not aware of.

cretz commented 1 month ago

In the new versions

Can you clarify, new versions of pydantic or new versions of the Python SDK? Specifically, can you confirm the sample does not work out of the box right now? If so, this may be a bug.

rakesh-163 commented 1 month ago

The same did not work out of the box with following versions of the SDK and Pydantic:

pydantic==2.8.2
temporalio==1.6.0

It worked when I made the one line change above.

cretz commented 1 month ago

The pydantic converter sample is meant for pydantic v1: https://github.com/temporalio/samples-python/blob/a0b2cdf4b0eef905776fba9b1a2805357b8b473e/pyproject.toml#L66-L68

97 is the open issue for v2.

rakesh-163 commented 1 month ago

In that case, this seems redundant. Thanks.