Skip to content

[FIX,PYOPENMS] Restore 3.5's in/out list updates and lost overloads; fix OPXLHelper - #10289

Merged
timosachsenberg merged 2 commits into
developfrom
claude/confident-lovelace-muuw2w-bindings
Sep 27, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
claude/confident-lovelace-muuw2w-bindings

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

This fixes the pyOpenMS 3.6 binding regressions that the release-readiness replay of the user guide found (#10260). They fall into four groups:

  • lists that silently stop updating;
  • calls that 3.5 had and 3.6 lost;
  • two OPXLHelper binding bugs;
  • char arguments that no longer take bytes.

A fifth, unrelated bug turned up while testing: MSExperiment.to_arrow() failed instead of falling back when its zero-copy module is missing.

1. In/out lists update the caller's list again

Many OpenMS functions update a std::vector<T>& argument. pyOpenMS 3.5 wrote the result back into the Python list the caller passed. nanobind cannot bind a Python list to a non-const vector reference, so the 3.6 bindings take the vector by value and return the updated copy.

As a result, 3.5 code still runs, but its list silently stays unchanged. For example, after IDFilter.removeUnreferencedProteins(prots, peps) the caller's prots still holds every protein.

Fix: pyopenms/addons/inout_lists.py wraps the 34 affected methods; the table in that file lists them. After the bound function returns, the wrapper copies the result into a Python list passed at the in/out position, positionally or by keyword, and it passes the return value through unchanged.

  • So both f(prots, peps) (3.5) and prots = f(prots, peps) (3.6) work.
  • The shape of the result tells which overload ran:
    • None (an overload that updates a bound container in place) is left alone;
    • a list goes to the in/out argument;
    • a tuple is mapped element by element.
  • Tuples and other sequences are accepted but not updated, as before.
  • apply_addons() installs the wrappers. They keep __name__, __qualname__ and the overload signatures (__nb_signature__), and their docstring says which argument is updated.
  • The stub step runs stubgen with PYOPENMS_STUBGEN=1, which leaves the bound functions unwrapped. stubgen would otherwise write (*args, **kwargs) for the wrapped methods; with it the stubs are unchanged.

A C++ caster that writes back after the call would be the cleaner long-term design, but it needs a new caster for every element type and a full rebuild on three platforms just before the release. The add-on works like the existing convexhull.py wrapping.

Five of these methods also changed their return type: PeptideIndexing.run(), PosteriorErrorProbabilityModel.fit() and initPlots(), IDFilter.updateProteinGroups() and AbsoluteQuantitation.optimizeCalibrationCurveIterative(). Each now returns a tuple instead of its 3.5 result.

  • The add-on restores their list updates.
  • The CHANGELOG's output-arguments entry now says that the tuple makes a check like if model.fit(...) always true.

2. Calls that 3.5 had

  • MapAlignmentAlgorithmIdentification:
    • align(maps, reference_index=-1) aligns several FeatureMaps, ConsensusMaps or PeptideIdentificationLists and returns one TransformationDescription per map.
    • The 3.5 form align(maps, transformations, reference_index) fills the list passed in.
    • setReference() takes a PeptideIdentificationList again.
    • Only a single-map align(map) was bound, so the median alignment of several maps was not available from Python (map_alignment.rst).
    • The new overloads come after the single-map ones, because an empty FeatureMap is also an empty sequence of maps.
  • IDFilter:
  • TransitionTSVFile and TransitionPQPFile took their file names as const char*, which nanobind accepts only as str. They now take std::string, which accepts bytes like the other file methods.

3. OPXLHelper

  • computeDeltaScores() was bound without a parameter: it scored an empty list and returned it. It now takes the identifications, a PeptideIdentificationList in place or a list.
  • For addXLTargetDecoyMV, addBetaAccessions, removeBetaPeptideHits, addProteinPositionMetaValues and computeDeltaScores, the by-value std::vector overload was registered first. A PeptideIdentificationList is a sequence, so that overload also took it and updated a copy.
  • The in-place PeptideIdentificationList overload now comes first, so these update the caller's container as in 3.5.

4. char arguments

nanobind's char caster accepts only a one-character str, while 3.5 accepted only bytes. The error is immediate, and the fix is one character. So this PR documents it as BREAKING, listing the affected methods, rather than wrapping them. AAIndex is included: its methods are static in 3.6, and it has no constructor.

5. MSExperiment.to_arrow() without _arrow_zerocopy

An import warnings inside the long_format branch made warnings a local name for the whole function. So when pyopenms._arrow_zerocopy is missing, the fallback raised UnboundLocalError instead of warning and exporting in Python.

  • I found this while testing in a build without that module.
  • It is a separate commit with its own regression test.

Validation

  • All binding modules were built from this branch against the 2026-09-24 nightly libraries (8b25c6e), with nanobind 3.1.0 on Python 3.11. The results below come from that build.
  • New tests: test_inout_lists.py (the add-on) and five tests in test_restored_call_forms.py (the C++ changes). All 69 tests in the two files pass.
    • Against develop's bindings built the same way, test_inout_lists.py cannot even be imported (the add-on does not exist there), and the five new call-form tests fail.
    • The add-on tests also check that every table entry names a list parameter of an overload that returns that shape, taken from __nb_signature__.
  • Full suite, this branch vs develop, both built as above:
    • develop: 6298 passed, 44 failed, 1 error; this branch: 6355 passed, 44 failed, 1 error.
    • Compared test by test through JUnit, none of the 6408 shared tests changes outcome, and all 57 new tests pass.
    • The 44 failures and the error happen in both builds and come from the local setup:
      • class-test data files that are not in the copied tests folder (the XIC/XIM/XIPM Parquet tests);
      • the _arrow_zerocopy module, which this local build does not produce (three test files were left out of both runs for that reason; eleven to_arrow tests hit the UnboundLocalError from section 5).
    • With the section 5 fix, 10 of those 11 pass through the Python fallback. The 11th counts warnings and also sees the fallback's own warning.
  • Stubs: nanobind.stubgen on the processing module with PYOPENMS_STUBGEN=1 writes the typed overloads, e.g. removeUnreferencedProteins(proteins: Sequence[ProteinIdentification], peptides: PeptideIdentificationList) -> list[ProteinIdentification]. Without it, stubgen writes def removeUnreferencedProteins(*args, **kwargs).
  • User guide: the two pages that [DOC,PYOPENMS] Update the pyOpenMS user guide to the 3.6 API; macOS 15 minimum #10285 still lists as failing now pass the replay (doc-examples.py), in [DOC,PYOPENMS] Update the pyOpenMS user guide to the 3.6 API; macOS 15 minimum #10285's version:

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes (with the local build described above; CI builds the wheels)
  • Updated or added python bindings for changed or new classes

🤖 Generated with Claude Code

https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7


Generated by Claude Code

Summary by CodeRabbit

  • Compatibility
    • Methods retaining their existing arguments may now return tuples containing the result and updated lists. Unpack these tuples explicitly; their truth value is always True.
    • Python lists passed to supported methods are updated in place. Tuples and other sequences are not.
    • Character arguments accept one-character strings; bytes are rejected. AAIndex methods are static, and its constructor is no longer available.
  • New Features
    • Map alignment supports multiple maps and peptide-identification runs, with optional reference selection.
    • Restored call forms include protein-hit score filtering, OPXL scoring, and string filenames for transition files.
  • Bug Fixes
    • Restored updates to caller-provided lists for supported methods.

…fix OPXLHelper

nanobind cannot bind a Python list to a non-const std::vector reference,
so the 3.6 bindings take such vectors by value and return the updated
copy. 3.5 code still ran, but the caller's list silently stayed
unchanged: after IDFilter.removeUnreferencedProteins(prots, peps) or
FalseDiscoveryRate().apply(prots), prots was untouched (#10260).

- pyopenms/addons/inout_lists.py wraps the 34 affected methods. After the
  call it copies the result into a Python list passed at the in/out
  position, so both f(prots, peps) and prots = f(prots, peps) work.
  apply_addons() installs it. The stub step sets PYOPENMS_STUBGEN, which
  skips the wrappers, because stubgen would describe them as
  (*args, **kwargs).
- MapAlignmentAlgorithmIdentification aligns several maps again, and
  accepts 3.5's align(maps, transformations, reference_index);
  setReference() takes a PeptideIdentificationList again.
- IDFilter.filterHitsByScore() takes a list of ProteinIdentification
  again, and updateProteinReferences() is a deprecated alias of
  removeDanglingProteinReferences().
- OPXLHelper.computeDeltaScores() was bound without its argument. The
  in-place PeptideIdentificationList overloads of the OPXLHelper methods
  now come before the by-value vector ones, which also accepted a
  PeptideIdentificationList and updated a copy.
- TransitionTSVFile and TransitionPQPFile take file names as
  std::string, which accepts bytes, instead of const char*.
- CHANGELOG: the above, the five methods that now return a tuple, and
  the char arguments that take a one-character str instead of bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7
…ut _arrow_zerocopy

An 'import warnings' inside the long_format branch made warnings a local
name for the whole function. When pyopenms._arrow_zerocopy is missing,
the fallback then raised UnboundLocalError instead of warning and
exporting in Python. The module already imports warnings.

Found while testing the bindings in a build without the zero-copy
module: 11 to_arrow tests failed there with the UnboundLocalError. With
the fix, 10 of them pass through the fallback. The 11th counts the
warnings and so also sees the fallback's own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 936d98e4-3d83-440f-a021-cdd7312d2569

📥 Commits

Reviewing files that changed from the base of the PR and between a28498a and b2aeee9.

📒 Files selected for processing (11)
  • CHANGELOG
  • src/pyOpenMS/CMakeLists.txt
  • src/pyOpenMS/bindings/bind_analysis.cpp
  • src/pyOpenMS/bindings/bind_misc.cpp
  • src/pyOpenMS/bindings/bind_processing.cpp
  • src/pyOpenMS/pyopenms/addons/__init__.py
  • src/pyOpenMS/pyopenms/addons/inout_lists.py
  • src/pyOpenMS/pyopenms/addons/msexperiment.py
  • src/pyOpenMS/tests/unittests/test_dataframe_columns.py
  • src/pyOpenMS/tests/unittests/test_inout_lists.py
  • src/pyOpenMS/tests/unittests/test_restored_call_forms.py
💤 Files with no reviewable changes (1)
  • src/pyOpenMS/pyopenms/addons/msexperiment.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The changes restore several pyOpenMS binding call forms and add compatibility handling for Python lists passed to methods that return updated lists. They also update stub generation, document compatibility details, and test the Arrow export fallback when its optional zero-copy module is unavailable.

Changes

Binding compatibility

Layer / File(s) Summary
In/out list compatibility
src/pyOpenMS/pyopenms/addons/*, src/pyOpenMS/CMakeLists.txt, src/pyOpenMS/tests/unittests/test_inout_lists.py, CHANGELOG
The addon wraps configured methods and writes returned list contents into supplied Python lists. Stub generation sets PYOPENMS_STUBGEN=1. Tests and changelog notes cover this behavior and tuple-return compatibility.
Restored binding call forms
src/pyOpenMS/bindings/bind_analysis.cpp, src/pyOpenMS/bindings/bind_misc.cpp, src/pyOpenMS/bindings/bind_processing.cpp, src/pyOpenMS/tests/unittests/test_restored_call_forms.py, CHANGELOG
Bindings add map-alignment overloads, peptide-list reference setting, protein score filtering, a deprecated protein-reference alias, and updated OPXL and transition-file call forms. Tests and changelog notes cover these APIs and related compatibility details.

Arrow fallback

Layer / File(s) Summary
Optional zero-copy fallback
src/pyOpenMS/pyopenms/addons/msexperiment.py, src/pyOpenMS/tests/unittests/test_dataframe_columns.py
to_arrow() continues to use the module-level warnings import. A regression test checks the warning and output row count when _arrow_zerocopy is unavailable.

Sequence Diagram(s)

sequenceDiagram
  participant PythonCaller
  participant inout_lists
  participant nanobindMethod
  PythonCaller->>inout_lists: Call wrapped method with Python list
  inout_lists->>nanobindMethod: Forward method call
  nanobindMethod-->>inout_lists: Return result containing updated list
  inout_lists->>PythonCaller: Write list contents back and return original result
Loading

Suggested reviewers: cbielow, claude

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b2aee

The restored call forms and list updates have no established issue requiring a change before merge; normal checks remain appropriate.

Security Architecture Review

Security architecture risk: 🔵 Low · up to b2aee

The changes affect how Python callers receive updated scientific data, but the reviewed paths do not show a new privilege boundary or broader external exposure. Some compatibility and security coverage remains incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The identified new mutation reaches lists supplied by callers of configured pyOpenMS methods. The reviewed wrapper does not introduce a cross-service, tenant, credential, or persistent-store access path.

Trust Boundaries and Controls

  • observed — Caller-provided arguments still cross into the existing bound method before compatibility writeback. The wrapper selects only configured positional or keyword targets and copies results only into list targets.

Resilience and Maintainability Implications

  • observed — Wrapper installation checks a marker before replacement, avoiding repeated wrapping when installation runs again.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 8 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: restoring pyOpenMS 3.5 in/out list updates and overloads, and fixing OPXLHelper.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 8 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

A rabbit checks the lists in spring,
Returned rows hop back with a bounce.
New call forms join the binding burrow,
A warning marks the fallback path,
And tidy tests complete the count.

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

timosachsenberg pushed a commit to timosachsenberg/openms-test-lab that referenced this pull request Sep 27, 2026
The first complete nightly since 2026-09-25 (four wheels, four
installers, all from f0f2424, develop after OpenMS/OpenMS#10285) was
checked with the full lab matrix, the Release readiness workflow and
the by-hand checks.

Now passing: A1, A2, C3 on every platform (the seven macOS TOPPAS tests
pass), C6, D1, D2, E8, E9, F1 and F6 (OpenSSL 3.6.4). Still blocking:
- C5: the Thermo default reader, fixed on develop by OpenMS/OpenMS#10274
  after this nightly;
- D5: the char-argument BREAKING note, added by OpenMS/OpenMS#10289;
- E4, F7 and F8, unchanged.

Three user-guide pages still fail but no longer count as regressions,
because 3.5.0 fails their rewritten versions too; the report notes this
gap in D2. The supported-platform paragraph of RELEASE-READINESS now
says macOS 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7
timosachsenberg added a commit to timosachsenberg/openms-test-lab that referenced this pull request Sep 27, 2026
…#4)

* Record the 2026-09-25 readiness check of the 3.6.0 nightly

The nightly of 2026-09-24 (published 2026-09-25) is still NOT READY, but
every artifact now comes from one revision, 8b25c6e, so this report can
judge one build end to end. The whole release matrix ran for the first
time, including the Windows, macOS and Linux Python 3.14 runs and the
Ubuntu 22.04 wheel run.

Changes against the 2026-09-24 report:
- A2, D6, B2/B5/B8/B9, F2, F5 and E9 pass. The Release workflow's Linux
  job builds the docs and runs Doxygen_Warning_test, which the previous
  report said no workflow did.
- F7 is new: the Windows installer is unsigned and release.yml has no
  Windows signing step. The macOS package is signed and notarized.
- The blocking failures in D1, D2/D5, F6, C3 (macOS), C5, E1/E2/E4/E8
  and F1/C6 are unchanged; the four commits since touch none of them.
- FeatureLinkerWNet is no longer in any package (OpenMS#10255), so C1
  counts 153 tools and C3 records its two tests as not registered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* Draft pyOpenMS 3.6.0 BREAKING notes from a 3.5.0/3.6.0 signature diff

The draft proposes CHANGELOG entries for D1 and D5 of the 2026-09-25
readiness check: output arguments that became return values, bytes that
became str inside returned containers, LogConfigHandler.getInstance(),
the callable database singletons and the renamed enums. Every example was
run in pyopenms 3.5.0 and in the 3.6.0.dev20260925 nightly.

Comparing the parsed method signatures of both builds also turned up
binding bugs that need fixing rather than a note:
- SimpleSearchEngineAlgorithm.search() raises std::bad_cast;
- copy.copy() returns a base-class object for 52 classes;
- in/out arguments were bound as pure outputs (XLMS spectrum generators,
  OPXLHelper.computeDeltaScores, IsotopeLabelingMDVs.calculateMDVAccuracy);
- 27 call forms lost their C++ default arguments;
- several overloads were dropped.

The appendix lists every 3.5.0 call form that 3.6.0 rejects. The
removed-classes section is still pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* Complete the pyOpenMS notes draft with the removed classes

Fill in the D1 section: for each of the 22 removed classes, whether the
C++ class went too, whether the binding was dropped on purpose, and the
3.6.0 replacement, run in the nightly. Propose BREAKING entries for the
removed classes and for MassTrace, which now names the kernel mass trace
rather than 3.5.0's FeatureFinder struct.

Add bug B6: SignalToNoiseEstimatorMedianRapid, SplineInterpolatedPeaks,
the ConsensusFeature ratio API and RealMassDecomposer are unusable
because their argument or result types are not bound.

Correct the enum accounting. Of the vanished nested members, 195 still
resolve under their 3.5.0 spelling. The rest are renamed or announced,
apart from five that are gone with no replacement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* Point the pyOpenMS notes draft at the fix PRs and correct two counts

Section 1's CHANGELOG entries and the fixes for B1, B2 and B4 are now in
OpenMS/OpenMS#10272, and the C5 vendor-reader fixes are in #10273 and
#10274. B2 now counts only classes that copied in 3.5.0: 52 slice and
10 cannot be copied, rather than 8. Classes new in 3.6 are counted
separately. replaceCVTerms lost its overload on 16 classes, not 17.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* Readiness report for the 2026-09-26 nightly: NOT READY, no installers

The wheels come from 3e73c70 (develop after OpenMS/OpenMS#10277). The
Release run on the same revision failed while notarizing the macOS
package, because the runner lost its network, so no installer of this
nightly was deployed. Rerun here: A1-A3 for the wheels, D1 (19
unannounced names, 0 with #10272 in develop), D2 (unchanged, 15
regressions), D6 and the source audit (E1-E3 now pass). The package
checks carry over from the 2026-09-25 report.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* Readiness report for the 2026-09-27 nightly: NOT READY

The first complete nightly since 2026-09-25 (four wheels, four
installers, all from f0f2424, develop after OpenMS/OpenMS#10285) was
checked with the full lab matrix, the Release readiness workflow and
the by-hand checks.

Now passing: A1, A2, C3 on every platform (the seven macOS TOPPAS tests
pass), C6, D1, D2, E8, E9, F1 and F6 (OpenSSL 3.6.4). Still blocking:
- C5: the Thermo default reader, fixed on develop by OpenMS/OpenMS#10274
  after this nightly;
- D5: the char-argument BREAKING note, added by OpenMS/OpenMS#10289;
- E4, F7 and F8, unchanged.

Three user-guide pages still fail but no longer count as regressions,
because 3.5.0 fails their rewritten versions too; the report notes this
gap in D2. The supported-platform paragraph of RELEASE-READINESS now
says macOS 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

---------

Co-authored-by: Claude <[email protected]>
@timosachsenberg
timosachsenberg merged commit 33ba5ea into develop Sep 27, 2026
33 checks passed
@timosachsenberg
timosachsenberg deleted the claude/confident-lovelace-muuw2w-bindings branch September 27, 2026 13:04
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