PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.31k stars 1.5k forks source link

Add extra info to pydantic error to help users recover #14275

Closed jlowin closed 4 days ago

jlowin commented 4 days ago

There is a longstanding issue with pickling locally-defined Pydantic models that is suddenly biting a lot of users (including myself 😅 ) now that we are optimistically persisting results by default for the transactional layer. A user testing ControlFlow immediately ran into this last night. We can take steps in CF proactively because we know what the user is trying to do, but I'm not sure how heavy-handed we can be in Prefect proper. For example, I do not think we can automatically select a different serializer at this point. Instead, this PR adds an explanation to what is otherwise a very cryptic error (TypeError: cannot pickle 'sqlite3.Connection' object), which we reraise.

jlowin commented 4 days ago

See also https://github.com/pydantic/pydantic/issues/8232