Hi there! I'm testing out
pydantic>2
(version
2.4.2
, to be exact) support released with
prefect==2.13.7
. Since the upgrade, we this error while deploying:
File "<snip>/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 996, in encode_default
return pydantic_encoder(dft)
^^^^^^^^^^^^^^^^^^^^^
File "<snip>/.venv/lib/python3.11/site-packages/pydantic/v1/json.py", line 90, in pydantic_encoder
raise TypeError(f"Object of type '{obj.__class__.__name__}' is not JSON serializable")
TypeError: Object of type 'ClassThatInheritsFromBaseModel' is not JSON serializable
This flow always worked before, and still works when downgrading with
pip install 'pydantic<2'
. Is this something that breaks on the
prefect
end or the
pydantic
end?
The context is that we have flow definitions that look like this:
@flow
def my_flow(complex_argument: ClassThatInheritsFromBaseModel = ClassThatInheritsFromBaseModel(some_value="a-sane-default")):
...
Just calling
ClassThatInheritsFromBaseModel(...).dict()
on all of the default args works, but adds clutter and makes type checkers unhappy.