Skip to content

[pyOpenMS][TEST] Prove Arrow zero-copy exports survive owner GC (#9460) - #9543

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-arrow-zerocopy-lifetime
Jun 16, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-arrow-zerocopy-lifetime

Conversation

@timosachsenberg

Copy link
Copy Markdown
Contributor

What

Adds lifetime tests (numpy/pyarrow importorskip) for the Arrow zero-copy exporters spectra_to_arrow() / chromatograms_to_arrow():

  1. snapshot every column while the source MSExperiment is still alive,
  2. del the experiment + gc.collect(),
  3. re-read every column and assert byte-equality with the snapshot, and that the (now owner-less) buffers still rebuild into a fresh Arrow table.

The snapshot is taken before deletion, so the comparison cannot pass vacuously (comparing corrupted data against itself).

Why

Closes the zero-copy-lifetime part of the §2 (pyOpenMS nanobind rewrite) [AUTO] task in the OpenMS 3.6.0 pre-release testing plan (#9460):

Prove zero-copy exports survive owner GC … the _arrow_zerocopy module hands buffers to PyArrow over the C Data Interface, lifetime riding on Arrow's release callback, not the source MSExperiment. test_arrow_zerocopy.py only checks shapes/columns today. … snapshot contents → del the source object → gc.collect() → re-read every value. Pass: bytes match the snapshot.

This is the riskiest of the zero-copy paths: unlike the numpy getters (which own their buffer via an nb::capsule + delete[], already covered by test_spectrum_zerocopy.py), the Arrow exports' buffer lifetime is detached from the source experiment. test_arrow_zerocopy.py exercised only shapes/columns/formats — never source-GC survival.

Test plan

Tests only — no production code changed. Verified against the built nanobind bindings two ways: direct script (All arrow zero-copy lifetime tests passed!) and pytest (2 passed). numpy/pyarrow importorskip keep it optional; the modules used (experiment/spectrum/kernel + _arrow_zerocopy) are unaffected by the unrelated stale-build _pyopenms_analysis warning.

Part of #9460. Follows #9524 … #9542.

🤖 Generated with Claude Code

…MS#9460)

pyopenms._arrow_zerocopy.spectra_to_arrow()/chromatograms_to_arrow() hand peak
buffers to PyArrow over the C Data Interface; their lifetime rides on Arrow's
release callback, not the source MSExperiment. The existing test_arrow_zerocopy.py
only checks shapes/columns -- never that the data survives the source being freed.

Adds lifetime tests (numpy/pyarrow importorskip): snapshot every column WHILE the
source experiment is alive, then `del` it + gc.collect(), then re-read and assert
byte-equality (and that the owner-less buffers still rebuild into a fresh table).
The snapshot is taken before deletion so the comparison cannot pass vacuously.

Closes the zero-copy-lifetime part of issue OpenMS#9460 Section 2. Verified against the
built nanobind bindings (2 passed).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@timosachsenberg, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 34 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5bdda083-cdda-4bd7-afd4-4e651a47a2d9

📥 Commits

Reviewing files that changed from the base of the PR and between aacd941 and 8c24e19.

📒 Files selected for processing (1)
  • src/pyOpenMS/tests/unittests/test_arrow_zerocopy_lifetime.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Timo Sachsenberg

Please consider applying the following patch:

--- AUTHORS	2026-06-15 17:57:22.562596841 +0000
+++ AUTHORS.new	2026-06-15 17:57:27.787211968 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@timosachsenberg
timosachsenberg merged commit 7bb91a5 into OpenMS:develop Jun 16, 2026
41 checks passed
@timosachsenberg timosachsenberg mentioned this pull request Jun 17, 2026
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.

1 participant