mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
interactive args: add title param
This commit is contained in:
parent
609684664a
commit
c4323e1179
@ -290,10 +290,11 @@ def _show_datasets(datasets):
|
|||||||
|
|
||||||
def _show_interactive_args(interactive_args):
|
def _show_interactive_args(interactive_args):
|
||||||
clear_screen()
|
clear_screen()
|
||||||
table = PrettyTable(["RID", "Key", "Type", "Group", "Tooltip"])
|
table = PrettyTable(["RID", "Title", "Key", "Type", "Group", "Tooltip"])
|
||||||
for rid, args in sorted(interactive_args.items(), key=itemgetter(0)):
|
for rid, input_request in sorted(interactive_args.items(), key=itemgetter(0)):
|
||||||
for key, procdesc, group, tooltip in args:
|
title = input_request["title"]
|
||||||
table.add_row([rid, key, procdesc["ty"], group, tooltip])
|
for key, procdesc, group, tooltip in input_request["arglist_desc"]:
|
||||||
|
table.add_row([rid, title, key, procdesc["ty"], group, tooltip])
|
||||||
print(table)
|
print(table)
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +167,8 @@ def get_argparser(with_file=True):
|
|||||||
|
|
||||||
|
|
||||||
class ArgumentManager(ProcessArgumentManager):
|
class ArgumentManager(ProcessArgumentManager):
|
||||||
def get_interactive(self, interactive_arglist):
|
def get_interactive(self, interactive_arglist, title):
|
||||||
|
print(title)
|
||||||
result = dict()
|
result = dict()
|
||||||
for key, processor, group, tooltip in interactive_arglist:
|
for key, processor, group, tooltip in interactive_arglist:
|
||||||
success = False
|
success = False
|
||||||
|
@ -214,7 +214,7 @@ class TraceArgumentManager:
|
|||||||
self.requested_args[key] = processor, group, tooltip
|
self.requested_args[key] = processor, group, tooltip
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_interactive(self, interactive_arglist):
|
def get_interactive(self, interactive_arglist, title):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ class ProcessArgumentManager:
|
|||||||
raise AttributeError("Supplied argument(s) not queried in experiment: " +
|
raise AttributeError("Supplied argument(s) not queried in experiment: " +
|
||||||
", ".join(unprocessed))
|
", ".join(unprocessed))
|
||||||
|
|
||||||
def get_interactive(self, interactive_arglist):
|
def get_interactive(self, interactive_arglist, title):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class HasEnvironment:
|
|||||||
self.kernel_invariants = kernel_invariants | {key}
|
self.kernel_invariants = kernel_invariants | {key}
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def interactive(self):
|
def interactive(self, title=""):
|
||||||
"""Request arguments from the user interactively.
|
"""Request arguments from the user interactively.
|
||||||
|
|
||||||
This context manager returns a namespace object on which the method
|
This context manager returns a namespace object on which the method
|
||||||
@ -349,7 +349,7 @@ class HasEnvironment:
|
|||||||
namespace.setattr_argument = setattr_argument
|
namespace.setattr_argument = setattr_argument
|
||||||
yield namespace
|
yield namespace
|
||||||
del namespace.setattr_argument
|
del namespace.setattr_argument
|
||||||
argdict = self.__argument_mgr.get_interactive(interactive_arglist)
|
argdict = self.__argument_mgr.get_interactive(interactive_arglist, title)
|
||||||
for key, value in argdict.items():
|
for key, value in argdict.items():
|
||||||
setattr(namespace, key, value)
|
setattr(namespace, key, value)
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ class InteractiveArgDB:
|
|||||||
self.pending = Notifier(dict())
|
self.pending = Notifier(dict())
|
||||||
self.futures = dict()
|
self.futures = dict()
|
||||||
|
|
||||||
async def get(self, rid, arglist_desc):
|
async def get(self, rid, arglist_desc, title):
|
||||||
self.pending[rid] = arglist_desc
|
self.pending[rid] = {"title": title, "arglist_desc": arglist_desc}
|
||||||
self.futures[rid] = asyncio.get_running_loop().create_future()
|
self.futures[rid] = asyncio.get_running_loop().create_future()
|
||||||
try:
|
try:
|
||||||
value = await self.futures[rid]
|
value = await self.futures[rid]
|
||||||
@ -136,7 +136,7 @@ class InteractiveArgDB:
|
|||||||
if rid not in self.futures:
|
if rid not in self.futures:
|
||||||
raise ValueError("no experiment with this RID is "
|
raise ValueError("no experiment with this RID is "
|
||||||
"waiting for interactive arguments")
|
"waiting for interactive arguments")
|
||||||
if {i[0] for i in self.pending.raw_view[rid]} != set(values.keys()):
|
if {i[0] for i in self.pending.raw_view[rid]["arglist_desc"]} != set(values.keys()):
|
||||||
raise ValueError("supplied and requested keys do not match")
|
raise ValueError("supplied and requested keys do not match")
|
||||||
self.futures[rid].set_result(values)
|
self.futures[rid].set_result(values)
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ def examine(device_mgr, dataset_mgr, file):
|
|||||||
class ArgumentManager(ProcessArgumentManager):
|
class ArgumentManager(ProcessArgumentManager):
|
||||||
_get_interactive = make_parent_action("get_interactive_arguments")
|
_get_interactive = make_parent_action("get_interactive_arguments")
|
||||||
|
|
||||||
def get_interactive(self, interactive_arglist):
|
def get_interactive(self, interactive_arglist, title):
|
||||||
arglist_desc = [(k, p.describe(), g, t)
|
arglist_desc = [(k, p.describe(), g, t)
|
||||||
for k, p, g, t in interactive_arglist]
|
for k, p, g, t in interactive_arglist]
|
||||||
arguments = ArgumentManager._get_interactive(arglist_desc)
|
arguments = ArgumentManager._get_interactive(arglist_desc, title)
|
||||||
for key, processor, _, _ in interactive_arglist:
|
for key, processor, _, _ in interactive_arglist:
|
||||||
arguments[key] = processor.process(arguments[key])
|
arguments[key] = processor.process(arguments[key])
|
||||||
return arguments
|
return arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user