-
Notifications
You must be signed in to change notification settings - Fork 7k
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
remove generated dataset folders after download tests #3376
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3376 +/- ##
=======================================
Coverage 74.80% 74.80%
=======================================
Files 105 105
Lines 9716 9716
Branches 1561 1561
=======================================
Hits 7268 7268
Misses 1961 1961
Partials 487 487 Continue to review full report at Codecov.
|
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.
Looks good, I just left one comment. If you could provide a few more information so that we have history of how this works that would be awesome.
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def root(): |
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 understand that you are using pytest specific functionalities here but could you elaborate on when this is triggered?
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.
The autouse=True
flag tells pytest
to trigger this automatically even if it is not explicitly used. The scope="module"
tells pytest
to run this once per module. In general, everything before the yield
is the setup whereas everything after it is the teardown.
Here, pytest
triggers this fixture the first time any test in this module is run and finishes it when the last test is run.
Summary: * remove generated dataset folders after download tests * revert unnecessary style changes Reviewed By: mthrok Differential Revision: D26422439 fbshipit-source-id: e24fff8a183768ecd5bac57cc073d27f40e7f3e8
While the actual download and extraction logic is mocked, some datasets still create an extra directory in the root directory:
vision/torchvision/datasets/mnist.py
Lines 140 to 141 in 5905de0
vision/torchvision/datasets/caltech.py
Line 44 in 5905de0
With this, all tests use a temporary directory instead of the current directory as root for the datasets. This temporary directory is simply removed after all tests are run.
Another option would be to mock the function that creates the extra directory (here
os.makedirs
). While not complicated, we would than need to manually check during code review that either