-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
[testing] port test_trainer_distributed to distributed pytest + TestCasePlus enhancements #8107
Merged
Conversation
This file contains 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
stas00
changed the title
Distr train test
[testing] port test_trainer_distributed to pytest-distributed + TestCasePlus enhancements
Oct 27, 2020
stas00
changed the title
[testing] port test_trainer_distributed to pytest-distributed + TestCasePlus enhancements
[testing] port test_trainer_distributed to distributed pytest + TestCasePlus enhancements
Oct 27, 2020
sgugger
approved these changes
Oct 28, 2020
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.
Thanks for this PR! It all looks good to me!
LysandreJik
approved these changes
Oct 28, 2020
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.
This is great, love the new properties. Thanks @stas00!
LGTM! cc @patrickvonplaten for awareness! |
sshleifer
approved these changes
Oct 28, 2020
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
fabiocapsouza
pushed a commit
to fabiocapsouza/transformers
that referenced
this pull request
Nov 15, 2020
…asePlus enhancements (huggingface#8107) * move the helper code into testing_utils * port test_trainer_distributed to work with pytest * improve docs * simplify notes * doc * doc * style * doc * further improvements * torch might not be available * real fix * Apply suggestions from code review Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
fabiocapsouza
added a commit
to fabiocapsouza/transformers
that referenced
this pull request
Nov 15, 2020
… + TestCasePlus enhancements (huggingface#8107)" This reverts commit 9018e16.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR:
ports
test_trainer_distributed
to run with pytest - it will skip if gpus < 2.includes various improvements via refactoring now 3 use cases of distributed testing by extending
TestCasePlus
with a whole set of convenient features:Feature 1: A set of fully resolved important file and dir path accessors.
In tests often we need to know where things are relative to the current test file, and it's not trivial since the test could be invoked from more than one directory or could reside in different sub-directories. This class solves this problem by sorting out all the basic paths and provides easy accessors to them:
pathlib
objects (all fully resolved):test_file_path
- the current test file path (=__file__
)test_file_dir
- the directory containing the current test filetests_dir
- the directory of thetests
test suiteexamples_dir
- the directory of theexamples
test suiterepo_root_dir
- the directory of the repositorysrc_dir
- the directory ofsrc
(i.e. where thetransformers
sub-dir resides)stringified paths - same as above but these return a string, rather than a
pathlib
objecttest_file_path_str
test_file_dir_str
tests_dir_str
examples_dir_str
repo_root_dir_str
src_dir_str
Feature 2: Get a copy of the
os.environ
object that sets upPYTHONPATH
correctly, depending on the test suite it's invoked from. This is useful for invoking external programs from the test suite - e.g. distributed training.All these are also documented in
testing.rst
.Fixes: #8058
@sgugger, @LysandreJik, @sshleifer