-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
build(python): Update to PyO3 to 0.18.0 #6531
build(python): Update to PyO3 to 0.18.0 #6531
Conversation
5ed32c9
to
3dfd28f
Compare
I still have tests failure because NumPy arrays containing strings cannot be converted to |
I believe it is related to PyO3/pyo3#2615 This blocked previous upgrade. |
@jjerphan maybe we can add a new constructor specialized for this case? Or we could ask upstream what is best way to do this in latest release? |
I guess we can ask upstream and in the mean time have a new constructor which has been specialized for this case with a comment indicating that such a constructor is temporary. What do you think of this approach? |
Yes, I think that's a good idea. |
Perfect. I am busy now, but I should be able to have a look at it tomorrow. I also have followed-up discussions with PyO3/pyo3#2615 (comment). |
Could someone point me to where the entry point for those failing tests is so that I can check which downcast/extraction is failing exactly? Thank you! |
@adamreichold I can come back to you in an hour. 👍 |
So by digging and observing that this seems to affect only NumPy arrays of strings, I suspect that this comes from |
I think I found the issue, your various impls like impl<'a, T> FromPyObject<'a> for Wrap<ChunkedArray<T>> use a helper function pub(crate) fn get_pyseq(obj: &PyAny) -> PyResult<(&PySequence, usize)> {
let seq = <PySequence as PyTryFrom>::try_from(obj)?;
let len = seq.len()?;
Ok((seq, len))
} and this will indeed fail with NumPy arrays as we do not downcast those to But I also think that your code does not actually use the sequence interface as both diff --git a/py-polars/src/conversion.rs b/py-polars/src/conversion.rs
index 463b65371..575d69fbd 100644
--- a/py-polars/src/conversion.rs
+++ b/py-polars/src/conversion.rs
@@ -125,10 +125,10 @@ impl<'a> FromPyObject<'a> for Wrap<BooleanChunked> {
impl<'a> FromPyObject<'a> for Wrap<Utf8Chunked> {
fn extract(obj: &'a PyAny) -> PyResult<Self> {
- let (seq, len) = get_pyseq(obj)?;
+ let len = obj.len()?;
let mut builder = Utf8ChunkedBuilder::new("", len, len * 25);
- for res in seq.iter()? {
+ for res in obj.iter()? {
let item = res?;
match item.extract::<&str>() {
Ok(val) => builder.append_value(val), should work. |
Thanks a lot @adamreichold. I believe that was the issue indeed. Will come back with a confirmation. I |
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
It looks like default values for all optional parameters must be provided as "required arguments after an |
Yes, everything with an
|
Is there a simple way to infer default values for signatures' arguments? |
In polars rust side all arguments are always required. So signature should just name all arguments. |
At the moment, I get this kind of warning:
I've tried to only specify the list of arguments' names, but I get other errors. It seems that default values for required arguments must be provided. For instance, I get the following error:
Edit: |
Did you add |
Mainly using the '#[pyo3(signature = ...)]' macro. See: https://pyo3.rs/v0.18.0/migration
I might be wrong, or there might be a naming discrepancy.
Everything should be up to date. Please, let me know if |
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.
Here are some questions regarding some of the proposed changes.
@@ -230,6 +230,7 @@ def _scan_parquet( | |||
rechunk, | |||
_prepare_row_count_args(row_count_name, row_count_offset), | |||
low_memory, | |||
cloud_options=storage_options, |
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 change wrong, or is there a naming discrepancy here?
Thanks a lot @jjerphan and @adamreichold for the help. Let me know when it is good to go. |
Thank you for your guidance, @ritchie46 and @adamreichold. I think this is mergeable. |
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Follow-up of #4794