Shortcuts

Frequently asked questions for LightningCLI

What does CLI stand for?

CLI is short for command line interface. This means it is a tool intended to be run from a terminal, similar to commands like git.


What is a yaml config file?

A YAML is a standard for configuration files used to describe parameters for sections of a program. It is a common tool in engineering and has recently started to gain popularity in machine learning. An example of a YAML file is the following:

# file.yaml
car:
    max_speed:100
    max_passengers:2
plane:
    fuel_capacity: 50
class_3:
    option_1: 'x'
    option_2: 'y'

If you are unfamiliar with YAML, the short introduction at realpython.com#yaml-syntax might be a good starting point.


What is a subcommand?

A subcommand is what is the action the LightningCLI applies to the script:

python main.py [subcommand]

See the Potential subcommands with:

python main.py --help

which prints:

...

fit                 Runs the full optimization routine.
validate            Perform one evaluation epoch over the validation set.
test                Perform one evaluation epoch over the test set.
predict             Run inference on your data.
tune                Runs routines to tune hyperparameters before training.

use a subcommand as follows:

python main.py fit
python main.py test

What is the relation between LightningCLI and argparse?

LightningCLI makes use of jsonargparse which is an extension of argparse. Due to this, LightningCLI follows the same arguments style as many POSIX command line tools. Long options are prefixed with two dashes and its corresponding values are separated by space or an equal sign, as --option value or --option=value. Command line options are parsed from left to right, therefore if a setting appears multiple times, the value most to the right will override the previous ones.


What is the override order of LightningCLI?

The final configuration of CLIs implemented with LightningCLI can depend on default config files (if defined), environment variables (if enabled) and command line arguments. The override order between these is the following:

  1. Defaults defined in the source code.

  2. Existing default config files in the order defined in default_config_files, e.g. ~/.myapp.yaml.

  3. Entire config environment variable, e.g. PL_FIT__CONFIG.

  4. Individual argument environment variables, e.g. PL_FIT__SEED_EVERYTHING.

  5. Command line arguments in order left to right (might include config files).


How do I troubleshoot a CLI?

The standard behavior for CLIs, when they fail, is to terminate the process with a non-zero exit code and a short message to hint the user about the cause. This is problematic while developing the CLI since there is no information to track down the root of the problem. To troubleshoot set the environment variable JSONARGPARSE_DEBUG to any value before running the CLI:

export JSONARGPARSE_DEBUG=true
python main.py fit

Note

When asking about problems and reporting issues, please set the JSONARGPARSE_DEBUG and include the stack trace in your description. With this, users are more likely to help identify the cause without needing to create a reproducible script.


© Copyright Copyright (c) 2018-2022, Lightning AI et al... Revision f4fcad36.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
1.8.3post1
1.8.3.post0
1.8.3
1.8.2
1.8.1
1.8.0.post1
1.8.0
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.10
1.5.9
1.5.8
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.10
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.4.9
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.