An empty get_module() returning NotImplementedError will skip all unit tests!
See original GitHub issueWhen a model in TorchBenchmark raises NotImplementedError
in the get_module()
function, it will skip all the unit tests!
This happens because test.py will accept and skip the exception, NotImplementedError. These are the reasons why every test is skipped:
- check_example
- check_device
- check_example and check_device directly calls
model.get_module()
, which may raiseNotImplementedError
.
- check_example and check_device directly calls
- train
- eval
- train and eval unit tests call
set_train()
andset_eval()
respectively before running the method set_train/eval()
will call_set_mode()
, where(model, _) = self.get_module()
is called and may raiseNotImplementedError
.
- train and eval unit tests call
For 1 and 2, it may make sense to skip them since their functionality requires get_module()
. However for 3 and 4, we may choose:
- Overwrite
_set_mode()
to something that works (or pass). - Skip
_set_mode()
and directly run train and eval. - Require every model to implement get_module(). (This would also fix 1 and 2).
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How do I skip a whole Python 'unittest' module at run time?
I can use @unittest.skipIf(...) to skip a unittest.TestCase class, but how do I skip the entire module? Applying skips to every class is...
Read more >unittest — Unit testing framework
Skipping a test is simply a matter of using the skip() decorator or one of its conditional variants, calling TestCase.skipTest() within a setUp()...
Read more >nose Documentation
nose collects tests from unittest.TestCase subclasses, of course. But you can also write simple test functions, as well as test classes that are ......
Read more >7. Incomplete and Skipped Tests — PHPUnit 9.5 Manual
When you are working on a new test case class, you might want to begin by writing empty test methods such as: public...
Read more >Python NotImplementedError | How to Avoid ...
When a Python content raises an exception, it should either deal with the exemption promptly else it ends and stops. Start Your Free...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here are a couple examples of
get_module()
being used to check correctness of custom transformations:Accomplishing the same thing with
train()
/eval()
would not be possible with the current design. Especially the custom sync logic in the first example.Yes this is the primary thing I use torchbench for.
Thank you for the explanation. Could you please help add
get_module()
interface to the models that are missing (listed by @aaronenyeshi in the comment above)? After that, we could fix a unit test that makes sure every model needs to implement this interface.