Skip to content
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

Refactor test_models to use pytest #3697

Merged

Conversation

NicolasHug
Copy link
Member

Pytest is now supported in the FB internal repo. We can start parametrizing tests!

This PR cleans up the test_models tests by relying on pytest.

@@ -132,25 +124,16 @@ def remove_prefix_suffix(text, prefix, suffix):

return expected_file

def assertExpected(self, output, subname=None, prec=None, strip_suffix=None):
def assertExpected(self, output, name, prec=None):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to tweak this a little because in the previous version, the check name was based on self.id(), which changes now that the tests are parametrized with pytest.

In fact I simplified it a bit because all what assertExpected needs to know is the name of the model, so I removed strip_suffix (which we don't need anymore) and also subname which was actually never used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general note I would like us to re-use as much as possible the testing utils from PyTorch, if it makes sense. This was originally taken from PyTorch tests, and now it is exposed via torch.testing I believe

@NicolasHug
Copy link
Member Author

There's a segfault with r2plus1d_18_cuda but it's unrelated: it also happens in other PRs like #3700 and #3699. I'll open an issue for it.

This should be good to merge!

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a ton for working on this!

@fmassa fmassa merged commit a64b54a into pytorch:master Apr 21, 2021
@@ -132,25 +124,16 @@ def remove_prefix_suffix(text, prefix, suffix):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The munged_id variable in the exact above line should have also been removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll submit a fix

try:
# We first try to assert the entire output if possible. This is not
# only the best way to assert results but also handles the cases
# where we need to create a new expected result.
self.assertExpected(output, prec=prec, strip_suffix=strip_suffix)
self.assertExpected(output, name, prec=prec)
raise AssertionError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NicolasHug I think this was left here by accident. This will cause the tests to be considered partially validated and marked as skipped.

facebook-github-bot pushed a commit that referenced this pull request May 4, 2021
Summary:
* refactor test_models to use pytest

* Also xfail the detection models

* Remove xfail and just comment out expected failing parts

* Comment out some more

* put back commented checks

* cleaning + comment

* docs

* void unnecessary changes

* r2plus1d_18 seems  to segfault on linux gpu??

* put back test, failure is unrelated

Reviewed By: NicolasHug

Differential Revision: D28169138

fbshipit-source-id: dc1332bf48a0fdf51158efc401df9c82a83e76f4

Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants