Repository navigation
installer: stop condemning a warm uv cache for a directory uv never writes - #10899
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
unslothai#10899 landed the same core fix on main (_UV_CACHE_DIR_INSTALLER_DEFAULT, so a caller's UV_CACHE_DIR and the installer's own default stop reading alike), with a probe that goes further than this branch's: a bucket-kind allowlist, case folding, dangling symlinks and UV_NO_CACHE. Conflicts in install.sh, install.ps1 and their suites are resolved in favour of main, and this branch drops its duplicate probe entirely. Two gaps remain, and are all that is left here: studio/setup.sh never reads the marker install.sh writes. Run standalone, it defaults to $STUDIO_HOME/cache/uv, which is the empty one after a shared-mode install, so the update refetches every wheel. It now reads the marker on the CLI's terms: a caller's UV_CACHE_DIR wins, UV_NO_CACHE leaves it unset, the marker wins only while its cache holds packages and uv can still write to it. setup.sh never writes the marker. _with_studio_uv_cache picked a cache without probing it. setup.sh treats the value it is handed as the caller's choice and skips its own probe, so a share remounted read-only since the install aborted every uv command in the update. The shell and Python probes call the same directories uv's, by install.ps1's and install.sh's kind list rather than a bare glob, so the four implementations agree.
Follow-up to #10626. Two cases where the adaptive cache selection throws away a cache it should have kept. Both were reproduced against the merged head, both are fixed here, and both new tests fail on
mainand pass on this branch.1. A bucket-shaped directory uv never writes condemned the whole cache
_uv_is_bucket_nameandTest-StudioUvBucketNameaccepted any<kind>-v<N>name. The write probe then created and deleted a file in every one of them, and a single failure refused the cache.That is right for
archive-v0, which uv renames downloads into. It is wrong for a directory that merely looks like a bucket. A read-onlyunused-v999sitting beside a perfectly good cache refused it, so the install fell back to the empty Studio cache and redownloaded Torch and CUDA it already had. Offline, it failed outright.Both helpers now also require the KIND to be one uv creates. That list is every
CacheBucketin uv 0.12.1, which is the versionUV_PINNED_VERSIONinstalls, read fromcrates/uv-cache/src/lib.rsat that tag:plus
built-wheels, from before it was folded intoarchive.Getting this list from the uv on the machine rather than from the uv we pin was wrong, and it mattered:
python-v0andbinaries-v0have been there since uv 0.8.16, andpython-v0is the bucket the installer's own managed-CPython step fills. A kind missing from the list is a bucket that never gets probed, so apython-v0left read-only by a privileged run would read as usable and the install would fail partway instead of falling back. The parity test now pinsUV_PINNED_VERSIONtoo, so bumping uv without re-reading its bucket list fails the test rather than silently leaving the new kind unprobed.unsloth_cli/commands/studio.pyalready had a kind list, a narrower one, because it only answers whether a bucket holds package bytes. Its docstring claimed it mirrored the installers; that is now stated accurately instead.2.
tr -d '\r'deleted carriage returns from inside the pathThe marker reader in
install.shstripped every CR in the file, not the trailing one.install.ps1writes the marker with a BOM and CRLF under PowerShell 5.1 and a WSL install shares$STUDIO_HOMEwith the Windows one, which is what the strip is for, but a cache directory whose own name contains a CR came back as a path that does not exist. The marker then read as stale and the next run quietly chose somewhere else, so the same inputs gave two different answers on consecutive runs.Now only a trailing CR is removed, which is what
Read-StudioUvCacheMarker'sTrim()on the PowerShell side already did.Not changed
A populated but read-only
archive-v0still refuses the cache. That is a real uv bucket: uv aborts renaming a download into it, so refusing is correct for any install that has to download anything. It costs an offline install that already held every wheel it needed, which is the narrower case, and there is no way to tell the two apart before uv runs.Verification
tests/sh/test_uv_cache_adaptive_selection.sh: 104 pass, 0 fail, over dash, bash and BusyBox ash with and without errexit. Againstmain'sinstall.shthe same file gives 101 pass and exactly the 3 new failures.tests/python/test_cross_platform_parity.py,test_windows_uv_cache_selection.py,test_windows_python_venv_hardening.py,unsloth_cli/tests/test_studio_update_uv_cache.py: 271 pass. The new Windows cases fail againstmain'sinstall.ps1.sh -n,bash -n,dash -nandbusybox sh -noninstall.sh;System.Management.Automation.Language.Parser.ParseFileoninstall.ps1;ast.parseonstudio.py.archive-v0,built-wheels-v3,simple-v20,interpreter-v4andpython-v0accepted;unused-v999,lost+found,archive-v0.backup,archive-v1-v,archive-v0-v1andArchive-v0rejected.