Repository navigation
fix(ui): a failed mass tolerance reload puts the old tolerance back - #305
Merged
Merged
Conversation
This was referenced Nov 10, 2026
Closed
A worker exception can follow a sample whose EICs were already replaced at the new tolerance. Revert only when the importer raised NothingToRegenerateError before its sample loop, the reload could not start, or no sample was rebuilt.
Collaborator
Author
|
Review verdict for head 22514ff: CLEAN after one fix round. Reviewed by GPT-6.1 Sol. Round 1, at 653b149:
Fix, 653b149..22514ff: the importer's two checks that run before its sample loop now raise Round 2, the fix diff only:
The partial-reload exception on |
This was referenced Nov 10, 2026
Jack-Coutts
added a commit
that referenced
this pull request
Nov 10, 2026
The rebuild bypasses apply_mass_tolerance, so #305's rollback would restore a tolerance from an earlier change, or raise AttributeError when there was none. The rebuild now records the current tolerance as the one to fall back to.
…-restores-tolerance # Conflicts: # docs/01_user_guide.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209. Re-applies #227 onto main.
The bug
Saving a new mass tolerance stored the value before the EIC reload ran. When the reload failed, the error box appeared but the stored tolerance stayed at the new value. Settings, the export changelog and the session file then reported a tolerance that no stored EIC was built with.
The fix
apply_mass_toleranceremembers the tolerance in force before the reload._mass_tolerance_reload_failedputs it back, but only when no EIC row can have been committed at the new tolerance. Exports and session files readself.mass_tolerancewhen they are written, and the app does not persist it anywhere else, so that one assignment reaches every place.A reload commits each sample as it goes, so a worker exception does not mean nothing was rebuilt.
regenerate_all_eics_with_mass_tolerancenow raisesNothingToRegenerateError(aRuntimeError) for its two checks that run before the sample loop: no active samples, and no compounds. The worker'sfailedsignal carries a second value,eics_replaced, which is false only for that error. Any other exception may follow a commit, so the handler keeps the new value, as main does, and says so.Why this signal. The importer already raises these two errors, so giving them a type adds no new control flow and catches nothing. The progress callback was the other candidate, but the importer does not call it after a commit, so it cannot tell "a sample was committed" from "a sample was skipped". An exception inside the loop before the first commit is treated as "may have committed". That keeps the new value in a case where reverting would also have been right, which is the safe direction.
The stored tolerance in each case:
A failure in the natural abundance correction step after the EICs are rebuilt does not reach this handler. The importer already catches it and logs a warning, so the reload completes and keeps the new value.
The user guide's Mass Tolerance section says what happens in each of these cases.
Checks
tests/test_failed_reload_restores_tolerance.pysaves a new tolerance through the Settings window and waits for the real reload thread. Without the change three cases fail: no samples (assert 0.35 == 0.2), the reload cannot start (assert 0.35 == 0.2) and no CDF readable (assert ['warning'] == ['critical']). The fourth case, one CDF readable, passes both ways and guards that a partial failure keeps the new value.test_reload_that_stops_after_rebuilding_a_sample_keeps_the_new_toleranceuses two real CDFs. The second one's folder is unreadable, socdf_path.exists()raisesPermissionErrorafter the first sample was committed at 0.35 Da. It asserts that the first sample's EIC holds[20.0, 20.0, 20.0](signal that only 0.35 Da matches) and that the stored tolerance is 0.35. On 653b149 it fails withassert 0.2 == 0.35.uv run python -m pytest -q: 676 passed.bench/reference.py check: exported results unchanged.Left out of #227
Its test patched
QThreadand called the worker by hand. The new tests use the real thread and real CDF files instead.