Hi there! I'm testing out `pydantic>2` (version `2...
# ask-community
r
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:
Copy code
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:
Copy code
@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.
👀 1
✅ 1
a
Hi @Richard Sundqvist! 👋 ! I’m keeping an eye on pydantic issues as they come up, so I’ll try to reproduce on my end and see if I can provide any clarity whether it’s a prefect or a pydantic issue.
r
@Alexander Azzam I created an issue for this: https://github.com/PrefectHQ/prefect/issues/10965 Repro is trivial, at least with a server running 🙂. Probably without, too.
🙌 2
b
I went into the same issue trying to prefect deploy a flow with ShellOperation.
pip install 'pydantic<2'
worked.
a
Hey @Richard Sundqvist I believe this has finally been addressed in today's release (https://prefect-community.slack.com/archives/CKNSX5WG3/p1698965320644549) please let us know if you still see this issue coming up
r
I've been following urimandujano's PR in fact 🙂. Quite a quick turnaround considering the number of curve balls that seem to have been involved. Please extend our thanks to everyone who worked on this!
a
Such a pleasure. We’re all grateful to you for taking the time to surface and leave an issue.
teamwork