def configure_history_parser(subparsers: argparse._SubParsersAction) -> None:
"""Add a history parser to an existing argparser.
Args:
subparsers: The parser object to be appended to.
"""
parser = subparsers.add_parser('history',
description='View prior FE training histories',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
allow_abbrev=False)
parser.add_argument('--limit', metavar='L', type=int, help="How many entries to return", default=15)
parser.add_argument('--interactive',
dest='interactive',
help="Whether to run an interactive session which lets you look up detailed information",
action='store_true',
default=False)
parser.add_argument('--args',
dest='include_args',
help="Whether to return a list of the args used to invoke the training",
action='store_true',
default=False)
parser.add_argument('--errors',
dest='errors',
help="Whether to focus on failed trainings and include extra error information",
action='store_true',
default=False)
parser.add_argument('--features',
dest='include_features',
help="Whether to return a list of the FE features used during each training",
action='store_true',
default=False)
parser.add_argument('--datasets',
dest='include_datasets',
help="Whether to return a list of the datasets used during each training",
action='store_true',
default=False)
parser.add_argument('--pipeline',
dest='include_pipeline',
help="Whether to return a list of the pipeline ops used during each training",
action='store_true',
default=False)
parser.add_argument('--network',
dest='include_network',
help="Whether to return a list of the network ops used during each training",
action='store_true',
default=False)
parser.add_argument('--traces',
dest='include_traces',
help="Whether to return a list of the traces used during each training",
action='store_true',
default=False)
parser.add_argument('--pks',
dest='include_pk',
help="Whether to return the database primary keys of each entry",
action='store_true',
default=False)
parser.add_argument('--csv',
dest='csv',
help='Print the response as a csv rather than a formatted table',
action='store_true',
default=False)
sp = parser.add_subparsers()
sql_parser = sp.add_parser('sql',
description='Perform a raw SQL query against the history database',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
allow_abbrev=False)
sql_parser.add_argument('query',
metavar='<Query>',
type=str,
help="ex: fastestimator history sql 'SELECT * FROM history'")
sql_parser.add_argument('--interactive',
dest='interactive',
help="Whether to run an interactive session which lets you look up detailed information",
action='store_true',
default=False)
sql_parser.add_argument('--csv',
dest='csv',
help='Print the response as a csv rather than a formatted table',
action='store_true',
default=False)
sql_parser.set_defaults(func=history_sql)
clear_parser = sp.add_parser('clear',
description='Clear out old history entries to save space',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
allow_abbrev=False)
clear_parser.add_argument('retain',
metavar='N',
nargs='?',
type=int,
help="How many of the most recent entries to keep",
default=20)
clear_parser.set_defaults(func=clear_history)
settings_parser = sp.add_parser('settings',
description="Modify history settings, such as how many logs to retain",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
allow_abbrev=False)
settings_parser.add_argument('--keep',
metavar='K',
type=int,
help="How many of the most recent history entries to keep")
settings_parser.add_argument('--keep_logs',
metavar='L',
type=int,
help="How many of the most recent log entries to keep")
settings_parser.set_defaults(func=settings)
parser.set_defaults(func=history_basic)