-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Test fetch v2 #22367
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
Test fetch v2 #22367
Conversation
The documentation is not available anymore as the PR was closed or merged. |
I guess it's ready for a review? |
No I haven't finished this PR yet. |
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.
Cool, LGTM! Looking forward to seeing it run!
@@ -667,11 +611,29 @@ def filter_tests(output_file, filters): | |||
f.write(" ".join(test_files)) | |||
|
|||
|
|||
def parse_commit_message(commit_message): |
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.
I would tend to favor explicit returns such as a dict {"skip": skip, "all_models": all_models, "test_all": test_all}
so that we don't need to look for the docs to understand what to do with the returned value
# Sagemaker tests are not meant to be run on the CI. | ||
if "tests/sagemaker" in tests: | ||
tests.remove("tests/sagemaker") |
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.
to verify with @philschmid
Co-authored-by: Lysandre Debut <[email protected]>
Hi @sgugger . Thank you a lot for working on this important task! I feel it's better for me to look this work in depth, and I tried to play with the test fetcher (on However, the first thing I tried (by following some sentences you mentioned) makes me a somehow confused. Here is what I saw:
|
Is the following block (on
[Not question - just to record something so I won't forget later]
|
Well, at least, when |
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.
No comments other than to say this was a very interesting and enjoyable PR to review ❤️
Thanks for adding!
|
||
# List here the models to always test. | ||
IMPORTANT_MODELS = [ | ||
# Most downloaded models |
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.
Shall we have a reminder somewhere to periodically update this?
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.
Not sure people are going to go read this periodically ;-) It's more of us to think of it when we add a new pipeline for instance.
return get_diff(repo, repo.head.commit, parent_commits) | ||
|
||
|
||
# (:?^|\n) -> Non-catching group for the beginning of the doc or a new line. |
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.
Detailed comments explaining regex ❤️ ❤️ ❤️
def test_infer_tests_to_run(self): | ||
with tempfile.TemporaryDirectory() as tmp_folder: | ||
tmp_folder = Path(tmp_folder) | ||
models = models = ["bert", "gpt2"] + [f"bert{i}" for i in range(10)] |
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.
What's the reason for reassigning models
here?
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.
Just a typo ;-)
@ydshieh, good catch on a modified test file missing from the tests launched. I have only put the dependencies and forgot those. Will fix. |
@ydshieh did you want to review more or is it good to merge? |
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.
Thank you @sgugger again for the great work and the patience for my slow review.
I am actually learning things here rather than giving useful reviews, but left 2 nits (typo and var. naming).
""" | ||
with open(os.path.join(PATH_TO_TRANFORMERS, module_fname), "r", encoding="utf-8") as f: | ||
if cache is not None and module_fname in cache: | ||
return cache[module_fname] |
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.
Very nice! I actually missed these 2 lines during the review, and I was thinking why not using cache but just adding content at the end.
f for f in modified_files if f.startswith("tests") and f.split(os.path.sep)[-1].startswith("test") | ||
] | ||
# Then we grab the corresponding test files. | ||
test_map = create_module_to_test_map(reverse_map=reverse_map, filter_models=filter_models) |
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.
good not to create reverse_map
twice!
utils/tests_fetcher.py
Outdated
if commit_flags["test_all_models"]: | ||
print("Testing all models found.") | ||
if commit_flags["test_all"]: | ||
print("Force- launching all tests") |
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.
When reading this part, I feel confused between between "test_all_models"
and "test_all"
.
Maybe run_fetched_tests
and run_all_tests
make it more clear.
Leave you to decide.
(and "Run all fetched tests.
)
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.
Going for no_filter instead, as I find it clearer and shorter than run_fetched_tests
.
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.
😮 💯 🔥
Co-authored-by: Yih-Dar <[email protected]>
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
* Test fetcher v2 * Fix regexes * Remove sanity check * Fake modification to OPT * Fixes some .sep issues * Remove fake OPT change * Fake modif for BERT * Fake modif for init * Exclude SageMaker tests * Fix test and remove fake modif * Fake setup modif * Fake pipeline modif * Remove all fake modifs * Adds options to skip/force tests * [test-all-models] Fake modif for BERT * Try this way * Does the command actually work? * [test-all-models] Try again! * [skip circleci] Remove fake modif * Remove debug statements * Add the list of important models * Quality * Update utils/tests_fetcher.py Co-authored-by: Lysandre Debut <[email protected]> * Address review comments * Address review comments * Fix and add test * Apply suggestions from code review Co-authored-by: Yih-Dar <[email protected]> * Address review comments --------- Co-authored-by: Lysandre Debut <[email protected]> Co-authored-by: Yih-Dar <[email protected]>
* Test fetcher v2 * Fix regexes * Remove sanity check * Fake modification to OPT * Fixes some .sep issues * Remove fake OPT change * Fake modif for BERT * Fake modif for init * Exclude SageMaker tests * Fix test and remove fake modif * Fake setup modif * Fake pipeline modif * Remove all fake modifs * Adds options to skip/force tests * [test-all-models] Fake modif for BERT * Try this way * Does the command actually work? * [test-all-models] Try again! * [skip circleci] Remove fake modif * Remove debug statements * Add the list of important models * Quality * Update utils/tests_fetcher.py Co-authored-by: Lysandre Debut <[email protected]> * Address review comments * Address review comments * Fix and add test * Apply suggestions from code review Co-authored-by: Yih-Dar <[email protected]> * Address review comments --------- Co-authored-by: Lysandre Debut <[email protected]> Co-authored-by: Yih-Dar <[email protected]>
What does this PR do?
This PR rewrites the test fetcher util to be more accurate in the tests collection, and also comes with a restriction on the tests run when a large amount of tests are picked when modifying a core file (like modeling_utils).
The code that extracts the dependencies of a given module now inspects the inits to pinpoint the exact location of imported objects. So for instance if a test file has an import
from transformers import BertModel
, this new version will detect a dependency ontransformers/models/bert/modeling_bert.py
. As a comparison, the previous version stopped attransformers/__init__.py
. This removes the need for all the complex logic that tried to match a given file with its corresponding tests, we now just look at the dependencies of the test file.The second change is that when a given file is seen to trigger too many model tests (current trigger is set at half the models, it can evolve), it will only keep the tests relative to a given list of important models. If a PR changes many modeling files, all the tests for those models will still run, but if a PR only changes modeling_utils (for instance), this will trigger the core model tests only. The list of important models is built using:
To bypass this rule, one can add a special command in a commit message (circleCI does not have access to labels, so I can't rely on that):
A couple of adjustments to Transformers should be done (in follow-up PRs) to have the test fetcher be more accurate and more efficient:
pipeline/__init__.py
) define real objects, it would be best to move them to a submodule.test_modeling_common.py
contains both the common tests and the test of the modeling_utils module. It would be best to split those in two files.Lastly, this PR adds lots of tests to make sure future work doesn't break the test fetcher :-)
To see how the test fetcher behaves on some examples:
__init__.py
all tests are run, but filtered to the list of important models [fetch summary] [job page]setup.py
all tests are run [fetch summary] [job page]