From 5aa6e7d340108c8d109cd608468e8dc1fa33030d Mon Sep 17 00:00:00 2001 From: Dominic Kerr Date: Tue, 10 Jan 2023 14:17:52 +0000 Subject: [PATCH] Fix `ProgressBarCallback` under-reporting (#1260) * Updated tqdm progress bar constructor to account for the effects of train_freq/n_steps/num_envs on total_timesteps. Ensure progress bar is "flushed" on training end. * Added description of PR #1260. Fixed formatting typo * Partial revert Co-authored-by: dominicgkerr Co-authored-by: Antonin RAFFIN Co-authored-by: Antonin Raffin --- docs/misc/changelog.rst | 3 ++- stable_baselines3/common/callbacks.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index 5a13454..7374f90 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -53,6 +53,7 @@ New Features: Bug Fixes: ^^^^^^^^^^ +- Updated ``ProgressBarCallback`` to more accurately display the proportion of remaining timesteps (@dominicgkerr) - Fixed return type of ``evaluate_actions`` in ``ActorCritcPolicy`` to reflect that entropy is an optional tensor (@Rocamonde) - Fixed type annotation of ``policy`` in ``BaseAlgorithm`` and ``OffPolicyAlgorithm`` - Allowed model trained with Python 3.7 to be loaded with Python 3.8+ without the ``custom_objects`` workaround @@ -180,7 +181,7 @@ Others: ^^^^^^^ - Fixed ``DictReplayBuffer.next_observations`` typing (@qgallouedec) - Added support for ``device="auto"`` in buffers and made it default (@qgallouedec) -- Updated ``ResultsWriter` (used internally by ``Monitor`` wrapper) to automatically create missing directories when ``filename`` is a path (@dominicgkerr) +- Updated ``ResultsWriter`` (used internally by ``Monitor`` wrapper) to automatically create missing directories when ``filename`` is a path (@dominicgkerr) Documentation: ^^^^^^^^^^^^^^ diff --git a/stable_baselines3/common/callbacks.py b/stable_baselines3/common/callbacks.py index 7f81a98..0ecd1ad 100644 --- a/stable_baselines3/common/callbacks.py +++ b/stable_baselines3/common/callbacks.py @@ -685,5 +685,6 @@ class ProgressBarCallback(BaseCallback): return True def _on_training_end(self) -> None: - # Close progress bar + # Flush and close progress bar + self.pbar.refresh() self.pbar.close()