Skip to content

Commit

Permalink
update with 6-1
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Jun 10, 2021
1 parent 0711eed commit 80eaec9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions pytorch_lightning/trainer/connectors/checkpoint_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def restore_callbacks(self) -> None:
if not self._loaded_checkpoint:
return

if any([key in self._loaded_checkpoint for key in DEPRECATED_CHECKPOINT_KEYS]):
if any(key in self._loaded_checkpoint for key in DEPRECATED_CHECKPOINT_KEYS):
raise ValueError(
"The checkpoint you're attempting to load follows an"
" outdated schema. You can upgrade to the current schema by running"
Expand All @@ -180,11 +180,10 @@ def restore_progress(self) -> None:

# crash if max_epochs is lower then the current epoch from the checkpoint
if self.trainer.max_epochs is not None and self.trainer.current_epoch > self.trainer.max_epochs:
m = f"""
you restored a checkpoint with current_epoch={self.trainer.current_epoch}
but the Trainer(max_epochs={self.trainer.max_epochs})
"""
raise MisconfigurationException(m)
raise MisconfigurationException(
f"You restored a checkpoint with current_epoch={self.trainer.current_epoch},"
f" but you have set Trainer(max_epochs={self.trainer.max_epochs})."
)

# Division deals with global step stepping once per accumulated batch
# Inequality deals with different global step for odd vs even num_training_batches
Expand Down
2 changes: 1 addition & 1 deletion tests/callbacks/test_early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_resume_early_stopping_from_checkpoint(tmpdir):
callbacks=[early_stop_callback],
)

with pytest.raises(MisconfigurationException, match=r'.*you restored a checkpoint with current_epoch*'):
with pytest.raises(MisconfigurationException, match=r"You restored a checkpoint with current_epoch"):
new_trainer.fit(model)


Expand Down

0 comments on commit 80eaec9

Please sign in to comment.