Skip to content

Small refactor of TOPPBase - #9621

Merged
timosachsenberg merged 4 commits into
OpenMS:developfrom
cbielow:refactor_Toppbase
Jul 7, 2026
Merged

timosachsenberg merged 4 commits into
OpenMS:developfrom
cbielow:refactor_Toppbase

Conversation

@cbielow

@cbielow cbielow commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Cleans up some includes, mostly in FLASHHelperClasses.h which included TOPPBase.h...

Moves TOPP tools which call an external executable to use TOPPExternalToolBase as base (so others do not have to bother with it).

It's not a full refactor, which I'd like to see, but its a start.

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
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

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.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • Refactor
    • Introduced a dedicated base class for tools that execute external programs, and migrated relevant tools to use it.
    • Improved early startup handling for -write_* command-line options.
    • Refined log-file initialization and output consistency.
  • Tests
    • Added unit tests for external-process execution outcomes.
    • Updated tests to cover logging output and citation formatting.
  • Chores
    • Updated includes and build configuration to ensure logging and file I/O compile reliably across tools.

cbielow and others added 2 commits June 18, 2026 09:43
- Move the Citation struct and the TOPPBase-specific parameter exceptions into
  a new lightweight TOPPBase_defs.h.
- Extract TOPPExternalToolBase (the runExternalProcess_ adapter over
  ExternalProcess) as an intermediate base class; re-parent SearchEngineBase and
  the external-tool adapters onto it.
- Slim TOPPBase.h: drop the Exception/LogStream/StringUtils/Colorizer and
  <fstream> includes, hold the log stream via a pimpl-ed std::ofstream, and stop
  FLASHHelperClasses.h from pulling in the whole TOPPBase header.
- Add the explicit includes (mostly CONCEPT/LogStream.h) to the TUs that relied
  on those now-removed transitive includes (include-what-you-use).
- Add TOPPBase_test coverage for the -log file output and Citation::toString(),
  plus a TOPPExternalToolBase_test for runExternalProcess_.
- Remove the redundant /bigobj flag from the TOPPView target (already set lib-wide).

No behaviour change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cbielow
cbielow requested a review from timosachsenberg June 18, 2026 08:20
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c8271eb-82a1-4841-8112-d06373d7962f

📥 Commits

Reviewing files that changed from the base of the PR and between 88856a3 and 4217e6c.

📒 Files selected for processing (2)
  • src/openms/source/APPLICATIONS/TOPPBase.cpp
  • src/openms/source/APPLICATIONS/sources.cmake
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/openms/source/APPLICATIONS/sources.cmake
  • src/openms/source/APPLICATIONS/TOPPBase.cpp

📝 Walkthrough

Walkthrough

This PR splits external-tool execution into a new base class, refactors TOPPBase logging and write-command handling, migrates several TOPP tools to the new base, and updates dependent includes, tests, and build files.

Changes

TOPPExternalToolBase extraction and TOPPBase refactor

Layer / File(s) Summary
TOPPBase_defs.h types
src/openms/include/OpenMS/APPLICATIONS/TOPPBase_defs.h
Adds Citation and three TOPP parameter exception classes to a new lightweight support header.
TOPPBase.h contract changes
src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h
Updates TOPPBase to use the new support header, change log storage, remove external-process declarations, and add handleWriteCommands_().
TOPPExternalToolBase implementation
src/openms/include/OpenMS/APPLICATIONS/TOPPExternalToolBase.h, src/openms/source/APPLICATIONS/TOPPExternalToolBase.cpp, src/openms/source/APPLICATIONS/sources.cmake
Adds TOPPExternalToolBase and its runExternalProcess_ implementations, and registers the new source file in the applications build.
TOPPBase.cpp control flow and logging
src/openms/source/APPLICATIONS/TOPPBase.cpp
Refactors main(), logging, parseCommandLine_(), and merged helper definitions within the translation unit.
SearchEngineBase migration
src/openms/include/OpenMS/APPLICATIONS/SearchEngineBase.h, src/openms/source/APPLICATIONS/SearchEngineBase.cpp
Switches SearchEngineBase to inherit from TOPPExternalToolBase.
External-tool adapters
src/topp/FileConverter.cpp, src/topp/LuciphorAdapter.cpp, src/topp/MaRaClusterAdapter.cpp, src/topp/NovorAdapter.cpp, src/topp/OpenNuXL.cpp, src/topp/PercolatorAdapter.cpp, src/topp/ProSE.cpp, src/topp/SpectraSTSearchAdapter.cpp
Migrates adapter tools from TOPPBase to TOPPExternalToolBase.
Include fixes, tests, and build wiring
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h, src/openms/source/ANALYSIS/TOPDOWN/PeakGroupScoring.cpp, src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp, src/topp/FLASHDeconv.cpp, src/topp/FeatureFinderLFQ.cpp, src/topp/INIUpdater.cpp, src/topp/MapAlignerPoseClustering.cpp, src/topp/MapStatistics.cpp, src/topp/MRMPairFinder.cpp, src/topp/OpenSwathExport.cpp, src/topp/OpenSwathInfer.cpp, src/topp/RNADigestor.cpp, src/topp/SiriusExport.cpp, src/tests/class_tests/openms/source/MassFeatureTrace_test.cpp, src/tests/class_tests/openms/executables.cmake, src/tests/class_tests/openms/source/TOPPBase_test.cpp, src/tests/class_tests/openms/source/TOPPExternalToolBase_test.cpp, src/openms/source/APPLICATIONS/sources.cmake
Adds direct <fstream>/LogStream.h includes where needed, updates class-test registration, moves runExternalProcess coverage, adds TOPPExternalToolBase tests, and adjusts CMake source settings.

