AllenNeuralDynamics / AllenNeuralDynamics/one-liner

Pickle errors with pydantic

Abierto
#62 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
3
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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)``

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.