Skip to content

Commit

Permalink
Fix issue with misfiring code widget observation
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Dec 8, 2024
1 parent d1814c2 commit 0c7c80a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/aiidalab_qe/common/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def _toggle_code(self, code_model: CodeModel):
code_widget = self.code_widgets[code_model.name]
if not code_model.is_rendered:
self._render_code_widget(code_model, code_widget)
code_widget.observe(
code_widget.update_resources,
"value",
)

def _render_code_widget(
self,
Expand All @@ -299,7 +303,7 @@ def _render_code_widget(
)
ipw.link(
(code_model, "selected"),
(code_widget.code_selection.code_select_dropdown, "value"),
(code_widget, "value"),
)
ipw.link(
(code_model, "num_cpus"),
Expand Down
3 changes: 1 addition & 2 deletions src/aiidalab_qe/common/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@ def __init__(self, **kwargs):
)
traitlets.link((self.code_selection, "value"), (self, "value"))

@traitlets.observe("value")
def _update_resources(self, change):
def update_resources(self, change):
if change["new"]:
self.set_resource_defaults(load_code(change["new"]).computer)

Expand Down

0 comments on commit 0c7c80a

Please sign in to comment.