AllenNeuralDynamics / AllenNeuralDynamics/one-liner
Pickle errors with pydantic
- Vorherrschende Sprache
- Python
- Sterne
- 3
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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)``
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.