Skip to content

Conversation

@huangyxi
Copy link

@huangyxi huangyxi commented Nov 6, 2025

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Nov 6, 2025
@huangyxi
Copy link
Author

huangyxi commented Nov 6, 2025

Previously, the progress bar was not properly initialized when running through the LightningCLI entry point.
This may have been caused by recent updates in dependencies such as jsonargparse or typeshed_client.

This change ensures that the RichProgressBar callback is correctly registered and displayed during training.

Minimal working example:

import torch
from torch import nn
from torch.utils.data import DataLoader, TensorDataset
import pytorch_lightning as pl
from pytorch_lightning.cli import LightningCLI
from pytorch_lightning.callbacks import RichProgressBar

# ==== Minimal Example Model and DataModule ====
INPUT_DIM = 10
OUTPUT_DIM = 1

class Model(pl.LightningModule):
	def __init__(self):
		super().__init__()
		self.layer = nn.Linear(INPUT_DIM, OUTPUT_DIM)

	def forward(self, x):
		return self.layer(x)

	def training_step(self, batch, _):
		x, y = batch
		loss = nn.functional.mse_loss(self(x), y)
		return loss

	def configure_optimizers(self):
		return torch.optim.SGD(self.parameters(), lr=0.1)

class Data(pl.LightningDataModule):
	def setup(self, stage=None):
		n_samples = 100
		x = torch.randn(n_samples, INPUT_DIM)
		y = torch.randn(n_samples, OUTPUT_DIM)
		self.ds = TensorDataset(x, y)

	def train_dataloader(self):
		return DataLoader(self.ds, batch_size=32)


# ==== CLI entrypoint ====
class CLI(LightningCLI):
	def add_arguments_to_parser(self, parser):
		parser.add_lightning_class_args(RichProgressBar, "rich_progress_bar")

def main():
	CLI(Model, Data)


if __name__ == "__main__":
	main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant