Skip to content

Commit

Permalink
Remove type error handling in _configure_checkpoint_callbacks (#9823)
Browse files Browse the repository at this point in the history
* remove type error handling in _configure_checkpoint_callbacks

* rm test

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
  • Loading branch information
daniellepintz and rohitgr7 authored Oct 12, 2021
1 parent dc27c72 commit dd6d797
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
9 changes: 0 additions & 9 deletions pytorch_lightning/trainer/connectors/callback_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,6 @@ def _configure_checkpoint_callbacks(self, checkpoint_callback: Optional[bool], e
# if both are set then checkpoint only if both are True
enable_checkpointing = checkpoint_callback and enable_checkpointing

# TODO: Remove this error in v1.5 so we rely purely on the type signature
if not isinstance(enable_checkpointing, bool):
error_msg = (
"Invalid type provided for `enable_checkpointing`: "
f"Expected bool but received {type(enable_checkpointing)}."
)
if isinstance(enable_checkpointing, Callback):
error_msg += " Pass callback instances to the `callbacks` argument in the Trainer constructor instead."
raise MisconfigurationException(error_msg)
if self._trainer_has_checkpoint_callbacks() and enable_checkpointing is False:
raise MisconfigurationException(
"Trainer was configured with `enable_checkpointing=False`"
Expand Down
6 changes: 0 additions & 6 deletions tests/checkpointing/test_model_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,12 +1187,6 @@ def test_model_checkpoint_mode_options():
ModelCheckpoint(mode="unknown_option")


def test_trainer_checkpoint_callback_bool(tmpdir):
mc = ModelCheckpoint(dirpath=tmpdir)
with pytest.raises(MisconfigurationException, match="Invalid type provided for `enable_checkpointing`"):
Trainer(enable_checkpointing=mc)


def test_check_val_every_n_epochs_top_k_integration(tmpdir):
model = BoringModel()
mc = ModelCheckpoint(dirpath=tmpdir, monitor="epoch", save_top_k=-1, filename="{epoch}")
Expand Down

0 comments on commit dd6d797

Please sign in to comment.