[Features] Generate a json schema from LightningCLI #17564
Labels
3rd party
Related to a 3rd-party
feature
Is an improvement or enhancement
lightningcli
pl.cli.LightningCLI
Description & Motivation
Idea
As the
LightningArgumentParser
did a very good job solving the possible parameters (see the --help output) with name, description, default value and type, it could be good add a command to export a custom json schema for the --config.A json/yaml schema could be useful to:
This is particularly useful in a Lightning context because the LightningArgumentParser did solve the possible model, optimizer, lr_scheduler ... and eventually custom classes such as transform. Using the project wide available classes. Having to write classes references without validation could be a pain and intelligent suggestion is always welcome.
Implementation idea
The easiest way to export a json schema is to build a Pydantic Model of the config and to use the pydantic .schema_json method.
So one idea could be to transform the cli.parser._actions object to a Pydantic Model
Pitch
No response
Alternatives
No response
Additional context
Here is an example of an IDE integration of json/yaml schema in VSCode: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
We just need to specify
# yaml-language-server: $schema=<urlToTheSchema>
to enable schema completion and validation in the IDE.Validation could also be made as a
pre-commit
hookcc @Borda @carmocca @mauvilsa
The text was updated successfully, but these errors were encountered: