Repository navigation
Accept the pre-rename alignment plan_name; start a new plan history CSV when its header differs - #143
Open
Anthony Sligar (sligara7) wants to merge 1 commit into
Conversation
…SV when its header differs Follow-up to NSLS2#139. Alignment runs taken before the rename still validate under TomoAlignmentScan v1. An existing CSV with other columns is moved aside instead of getting rows under the wrong header. A missing proposal directory or missing start fields logs one warning instead of an error with a traceback. Assisted-by: copilot:claude-opus-5-5
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Overlapping _record_run calls can permanently overwrite archived history, so the header-check, rotation, and append sequence must be serialized per CSV path and existing archives protected from overwrite.
1 open issue
What changed in this PR
This follow-up to #139 preserves validation of older tomography alignment runs and updates the auto-exporter’s plan-history handling.
Changes:
- Accept both legacy and current alignment plan names under the existing v1 spec.
- Archive CSV files with incompatible headers before recording new history.
- Use warnings without tracebacks for missing proposal directories or required metadata, with regression tests.
| File | Description |
|---|---|
tests/test_specs.py |
Tests validation of the legacy alignment plan name. |
tests/test_auto_exporter.py |
Tests CSV rotation and warning behavior. |
src/hextools/specs.py |
Accepts and documents both alignment plan names. |
src/hextools/exporters/auto_exporter.py |
Adds header-based CSV rotation and quieter missing-data handling. |
Review effort: Balanced
Comment on lines
+90
to
+92
| stamp = datetime.now().strftime("%Y%m%d-%H%M%S") | ||
| old = csv_path.with_name(f"{csv_path.stem}.{stamp}{csv_path.suffix}") | ||
| csv_path.rename(old) |
This branch has not been deployed
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.

Follow-up to #139, for the review comments left open there.
validate_tomo_alignment_scanacceptstomography_alignment_scanas well astomo_alignment_scan, so alignment runs taken before the rename still validate underTomoAlignmentScanv1.plan_history.csv: if an existing file has different columns (e.g. an old--csvfile), it is moved aside as<name>.<timestamp>.csvand a new file is started, instead of appending rows under the wrong header.data_session/cycle/scan_id, now logs one warning instead of an error with a traceback for every run.Verification: mock tests only. Four new tests (
tests/test_specs.py,tests/test_auto_exporter.py) fail onmain(8600f17) and pass here;pytest --ignore=tests/gui556 passed,pixi run type-check(pyright) 0 errors,pre-commit run --all-filesclean. Not run at the beamline.