Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
e079f2f
By default enable rich progress bar if rich is available
Sep 22, 2021
c2374a1
Improvements for rich progress
Sep 22, 2021
276ea83
Add CHANGELOG.md
Sep 22, 2021
1a0d7d8
Merge branch 'master' into feat/enable_rich_default
Sep 22, 2021
254d361
Merge branch 'master' into feat/enable_rich_default
Sep 23, 2021
3205972
Update pytorch_lightning/trainer/connectors/callback_connector.py
Sep 23, 2021
20dc085
Improvements for rich progress
Sep 23, 2021
00ee0d2
Merge remote-tracking branch 'origin/feat/enable_rich_default' into f…
Sep 23, 2021
96ce411
Update tests/callbacks/test_rich_progress_bar.py
Sep 23, 2021
50d56ae
Add check
Sep 23, 2021
ae8bf33
Improvements for rich progress
Sep 23, 2021
2082873
Handle DDP
Sep 23, 2021
6a81e26
Merge branch 'master' into feat/enable_rich_default
Sep 23, 2021
41786be
Update pytorch_lightning/trainer/connectors/callback_connector.py
Sep 23, 2021
cffc91d
Add comments
Sep 23, 2021
79f0c8f
Cleanups, fix test for example sizes
Sep 24, 2021
7735fc6
Add comment
Sep 24, 2021
b7403ae
Small logic fixes
Sep 24, 2021
57ee691
Fix name
Sep 24, 2021
9f0115c
Improvements for rich progress
Sep 27, 2021
90cbe1e
Fix tests
Sep 27, 2021
9210d41
Merge branch 'master' into feat/enable_rich_default
Sep 27, 2021
56b9000
Set variable correctly
Sep 27, 2021
41ade74
Cleanup terminate
Sep 27, 2021
df327db
Improvements for rich progress
Sep 27, 2021
e0b1365
Make sure to clean up process
Sep 27, 2021
24ea978
Improvements for rich progress
Sep 28, 2021
a29401f
Improvements for rich progress
Sep 28, 2021
9ce2795
Fixes
Sep 28, 2021
5ce97f2
Merge branch 'master' into feat/enable_rich_default
Sep 28, 2021
baad9ac
Merge branch 'master' into feat/enable_rich_default
Sep 29, 2021
377ae9c
Merge branch 'master' into feat/enable_rich_default
Sep 29, 2021
0a4c60a
Update message
Sep 29, 2021
24f1b3c
Merge branch 'master' into feat/enable_rich_default
Sep 29, 2021
e931689
Fix pulse bar
Sep 30, 2021
80725a2
Merge branch 'master' into feat/enable_rich_default
Sep 30, 2021
b8bfef8
Merge branch 'master' into feat/enable_rich_default
Oct 5, 2021
94b70c2
Attempt to fix tests
Oct 5, 2021
0377894
temp
Oct 5, 2021
129b7d4
Revert "temp"
Oct 5, 2021
adcd780
Remove enable
Oct 5, 2021
1b1ed94
delay console init
awaelchli Oct 5, 2021
5d8cb30
isenabled
Oct 5, 2021
fe68e78
Clear out from state
Oct 5, 2021
3d7827e
Fix var name
Oct 5, 2021
0c7559e
Turn off progress bar for everything
Oct 6, 2021
1c7a8af
Remove checks, enable rich object
Oct 6, 2021
ed41233
Revert "Remove checks, enable rich object"
Oct 6, 2021
c969f61
Remove console
Oct 6, 2021
008b9f0
Clear update
Oct 6, 2021
4be11db
Remove more
Oct 6, 2021
3207a7c
Attempt
Oct 6, 2021
184df4b
verify non-spawn support
awaelchli Oct 12, 2021
ece1f8d
Merge branch 'master' into feat/enable_rich_default
awaelchli Oct 12, 2021
1ca117f
Revert "Remove more"
Oct 12, 2021
f176fc6
Revert "Clear update"
Oct 12, 2021
13fbf4b
Revert "Remove console"
Oct 12, 2021
cc74594
Various reverts from debugging
Oct 12, 2021
ef41642
Remove bool
Oct 12, 2021
a6ecb5f
Address code review
Oct 13, 2021
71adf49
Drop metrics to see if code passes
Oct 13, 2021
740cee3
Merge branch 'master' into feat/enable_rich_default
Oct 18, 2021
da93fa0
re-introduce code
Oct 18, 2021
a737b5a
Drop case
Oct 20, 2021
3e6579f
Clean up code by keeping reference to progress bar in metrics column
Oct 20, 2021
46808e8
Update pytorch_lightning/trainer/connectors/callback_connector.py
Oct 20, 2021
b560615
Add prints
Oct 20, 2021
91245f5
skip test
kaushikb11 Oct 21, 2021
ebc0d17
Update tests/callbacks/test_rich_progress_bar.py
kaushikb11 Oct 22, 2021
dd10585
move to special tests
tchaton Oct 22, 2021
f4211d4
Attempt a new fix
Oct 25, 2021
432d68b
Merge branch 'master' into feat/enable_rich_default
Oct 25, 2021
761df3f
debug
Oct 25, 2021
72f3d06
Cleanup
Oct 25, 2021
ba16ff9
Cleanup
Oct 25, 2021
1c18df1
Update tests/models/test_grad_norm.py
Oct 25, 2021
785d54f
Remove
Oct 25, 2021
d5d0d02
Merge branch 'master' into feat/enable_rich_default
Oct 25, 2021
ec090c0
add note
Oct 25, 2021
f05ad1a
Apply suggestions from code review
Borda Oct 25, 2021
377424f
Include ddp spawn guard again
Oct 25, 2021
17fafc5
Merge branch 'master' into feat/enable_rich_default
awaelchli Oct 26, 2021
9eb1ed8
See if turning of auto refresh fixes test
Oct 27, 2021
463bde2
Drop check
Oct 27, 2021
8f10fa9
Merge branch 'master' into feat/enable_rich_default
Nov 1, 2021
21c6a83
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 1, 2021
75fff92
merge fixes
Nov 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Changed logging of `LightningModule` and `LightningDataModule` hyperparameters to raise an exception only if there are colliding keys with different values ([#9496](https://github.com/PyTorchLightning/pytorch-lightning/pull/9496))


- Enable RichProgressBar by default if Rich is available ([#9647](https://github.com/PyTorchLightning/pytorch-lightning/pull/9647))


### Deprecated

- Deprecated `LightningModule.summarize()` in favor of `pytorch_lightning.utilities.model_summary.summarize()`
Expand Down
23 changes: 18 additions & 5 deletions pytorch_lightning/trainer/connectors/callback_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
)
from pytorch_lightning.callbacks.rich_model_summary import RichModelSummary
from pytorch_lightning.callbacks.timer import Timer
from pytorch_lightning.utilities import ModelSummaryMode, rank_zero_info
from pytorch_lightning.utilities import _RICH_AVAILABLE, ModelSummaryMode, rank_zero_info
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.warnings import rank_zero_deprecation
from pytorch_lightning.utilities.warnings import rank_zero_deprecation, rank_zero_warn


class CallbackConnector:
Expand Down Expand Up @@ -130,8 +130,17 @@ def _configure_swa_callbacks(self):
self.trainer.callbacks = [StochasticWeightAveraging()] + self.trainer.callbacks

def configure_progress_bar(self, refresh_rate=None, process_position=0):
if os.getenv("COLAB_GPU") and refresh_rate is None:
# smaller refresh rate on colab causes crashes, choose a higher value
use_rich_progress_bar = _RICH_AVAILABLE
if use_rich_progress_bar and refresh_rate is not None:
rank_zero_warn(
"``RichProgressBar`` does not support setting the refresh rate via the Trainer. "
"If you'd like to change the refresh rate and continue using the ``RichProgressBar``, "
"please pass ``callbacks=RichProgressBar(refresh_rate=4)``. "
"Setting to the ``TQDMProgressBar``."
)
use_rich_progress_bar = False
if not use_rich_progress_bar and os.getenv("COLAB_GPU") and refresh_rate is None:
# smaller refresh rate on colab causes crashes for TQDM, choose a higher value
refresh_rate = 20
refresh_rate = 1 if refresh_rate is None else refresh_rate

Expand All @@ -144,7 +153,11 @@ def configure_progress_bar(self, refresh_rate=None, process_position=0):
if len(progress_bars) == 1:
progress_bar_callback = progress_bars[0]
elif refresh_rate > 0:
progress_bar_callback = ProgressBar(refresh_rate=refresh_rate, process_position=process_position)
progress_bar_callback = (
RichProgressBar()
if use_rich_progress_bar
else ProgressBar(refresh_rate=refresh_rate, process_position=process_position)
)
self.trainer.callbacks.append(progress_bar_callback)
else:
progress_bar_callback = None
Expand Down
9 changes: 7 additions & 2 deletions pytorch_lightning/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
from importlib.util import find_spec

import pkg_resources
import torch
from packaging.version import Version
from pkg_resources import DistributionNotFound
Expand Down Expand Up @@ -53,7 +54,11 @@ def _compare_version(package: str, op, version) -> bool:
except (ModuleNotFoundError, DistributionNotFound):
return False
try:
pkg_version = Version(pkg.__version__)
if hasattr(pkg, "__version__"):
pkg_version = Version(pkg.__version__)
else:
# try pkg_resources to infer version
pkg_version = Version(pkg_resources.get_distribution(pkg).version)
except TypeError:
# this is mock by sphinx, so it shall return True ro generate all summaries
return True
Expand Down Expand Up @@ -85,7 +90,7 @@ def _compare_version(package: str, op, version) -> bool:
_NEPTUNE_GREATER_EQUAL_0_9 = _NEPTUNE_AVAILABLE and _compare_version("neptune", operator.ge, "0.9.0")
_OMEGACONF_AVAILABLE = _module_available("omegaconf")
_POPTORCH_AVAILABLE = _module_available("poptorch")
_RICH_AVAILABLE = _module_available("rich")
_RICH_AVAILABLE = _module_available("rich") and _compare_version("rich", operator.ge, "10.2.2")
_TORCH_CPU_AMP_AVAILABLE = _compare_version(
"torch", operator.ge, "1.10.dev20210902"
) # todo: swap to 1.10.0 once released
Expand Down
21 changes: 20 additions & 1 deletion tests/callbacks/test_rich_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pytest

from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ProgressBarBase, RichProgressBar
from pytorch_lightning.callbacks import ProgressBar, ProgressBarBase, RichProgressBar
from pytorch_lightning.callbacks.progress.rich_progress import RichProgressBarTheme
from pytorch_lightning.utilities.imports import _RICH_AVAILABLE
from tests.helpers.boring_model import BoringModel
Expand All @@ -44,6 +44,25 @@ def test_rich_progress_bar_refresh_rate():
assert progress_bar.is_disabled


@RunIf(rich=True)
def test_rich_progress_bar_refresh_rate_colab(tmpdir):
"""Test that the refresh rate is set correctly based on the Trainer, and warn if the user sets the argument."""
trainer = Trainer(default_root_dir=tmpdir)
assert trainer.progress_bar_callback.refresh_rate_per_second == 10
assert isinstance(trainer.progress_bar_callback, RichProgressBar)

trainer = Trainer(default_root_dir=tmpdir, progress_bar_refresh_rate=None)
assert isinstance(trainer.progress_bar_callback, RichProgressBar)
assert trainer.progress_bar_callback.refresh_rate_per_second == 10

with pytest.warns(
UserWarning, match="``RichProgressBar`` does not support setting the refresh rate via the Trainer. "
):
trainer = Trainer(default_root_dir=tmpdir, progress_bar_refresh_rate=19)
assert isinstance(trainer.progress_bar_callback, ProgressBar)
assert trainer.progress_bar_callback.refresh_rate == 19


@RunIf(rich=True)
@mock.patch("pytorch_lightning.callbacks.progress.rich_progress.Progress.update")
def test_rich_progress_bar(progress_update, tmpdir):
Expand Down