Richard Sundqvist
10/16/2023, 12:34 PMpydantic>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.Alexander Azzam
10/16/2023, 1:23 PMRichard Sundqvist
10/16/2023, 2:18 PMBaiji He
10/27/2023, 7:00 AMpip install 'pydantic<2'
worked.Alexander Azzam
11/02/2023, 10:50 PMRichard Sundqvist
11/03/2023, 7:05 AMAlexander Azzam
11/03/2023, 10:46 AMAlexander Azzam
11/03/2023, 10:47 AM