Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions artiq/dashboard/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,40 @@ def __init__(self, manager, dock, expurl):
self.setItemWidget(self.bottom_item, 1, buttons)

def reset_entry(self, key):
asyncio.ensure_future(self._recompute_argument(key))
asyncio.ensure_future(self._recompute_arguments([key]))

async def _update_defaults(self):
keys = self._arguments.keys()
await self._recompute_arguments(keys, False)
for key in keys:
widgets = self._arg_to_widgets.get(key, {})
entry = widgets.get("entry")
modified_value_icon = widgets.get("modified_value_icon")
if entry is not None and modified_value_icon is not None:
if entry.is_default():
modified_value_icon.setVisible_(False)
else:
modified_value_icon.setVisible_(True)

async def _recompute_argument(self, name):
async def _recompute_arguments(self, keys, update=True):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already exists a _recompute_arguments_task in this file hooked up to the Recompute all arguments button, and as such this is confusing. Instead of modifying this function, I would call compute_expdesc directly in _update_defaults and accept the code duplication that comes with it.

try:
expdesc, _ = await self.manager.compute_expdesc(self.expurl)
except:
logger.error("Could not recompute argument '%s' of '%s'",
name, self.expurl, exc_info=True)
except Exception:
logger.error("Could not recompute arguments for keys of '%s'",
self.expurl, exc_info=True)
return
argument = self.manager.get_submission_arguments(self.expurl)[name]

procdesc = expdesc["arginfo"][name][0]
state = procdesc_to_entry(procdesc).default_state(procdesc)
argument["desc"] = procdesc
argument["state"] = state
self.update_argument(name, argument)
for name in keys:
argument = self.manager.get_submission_arguments(self.expurl)[name]
try:
procdesc = expdesc["arginfo"][name][0]
except KeyError:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens when removing an argument from the file and then refreshing the repository HEAD, correct? I am not certain that emitting a warning is the proper way to handle this. The behavior on master simply emits an error if attempting to reset to default, which also does not seem correct. Removing the widget from the EntryArea seems better to me. Whether this should be done at repository refresh or when resetting the individual entry is debatable (I lean towards the latter).

logging.warning(f"Default value for {name} is missing")
continue
state = procdesc_to_entry(procdesc).default_state(procdesc)
argument["desc"] = procdesc
if update:
argument["state"] = state
self.update_argument(name, argument)
self.dock.apply_window_color()

def apply_color(self, color):
Expand Down Expand Up @@ -568,6 +586,10 @@ def __init__(self, main_window, dataset_sub,
quick_open_shortcut.setContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
quick_open_shortcut.activated.connect(self.show_quick_open)

def update_open_experiments_defaults(self):
for experiment in self.open_experiments.values():
experiment.argeditor.update_defaults()

def set_dataset_model(self, model):
self.datasets = model

Expand Down
8 changes: 7 additions & 1 deletion artiq/dashboard/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,13 @@ def __init__(self, exp_manager, d_shortcuts,
self.el)

def scan_repository():
asyncio.ensure_future(experiment_db_ctl.scan_repository_async())
future = asyncio.ensure_future(
experiment_db_ctl.scan_repository_async())

def on_complete(future):
self.exp_manager.update_open_experiments_defaults()
future.add_done_callback(on_complete)

scan_repository_action.triggered.connect(scan_repository)
self.el.addAction(scan_repository_action)

Expand Down
Loading