Skip to content
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 pyo3 and numpy crates to version 0.23 #20111

Merged
merged 37 commits into from
Dec 13, 2024

Conversation

bschoenmaeckers
Copy link
Contributor

Updated to latest pyo3 while ignoring most deprecations for now.

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 57.12954% with 460 lines in your changes missing coverage. Please review.

Project coverage is 79.61%. Comparing base (f599e88) to head (73f3a90).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../polars-python/src/lazyframe/visitor/expr_nodes.rs 0.00% 293 Missing ⚠️
...rates/polars-python/src/lazyframe/visitor/nodes.rs 8.53% 75 Missing ⚠️
crates/polars-python/src/map/series.rs 66.21% 25 Missing ⚠️
crates/polars-python/src/series/aggregation.rs 74.07% 14 Missing ⚠️
crates/polars-python/src/lazyframe/visit.rs 23.52% 13 Missing ⚠️
crates/polars-python/src/conversion/mod.rs 90.32% 9 Missing ⚠️
crates/polars-python/src/series/general.rs 66.66% 5 Missing ⚠️
crates/polars-python/src/cloud.rs 33.33% 4 Missing ⚠️
crates/polars-python/src/map/lazy.rs 69.23% 4 Missing ⚠️
crates/polars-python/src/map/dataframe.rs 75.00% 3 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20111      +/-   ##
==========================================
+ Coverage   79.59%   79.61%   +0.02%     
==========================================
  Files        1565     1565              
  Lines      218462   218316     -146     
  Branches     2475     2475              
==========================================
- Hits       173885   173816      -69     
+ Misses      44010    43933      -77     
  Partials      567      567              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stinodego stinodego changed the title chore: update to pyo3 v0.23 build: Update pyo3 and numpy crates to version 0.23 Dec 2, 2024
@github-actions github-actions bot added build Changes that affect the build system or external dependencies python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Dec 2, 2024
@stinodego stinodego changed the title build: Update pyo3 and numpy crates to version 0.23 build(python): Update pyo3 and numpy crates to version 0.23 Dec 2, 2024
@stinodego stinodego removed the rust Related to Rust Polars label Dec 2, 2024
@stinodego
Copy link
Member

stinodego commented Dec 3, 2024

@bschoenmaeckers Thanks for picking this up! Looks like the new PyO3 version causes deadlock somewhere - can you reproduce this locally? There's probably a clue in the migration guide somewhere on what could be causing this.

@bschoenmaeckers
Copy link
Contributor Author

@bschoenmaeckers Thanks for picking this up! Looks like the new PyO3 version causes deadlock somewhere - can you reproduce this locally? There's probably a clue in the migration guide somewhere on what could be causing this.

Haven't had time to dig deeper today, but I could quite consistently reproduce this error locally with the following command.

pytest tests/unit/operations/map/test_map_elements.py -n 4 --verbose

@bschoenmaeckers
Copy link
Contributor Author

Deadlock happens in the Display implementation of PyErr when 2 threads call warning_function at the same time. Will investigate further to reproduce this within Pyo3.

fn warning_function(msg: &str, warning: PolarsWarning) {
Python::with_gil(|py| {
let warn_fn = UTILS.bind(py).getattr(intern!(py, "_polars_warn")).unwrap();
if let Err(e) = warn_fn.call1((msg, Wrap(warning))) {
eprintln!("{e}")
}
});
}

@ritchie46
Copy link
Member

ritchie46 commented Dec 4, 2024

@bschoenmaeckers

Ah (spent too many hours on this0, I also came to the conclusion that it is related to the warning. What I observe is that the GIL doesn't matter, but if I call warning.warn in _polars_warn we deadlock. if we do anything else there it seems to be ok.

@bschoenmaeckers
Copy link
Contributor Author

Does this solve the deadlock? https://github.com/PyO3/pyo3/pull/4766/files

Looks like it does!

@ritchie46
Copy link
Member

Great! :)

@bschoenmaeckers
Copy link
Contributor Author

I fixed all the deprecation warnings. So this is ready for review.

object_store = { version = "0.11", default-features = false }
once_cell = "1"
parking_lot = "0.12"
percent-encoding = "2.3"
pin-project-lite = "0.2"
pyo3 = "0.22"
pyo3 = { git = "https://github.com/bschoenmaeckers/pyo3.git", branch = "release-0.23" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add back the temporary fix for PyO3/pyo3#4764 until PyO3/pyo3#4766 is released. If that is desirable.

@ritchie46
Copy link
Member

Thanks a lot @bschoenmaeckers. Can you rebase? There are some conflicts.

@bschoenmaeckers
Copy link
Contributor Author

Thanks a lot @bschoenmaeckers. Can you rebase? There are some conflicts.

Done,

@ritchie46
Copy link
Member

Thanks a lot for pushing this effort @bschoenmaeckers. Greatly appreciated. P.S. I see you live in the Netherlands. Might you be interested, we're hiring ;)

@ritchie46 ritchie46 merged commit df8672d into pola-rs:main Dec 13, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Changes that affect the build system or external dependencies python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants