-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make SchemaError and SchemaErrors picklable #722
Conversation
Codecov Report
@@ Coverage Diff @@
## master #722 +/- ##
=======================================
Coverage 98.40% 98.40%
=======================================
Files 39 39
Lines 3757 3773 +16
=======================================
+ Hits 3697 3713 +16
Misses 60 60
Continue to review full report at Codecov.
|
Thanks @matthiashuschle !
It's not great, but the only place this is documented is the
This makes sense to do. Maybe state explicitly what state isn't preserved? (e.g. "Pickling ParserError does not preserve the following state: failure_cases, data, etc.") |
also, be sure to set up pre-commit to catch mypy/linting/unit test errors |
7862556
to
7ee5d82
Compare
Thanks @cosmicBboy ! |
okay, gonna merge this into |
thanks @matthiashuschle, and congrats on your first contribution to pandera! 🎉🚀 |
description
ParserError
.BaseException
implements__reduce__
, which expects anargs
attribute in the object, it needs to be overridden.ReducedPickleExceptionBase
was created as base class for exceptions that need to convert attributes before pickling, so actual changes in the final exception classes are minimal.__reduce__
composes the state fromargs
, and__dict__
, and converts all__dict__
elements listed inTO_STRING_KEYS
to strings. The return signature of__reduce__
uses the three-tuple, that uses__new__
for object creation and then updates it via__setstate__
.__setstate__
creates a warning stating the non-conservation of state, listing converted keys.SchemaErrors.schema_errors
is not primitive, but not transformed in the process. I did not encounter an unpicklable case and it is highly unlikely to become problematic in size.rejected ideas - up for discussion
sample
orhead
instead of string conversion to reduce memory footprint of data members. The idea is to allow some degree of inspection. However, all ways to reduce data size are arbitrary to some degree, and string representation breaks any attempt to accidentally use incomplete data in further processing.