Sequence Diagram(s)

sequenceDiagram
  participant TOPPBase as TOPPBase::main
  participant ETB as TOPPExternalToolBase
  participant EP as ExternalProcess

  TOPPBase->>TOPPBase: handleWriteCommands_()
  TOPPBase->>ETB: runExternalProcess_(exe, args, workdir, env)
  ETB->>EP: run(...)
  EP-->>ETB: RETURNSTATE + captured output
  ETB-->>TOPPBase: ExitCodes
  TOPPBase->>TOPPBase: log_->close()
Loading

Suggested reviewers: jpfeuffer

Poem

A bunny hopped through headers bright,
and split the tools just right.
TOPPExternalToolBase took the run,
while logs and cites came out more fun.
🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.09% which is insufficient. The required threshold is 80.00%. 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 is broadly accurate and points to the main refactor around TOPPBase and related external-tool changes.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/openms/include/OpenMS/APPLICATIONS/TOPPExternalToolBase.h (1)

19-27: ⚡ Quick win

Add @ingroup for the new public class.

Please add a Doxygen group tag to the class block so it lands in the expected docs section.

Suggested doc update
   /**
     `@brief` Base class for TOPP tools that invoke an external executable.
+    `@ingroup` Applications
 
     Adds `@ref` runExternalProcess_ - a thin adapter over `@ref` ExternalProcess that maps its

As per coding guidelines, **/*.{h,.doxygen} documentation should include grouping (@defgroup/@ingroup).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/APPLICATIONS/TOPPExternalToolBase.h` around lines
19 - 27, Add a Doxygen `@ingroup` tag to the documentation block of the
TOPPExternalToolBase class. Locate the comment block that begins with /** and
documents the TOPPExternalToolBase class, and insert an appropriate `@ingroup` tag
within that comment block to group the class documentation according to the
project's Doxygen organization structure.

Source: Coding guidelines

src/openms/source/APPLICATIONS/TOPPBase.cpp (1)

2471-2482: ⚡ Quick win

Use OpenMS logging macros instead of direct std::cout here.

Line 2480 writes directly to cout; this bypasses the project’s logging convention.

Suggested fix
-      cout << "Writing to '" << log_destination << '\'' << "\n";
+      OPENMS_LOG_INFO << "Writing to '" << log_destination << '\'' << "\n";

As per coding guidelines, **/*.cpp should use OpenMS logging macros and avoid direct std::cout/err.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/APPLICATIONS/TOPPBase.cpp` around lines 2471 - 2482, In the
enableLogging_() method of the TOPPBase class, replace the direct std::cout
statement that writes "Writing to..." with the appropriate OpenMS logging macro
to maintain consistency with the project's logging conventions. The std::cout
call should be replaced with a logging macro call that achieves the same output
but follows the established logging pattern used throughout the codebase.

Source: Coding guidelines

src/openms/include/OpenMS/APPLICATIONS/TOPPBase_defs.h (1)

22-33: ⚡ Quick win

Add Doxygen grouping metadata for new public API types.

Please add @ingroup (and full @brief block comments for the exception classes) so these symbols are discoverable in generated docs consistently with the rest of the public API.

Suggested doc update
   /**
     `@brief` Stores Citations for individual TOPP tools.
+    `@ingroup` Applications
 
     An example would be
@@
-    /// An unregistered parameter was accessed
+    /**
+      `@brief` An unregistered parameter was accessed.
+      `@ingroup` Applications
+    */
     class OPENMS_DLLAPI UnregisteredParameter :
       public Exception::BaseException
@@
-    /// A parameter was accessed with the wrong type
+    /**
+      `@brief` A parameter was accessed with the wrong type.
+      `@ingroup` Applications
+    */
     class OPENMS_DLLAPI WrongParameterType :
       public Exception::BaseException
@@
-    /// A required parameter was not given
+    /**
+      `@brief` A required parameter was not given.
+      `@ingroup` Applications
+    */
     class OPENMS_DLLAPI RequiredParameterNotGiven :
       public Exception::BaseException

