jacinle.cli.argument#

A customized argument parser.

Classes

AsEnumAction

JacArgumentParser

A customized argument parser.

SetDeviceAction

Class AsEnumAction

class AsEnumAction[source]#

Bases: Action

__call__(parser, namespace, values, option_string=None)[source]#

Call self as a function.

__init__(option_strings, dest, type, nargs=None, const=None, default=None, choices=None, required=False, help=None, metavar=None)[source]#
__new__(**kwargs)#
format_usage()#

Class JacArgumentParser

class JacArgumentParser[source]#

Bases: ArgumentParser

A customized argument parser. The main difference is that JacArgumentParser supports additional types, including:

  • type='bool': a boolean value, internally converted to True (true, t, yes, y, 1) or False (no, n, false, f, 0).

  • type='checked_file': a file path, checked to be an existing file.

  • type='checked_dir': a directory path, checked to be an existing directory.

  • type='ensured_dir': a directory path, checked to be an existing directory, and created if not.

  • type='kv': a key-value pair, separated by = and ;. For example, --configs "data.int_or_float=int_value; data.string='string_value'".

  • action='set_device': set CUDA visible devices.

  • action='as_enum': convert the argument to an enum value.

__init__(*args, **kwargs)[source]#
__new__(**kwargs)#
add_argument(dest, ..., name=value, ...)#
add_argument(option_string, option_string, ..., name=value, ...) None
add_argument_group(*args, **kwargs)#
add_mutually_exclusive_group(**kwargs)#
add_subparsers(**kwargs)#
convert_arg_line_to_args(arg_line)#
error(message: string)#

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

exit(status=0, message=None)#
format_help()#
format_usage()#
get_default(dest)#
parse_args(args=None, namespace=None)#
parse_intermixed_args(args=None, namespace=None)#
parse_known_args(args=None, namespace=None)#
parse_known_intermixed_args(args=None, namespace=None)#
print_help(file=None)#
print_usage(file=None)#
register(registry_name, value, object)#
set_defaults(**kwargs)#

Class SetDeviceAction

class SetDeviceAction[source]#

Bases: Action

__call__(parser, namespace, values, option_string=None)[source]#

Call self as a function.

__init__(option_strings, dest, format='int', set_device=True, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]#
__new__(**kwargs)#
format_usage()#