fix(utils): don't crash check_os_kernel on non-standard kernel release strings#4077
Open
eldar702 wants to merge 1 commit into
Open
fix(utils): don't crash check_os_kernel on non-standard kernel release strings#4077eldar702 wants to merge 1 commit into
eldar702 wants to merge 1 commit into
Conversation
…e strings check_os_kernel() unpacked re.split(r"(\d+\.\d+\.\d+)", info.release) with `_, version, *_ = ...`, which raises ValueError when the kernel release string does not contain a full X.Y.Z version (e.g. custom builds, some containers/WSL report "5.15", "6.1-arch1", or "unknown"). Because this function runs during Accelerator.__init__, an unparseable release aborts initialization with an opaque error, even though the function is only meant to emit a best-effort warning. Use re.search to extract the version and skip the check gracefully when no X.Y.Z pattern is present. Adds a regression test covering non-standard release strings. AI-assisted contribution.
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
check_os_kernel()abortsAcceleratorinitialization with an opaqueValueError: not enough values to unpackon Linux hosts whose kernel release string doesn't contain a fullX.Y.Zversion — e.g. custom kernels, some containers/WSL reporting"5.15","6.1-arch1", or"unknown". The cause is_, version, *_ = re.split(r"(\d+\.\d+\.\d+)", info.release), which yields too few parts when there's noX.Y.Zmatch.Fix
Use
re.searchfor theX.Y.Zpattern and return early (skip the version warning) when no standard version is present. On standard release strings the extracted version is identical to before — no behavior change.Tests
Regression test covering non-standard release strings (RED before / GREEN after).
tests/test_utils.py: 46 passed; ruff clean.AI-assisted contribution.