As per coding guidelines, **/*.{h,.doxygen} requires Doxygen @brief usage with grouping via @defgroup/@ingroup.

Also applies to: 50-85

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/APPLICATIONS/TOPPBase_defs.h` around lines 22 - 33,
The documentation comment for the Citation struct is missing Doxygen grouping
metadata required by the coding guidelines for public API types. Add an
`@ingroup` directive to the comment block that starts with "Stores Citations for
individual TOPP tools" to ensure the Citation type is properly grouped in
generated documentation. Additionally, verify that the `@brief` statement is
present and properly formatted at the beginning of the comment block. Apply the
same Doxygen grouping updates to all other public type documentation in the file
mentioned in the "Also applies to" section (lines 50-85).

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/openms/include/OpenMS/APPLICATIONS/TOPPBase_defs.h`:
- Around line 22-33: The documentation comment for the Citation struct is
missing Doxygen grouping metadata required by the coding guidelines for public
API types. Add an `@ingroup` directive to the comment block that starts with
"Stores Citations for individual TOPP tools" to ensure the Citation type is
properly grouped in generated documentation. Additionally, verify that the
`@brief` statement is present and properly formatted at the beginning of the
comment block. Apply the same Doxygen grouping updates to all other public type
documentation in the file mentioned in the "Also applies to" section (lines
50-85).

In `@src/openms/include/OpenMS/APPLICATIONS/TOPPExternalToolBase.h`:
- Around line 19-27: Add a Doxygen `@ingroup` tag to the documentation block of
the TOPPExternalToolBase class. Locate the comment block that begins with /**
and documents the TOPPExternalToolBase class, and insert an appropriate `@ingroup`
tag within that comment block to group the class documentation according to the
project's Doxygen organization structure.

In `@src/openms/source/APPLICATIONS/TOPPBase.cpp`:
- Around line 2471-2482: In the enableLogging_() method of the TOPPBase class,
replace the direct std::cout statement that writes "Writing to..." with the
appropriate OpenMS logging macro to maintain consistency with the project's
logging conventions. The std::cout call should be replaced with a logging macro
call that achieves the same output but follows the established logging pattern
used throughout the codebase.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2308abc6-fca4-456b-b3bf-ac7504da25ba

📥 Commits

Reviewing files that changed from the base of the PR and between 8b54416 and 6b13c9e.

📒 Files selected for processing (33)
  • src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h
  • src/openms/include/OpenMS/APPLICATIONS/SearchEngineBase.h
  • src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h
  • src/openms/include/OpenMS/APPLICATIONS/TOPPBase_defs.h
  • src/openms/include/OpenMS/APPLICATIONS/TOPPExternalToolBase.h
  • src/openms/source/ANALYSIS/TOPDOWN/PeakGroupScoring.cpp
  • src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
  • src/openms/source/APPLICATIONS/SearchEngineBase.cpp
  • src/openms/source/APPLICATIONS/TOPPBase.cpp
  • src/openms/source/APPLICATIONS/TOPPExternalToolBase.cpp
  • src/openms/source/APPLICATIONS/sources.cmake
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/MassFeatureTrace_test.cpp
  • src/tests/class_tests/openms/source/TOPPBase_test.cpp
  • src/tests/class_tests/openms/source/TOPPExternalToolBase_test.cpp
  • src/topp/FLASHDeconv.cpp
  • src/topp/FeatureFinderLFQ.cpp
  • src/topp/FileConverter.cpp
  • src/topp/INIUpdater.cpp
  • src/topp/LuciphorAdapter.cpp
  • src/topp/MRMPairFinder.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/topp/MapAlignerPoseClustering.cpp
  • src/topp/MapStatistics.cpp
  • src/topp/NovorAdapter.cpp
  • src/topp/OpenNuXL.cpp
  • src/topp/OpenSwathExport.cpp
  • src/topp/OpenSwathInfer.cpp
  • src/topp/PercolatorAdapter.cpp
  • src/topp/ProSE.cpp
  • src/topp/RNADigestor.cpp
  • src/topp/SiriusExport.cpp
  • src/topp/SpectraSTSearchAdapter.cpp
💤 Files with no reviewable changes (1)
  • src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h

@timosachsenberg

Copy link
Copy Markdown
Contributor

hi can you give summarize what the advantage is?
e.g. for NuXL and SimpleSearchEngine (which calls perolator)?

@cbielow

cbielow commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

you mean the advantage of TOPPExternalToolBase ?
It's a tad cleaner, since TOPPBase itself does not need to know how to run external tools (most TOPP tools run internal algorithms). It's not a must though. We can revert that and only stick with the FlashHelper and include cleanup.

@timosachsenberg

Copy link
Copy Markdown
Contributor

I am open for that idea. Just did not come to my mind yet

@timosachsenberg

Copy link
Copy Markdown
Contributor

I think it is fine. maybe not use inheritance?

@timosachsenberg

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	src/topp/FeatureFinderLFQ.cpp
#	src/topp/MapAlignerPoseClustering.cpp
@timosachsenberg
timosachsenberg merged commit b14c3ba into OpenMS:develop Jul 7, 2026
38 checks passed
timosachsenberg added a commit that referenced this pull request Jul 13, 2026
… (#9731)

Backfill CHANGELOG coverage for recently merged PRs that lacked entries:
Docker Arrow APT source fix (#9728), TOPPBase external-tool refactor
(#9621), cross-reference the SPS precursor-matching feature to its PR
(#9706), and note the pyOpenMS binding for addChargeAdduct (#9719).


Claude-Session: https://claude.ai/code/session_012umKmTwmgGLGShG6wyQjxQ

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.

2 participants