def parse_args_to_config(argv: Sequence[str]) -> BenchmarkConfig:
"""Parse sequence of string arguments into a config.
Args:
argv: Sequence of string arguments.
Returns:
Configuration.
"""
parser = argparse.ArgumentParser(
description='Task Performance Suite.',
prog='python -m taps.run',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
subparsers = parser.add_subparsers(
title='Applications',
dest='name',
required=True,
help='application to execute',
)
apps = collections.OrderedDict(sorted(get_registered_apps().items()))
for name, config in apps.items():
subparser = subparsers.add_parser(
name,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
RunConfig.add_argument_group(subparser, argv=argv, required=True)
ExecutorChoicesConfig.add_argument_group(
subparser,
argv=argv,
required=True,
)
DataTransformerChoicesConfig.add_argument_group(
subparser,
argv=argv,
required=False,
)
FilterConfig.add_argument_group(
subparser,
argv=argv,
required=True,
)
config.add_argument_group(subparser, argv=argv, required=True)
args = parser.parse_args(argv)
options = vars(args)
app_name = options['name']
executor_config = get_executor_config(**options)
transformer_config = get_transformer_config(**options)
filter_config = FilterConfig(**options)
run_config = RunConfig(**options)
app_config = apps[app_name](**options)
return BenchmarkConfig(
name=app_name,
timestamp=datetime.now(),
executor_name=options['executor'],
app=app_config,
executor=executor_config,
transformer=transformer_config,
filter=filter_config,
run=run_config,
)