Repository navigation
fix(eic): mark samples left at an old mass tolerance in the export and plots - #310
Merged
Merged
Conversation
…d plots A sample whose CDF could not be read during a mass tolerance reload kept its old-tolerance EICs. After the warning closed nothing showed it, and its areas went into the workbook unmarked. The reload now records the failure in samples.eics_stale and clears it when the sample is rebuilt. The export fills that sample's cells light gold on every sheet, the changelog colour key explains the colour, and its plot captions say "old mass tolerance". Fixes #206.
…g them Every sample is marked before the reload loop and cleared when its EICs are replaced, so a reload that raises partway leaves unreached samples marked. Export now asks for confirmation when an active sample is stale.
Collaborator
Author
|
Review verdict for head 3e3270d: CLEAN after one fix round. Reviewed by GPT-6.1 Sol. Round 1, at feee390:
Round 2, the fix diff only:
Defect already on |
This was referenced Nov 10, 2026
Jack-Coutts
changed the base branch from
fix/168-restored-items-get-current-eics
to
main
November 10, 2026 20:26
…mples-v2 # Conflicts: # docs/01_user_guide.md # docs/Reference_Mass_Tolerance.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 #206. Re-applies #215 onto
fix/168-restored-items-get-current-eics(#306) after the UI redesign.Part of #307. This PR covers the marking half: a reload that stops partway leaves every sample it did not rebuild marked stale. #305 covers the message half, the failure dialog and the tolerance it puts back.
The bug
When the mass tolerance changes and a sample's CDF cannot be read, that sample keeps its EICs from the old tolerance. The "Regeneration Incomplete" warning names it once. After that dialog closes nothing shows the sample is stale, and its areas go into the workbook next to samples built at the new tolerance with no mark. With #306 deleted samples are rebuilt too, so a deleted sample with a bad CDF is stale as well and becomes stale and visible when restored.
A reload can also raise partway, for example a
PermissionErrorwhile checking a later sample's CDF path (#307). The samples it already rebuilt hold the new tolerance and the rest keep the old one, with no record of which are which.The fix
The reload records the result per sample in a new
samples.eics_stalecolumn. Before the sample loop it sets the flag on every sample, deleted ones included, in oneUPDATE. A sample rebuilt at the new tolerance is set back to 0 in the same transaction that replaces its EICs. So a sample whose CDF fails, and every sample a raising reload never reached, stays marked. A reload that succeeds clears every flag, including samples whose batch is empty because every compound's RT window fell outside the scan range.list_stale_samples()insample_reader.pyis the one query for the stale state, and #244 can build its "rebuild stale samples" action on it. It includes deleted samples, so a restored stale sample is marked with no restore-specific code.The flag shows in three places:
MainWindow._confirm, the same prompt the missing internal standard uses.PeakVerdict.STALE, so no sheet writer changed. Gold replaces any validation fill for that sample, because its numbers are wrong whatever the review said. The changelog's Cell Colour Key gains one line for gold, so the colour is explained next to the workbook.s2 · old mass tolerance. The reload already re-plots when it finishes, and a restore re-plots too, so the mark appears without changes to the reload handlers.The sample list and a separate changelog section were left out. The sample list would need a refresh hook in the reload completion handler, which #305 owns. A changelog list of names repeats what the gold cells and the export warning already show.
The flag clears when the sample is rebuilt at the current tolerance. A later successful reload clears it. A re-import clears it too, because loading CDFs goes through
clear_database, which deletes the sample rows.Older databases get the column from
_run_migrations, the sameALTER TABLE ... ADD COLUMNpattern the compounds columns use, with default 0. Older samples are treated as not stale. MANIC clears the database at every start, so an older database file never holds EICs that need a flag. Session files hold methods only and need a re-import of the raw data, so they carry no stale field and gain none. A session import that changes the tolerance runs the same reload and sets the flag the same way.The docs say what the export warning, the gold cells and the caption mean and how to clear them.
Checks
tests/test_stale_sample_marking.pyhas three tests.{'s2': {'00000000'}} != {'s2': {'FFFFE699'}}). Then it puts the file back, reloads again, and checks the gold is gone. With only the clearing write removed, that half fails ({'s2': {'FFFFE699'}} != {'s2': {'00000000'}}).PermissionError, which stops the reload. It checkslist_stale_samples() == ['s2', 's3', 's4']. On the previous head (feee390), which marked only after the loop, it fails with[] == ['s2', 's3', 's4']. The test patchesPath.existsfor s3 instead of making the folder unreadable, becausechmoddoes not block a folder on the Windows CI runner.samplestable has noeics_stalecolumn. Without the migration it fails withno such column: eics_stale. With it, no sample is stale.tests/test_export_warns_about_stale_samples.pydrivesMainWindow.export_datawith one stale sample. Declined, the user is never asked for a location and no file is written. Without the warning it fails ([PosixPath('.../out.xlsx')] == []). Accepted, the workbook is written with s1 and s2 on Raw Values.s2 · old mass tolerance, and Raw Values, Corrected Values, Isotope Ratio, % Label Incorporation and Abundances each filled only s2 gold.uv run python -m pytest -q: 677 passed.bench/reference.py check: exported results unchanged.Left out of #215
_mass_tolerance_reload_completed, which fix(ui): a failed mass tolerance reload puts the old tolerance back #305 owns.Known limits