diff --git a/CHANGELOG.md b/CHANGELOG.md index b08688417c565..b71d92fc585af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an issue to make the `step` argument in `WandbLogger.log_image` work ([#11716](https://github.com/PyTorchLightning/pytorch-lightning/pull/11716)) - Fixed `restore_optimizers` for mapping states ([#11757](https://github.com/PyTorchLightning/pytorch-lightning/pull/11757)) - With `DPStrategy`, the batch is not explictly moved to the device ([#11780](https://github.com/PyTorchLightning/pytorch-lightning/pull/11780)) - +- Fixed an issue to avoid val bar disappear after `trainer.validate()` ([#11700](https://github.com/PyTorchLightning/pytorch-lightning/pull/11700)) ## [1.5.9] - 2022-01-18 diff --git a/_notebooks b/_notebooks index 0c325829101d5..290fb466de1fc 160000 --- a/_notebooks +++ b/_notebooks @@ -1 +1 @@ -Subproject commit 0c325829101d5a6ebf32ed99bbf5b09badf04a59 +Subproject commit 290fb466de1fcc2ac6025f74b56906592911e856 diff --git a/pytorch_lightning/callbacks/progress/tqdm_progress.py b/pytorch_lightning/callbacks/progress/tqdm_progress.py index 11103e4b0595d..306e3edfe06bf 100644 --- a/pytorch_lightning/callbacks/progress/tqdm_progress.py +++ b/pytorch_lightning/callbacks/progress/tqdm_progress.py @@ -183,12 +183,12 @@ def init_predict_tqdm(self) -> Tqdm: def init_validation_tqdm(self) -> Tqdm: """Override this to customize the tqdm bar for validation.""" # The main progress bar doesn't exist in `trainer.validate()` - has_main_bar = self.main_progress_bar is not None + has_main_bar = self.trainer.state.fn != "validate" bar = Tqdm( desc="Validating", position=(2 * self.process_position + has_main_bar), disable=self.is_disabled, - leave=False, + leave=not has_main_bar, dynamic_ncols=True, file=sys.stdout, ) diff --git a/tests/callbacks/test_tqdm_progress_bar.py b/tests/callbacks/test_tqdm_progress_bar.py index b17c0f49e48ff..da5a9a06a1844 100644 --- a/tests/callbacks/test_tqdm_progress_bar.py +++ b/tests/callbacks/test_tqdm_progress_bar.py @@ -104,10 +104,12 @@ def test_tqdm_progress_bar_totals(tmpdir): m = bar.total_val_batches assert len(trainer.train_dataloader) == n assert bar.main_progress_bar.total == n + m + assert bar.main_progress_bar.leave # check val progress bar total assert sum(len(loader) for loader in trainer.val_dataloaders) == m assert bar.val_progress_bar.total == m + assert not bar.val_progress_bar.leave # main progress bar should have reached the end (train batches + val batches) assert bar.main_progress_bar.n == n + m @@ -126,6 +128,7 @@ def test_tqdm_progress_bar_totals(tmpdir): assert bar.val_progress_bar.total == m assert bar.val_progress_bar.n == m assert bar.val_batch_idx == m + assert bar.val_progress_bar.leave trainer.test(model) @@ -133,6 +136,7 @@ def test_tqdm_progress_bar_totals(tmpdir): k = bar.total_test_batches assert sum(len(loader) for loader in trainer.test_dataloaders) == k assert bar.test_progress_bar.total == k + assert bar.test_progress_bar.leave # test progress bar should have reached the end assert bar.test_progress_bar.n == k