-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat: migrate to pyo3 #3520
base: master
Are you sure you want to change the base?
feat: migrate to pyo3 #3520
Conversation
0d6946a
to
ec727a7
Compare
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.
@anonrig Thank you for starting this, moving to PyO3 has been on our wishlist for a while! Couple of questions:
- Whats the reason for moving the crate to
py/rust
? I would prefer a top level workspace craterelay-pyo3
or similar (essentially renamingrelay-cabi
). - Should we split this into multiple steps and as a first step introduce Py03 for the bindings without introducing the dependency in many of our crates? E.g.
normalize_global_config
could be a#[pyfunction]
which still callsserde
internally. Ideally the function signatures on the python side (including error handling) do not change. This would reduce the risk of rolling this out.
a93c0aa
to
90dd8d1
Compare
Hey @jjbayer, thank you for the quick Look!
There was no specific reason, merely choice. @loewenheim fixed it and moved it into the correct place in the repo.
Ideally yes, for now, we're trying to focus on correctness, and meanwhile I'll prepare a document to discuss our options to merge and release this. |
1b96b9d
to
267a20f
Compare
Unfortunately it's currently impossible to convert between |
@loewenheim any next steps planned for this? |
@jjbayer There's still some work to be done; I'm a bit busy with other things but I do want to get this over the finish line. |
Goal
The goal of this pull-request is to remove
relay_cabi
,relay_ffi
andrelay_ffi_macros
and replace it with a more modern approach: pyo3. The proposed changes reduce the Python surface area of the implementation and implements most of the functionality in Rust, making maintenance a lot easier to the current approach.Limitations
Missing functionality:
validate_register_response
does not returnuuid
as Uuid type, but returns as a string. This is due to the limitation of pyo3.SecretKey
does not have a function calledpack
. This is due to the limitation of pyo3, since it requiresjson.dumps
to be called on an unknown JSON object. The lack of object signature knowledge results in the requirement of callingjson.dumps
on Python side.relay_store_normalizer_normalize_event
requires an object ofAnnotated<Event>
to be deserialized and serialized. Unfortunately, pyo3 doesn't support structs with generics. Therefore, deserializer/serializer can not be used, andnormalize_event
can not be implemented in a relatively easy way. This applies to several other functions such aspii_strip_event
.Todo
sentry_relay.validate_pii_selector
usage