Add subcommands to LightningCLI #13687
-
I am not sure if this is possible and I am missing how to do this. But I couldn't figure out how to do it from the docs. How can I add my own subcommands by extending LightningCLI ? Say, my model code is part of an overall application I want to add a subcommand like Is this possible with the current API? Are there any plans for it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is possible. First you would subclass |
Beta Was this translation helpful? Give feedback.
It is possible. First you would subclass
Trainer
and add methods for each of the subcommands you want. These new methods should be usable independent of the CLI. Then you would need to subclassLightningCLI
, in the__init__
make your new trainer the default and override https://github.com/Lightning-AI/lightning/blob/d4c7f91fec6f4cd8edf5124a5cdfac08a07c4bde/src/pytorch_lightning/utilities/cli.py#L534-L543