artiq_client: implement interactive arguments

This commit is contained in:
Sébastien Bourdeauducq 2024-02-28 11:51:30 +08:00
parent de29db0b35
commit 3e8a853e53

View File

@ -113,11 +113,20 @@ def get_argparser():
"del-dataset", help="delete a dataset") "del-dataset", help="delete a dataset")
parser_del_dataset.add_argument("name", help="name of the dataset") parser_del_dataset.add_argument("name", help="name of the dataset")
parser_supply_interactive = subparsers.add_parser(
"supply-interactive", help="supply interactive arguments")
parser_supply_interactive.add_argument(
"rid", metavar="RID", type=int, help="RID of target experiment")
parser_supply_interactive.add_argument(
"arguments", metavar="ARGUMENTS", nargs="*",
help="interactive arguments")
parser_show = subparsers.add_parser( parser_show = subparsers.add_parser(
"show", help="show schedule, log, devices or datasets") "show", help="show schedule, log, devices or datasets")
parser_show.add_argument( parser_show.add_argument(
"what", metavar="WHAT", "what", metavar="WHAT",
choices=["schedule", "log", "ccb", "devices", "datasets"], choices=["schedule", "log", "ccb", "devices", "datasets",
"interactive-args"],
help="select object to show: %(choices)s") help="select object to show: %(choices)s")
subparsers.add_parser( subparsers.add_parser(
@ -136,8 +145,7 @@ def get_argparser():
"ls", help="list a directory on the master") "ls", help="list a directory on the master")
parser_ls.add_argument("directory", default="", nargs="?") parser_ls.add_argument("directory", default="", nargs="?")
subparsers.add_parser( subparsers.add_parser("terminate", help="terminate the ARTIQ master")
"terminate", help="terminate the ARTIQ master")
common_args.verbosity_args(parser) common_args.verbosity_args(parser)
return parser return parser
@ -209,6 +217,11 @@ def _action_scan_devices(remote, args):
remote.scan() remote.scan()
def _action_supply_interactive(remote, args):
arguments = parse_arguments(args.arguments)
remote.supply(args.rid, arguments)
def _action_scan_repository(remote, args): def _action_scan_repository(remote, args):
if getattr(args, "async"): if getattr(args, "async"):
remote.scan_repository_async(args.revision) remote.scan_repository_async(args.revision)
@ -275,6 +288,15 @@ def _show_datasets(datasets):
print(table) print(table)
def _show_interactive_args(interactive_args):
clear_screen()
table = PrettyTable(["RID", "Key", "Type", "Group", "Tooltip"])
for rid, args in sorted(interactive_args.items(), key=itemgetter(0)):
for key, procdesc, group, tooltip in args:
table.add_row([rid, key, procdesc["ty"], group, tooltip])
print(table)
def _run_subscriber(host, port, subscriber): def _run_subscriber(host, port, subscriber):
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
@ -346,6 +368,8 @@ def main():
_show_dict(args, "devices", _show_devices) _show_dict(args, "devices", _show_devices)
elif args.what == "datasets": elif args.what == "datasets":
_show_dict(args, "datasets", _show_datasets) _show_dict(args, "datasets", _show_datasets)
elif args.what == "interactive-args":
_show_dict(args, "interactive_args", _show_interactive_args)
else: else:
raise ValueError raise ValueError
else: else:
@ -356,6 +380,7 @@ def main():
"set_dataset": "dataset_db", "set_dataset": "dataset_db",
"del_dataset": "dataset_db", "del_dataset": "dataset_db",
"scan_devices": "device_db", "scan_devices": "device_db",
"supply_interactive": "interactive_arg_db",
"scan_repository": "experiment_db", "scan_repository": "experiment_db",
"ls": "experiment_db", "ls": "experiment_db",
"terminate": "master_management", "terminate": "master_management",