avoid suppressing exception in `FitLoop` (#9206)

This commit is contained in:
Adrian Wälchli 2021-09-01 12:03:18 +02:00 committed by GitHub
parent 65b3dc4495
commit eacece1c3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -13,7 +13,6 @@
# limitations under the License.
import logging
from contextlib import suppress
from typing import Any, Dict, Optional
from pytorch_lightning.loops import Loop
@ -181,8 +180,7 @@ class FitLoop(Loop):
self.trainer.train_dataloader.load_state_dict(self._dataloader_state_dict)
self._dataloader_state_dict = {}
# TODO: specify the possible exception
with suppress(Exception):
if callable(getattr(self.trainer.train_dataloader.sampler, "set_epoch", None)):
# set seed for distributed sampler (enables shuffling for each epoch)
self.trainer.train_dataloader.sampler.set_epoch(self.current_epoch)