Make File.is_installed binary-safe - #1044
Merged
podkidyshev merged 1 commit intoSep 21, 2026
Merged
Conversation
File.is_installed compared the installed copy with the source using read_text(), which raises UnicodeDecodeError for files that are not valid UTF-8. install() copies bytes with shutil.copyfile, so compare bytes as well. Also report a content mismatch as such. Until now the message said that the file does not exist even when it existed with different contents. Fixes NVIDIA#782 Signed-off-by: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com>
MaxFreedomPollard
requested review from
jj10306,
podkidyshev,
rutayan-nv and
srivatsankrishnan
as code owners
September 19, 2026 06:19
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: NVIDIA/cloudai/.coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughWalkthroughChangesFile installation validation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
podkidyshev
approved these changes
Sep 21, 2026
Contributor
|
@MaxFreedomPollard thank you for contribution, it's a good change 👍 |
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.
Summary
Fixes #782.
File.is_installedcompared the installed copy with the source usingread_text(), which raisesUnicodeDecodeErrorfor files that are not valid UTF-8. It now compares bytes, which matchesinstall(), where the file is copied withshutil.copyfile.File <installed path> differs from <src>.The issue lists the Slurm and Kubernetes installers, but since #885 the check lives in
File.is_installed, so that is the only place that needs the change.Test Plan
test_is_installed_binary_fileandtest_is_installed_missing_file, and the existing content-mismatch test now checks the message. Without the fix, the binary test fails withUnicodeDecodeErrorand the mismatch test gets the "does not exist" message.uv run --locked --extra dev pytest: 1960 passed, 5 skipped.uv run --locked --extra dev pre-commit run --fileson the two changed files: all hooks pass.Additional Notes
read_text()also normalizes line endings, so two files that differed only in CRLF vs LF used to count as the same. With a byte comparison they no longer do, which seems right for checking whether the copy made bycopyfileis still identical to the source.