Skip to content

Conversation

@PhilipDeegan
Copy link
Member

@PhilipDeegan PhilipDeegan commented Oct 15, 2025

seeing compile errors since pybind/pybind11#5866

should be resolved with the additional requires

also updated to smart_holders instead of shared_ptrs as noted here https://pybind11.readthedocs.io/en/stable/advanced/smart_ptrs.html#py-smart-holder

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

📝 Walkthrough

Walkthrough

Replace std::shared_ptr holder policies with py::smart_holder in multiple pybind11 class bindings, adjust Span and PyWrapper bindings, move PatchDataVectorDouble registrations earlier in module init, and add a requires clause to PatchData’s templated constructor to restrict constructibility.

Changes

Cohort / File(s) Summary
Smart holder migration
src/python3/cpp_simulator.hpp, src/python3/cpp_etc.cpp
Replace std::shared_ptr<T> holder policies with py::smart_holder for multiple py::class_ bindings (e.g., PatchData variants, ContiguousParticles, DataWrangler, PatchLevel, Splitter, Simulator, SamraiLifeCycle, PHARE::amr::Hierarchy, Span, PyWrapper).
Span / PyWrapper binding adjustments
src/python3/cpp_etc.cpp
Change py::class_<core::Span<double>, std::shared_ptr<...>>py::class_<core::Span<double>, py::smart_holder>. Change PyArrayWrapper<double> binding to use py::smart_holder and declare core::Span<double> as a base.
PatchDataVectorDouble registration move
src/python3/cpp_simulator.cpp
Add declarePatchData<std::vector<double>, N>(...) for N=1,2,3 earlier in module init and remove the later duplicate registrations.
Constructor constraint addition
src/python3/patch_data.hpp
Add requires std::is_constructible_v<Data, Args&&...> to PatchData(Args&&...) and fix forwarding to data(std::forward<Args>(args)...).

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • nicolasaunai
  • UCaromel

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title broadly indicates pybind related updates but fails to specify the key changes such as switching to pybind11 smart_holder and pinning the pybind11 version to resolve compile errors, making it too generic to clearly convey the main purpose of the PR. Please rename the PR to explicitly mention using smart_holder and pinning the pybind11 version to address compile errors, for example “Use pybind11 smart_holder and pin version to fix compile errors.”
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The description clearly states the compile errors introduced by a recent pybind11 pull request, references the need for an additional requires clause, and notes the switch to smart_holder usage, directly correlating to the changes made in the code.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/python3/cpp_simulator.hpp (1)

35-41: Add pybind11 smart_holder include and type-casters for shared_ptr interop

  • Add #include <pybind11/smart_holder.h> in src/python3/cpp_simulator.hpp (or a common binding header).
  • Define PYBIND11_SMART_HOLDER_TYPE_CASTERS for your shared_ptr-backed types (e.g. Sim, PHARE::amr::Hierarchy, and any other smart_holder types) alongside your type aliases.
🧹 Nitpick comments (1)
src/python3/cpp_etc.cpp (1)

44-46: Switch to smart_holder: ensure header and casters are available.

Verify that pybind11/smart_holder.h is included (likely via python3/pybind_def.hpp). If not, include it explicitly here or in a common header.

If Span/PyArrayWrapper (or any related APIs) pass/return std::shared_ptr across the Python boundary, add the required smart‑holder type‑casters for those types.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 238185f and 8d5c772.

📒 Files selected for processing (4)
  • res/cmake/dep/pybind.cmake (1 hunks)
  • src/python3/cpp_etc.cpp (1 hunks)
  • src/python3/cpp_simulator.cpp (1 hunks)
  • src/python3/cpp_simulator.hpp (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.hpp

⚙️ CodeRabbit configuration file

Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

Files:

  • src/python3/cpp_simulator.hpp
🧠 Learnings (1)
📓 Common learnings
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-07-26T22:04:34.160Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-10-09T08:32:15.667Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
🧬 Code graph analysis (1)
src/python3/cpp_simulator.cpp (1)
src/python3/cpp_simulator.hpp (8)
  • declarePatchData (32-42)
  • declarePatchData (32-32)
  • declare_essential (182-194)
  • declare_essential (182-182)
  • declareDim (45-60)
  • declareDim (45-45)
  • declare_all (168-179)
  • declare_all (168-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-13)
🔇 Additional comments (1)
src/python3/cpp_simulator.cpp (1)

15-17: OK to register PatchDataVectorDouble_ earlier.*

Reordering looks fine. Please confirm the later duplicate registrations were removed to avoid multiple-definition/overwrite at import.

@PhilipDeegan PhilipDeegan changed the title pin pybind version and use smart_holder pybind updates for latest master Oct 15, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d5c772 and e4601bb.

📒 Files selected for processing (1)
  • src/python3/patch_data.hpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.hpp

⚙️ CodeRabbit configuration file

Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

Files:

  • src/python3/patch_data.hpp
🧠 Learnings (1)
📓 Common learnings
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-07-26T22:04:34.160Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-10-09T08:32:15.667Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.

@PhilipDeegan
Copy link
Member Author

this is unnecessary strictly since pybind was fixed, but maybe we want it regardless

@nicolasaunai nicolasaunai merged commit 45128ed into PHAREHUB:master Nov 7, 2025
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants