-
Notifications
You must be signed in to change notification settings - Fork 1.2k
tests: unblock nightly integ tests on pytest 9.1 and make collection deterministic #9180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
851ec58
tests: unblock nightly integ tests on pytest 9.1 and make collection …
roger-zhangg 01bb427
refactor: collect walk_modules results in a list instead of a set
roger-zhangg 5880a6b
tests: scope the pytest 9.1 warning ignore to the classes that need i…
roger-zhangg ceb03b0
perf: dedup walk_modules via a parallel set; fix per-file suppression…
roger-zhangg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[PERFORMANCE] The
seenset makes the dedup check O(1), but the amplification it was added to compensate for is itself removable — the recursion is redundant.pkgutil.walk_packagesalready yields the entire tree: for every entry withispkgit imports the package and doesyield from walk_packages(path, info.name + "."). So by the time the loop reacheswalk_modules(submodule, visited, seen), every name that recursive call can produce is already inseenand gets skipped. The recursion contributes no names — only cost.That cost is what the new docstring describes: because
__import__("samcli.cli")returns the top-levelsamcli, each of the ~150 packages triggers another full-tree walk from the root. The set removes the ~108k membership checks, but the ~150 redundant walks remain, and their real expense is the filesystem work (_iter_file_finder_modulesdoes anos.listdir+ sort per directory, so ~150 × ~150 directory listings) plus the importlib machinery. This runs at import time ofsamcli.cli.hidden_imports, which is hit by the pyinstaller hook,samdevstartup, and two unit test modules.Dropping the recursive branch keeps the original two-argument signature, so the
seenparameter does not need to leak into the API where a caller could pass a set that is out of sync withvisited:This preserves discovery order and dedup, so all four tests in tests/unit/cli/test_pyinstaller_imports.py still hold — including
test_walk_modules_does_not_add_duplicates, sinceseenis rebuilt fromvisitedon each call.