bilby.core.utils.cmd.set_up_command_line_arguments

bilby.core.utils.cmd.set_up_command_line_arguments()[source]

Sets up command line arguments that can be used to modify how scripts are run.

Returns:
command_line_args, command_line_parser: tuple

The command_line_args is a Namespace of the command line arguments while the command_line_parser can be given to a new argparse.ArgumentParser as a parent object from which to inherit.

Notes

The command line arguments are passed initially at runtime, but this parser does not have a –help option (i.e., the command line options are available for any script which includes import bilby, but no help command is available. This is done to avoid conflicts with child argparse routines (see the example below).

Examples

In the following example we demonstrate how to setup a custom command line for a project which uses bilby.

# Here we import bilby, which initialises and parses the default command-line args
>>> import bilby
# The command line arguments can then be accessed via
>>> bilby.core.utils.command_line_args
Namespace(clean=False, log_level=20, quite=False)
# Next, we import argparse and define a new argparse object
>>> import argparse
>>> parser = argparse.ArgumentParser(parents=[bilby.core.utils.command_line_parser])
>>> parser.add_argument('--argument', type=int, default=1)
>>> args = parser.parse_args()
Namespace(clean=False, log_level=20, quite=False, argument=1)

Placing these lines into a script, you’ll be able to pass in the usual bilby default arguments, in addition to –argument. To see a list of all options, call the script with –help.