lightning_template.utils.progress.rich_progress#

Classes#

RichProgressBar

Create a progress bar with rich text formatting.

Module Contents#

class lightning_template.utils.progress.rich_progress.RichProgressBar(show_version: bool | None = False, show_eta_time: bool | None = False, *args: Any, **kwargs: Any)#

Bases: lightning.pytorch.callbacks.progress.rich_progress.RichProgressBar

Create a progress bar with rich text formatting.

Install it with pip:

pip install rich
from lightning.pytorch import Trainer
from lightning.pytorch.callbacks import RichProgressBar

trainer = Trainer(callbacks=RichProgressBar())
Parameters:
  • refresh_rate – Determines at which rate (in number of batches) the progress bars get updated. Set it to 0 to disable the display.

  • leave – Leaves the finished progress bar in the terminal at the end of the epoch. Default: False

  • theme – Contains styles used to stylize the progress bar.

  • console_kwargs – Args for constructing a Console

Raises:

ModuleNotFoundError – If required rich package is not installed on the device.

Note

PyCharm users will need to enable “emulate terminal” in output console option in run/debug configuration to see styled output. Reference: https://rich.readthedocs.io/en/latest/introduction.html#requirements

show_version = False#
show_eta_time = False#
on_train_start(trainer, pl_module)#

Called when the train begins.

get_metrics(trainer: lightning.pytorch.Trainer, pl_module: lightning.pytorch.LightningModule) Dict[str, int | str]#

Combines progress bar metrics collected from the trainer with standard metrics from get_standard_metrics. Implement this to override the items displayed in the progress bar.

Here is an example of how to override the defaults:

def get_metrics(self, trainer, model):
    # don't show the version number
    items = super().get_metrics(trainer, model)
    items.pop("v_num", None)
    return items
Returns:

Dictionary with the items to be displayed in the progress bar.