Skip to content

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
NSLS2:mainfrom
sligara7:alignment-name-and-csv-followups
Open

Anthony Sligar (sligara7) wants to merge 1 commit into
NSLS2:mainfrom
sligara7:alignment-name-and-csv-followups

Conversation

@sligara7

Copy link
Copy Markdown
Contributor

Follow-up to #139, for the review comments left open there.

  • validate_tomo_alignment_scan accepts tomography_alignment_scan as well as tomo_alignment_scan, so alignment runs taken before the rename still validate under TomoAlignmentScan v1.
  • plan_history.csv: if an existing file has different columns (e.g. an old --csv file), it is moved aside as <name>.<timestamp>.csv and a new file is started, instead of appending rows under the wrong header.
  • A missing proposal directory, or a run without 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 on main (8600f17) and pass here; pytest --ignore=tests/gui 556 passed, pixi run type-check (pyright) 0 errors, pre-commit run --all-files clean. Not run at the beamline.

…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
Copilot AI balanced review requested due to automatic review settings November 9, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants