Repository navigation
[FIX] Refactor Normalizer instantiation and remove redundant assertions - #10057
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughChangesPercolator integration
Suggested reviewers: Poem
Merge Risk: ⚪ Minimal · up to The normalizer lifecycle cleanup and vendored Percolator updates introduce no identified current-head correctness or runtime risk. The change is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 unsupported.)
✨ 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 |
timosachsenberg
left a comment
There was a problem hiding this comment.
Reviewed against #10049 and the vendoring tooling. The Percolator.cpp half is correct; the patch-file half is corrupt and blocks merge.
✅ Percolator.cpp — correct fix
SetHandler::normalizeFeatures(Normalizer*& pNorm) assigns pNorm = Normalizer::getNormalizer() unconditionally (SetHandler.cpp:70) before any use, so passing nullptr is right. I checked both call sites: nothing between the declaration (:479, :770) and normalizeFeatures() (:504, :794) dereferences normalizer — only the SanityCheck setup, which either throws out of the function or succeeds without touching it. Every downstream use (preIterationSetup, train, getAvgWeights) runs after the assignment, and resetNormalizer()/setType() still precede the single construction so the subclass is chosen correctly. After this change getNormalizer() has exactly one caller in the whole tree, which is upstream's contract (Caller.cpp).
🔴 Blocking: patches/01-namespace-wrap.patch no longer parses
The new hunk was hand-written instead of regenerated, and it isn't a valid unified diff:
$ git apply --numstat -p0 src/openms/thirdparty/percolator/patches/01-namespace-wrap.patch
error: corrupt patch at line 717(develop's version of the same file parses fine.) The three defects are in the inline comment below.
This is not a local failure. git apply parses the entire patch before applying anything, so all 65 file sections are lost, not just Normalizer.cpp — every namespace wrap, every std:: qualification, the parseOptions body removal, etc. And sync-from-upstream.sh swallows it:
$ git apply --reject --whitespace=nowarn -p0 .../01-namespace-wrap.patch ; echo "exit=$?"
error: corrupt patch at line 717
exit=128
$ find . -name '*.rej' | wc -l
0The script runs git apply … || true and then warns only if *.rej files exist. A parse error produces none, so the next ./sync-from-upstream.sh copies raw upstream over the vendored tree, fails to patch it, prints >>> Done. and leaves a tree that doesn't compile. Nothing in CI applies this patch, so it would sit undetected until someone re-syncs.
Fix: regenerate rather than hand-edit — UPSTREAM.md asks for exactly this ("regenerate patches/01-namespace-wrap.patch from the post-adaptation tree rather than hand-editing sources"). The corrected replacement hunks are in the inline comment. I derived them by reconstructing the pinned-SHA upstream Normalizer.cpp (reverse-applying develop's patch section; it round-trips bit-identically) and diffing that against this PR's Normalizer.cpp with the diff -urN --label … invocation from UPSTREAM.md. The result applies cleanly and the full patch parses again.
❓ Does the vendored Normalizer.cpp edit belong in this PR?
#10049 lists it as optional belt-and-braces, and it cuts both ways:
- With the
Percolator.cppfix in,getNormalizer()has exactly one caller left. Theassert(false)can now only fire on a genuine regression — i.e. someone reintroducing the double-instantiation this PR just removed. Deleting it removes the tripwire that caught this bug in the first place, and it's the only thing flagging the related hazard where a secondgetNormalizer()after a differentsetType()silently returns a stale singleton of the wrong subclass. - Against that, it's a permanent behavioural divergence from upstream that every future syncer has to carry.
My preference would be to land the Percolator.cpp fix alone (the actual root cause) and leave upstream untouched. If you'd rather keep the guard removal, that's defensible — but please then also add a line to the "Patches" section of UPSTREAM.md, since it currently describes 01-namespace-wrap.patch as covering only namespace/compile adaptations, and a silent behavioural change to upstream code is exactly the kind of thing a future re-sync needs to know is deliberate.
Minor
- CHANGELOG: not updated (checklist item is unticked). Comparable Percolator fixes get entries — e.g. the
-percolator_executableabort fix underPercolatorAdapter. A Debug-build abort across 18 tests seems worth aFix:line. - Comment wording: "normalizeFeatures() owns Normalizer construction via its out-parameter" is slightly off — the static singleton owns the object,
resetNormalizer()frees it;normalizeFeatures()is just the factory call site. #10049's phrasing plus acf. upstream Caller.cpppointer would age better for the next reader. - No regression coverage: all five workflows build
Release, soNDEBUGhides this entire class of bug. Out of scope here, but a single Debug job (even justPercolator_test) would be what stops the next one.
Generated by Claude Code
|
|
||
| @@ -90,3 +93,5 @@ | ||
|
|
||
| @@ -72,10 +75,7 @@ |
There was a problem hiding this comment.
This hunk is not a valid unified diff, and because git apply parses the whole file before applying anything, it takes down all 65 file sections of the patch (details in the review summary).
Three defects:
- Line counts don't match the body. The header claims 10 old / 7 new lines; the body supplies 3 deletions + 4 context = 7 old / 4 new.
git applyruns into the next@@mid-fragment and bails withcorrupt patch at line 717. - No leading context. The hunk opens straight on a
-line, so the deleted} else {isn't anchored to the} else { theNormalizer = new NoNormalizer(); }block it follows. - The following
@@ -90,3 +93,5 @@hunk was damaged too — both context lines lost one space of indentation (}→},out[i] = …→out[i] = …), so they no longer match the file, and its new-side start should now be+90, not+93(three lines were removed above it).
Replacing both hunks with what diff -urN actually produces for upstream-Normalizer.cpp → this PR's Normalizer.cpp:
@@ -68,9 +71,6 @@
} else {
theNormalizer = new NoNormalizer();
}
- } else {
- assert(false);
- cerr << "Multiple instantiations of Normalizer" << endl;
}
return theNormalizer;
}
@@ -90,3 +90,5 @@
}
out[i] = (in[i] - subScore) / scale; // update the intercept m0
}
+
+}}} // namespace OpenMS::Internal::PercolatorAlso drop the blank lines the hand-edit inserted between hunks — diff -urN doesn't emit them, so they'd reappear as noise on the next regeneration.
Generated by Claude Code
|
Verified both halves of my review locally. Summary: the 1. The fix works — reproduced the abort, then watched it go awayThe vendored subtree is a standalone CMake target with no libOpenMS dependency, so it builds on its own in Debug (
The abort message matches #10049 exactly. Row 2 is the interesting one: the Deferring construction doesn't disturb anything else:
2. The patch file — confirmed against a real upstream checkoutI cloned
The zero reject count on the failing run is the operationally nasty part: Also confirmed that real upstream Corrected branchPushed to Two things I deliberately left out, since they're yours to decide: the CHANGELOG entry, and — if the vendored Generated by Claude Code |
…coring single-transition fixes (#10065) Two recently merged fixes landed without their own CHANGELOG entry: - #10057 (fixes #10049) - Percolator::train()/rescore() called Normalizer::getNormalizer() themselves even though SetHandler::normalizeFeatures() already does so via its out-parameter, tripping the vendored Normalizer's "Multiple instantiations" assert in Debug builds. - #10055 (fixes #10050) - MRMScoring's cross-correlation/mutual-information scoring functions required a matrix of at least 2x2, rejecting single-transition compounds. Claude-Session: https://claude.ai/code/session_01CHEsujKnJFTTChdC6Q8qGu Co-authored-by: Claude <[email protected]>
…ch 01, repair patch 01, make the sync fail on unapplied patches (#10485) * [DOC] Percolator: keep the later patches out of a regenerated patch 01 (UPSTREAM.md) The documented regeneration of patches/01-namespace-wrap.patch diffed the upstream files against the current vendored tree. Since #10474 the tree also holds patch 02 (std::atomic includeNegativesInResult), so a regenerated patch 01 would contain that change too; sync-from-upstream.sh then applies 01 before 02, and 02 is rejected (PosteriorEstimator.{h,cpp}.rej). Reported by CodeRabbit on #10474. The flow now reverse-applies the later patches (02-*.patch, ...) on a staged copy of the tree and diffs against that copy. It also: - runs from src/openms/thirdparty/percolator/ throughout; it read whitelist.txt and UPSTREAM_COMMIT from there but diffed against src/openms/thirdparty/percolator/<file>, which does not exist from there, so patch 01 came out as a deletion of every file; - sorts with LC_ALL=C, the order of the committed patch; under en_US.UTF-8 the file sections came out in a different order. Checked in a scratch copy: the regenerated patch 01 contains no patch-02 line, and upstream eb157f7 + the regenerated 01 + 02 (sync-from-upstream.sh, which applies 01 and then 02) reproduces every vendored source file, with no *.rej. The regenerated 01 differs from the committed one only in the Normalizer.cpp hunks; the next commit replaces the committed 01 with it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] Percolator: regenerate patches/01-namespace-wrap.patch, which git apply rejected A hand edit of the Normalizer.cpp hunks in #10057 left the patch malformed: the added hunk declares 10 old lines but carries 7, and several context lines lost their leading space. git apply stops with "corrupt patch at line 717" and applies none of the patch, so sync-from-upstream.sh, even at the pinned SHA, left all 65 vendored files as plain upstream copies (and rejected a hunk of patch 02). The new patch 01 is the output of the regeneration flow in UPSTREAM.md, run on this tree. It differs from the old one only in the Normalizer.cpp hunks. upstream eb157f7 + 01 + 02 through sync-from-upstream.sh now reproduces every vendored source file again, with no *.rej. No source file changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [DOC] Percolator: stop the patch-01 regeneration at the first error (UPSTREAM.md) The snippet ignored failed downloads, failed reverse-applies of the later patches and diff errors, and truncated patch 01 before generating the new one; a failed step silently produced a wrong patch 01. It now runs under set -euo pipefail in a subshell, downloads into a fresh temp directory, iterates the whitelist (a stale non-whitelisted file such as an upstream ssl.cpp no longer gets a section), detects git-format later patches (-p1) as sync-from-upstream.sh does, and replaces patch 01 only at the end. Also correct the wording: patch 01 no longer covers the later patches, and the re-sync check was last verified on 2026-10-09. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] Percolator: sync-from-upstream.sh fails when a patch does not apply git apply errors were ignored, so a patch that does not parse (patch 01 since #10057) left no .rej, and the script recorded the upstream commit and printed "Done" with exit code 0. Collect the failing patches, report them and exit 1 before recording the upstream commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [DOC] Percolator: patch-01 regeneration also stops when listing or writing the patch fails (UPSTREAM.md) A failing command substitution in a for list does not trigger set -e, so when patches/ could not be listed the later patches were not reverse-applied and patch 01 absorbed them, with exit code 0. The list is now assigned to a variable first, so a failed listing stops the snippet. Patch 01 is written to a temporary file in patches/ and renamed over the old one, so a failed write no longer leaves a truncated patch 01. The check after regenerating now passes the SHA from UPSTREAM_COMMIT to sync-from-upstream.sh: without an argument the script syncs to its built-in default, which a sync to another ref does not update. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [DOC] Percolator: patch-01 regeneration writes through a per-run temporary directory (UPSTREAM.md) The temporary file for the new patch 01 had a fixed name, so two regenerations at the same time could write the same file. Use a directory from mktemp -d inside patches/ instead (same file system, so the final mv is still a rename), and remove it on exit. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] Percolator: sync-from-upstream.sh patches a staging tree, vendored files change only if every patch applies `git apply --reject` applied the hunks that fit before a patch failed and left *.rej files next to partially patched vendored sources. The upstream files are now copied into a temporary staging tree, the whole patch series is applied and line endings are normalized there, and the result is copied into the vendored directory only after every patch succeeded. A failing patch exits non-zero and leaves the vendored files untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Timo Sachsenberg <[email protected]>
Description
Addresses #10049
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
Bug Fixes
Maintenance