-
-
Notifications
You must be signed in to change notification settings - Fork 766
Use python imports to identify fixtures (part 2/6) #5702
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
Merged
Merged
Conversation
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
In order for pants to detect which changes need to be re-run after changing fixtures, pants needs to be able to infer the relevant dependencies. We could use a super-level target to depend on everything, but then we lose the fine-grained invalidation. The only way to tell pants that a test file is using a particular set of fixtures is via python imports. So, this adds some boilerplate python in every pack dir: __init__.py fixture.py
c169698
to
f57f006
Compare
edit: moved to PR description |
rush-skills
approved these changes
Aug 11, 2022
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.
LGTM overall
khushboobhatia01
approved these changes
Aug 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
maintenance
pantsbuild
refactor
size/XXL
PR that changes 1000+ lines. You should absolutely split your PR into several.
tests
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.
Background
I'm working towards introducing
pants
. Eventually I would like to use pants to run tests to take advantage of the fine-grained per-file caching of results that accounts for dependencies by python files (pants infers the deps by reading the python files).In order to use the fine-grained caching, Pants needs to know which tests rely on which fixtures. We could add extra metadata to tie the tests to the fixtures, but that would be an additional maintenance burden that will become out-of-date. We can also include all fixtures for all tests, but then we don't benefit from the fine-grained per-file caching. However, pants can already infer dependencies based on python imports, so that is what this PR (and several follow-up PRs) takes advantage of.
Overview
This PR builds on, and follows the patterns established in, #5699.
This PR does the following:
__init__.py
.fixture.py
file in each fixture that uses the fixturesloader utils (where helpful) to identify itself withPATH
andNAME
vars.PATH
and/orNAME
vars from that fixture.This PR updates all fixture packs, skipping any fixtures that need something slightly different (like
dummy_pack_7
anddummy_pack_9
).Follow-up PRs will address other fixture packs and other sets of fixtures. I will submit those PRs after this one is merged.
Statistics
Stats for this PR:
32 pack fixtures got 62 new files (a
fixture.py
in each; a__init__.py
in all but 2 pack fixtures which already had it)All 32 copies of
fixture.py
have the same 16 lines, 13 of which are our copyright/license header.The remaining 38 files (=100-62) are test files that use the vars from the pack fixtures.
Lines changed in test files:
-298
lines+238
lines = 750 lines - 512 lines (512 = 16 copied lines * 32fixture.py
files)