AllenNeuralDynamics / AllenNeuralDynamics/one-liner

Pickle errors with pydantic

未關閉
#62 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
3
分支
0
PR 合併指標
30 天內沒有已合併 PR

描述

When returning ``model_dump()`` from a pydantic model, if its in python mode (default behavior) it will preserve python objects which breaks the client side code.

# Example (with Enum)

## RouterServer

```python
class Nums(Enum):
ONE = "one"
TWO = "two"

class Model(BaseModel):
input: str
num: Nums

class Test:
def test(self, input: str, num: Nums = []) -> Model:
# model_dump runs in python mode and will preserve the Nums object
# ex. {'input': 'Hello'. 'num': '}
return Model(input=input, num=num) .model_dump()
```
## RouterClient

```python
client = RouterClient()
print(client.call_by_name("test", args=["Hello World!", "one"]))
```

I believe one-liner will pickle the return as ``'input': 'Hello'. 'num': '}``

Then the client will try to do: ``__main__.Nums.ONE`` and fail. I think this will be true for any python object from ``model_dumps(mode=python)``

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。