pytorch
38905509 - [RPC tests] Fix @_skip_if_tensorpipe always skipping for all agents (#40860)

Commit
4 years ago
[RPC tests] Fix @_skip_if_tensorpipe always skipping for all agents (#40860) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/40860 It turns out that the `@_skip_if_tensorpipe_agent` decorator was written in such a way that it accidentally caused the test to become a no-op (and thus always succeed) for all agents. What this means is that all tests wrapped by that decorator were never ever being run, for any agent. My understanding of the root cause is that the following code: ``` @_skip_if_tensorpipe_agent def test_foo(self): self.assertEqual(2 + 2, 4) ``` ended up behaving somewhat like this: ``` def test_foo(self): def original_test_func(self): self.assertEqual(2 + 2, 4) return unittest.skipIf(self.agent == "TENSORPIPE")(original_test_func) ``` which means that the test body of the decorated method was not actually calling the original test method. This issue probably came from the `@_skip_if_tensorpipe_agent` being copy-pasted from `requires_process_group_agent` (which, however, is not a decorator but rather a decorator *factory*). An unfortunate naming (calling `decorator` what was in fact the wrapped method) then hindered readability and hid the issue. Note that a couple of tests had become legitimately broken in the meantime and no one had noticed. The breakages have been introduced in #39909 (a.k.a., D22011868 (https://github.com/pytorch/pytorch/commit/145df306aee0884810aa7660db8e46b1daf90bf7)). ghstack-source-id: 107045916 Test Plan: Discovered this as part of my refactoring, in D22332611. After fixing the decorator two tests started breaking (for real reasons). After fixing them all is passing. Differential Revision: D22332611 fbshipit-source-id: f88ca5574675fdb3cd09a9f6da12bf1e25203a14
Author
lw lw
Parents
Loading