Skip to content

Fix pyOpenMS import failure when built with WITH_WNETALIGN=OFF - #9957

Merged
timosachsenberg merged 2 commits into
developfrom
claude/openms-issue-9946-eybwtm
Aug 25, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
claude/openms-issue-9946-eybwtm

Conversation

@timosachsenberg

Copy link
Copy Markdown
Contributor

Description

Fixes #9946.

Building with -DWITH_WNETALIGN=OFF excludes WNetMatcher.cpp and FeatureGroupingAlgorithmWNet.cpp from libOpenMS, but bind_misc.cpp referenced their symbols unconditionally. Since shared modules resolve symbols lazily, the build succeeded with zero errors and every import pyopenms then failed with an undefined-symbol ImportError in _pyopenms_misc — making the entire package unusable.

The fix: guard the WNet includes and the WNetMatcherDistanceMetric / WNetMatchResult / WNetMatcher / FeatureGroupingAlgorithmWNet bindings with #ifdef WITH_WNETALIGN, and note the availability plus the hasattr(pyopenms, "WNetMatcher") feature-detection idiom in the docstrings — the same pattern used for BrukerTimsFile / WITH_OPENTIMS.

Why no CMake change (deviating from the approach sketched in the issue): config.h.in already carries #cmakedefine WITH_WNETALIGN 1, which ToolHandler.cpp already uses to conditionally register FeatureLinkerWNet. Reusing that macro (via an explicit #include <OpenMS/config.h>) needs no build-system change and also works for standalone wheel builds against an installed OpenMS, where config.h is installed with the headers. Exporting OPENMS_HAS_WNETALIGN publicly would have added a second, redundant mechanism — that macro is currently defined but referenced nowhere.

