Skip to content

Commit a200428

Browse files
authored
Merge 97f77fc into e1f5eac
2 parents e1f5eac + 97f77fc commit a200428

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pytorch_lightning/trainer/training_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def check_checkpoint_callback(self, should_update, is_last=False):
154154
if should_update and self.trainer.checkpoint_connector.has_trained:
155155
callbacks = self.trainer.checkpoint_callbacks
156156

157-
if is_last and any(cb.save_last for cb in callbacks):
157+
if is_last and any(cb.save_last and cb.verbose for cb in callbacks):
158158
rank_zero_info("Saving latest checkpoint...")
159159

160160
model = self.trainer.lightning_module

tests/checkpointing/test_model_checkpoint.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,19 +672,24 @@ def test_default_checkpoint_behavior(tmpdir):
672672
@pytest.mark.parametrize('max_epochs', [1, 2])
673673
@pytest.mark.parametrize('should_validate', [True, False])
674674
@pytest.mark.parametrize('save_last', [True, False])
675-
def test_model_checkpoint_save_last_warning(tmpdir, caplog, max_epochs, should_validate, save_last):
675+
@pytest.mark.parametrize('verbose', [True, False])
676+
def test_model_checkpoint_save_last_warning(tmpdir, caplog, max_epochs, should_validate, save_last, verbose):
676677
"""Tests 'Saving latest checkpoint...' log"""
677678
model = LogInTwoMethods()
678679
if not should_validate:
679680
model.validation_step = None
680681
trainer = Trainer(
681682
default_root_dir=tmpdir,
682-
callbacks=[ModelCheckpoint(monitor='early_stop_on', dirpath=tmpdir, save_top_k=0, save_last=save_last)],
683+
callbacks=[
684+
ModelCheckpoint(
685+
monitor='early_stop_on', dirpath=tmpdir, save_top_k=0, save_last=save_last, verbose=verbose
686+
)
687+
],
683688
max_epochs=max_epochs,
684689
)
685690
with caplog.at_level(logging.INFO):
686691
trainer.fit(model)
687-
assert caplog.messages.count('Saving latest checkpoint...') == save_last
692+
assert caplog.messages.count('Saving latest checkpoint...') == (verbose and save_last)
688693

689694

690695
def test_model_checkpoint_save_last_checkpoint_contents(tmpdir):

0 commit comments

Comments
 (0)