Does LightningCLI support user-defined subcommands? #14314
-
|
I would like to define some new subcommands along with the default ones and be able to attach some function calls to it. The documentation does not seem to show this use case so I'm wondering if this is possible. For example, to visualize the output of some model. Or would it be best to just customize the behaviour of some existing subcommands as described here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
To define new subcommands I would recommend the following. First you subclass |
Beta Was this translation helpful? Give feedback.
To define new subcommands I would recommend the following. First you subclass
Trainerand add methods for each of the subcommands you want. These new methods should be usable independent of the CLI. Then subclassLightningCLI, 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