Skip to content

Does LightningCLI support user-defined subcommands? #14314

Discussion options

You must be logged in to vote

To define new subcommands I would recommend the following. First you subclass Trainer and add methods for each of the subcommands you want. These new methods should be usable independent of the CLI. Then subclass LightningCLI, in the __init__ make your new trainer the default and to add the subcommands simply override/extend https://github.com/Lightning-AI/lightning/blob/7a617ec90e1566c763be8ac7a200af1e4025412c/src/pytorch_lightning/cli.py#L425-L434

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mauvilsa
Comment options

@cgoliver
Comment options

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