Configs

The system config module.

lorien.configs.append_config_parser(full_name: str, desc: str)

Append configs to another config parser as a config group for parsing command line interface.

Parameters
  • full_name (str) -- The full command name to be appended. Use "." to represent the complete hierarchy of the config parser to be appended.

  • desc (str) -- The description of the config gruop.

Returns

reg -- A callable function for appending.

Return type

Callable

lorien.configs.create_config_parser(desc: str, **kwargs) argparse.ArgumentParser

Create an argument parser to parse the CLIs.

Parameters

desc (str) -- The descriptions to the paresr being created.

Returns

parser -- The created parser.

Return type

argparse.ArgumentParser

lorien.configs.make_config_parser(sys_args: List[str]) argparse.Namespace

Generate CLI from the registered configs.

Parameters

sys_args (List[str]) -- The list of system arguments (e.g., sys.argv).

Returns

configs -- The parsed CLI argument namespace.

Return type

argparse.Namespace

lorien.configs.read_args_from_files(astrs: List[str]) List[str]

Convert command line arguments to a list. If the argument starts with the defined "fromfile_prefix_chars" (@), then it indicates a config file in YAML format. This function will parse the config file and expand the content to argument list.

For example, a CLI is defined as follows. The model command can be specified multiple times to form a list of models.

exec --model alexnet --model resnet50_v2

This is equivalent to the following:

exec @models.yaml

where the config file models.yaml has:

model:
  - alexnet
  - resnet50_v2
Parameters

astrs (List[str]) -- The full list of command line arguments.

Returns

arg_list -- The expanded argument list.

Return type

List[str]

lorien.configs.register_config_parser(full_name: str)

Register config parser for parsing command line interface.

Parameters

full_name (str) -- The full command name. If the command should be register under another command, using "." to represent the complete hierarchy (e.g., gen-workload.modelzoo).

Returns

reg -- A callable function for registration.

Return type

Callable