Skip to content

Commit 4aa8af7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bac8431 commit 4aa8af7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/tests_pytorch/loops/test_training_epoch_loop.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import contextlib
1415
import logging
1516
from unittest.mock import Mock, patch
1617

@@ -264,10 +265,8 @@ def test_broadcast_sigterm_interval(n_steps):
264265
# before it tries to fetch a batch and run training.
265266
mock_fetcher = Mock()
266267
mock_fetcher.__next__ = Mock(side_effect=StopIteration)
267-
try:
268+
with contextlib.suppress(StopIteration, TypeError, AttributeError):
268269
epoch_loop.advance(mock_fetcher)
269-
except (StopIteration, TypeError, AttributeError):
270-
pass
271270

272271
assert mock_broadcast.call_count == total_steps // n_steps
273272
assert epoch_loop._sigterm_broadcast_step == total_steps % n_steps
@@ -308,8 +307,9 @@ def test_broadcast_sigterm_forced_at_epoch_boundary():
308307
def test_broadcast_sigterm_interval_ddp(tmp_path):
309308
"""Test that broadcast_sigterm_every_n_steps controls broadcast frequency in real DDP training.
310309
311-
Uses ddp_spawn to exercise real torch.distributed broadcast paths (lines 300-304, 408-410).
312-
After training, _sigterm_broadcast_step should be 0 because the epoch-end forced broadcast resets it.
310+
Uses ddp_spawn to exercise real torch.distributed broadcast paths (lines 300-304, 408-410). After training,
311+
_sigterm_broadcast_step should be 0 because the epoch-end forced broadcast resets it.
312+
313313
"""
314314
n_steps = 5
315315
limit_train_batches = 7 # 7 % 5 = 2 remaining steps, triggers epoch-end forced broadcast

0 commit comments

Comments
 (0)