You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(pathfinder): look up site-packages sub-directories with a plain join - #3631
find_sub_dirs walked each path part with a stack so that a * part could match any directory. None of the 259 site-packages directories in the five catalogs has a * part, so the walk only ever joined the parts and checked that the result is a directory. It now does exactly that (61 -> 35 lines).
find_sub_dirs_no_cache is folded into find_sub_dirs_cached. The cache and the other two function names are unchanged, so the tests that patch find_sub_dirs_all_sitepackages are untouched.
One capability of this private helper goes away: * is no longer a wildcard. The two wildcard tests are replaced by one that pins the new rule: every part is a literal name.
No behavior change for any catalog entry. Checked beyond the test suite: the old and new lookups agree on 9,840 lookups over 120 random directory trees (plain directories, files in the way, symlinks, dangling symlinks, missing parents).
Testing
Full cuda_pathfinder test suite at this commit: 1298 passed, 6 skipped (Linux, Python 3.14).
pre-commit clean, including mypy-pathfinder. mypy also passes with --platform win32.
Reviewing files that changed from the base of the PR and between 71f7017 and 1d3be55.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Behavior Changes
Directory searches now treat * as a literal path component instead of expanding it to match subdirectories. It matches only when a directory is literally named *.
The uncached directory-search option is no longer available.
The uncached lookup function was removed. The cached lookup now joins each parent directory with the supplied components and returns existing directories. Tests now treat * as a literal component.
Changes: Directory lookup
Layer / File(s)
Summary
Join and validate directory paths cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py, cuda_pathfinder/tests/test_utils_find_sub_dirs.py
The lookup directly joins each parent directory with the supplied components and filters for existing directories. Tests cover literal * behavior and ordinary components with an empty parent path.
Possibly related PRs
NVIDIA/cuda-python#2425: Both changes use a joined-path check for exact directory lookup in pathfinder discovery.
Change: Refactor
Merge Risk: Minimal · previous review 71f70
This refactor simplifies directory lookup. Catalog entries, as reported by the author, contain no wildcard parts, so behavior should be unchanged. No merge-blocking risk was identified.
Security architecture risk: Minimal · up to 71f70
Site-packages discovery now uses literal directory names instead of expanding wildcards. The existing catalog lookups do not rely on wildcard expansion, and the change does not add search roots or change their precedence.
Retained concerns
No architecture-level concerns identified.
Security review details
Trust Boundaries and Controls
observed — Both revisions take roots from Python's site configuration and include the user-site directory only when it is enabled and available, at the same position in the search order. The directory predicate checks existence and type; it is not an ownership or symlink-containment check.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 7 remain after this review.
…ain join
`find_sub_dirs` walked each path part with a stack so that a `*` part
could match any directory. None of the 259 site-packages directories in
the five catalogs has a `*` part, so the walk only ever joined the parts
and checked that the result is a directory.
It now does exactly that. `find_sub_dirs_no_cache` is folded into
`find_sub_dirs_cached`; the cache and the other two function names are
unchanged.
The private helper no longer treats `*` as a wildcard. The two wildcard
tests are replaced by one that pins the new rule: every part is a
literal name.
No behavior change for any catalog entry. Old and new lookups agree on
9,840 lookups over 120 random directory trees (plain directories, files
in the way, symlinks, dangling symlinks, missing parents).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.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
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.
— codex on behalf of Ralf —
Description
Part 22 of 23 of a readability stack for
cuda.pathfinder(stack: #3623 → #3602 → #3603 → #3604 → #3605 → #3606 → #3607 → #3608 → #3609 → #3610 → #3611 → #3613 → #3618 → #3619 → #3620 → #3621 → #3622 → #3627 → #3628 → #3629 → #3630 → #3631 → #3632). No behavior change.find_sub_dirswalked each path part with a stack so that a*part could match any directory. None of the 259 site-packages directories in the five catalogs has a*part, so the walk only ever joined the parts and checked that the result is a directory. It now does exactly that (61 -> 35 lines).find_sub_dirs_no_cacheis folded intofind_sub_dirs_cached. The cache and the other two function names are unchanged, so the tests that patchfind_sub_dirs_all_sitepackagesare untouched.One capability of this private helper goes away:
*is no longer a wildcard. The two wildcard tests are replaced by one that pins the new rule: every part is a literal name.No behavior change for any catalog entry. Checked beyond the test suite: the old and new lookups agree on 9,840 lookups over 120 random directory trees (plain directories, files in the way, symlinks, dangling symlinks, missing parents).
Testing
cuda_pathfindertest suite at this commit: 1298 passed, 6 skipped (Linux, Python 3.14).mypy-pathfinder. mypy also passes with--platform win32.mainare still byte-identical (Linux, simulated Windows x64 and arm64), and all 526 public-API scenarios give the same result as fix(pathfinder): check for an already-loaded library before searching the disk #3623.PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
subprocess.runcall in the canary probe, now incanary_probe.pyChecklist
🤖 Generated with Claude Code