---
title: ProgressBar
description: |-
  The base class for progress bars in Lightning. It is a Callback that keeps
  track of the batch progress in the Trainer. You should implement your
  highly custom progress bars with this as the base class
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.callbacks.ProgressBar
---
# ProgressBar {#progressbar}

### `class lightning.pytorch.callbacks.ProgressBar` {#lightning.pytorch.callbacks.ProgressBar}

Bases: [`Callback`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.callbacks.Callback.md#lightning.pytorch.callbacks.Callback "lightning.pytorch.callbacks.callback.Callback")

The base class for progress bars in Lightning. It is a [`Callback`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.callbacks.Callback.md#lightning.pytorch.callbacks.Callback "lightning.pytorch.callbacks.Callback") that keeps track of the batch progress in the [`Trainer`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.trainer.trainer.Trainer.md#lightning.pytorch.trainer.trainer.Trainer "lightning.pytorch.trainer.trainer.Trainer"). You should implement your highly custom progress bars with this as the base class.

Example:

```python
class LitProgressBar(ProgressBar):

    def __init__(self):
        super().__init__()  # don't forget this :)
        self.enable = True

    def disable(self):
        self.enable = False

    def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx):
        super().on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)  # don't forget this :)
        percent = (batch_idx / self.total_train_batches) * 100
        sys.stdout.flush()
        sys.stdout.write(f'{percent:.01f} percent complete \r')

bar = LitProgressBar()
trainer = Trainer(callbacks=[bar])
```

#### `disable()` {#lightning.pytorch.callbacks.ProgressBar.disable}

You should provide a way to disable the progress bar.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `enable()` {#lightning.pytorch.callbacks.ProgressBar.enable}

You should provide a way to enable the progress bar.

The [`Trainer`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.trainer.trainer.Trainer.md#lightning.pytorch.trainer.trainer.Trainer "lightning.pytorch.trainer.trainer.Trainer") will call this in e.g. pre-training routines like the [learning rate finder](/docs/pytorch/2.6.6/reference/advanced/training_tricks.md#learning-rate-finder). to temporarily enable and disable the training progress bar.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `get_metrics(trainer, pl_module)` {#lightning.pytorch.callbacks.ProgressBar.get_metrics}

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:

```python
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
```

Return type:

[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), `Union`\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)"), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]\]\]

Returns:

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

#### `print(*args, **kwargs)` {#lightning.pytorch.callbacks.ProgressBar.print}

You should provide a way to print without breaking the progress bar.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `setup(trainer, pl_module, stage)` {#lightning.pytorch.callbacks.ProgressBar.setup}

Called when fit, validate, test, predict, or tune begins.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `property total_predict_batches_current_dataloader: Union[int, float]` {#lightning.pytorch.callbacks.ProgressBar.total_predict_batches_current_dataloader}

The total number of prediction batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return `inf` if the predict dataloader is of infinite size.

#### `property total_test_batches_current_dataloader: Union[int, float]` {#lightning.pytorch.callbacks.ProgressBar.total_test_batches_current_dataloader}

The total number of testing batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return `inf` if the test dataloader is of infinite size.

#### `property total_train_batches: Union[int, float]` {#lightning.pytorch.callbacks.ProgressBar.total_train_batches}

The total number of training batches, which may change from epoch to epoch.

Use this to set the total number of iterations in the progress bar. Can return `inf` if the training dataloader is of infinite size.

#### `property total_val_batches: Union[int, float]` {#lightning.pytorch.callbacks.ProgressBar.total_val_batches}

The total number of validation batches, which may change from epoch to epoch for all val dataloaders.

Use this to set the total number of iterations in the progress bar. Can return `inf` if the predict dataloader is of infinite size.

#### `property total_val_batches_current_dataloader: Union[int, float]` {#lightning.pytorch.callbacks.ProgressBar.total_val_batches_current_dataloader}

The total number of validation batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return `inf` if the validation dataloader is of infinite size.

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
