otx.cli.utils.parser#

Utils for parsing command line arguments.

Functions

add_hyper_parameters_sub_parser(parser, config)

Adds hyper parameters sub parser.

gen_param_help(hyper_parameters)

Generates help for hyper parameters section.

gen_params_dict_from_args(args[, ...])

Generates hyper parameters dict from parsed command line arguments.

get_override_param(params)

Get override param list from params.

get_parser_and_hprams_data()

A function to distinguish between when there is template input and when there is no template input.

str2bool(val)

If input type is string, convert it to boolean.

Classes

MemSizeAction(option_strings, dest[, nargs])

Parser add on to parse memory size string.

ShortDefaultsHelpFormatter(prog[, ...])

Text Help Formatter that shortens.

class otx.cli.utils.parser.MemSizeAction(option_strings, dest, nargs=None, **kwargs)[source]#

Bases: Action

Parser add on to parse memory size string.

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

Parse and set the attribute of namespace.

class otx.cli.utils.parser.ShortDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]#

Bases: RawTextHelpFormatter

Text Help Formatter that shortens.

otx.cli.utils.parser.add_hyper_parameters_sub_parser(parser, config, modes=None, return_sub_parser=False) ArgumentParser | None[source]#

Adds hyper parameters sub parser.

otx.cli.utils.parser.gen_param_help(hyper_parameters: Dict) Dict[source]#

Generates help for hyper parameters section.

otx.cli.utils.parser.gen_params_dict_from_args(args, override_param: List | None = None, type_hint: dict | None = None) Dict[str, dict][source]#

Generates hyper parameters dict from parsed command line arguments.

otx.cli.utils.parser.get_override_param(params)[source]#

Get override param list from params.

otx.cli.utils.parser.get_parser_and_hprams_data()[source]#

A function to distinguish between when there is template input and when there is no template input.

Inspect the template using pre_parser to get the template’s hyper_parameters information. Finally, it returns the parser used in the actual main.

otx.cli.utils.parser.str2bool(val: str | bool) bool[source]#

If input type is string, convert it to boolean.

Parameters:

val (Union[str, bool]) – value to convert to boolean.

Raises:

argparse.ArgumentTypeError – If type is neither string and boolean, raise an error.

Returns:

return converted boolean value.

Return type:

bool