Repository navigation
refactor:make-libsvm-dependency-private - #8557
Sahil-Shadwal wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughLibSVM is moved from the public dependency list to the private dependency list in the OpenMS CMakeLists.txt configuration, making LibSVM types private in the API surface instead of exposed to consuming projects. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/CMakeLists.txt
🧰 Additional context used
📓 Path-based instructions (1)
**/*
📄 CodeRabbit inference engine (AGENTS.md)
Use lowercase file extensions, except ML, XML, and mzData
Files:
src/openms/CMakeLists.txt
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T17:04:02.774Z
Learning: Applies to **/*.{h,cpp,cxx,cc,hpp} : Add OPENMS_DLLAPI to all non-template exported classes, structs, functions, and variables; not on templates; include in friend operator declarations
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-12-20T17:04:02.774Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T17:04:02.774Z
Learning: Applies to **/*.{h,cpp,cxx,cc,hpp} : Add OPENMS_DLLAPI to all non-template exported classes, structs, functions, and variables; not on templates; include in friend operator declarations
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use the established naming patterns for classes, methods, and variables
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-12-20T17:04:02.774Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T17:04:02.774Z
Learning: Applies to src/tests/topp/CMakeLists.txt : Add TOPP tests in src/tests/topp/CMakeLists.txt
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/openms/CMakeLists.txt
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.
Applied to files:
src/openms/CMakeLists.txt
🔇 Additional comments (2)
src/openms/CMakeLists.txt (2)
62-62: LGTM!The comment clearly documents why LibSVM is a private dependency and follows the established pattern used for Eigen3::Eigen.
73-73: LGTM!The addition of LibSVM::LibSVM to the private dependencies list is correctly implemented. Combined with its removal from the public dependencies, this properly transitions LibSVM to private linkage.
| #------------------------------------------------------------------------------ | ||
| # all the dependency libraries are linked into libOpenMS.so | ||
| set(OPENMS_DEP_LIBRARIES Evergreen LibSVM::LibSVM XercesC::XercesC Qt6::Core Qt6::Network) | ||
| set(OPENMS_DEP_LIBRARIES Evergreen XercesC::XercesC Qt6::Core Qt6::Network) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for LibSVM usage in public OpenMS headers
# Expected: No LibSVM includes or types in public API headers (except commented-out code)
echo "=== Searching for LibSVM includes in public headers ==="
rg -n --type=cpp --type=c -g '*.h' -g '*.hpp' 'include.*[<"].*svm\.h[>"]' src/openms/include/OpenMS/
echo -e "\n=== Searching for LibSVM types (svm_model, svm_node, svm_parameter, svm_problem) in public headers ==="
rg -n --type=cpp --type=c -g '*.h' -g '*.hpp' '\bsvm_(model|node|parameter|problem)\b' src/openms/include/OpenMS/
echo -e "\n=== Checking SimpleSVM.h specifically ==="
fd -e h -e hpp SimpleSVM --exec cat {}Repository: OpenMS/OpenMS
Length of output: 6669
LibSVM types ARE exposed in the public API; removal from public dependencies is incorrect.
The verification script reveals that svm_model is directly exposed in src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.h (line 20 forward declaration, line 308 member variable). Despite the commented-out include in SimpleSVM.h, downstream projects that use FeatureFindingMetabo.h depend on LibSVM for the svm_model type. Removing LibSVM from public dependencies while keeping it exposed in a public header creates a broken configuration where the type is declared but the library is not linked.
Either:
- Move FeatureFindingMetabo.h to internal headers and provide a public interface wrapper, or
- Keep LibSVM as a public dependency.
There was a problem hiding this comment.
@coderabbitai How about making FeatureFindingMetabo use the SimpleSVM wrapper which wraps around libsvm?
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Examine SimpleSVM header to understand the wrapper interface
echo "=== SimpleSVM.h ==="
fd -e h -e hpp SimpleSVM src/openms/include --exec cat {}
echo -e "\n=== SimpleSVM.cpp implementation ==="
fd -e cpp SimpleSVM src/openms/source --exec cat {}
Length of output: 29825
🏁 Script executed:
#!/bin/bash
# Examine FeatureFindingMetabo's usage of svm_model in detail
echo "=== FeatureFindingMetabo.h content (focusing on svm_model usage) ==="
cat src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.h | grep -n -A5 -B5 'svm_model'
echo -e "\n=== FeatureFindingMetabo.cpp usage of svm_model ==="
fd -e cpp FeatureFindingMetabo src/openms/source --exec rg -n -C5 'svm_model' {}
Length of output: 773
🏁 Script executed:
#!/bin/bash
# Check how svm_model is used throughout FeatureFindingMetabo implementation
echo "=== Full search for LibSVM usage in FeatureFindingMetabo source files ==="
fd -e cpp FeatureFindingMetabo src/openms/source --exec rg -n 'svm_' {}
Length of output: 1152
@jpfeuffer That's an excellent suggestion! Using SimpleSVM as a wrapper would be the right architectural approach since it already properly encapsulates LibSVM types using the Pimpl pattern. However, SimpleSVM would need to be extended first to support FeatureFindingMetabo's use case.
Current gap:
FeatureFindingMetabo loads pre-trained SVM models from files and performs predictions:
svm_load_model()to load a model from disk (line 464 in FeatureFindingMetabo.cpp)svm_predict()for prediction without probability estimates (line 445)- Manual model lifecycle management
SimpleSVM currently only supports:
- Training new models via
setup() - Prediction with probability estimates via
predict() - No model serialization/deserialization from files
Required SimpleSVM enhancements:
-
Model loading/saving API:
void loadModel(const String& filepath); void saveModel(const String& filepath) const;
-
Prediction without probabilities (or confirm existing
predict()works for this use case) -
Model lifecycle management within SimpleSVM to handle loaded models
Recommendation:
This refactoring would properly encapsulate LibSVM and allow it to become a private dependency. Would you like me to create a GitHub issue to track this enhancement? Once SimpleSVM supports model loading, FeatureFindingMetabo could be refactored to use it, and then LibSVM can be made private.
For now, LibSVM must remain a public dependency until this refactoring is completed.
🧠 Learnings used
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T17:04:02.774Z
Learning: Applies to src/tests/topp/CMakeLists.txt : Add TOPP tests in src/tests/topp/CMakeLists.txt
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
There was a problem hiding this comment.
@coderabbitai Yes, please create an issue for it.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Create GitHub issue for SimpleSVM enhancement to support model loading/saving
gh issue create \
--repo OpenMS/OpenMS \
--title "Enhance SimpleSVM wrapper to support model loading and saving" \
--body "## Context
In PR #8557, we attempted to make LibSVM a private dependency. However, \`svm_model\` is currently exposed in the public header \`FeatureFindingMetabo.h\`, which prevents LibSVM from being made private.
Discussion: https://github.com/OpenMS/OpenMS/pull/8557#discussion_r2644831521
## Proposed Solution
Refactor \`FeatureFindingMetabo\` to use the \`SimpleSVM\` wrapper instead of directly using LibSVM types. This requires enhancing \`SimpleSVM\` to support model serialization and deserialization.
## Required SimpleSVM Enhancements
Currently, \`SimpleSVM\` only supports:
- Training new models via \`setup()\`
- Prediction with probability estimates via \`predict()\`
\`FeatureFindingMetabo\` needs:
- Loading pre-trained SVM models from files
- Prediction without probability estimates (or confirmation that existing API supports this)
- Proper model lifecycle management
## Expected Outcome
Once \`SimpleSVM\` supports model loading/saving, \`FeatureFindingMetabo\` can be refactored to use it, properly encapsulating LibSVM and allowing it to become a private dependency as intended in PR #8557.
---
Requested by: @jpfeuffer
Related PR: #8557" \
--assignee jpfeuffer
Length of output: 44
@jpfeuffer I've created issue #8558 to track the SimpleSVM enhancement: #8558
The issue outlines the required functionality (model loading/saving, prediction support) and explains how this will enable FeatureFindingMetabo to use SimpleSVM instead of directly exposing LibSVM types, ultimately allowing LibSVM to become a private dependency as intended in this PR.
🧠 Learnings used
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T17:04:02.774Z
Learning: Applies to src/tests/topp/CMakeLists.txt : Add TOPP tests in src/tests/topp/CMakeLists.txt
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
|
did you build and test it? |
To be honest, I relied on static analysis (grepping for includes) and missed the forward declaration in FeatureFindingMetabo.h. I didn't perform a full local build, which would have caught the linker error. CodeRabbit's analysis is correct. LibSVM must remain a public dependency until |
|
@Sahil-Shadwal sorry this is not acceptable. Builds and tests are mandatory before opening a PR. How should relying on static analysis even work for a language as C++? |
Description
This PR addresses issue #8547 by making the
LibSVMdependency private in the CMake configuration.Analysis: After reviewing all public headers, I found that LibSVM types are not exposed in OpenMS's public API. The only reference in public headers is a commented-out include in SimpleSVM.h. Since downstream users never interact with LibSVM types directly, it can safely be moved to private dependencies.
Changes:
LibSVM::LibSVMfromOPENMS_DEP_LIBRARIES(public dependencies)LibSVM::LibSVMtoOPENMS_DEP_PRIVATE_LIBRARIES(private dependencies)Eigen3::EigenNote: Other dependencies like XercesC and Qt6 must remain public as their types appear in public API signatures (e.g.,
XMLHandlerclass,QObjectinheritance).Closes #8547
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.