Make symlink name templating resilient to missing event keys#29
Open
Eliot Gann (EliotGann) wants to merge 4 commits into
Open
Make symlink name templating resilient to missing event keys#29Eliot Gann (EliotGann) wants to merge 4 commits into
Eliot Gann (EliotGann) wants to merge 4 commits into
Conversation
Previously an unresolved {name} placeholder in the destination filename
template (e.g. a sample_name referencing a motor 'x' that was absent from
the primary stream) raised KeyError and failed the whole flow.
Add a safe str.format helper that leaves unresolved {name} placeholders
literally in the output (preserving any format spec) and logs a warning,
plus an opt-in SAFE_KEY_ALIASES table for known short-name fallbacks.
Eliot Gann (EliotGann)
requested review from
Jun Aishima (JunAishima) and
Copilot
June 25, 2026 16:52
There was a problem hiding this comment.
Pull request overview
This PR hardens symlink destination filename templating so missing event keys no longer raise KeyError and fail the flow, by introducing a “safe” formatting helper that leaves unresolved placeholders intact and optionally supports short-name aliases.
Changes:
- Added
_safe_formatand supporting classes to safely renderstr.formattemplates while preserving unresolved placeholders. - Added
SAFE_KEY_ALIASESto optionally map known short names (e.g.,x) to canonical event keys (e.g.,piezo_x) when present. - Updated
get_symlink_pairsto use two safe formatting passes instead of chained.format(...).format(...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The second pass's input contains every literal {key} the first pass left
behind, so its missing-key set is a superset; warning only there yields at
most one warning per unresolved name per filename.
The success/failure summary lines were plain strings, so they printed
literal {success_rate} / {len(failed)} braces instead of values. Also the
'success_rate' variable was computing the failure fraction; correct it to
linked/total so the label matches the value.
Jun Aishima (JunAishima)
approved these changes
Jul 16, 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.
Previously an unresolved {name} placeholder in the destination filename template (e.g. a sample_name referencing a motor 'x' that was absent from the primary stream) raised KeyError and failed the whole flow.
Add a safe str.format helper that leaves unresolved {name} placeholders literally in the output (preserving any format spec) and logs a warning, plus an opt-in SAFE_KEY_ALIASES table for known short-name fallbacks.