Extract shared atomic-publish helper in shell command template - #140
Merged
Conversation
Both the uv bootstrap dir and the cached environment now publish via a single groundhog_publish() helper (build-in-temp, optionally validate, atomically rename, discard on lost race). The optional validation command also gates clearing a stale/broken destination before the rename, preserving each call site's prior semantics exactly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What changed
After #138 and #139,
shell_command.sh.jinjacontained two near-identical copies of the build-in-temp-then-atomically-publish idiom: one for the uv bootstrap dir ($UV_BOOT_TMP→$UV_BOOT) and one for the cached environment ($ENV_TMP→$ENV_DIR). This extracts a singlegroundhog_publish TMP FINAL [VALIDATE_CMD...]helper, defined once near the top of the template, and calls it from both sites.The two sites had diverged slightly in review, so the optional validation command does double duty to unify them while preserving each site's exact prior semantics:
uv_works(runs$1/bin/uv --version): the fresh install is validated before publishing, an existing-but-broken$UV_BOOT(e.g. after a partial scratch purge) is treated as unusable and cleared before the rename, and a racer's working publish is kept over ours.uv_worksalso replaces the inline--versionchecks at the reuse and selection gates.$ENV_DIRcounts as usable and is never cleared, exactly as before.The helper (and
uv_works) use subshell function bodiesf() ( ... )rather than{ ... }, so they contain no literal braces — no{% raw %}blocks or brace-doubling needed for Globus Compute's.format()call on the rendered command.Substring assertions in
TestEnvReuseTemplatingandTestUvBootstrapTemplatingare updated to target the helper, including a check that it is defined once and called from exactly two sites.Verification
uv run pytest tests/ -q: 370 passeduv run ruff check .anduv run ty check .: clean[tool.uv]config), applied.format(), and verified withbash -n🤖 Generated with Claude Code