Verified locally on Ubuntu 24.04 / GCC 13.3 (the issue's repro environment) with -DCMAKE_BUILD_TYPE=Release -DWITH_GUI=OFF -DPYOPENMS=ON -DWITH_WNETALIGN=OFF:

  • import pyopenms succeeds; all four WNet names are absent and feature-detectable via hasattr
  • nm -D _pyopenms_misc.so shows zero WNet symbol references (previously U OpenMS::WNetMatcher::metricFromString(...))
  • full pyOpenMS test suite: 5673 passed, 86 skipped, 11 xfailed, 7 xpassed, 0 failed
  • a preprocessor-projection check confirms the default WITH_WNETALIGN=ON path compiles the identical binding set as before (CI exercises that configuration)

Checklist

  • Make sure that you are listed in the AUTHORS file (no new author; driven by @timosachsenberg, already listed)
  • 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
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

Generated by Claude Code

claude added 2 commits August 24, 2026 18:10
With -DWITH_WNETALIGN=OFF, WNetMatcher.cpp and
FeatureGroupingAlgorithmWNet.cpp are excluded from libOpenMS, but
bind_misc.cpp still referenced their symbols unconditionally. Shared
modules resolve symbols lazily, so the build succeeded and every
'import pyopenms' then failed with an undefined-symbol ImportError in
_pyopenms_misc (issue #9946).

Guard the WNet includes and bindings with #ifdef WITH_WNETALIGN, using
the macro already exported through OpenMS/config.h (the same mechanism
ToolHandler.cpp uses to conditionally register FeatureLinkerWNet), and
document the availability plus the hasattr() feature-detection idiom in
the affected docstrings, following the WITH_OPENTIMS/BrukerTimsFile
precedent.

No CMake changes are needed: config.h already carries
'#cmakedefine WITH_WNETALIGN 1' and is installed alongside the other
headers, so the guard works both for in-tree pyOpenMS builds and for
standalone wheel builds against an installed OpenMS.

Fixes #9946

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TdWTAurDnbxsMorHTuCQTT
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 14 minutes.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9bc24ce-d7b9-48aa-995e-20401bf5dd92

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd05a9 and 61b579e.

📒 Files selected for processing (2)
  • CHANGELOG
  • src/pyOpenMS/bindings/bind_misc.cpp

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.

@timosachsenberg
timosachsenberg merged commit 7cffd15 into develop Aug 25, 2026
35 checks passed
@timosachsenberg
timosachsenberg deleted the claude/openms-issue-9946-eybwtm branch August 25, 2026 06:31
timosachsenberg pushed a commit that referenced this pull request Sep 24, 2026
… builds

Extends the previous commit from the pull request builds to every build the
repository runs: the Release workflow no longer turns WITH_WNETALIGN back on,
the pyOpenMS wheel workflow configures OpenMS with WITH_WNETALIGN=OFF for
every event, and the container image passes it too. The installers, the
wheels and the images therefore no longer contain FeatureLinkerWNet or the
WNetMatcher / FeatureGroupingAlgorithmWNet bindings (pyopenms feature-detects
those with hasattr since #9957).

The CMake default is unchanged (ON), so source builds keep the feature, and
a manual run of the Build and Test workflow can still opt in through its
wnetalign input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0141tQxVx5GENqUuU8zJh2NT
timosachsenberg added a commit that referenced this pull request Sep 24, 2026
…F) (#10255)

* [CI] Leave the WNet alignment out of CI builds by default

The ci presets, which the Build and Test and the Release workflows share,
set WITH_WNETALIGN=OFF and no longer request the wnetalign vcpkg feature,
so pull request CI neither fetches pylmcf/wnet/wnetalign nor compiles
FeatureLinkerWNet and its classes. The pyOpenMS wheel workflow passes
WITH_WNETALIGN=OFF for pull requests as well.

What is shipped does not change. The build action gains a wnetalign input
that turns the option back on; the Release workflow sets it, so the
installers keep FeatureLinkerWNet, and CMake then fetches the same pinned
versions the vcpkg ports install. Wheels built for nightly, tags and manual
runs keep the WNet bindings, and the container and bioconda builds, which
rely on the CMake default (ON), are untouched. A manual run of Build and
Test can opt in through a workflow_dispatch input.

The CI presets build the documentation, which did not work with
WITH_WNETALIGN=OFF:

- DefaultParamHandlerDocumenter documented FeatureGroupingAlgorithmWNet
  unconditionally, so it failed to link against a libOpenMS without the
  class. The class is now documented only when WITH_WNETALIGN is defined.
- FeatureLinkerWNet's page includes the command line and INI documentation
  TOPPDocumenter writes, and FeatureGroupingAlgorithmWNet's the parameter
  table DefaultParamHandlerDocumenter writes. Neither is written without
  the WNet alignment, and doxygen's three "included file ... is not found"
  warnings would fail Doxygen_Warning_test. As for WITH_GUI (#10241), these
  parts are marked @if WITH_WNETALIGN and doc/CMakeLists.txt enables that
  section when the option is on.

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

* [CI] Leave the WNet alignment out of the release, wheel and container builds

Extends the previous commit from the pull request builds to every build the
repository runs: the Release workflow no longer turns WITH_WNETALIGN back on,
the pyOpenMS wheel workflow configures OpenMS with WITH_WNETALIGN=OFF for
every event, and the container image passes it too. The installers, the
wheels and the images therefore no longer contain FeatureLinkerWNet or the
WNetMatcher / FeatureGroupingAlgorithmWNet bindings (pyopenms feature-detects
those with hasattr since #9957).

The CMake default is unchanged (ON), so source builds keep the feature, and
a manual run of the Build and Test workflow can still opt in through its
wnetalign input.

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

* Make the WNet alignment opt-in: WITH_WNETALIGN defaults to OFF

WITH_WNETALIGN now defaults to OFF, so no build fetches pylmcf/wnet/wnetalign
or compiles FeatureLinkerWNet and its classes unless it is configured with
-DWITH_WNETALIGN=ON.

This replaces the per-build switches of the two previous commits: the wheel
workflow and the container image rely on the default again, the build
action's wnetalign input and the manual opt-in of the Build and Test
workflow are gone, and the Release workflow is as on develop. The ci presets
keep WITH_WNETALIGN=OFF explicitly, like WITH_ONNX, and do not request the
wnetalign vcpkg feature.

The documentation that stated the old default is updated: the CHANGELOG
(dependencies, FeatureLinkerWNet and the library entry), the CMake parameter
reference, AGENTS.md and the pyOpenMS docstrings. FeatureLinkerWNet's page and
FeatureGroupingAlgorithmWNet's class documentation note that they are only
built with the option. The documenter guard and the @if WITH_WNETALIGN
sections from the first commit are what let the documentation of a
default build pass Doxygen_Warning_test.

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

* CHANGELOG: keep the WITH_WNETALIGN qualifier off PipEchoAlgorithm

The library entry listed PipEchoAlgorithm and the WNet classes together
under one WITH_WNETALIGN=ON qualifier, which reads as if PipEchoAlgorithm
needed the option too; it is built unconditionally. Split the entry so the
qualifier covers only FeatureGroupingAlgorithmWNet/WNetMatcher (CodeRabbit
review on #10255).

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

---------

Co-authored-by: Claude <[email protected]>
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.

[BUG] pyOpenMS is unimportable when built with -DWITH_WNETALIGN=OFF (undefined symbol WNetMatcher::metricFromString)

2 participants