Repository navigation
Tomo dark/flat: never link another proposal's dark/flat - #105
Merged
Jakub Wlodek (jwlodek) merged 5 commits intoOct 23, 2026
Merged
Conversation
RE.md is shared by the beamline and kept last_dark_flat_uid across a proposal switch, so tomo scans in a new proposal were exported with the previous proposal's dark/flat (HEX scans 249-256, pass-312143 -> scan 246, pass-314022). - switch_proposal removes last_dark_flat_uid/scan_id when moving to a different proposal (the GUI's queueserver path removes them from the worker's RE.md too). - The exporter links the start document's dark/flat only if it is from the same proposal, and skips an unresolvable uid with a warning instead of failing the export. An explicit dark_flat_id is still used as given. Assisted-by: copilot:claude-opus-5-5
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Failed proposal switches can delete the active proposal’s valid calibration metadata before authentication succeeds.
1 open issue
What changed in this PR
This PR prevents tomography exports from automatically linking another proposal’s dark/flat calibration, addressing stale metadata retained across proposal switches.
Changes:
- Clears tracked dark/flat metadata when changing proposals, including through the GUI’s QueueServer path.
- Checks proposal identity before linking automatic calibrations, skips unresolved references, and preserves explicit overrides.
- Adds seven regression tests covering proposal switching and calibration selection.
| File | Description |
|---|---|
| tests/test_dark_flat_proposal.py | Tests metadata cleanup and calibration selection. |
| src/hextools/utils/__init__.py | Defines shared calibration keys and clears them on proposal changes. |
| src/hextools/tomography/utils.py | Uses shared keys when tracking dark/flat runs. |
| src/hextools/gui/live_re_md_viewer.py | Propagates calibration-key removal to the QueueServer worker. |
| src/hextools/exporters/tomography.py | Validates automatically selected calibrations against the scan’s proposal. |
Review effort: Balanced
Jakub Wlodek (jwlodek)
requested changes
Oct 22, 2026
Jakub Wlodek (jwlodek)
left a comment
Contributor
There was a problem hiding this comment.
Few comments
…; drop the GUI worker script Review (jwlodek, Copilot): a same-proposal dark/flat from an earlier cycle is stale; a failed login must keep the current proposal's dark/flat. The exporter check covers every way of switching (GUI, CLI sync-experiment, queueserver worker), so the GUI no longer edits the worker's RE.md. Assisted-by: copilot:claude-opus-5-5
…oposal switch; warn on an unresolvable explicit id Review (jwlodek): switch_proposal no longer clears RE.md; clear_last_dark_flat() does, and reset_scan_id calls it, so it runs in the RE that owns RE.md (worker or local). The exporter warns and links no dark/flat when an explicit dark_flat_id does not resolve, instead of raising; resolve_dark_flat_run logs the dark/flat it uses. Assisted-by: copilot:claude-opus-5-5
Jakub Wlodek (jwlodek)
left a comment
Contributor
There was a problem hiding this comment.
One last note
Co-authored-by: Jakub Wlodek <jwlodek.dev@gmail.com>
… too Follows the accepted suggestion: drop the now always-true guard, update the docstring, and replace the 'explicit id honoured across proposals' test with one that refuses it and one that an explicit id overrides the start document. Assisted-by: copilot:claude-opus-5-5
Jakub Wlodek (jwlodek)
approved these changes
Oct 23, 2026
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.


A tomo scan in a new proposal was exported with the previous proposal's dark/flat: at HEX, scans 249–256 (pass-312143) all link dark/flat scan 246 (pass-314022).
RE.mdis shared by the beamline and keepslast_dark_flat_uidacross a proposal switch, and the exporter linked it without checking.sync-experiment, queueserver worker). An explicitdark_flat_idis used as given. An unresolvable dark/flat (implicit or explicit) is skipped with a warning instead of failing the export.clear_last_dark_flat()removeslast_dark_flat_uid/last_dark_flat_scan_idfromRE.md;reset_scan_idcalls it, since resetting the scan ID also retires earlier dark/flats.Verification: mock/unit tests only.
tests/test_dark_flat_proposal.py(9 tests); the new stub and explicit-id tests fail on the previous commit. Full suite: 335 passed (non-GUI), 48 passed (GUI, offscreen). Root cause confirmed from Tiled at HEX (scans 249–256); not yet run on the beamline. Already-exported .nxs files for 249–256 need a re-export after this merges.