-
Notifications
You must be signed in to change notification settings - Fork 174
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
[CHORE] Centralize pyo3 pickling around __reduce__
+ bincode macro.
#1394
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1394 +/- ##
==========================================
- Coverage 87.81% 87.79% -0.02%
==========================================
Files 60 60
Lines 6041 6032 -9
==========================================
- Hits 5305 5296 -9
Misses 736 736
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Thanks for taking this on
@@ -11,7 +11,7 @@ use common_error::{DaftError, DaftResult}; | |||
/// Supported image formats for Daft's I/O layer. | |||
#[allow(clippy::upper_case_acronyms)] | |||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] | |||
#[cfg_attr(feature = "python", pyclass)] | |||
#[cfg_attr(feature = "python", pyclass(module = "daft.daft"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make an attr that is daftpyclass=pyclass(module = "daft.daft")
and use that everywhere?
&self, | ||
py: Python, | ||
cast_tensor_type_for_ray: Option<bool>, | ||
) -> PyResult<PyObject> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a bad diff? what's different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is a driveby! This was me noticing that we were redundantly capturing the GIL with Python::with_gil(|py| ...)
when pyo3 methods already have the GIL, and the py: Python
marker token can be transparently injected into the method by specifying it as an argument.
} | ||
|
||
impl_bincode_py_state_serialization!(PyField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be a good macro to implement as a derive so we can #[derive(PySerDe)]
e01594f
to
fec0c70
Compare
This PR ports all pyo3-exposed classes that need to be picklable to use a
__reduce__
+ bincode macro, which removes the need for a dummy/inefficient no-arg constructor.