Skip to content

refactor(pathfinder): look up site-packages sub-directories with a plain join - #3631

Open
rparolin wants to merge 1 commit into
pathfinder-readability/21-one-conda-prefix-readerfrom
pathfinder-readability/22-plain-sub-dir-lookup
Open

rparolin wants to merge 1 commit into
pathfinder-readability/21-one-conda-prefix-readerfrom
pathfinder-readability/22-plain-sub-dir-lookup

Conversation

@rparolin

@rparolin rparolin commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

— 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_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.
  • The step-by-step comparisons against main are 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.
  • Not run on Windows. Windows rules are exercised by tests that simulate Windows on Linux.

PLC Local Security Evidence (Advisory)

Local advisory checks only, run over the whole stack. Not release-gate results.

Check Status Tool Details
Secrets SKIP Pulse Secret Scanner scanner image not available locally (registry login); the repo trufflehog pre-commit hook passed
SAST WARN Semgrep 1 finding, not from this stack: the existing subprocess.run call in the canary probe, now in canary_probe.py
Dependencies WARN pip-audit / osv-scanner no manifest or lockfile in scope, so the local scan could not run; this stack changes no dependencies
License N/A - no dependencies changed
Container N/A - no container changed

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rparolin
rparolin added this pull request to stack #3616 November 26, 2026 18:40
@github-actions github-actions Bot added the cuda.pathfinder Everything related to the cuda.pathfinder module label Nov 26, 2026
@rparolin rparolin added the enhancement Any code-related improvements label Nov 26, 2026
@rparolin rparolin added this to the cuda.pathfinder next milestone Nov 26, 2026
@rparolin rparolin self-assigned this Nov 26, 2026
@rparolin
rparolin requested review from juenglin and rwgk November 26, 2026 18:42
@rparolin
rparolin marked this pull request as ready for review November 26, 2026 18:47
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e2d61ab and ff66426.

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 join each parent path with the supplied components and return matching existing directories in parent order.
    • The * component is treated literally rather than expanded to match subdirectories; it matches only if a directory is actually 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 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.

Change: Refactor

Merge Risk: Minimal · previous review d8f29

This refactor changes a private directory lookup to treat each path part literally. The author reports that no catalog entry uses wildcards, and the tests were updated to match. No actionable merge risk remains.

Architecture risk: Low · up to d8f29

The directory lookup contract changes from wildcard expansion to literal path-component resolution, so callers receive only existing directories at the exact supplied paths.

When the search caller supplies path components, the lookup now returns only existing joined directories and treats * literally rather than expanding it.

Changed areas: cuda_pathfinder

Review details

Systems and components

  • observed — 2 changed files mapped to cuda_pathfinder.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1d3be55 and d8f2929.

Files selected for processing: 1

  • cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 6 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

@rwgk
rwgk removed this pull request from stack #3616 November 26, 2026 19:19
@rwgk
rwgk force-pushed the pathfinder-readability/22-plain-sub-dir-lookup branch from 71f7017 to 0b2fb2b Compare November 26, 2026 19:19
@copy-pr-bot

copy-pr-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rwgk
rwgk added this pull request to stack #3633 November 26, 2026 19:19
@rparolin

rparolin commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test d8f2929

@rparolin
rparolin force-pushed the pathfinder-readability/22-plain-sub-dir-lookup branch from d8f2929 to e2d61ab Compare December 4, 2026 17:54
…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>
@rparolin
rparolin force-pushed the pathfinder-readability/22-plain-sub-dir-lookup branch from e2d61ab to ff66426 Compare December 4, 2026 20:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.pathfinder Everything related to the cuda.pathfinder module enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants