From d5e1b9c4dad664863d41bbe5e20b528179537d25 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Sat, 21 Dec 2024 11:27:49 +0000 Subject: [PATCH] Update app w.r.t new external code setup notebook --- src/aiidalab_qe/app/submission/__init__.py | 41 +++++++++++-------- .../app/submission/global_settings/setting.py | 8 ---- src/aiidalab_qe/app/wrapper.py | 10 ++++- src/aiidalab_qe/common/panel.py | 13 ++---- src/aiidalab_qe/common/widgets.py | 6 ++- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/aiidalab_qe/app/submission/__init__.py b/src/aiidalab_qe/app/submission/__init__.py index 23feab243..5026fc5f0 100644 --- a/src/aiidalab_qe/app/submission/__init__.py +++ b/src/aiidalab_qe/app/submission/__init__.py @@ -154,6 +154,14 @@ def render(self): (self.submission_warning_messages, "value"), ) + self.refresh_resources_button = ipw.Button( + description="Refresh resources", + icon="refresh", + button_style="primary", + layout=ipw.Layout(width="fit-content", margin="2px 2px 12px"), + ) + self.refresh_resources_button.on_click(self._refresh_resources) + self.tabs = ipw.Tab( layout=ipw.Layout(min_height="250px"), selected_index=None, @@ -165,33 +173,30 @@ def render(self): self.children = [ InAppGuide(identifier="submission-step"), - ipw.HTML(""" -
-

Codes

-
- """), ipw.HTML("""
- Select the code to use for running the calculations. The codes on + Select the codes to use for running the calculations. The codes on the local machine (localhost) are installed by default, but you can - configure new ones on potentially more powerful machines by clicking - on "Setup new code". + configure new ones on potentially more powerful machines by visiting + the resource + setup page (see also + button at the top of the app). Make sure to click the Refresh + resources button below after making changes to AiiDA resources + to update the app resources.
"""), + self.refresh_resources_button, self.tabs, self.sssp_installation, self.qe_setup, self.submission_blocker_messages, self.submission_warning_messages, ipw.HTML(""" -
-

Labeling Your Job

-

- Label your job and provide a brief description. These details - help identify the job later and make the search process easier. - While optional, adding a description is recommended for better - clarity. -

+
+ Label your job and provide a brief description. These details + help identify the job later and make the search process easier. + While optional, adding a description is recommended for better + clarity.
"""), self.process_label, @@ -304,6 +309,10 @@ def _toggle_qe_installation_widget(self): qe_installation_display = "none" if self._model.qe_installed else "block" self.qe_setup.layout.display = qe_installation_display + def _refresh_resources(self, _=None): + for _, model in self._model.get_models(): + model.refresh_codes() + def _update_tabs(self): children = [] titles = [] diff --git a/src/aiidalab_qe/app/submission/global_settings/setting.py b/src/aiidalab_qe/app/submission/global_settings/setting.py index 7a1024374..a94d817e3 100644 --- a/src/aiidalab_qe/app/submission/global_settings/setting.py +++ b/src/aiidalab_qe/app/submission/global_settings/setting.py @@ -120,14 +120,6 @@ def _render_code_widget( ], ) - def update_options(_, model=code_model): - model.update(self._model.DEFAULT_USER_EMAIL, refresh=True) - - code_widget.code_selection.code_select_dropdown.observe( - update_options, - "options", - ) - def toggle_widget(_=None, model=code_model, widget=code_widget): widget = self.code_widgets[model.name] widget.layout.display = "block" if model.is_active else "none" diff --git a/src/aiidalab_qe/app/wrapper.py b/src/aiidalab_qe/app/wrapper.py index 18883a6e1..edc93fbc9 100644 --- a/src/aiidalab_qe/app/wrapper.py +++ b/src/aiidalab_qe/app/wrapper.py @@ -212,13 +212,21 @@ def __init__(self) -> None: disabled=True, ) + self.setup_resources_link = LinkButton( + description="Setup resources", + link="../home/code_setup.ipynb", + icon="database", + disabled=True, + ) + self.controls = ipw.HBox( children=[ self.guide_toggle, self.about_toggle, self.calculation_history_link, + self.setup_resources_link, self.new_workchain_link, - ] + ], ) self.controls.add_class("app-controls") diff --git a/src/aiidalab_qe/common/panel.py b/src/aiidalab_qe/common/panel.py index 6cba62a16..5f17e62e5 100644 --- a/src/aiidalab_qe/common/panel.py +++ b/src/aiidalab_qe/common/panel.py @@ -225,6 +225,10 @@ def add_model(self, identifier, model): super().add_model(identifier, model) model.update(self.DEFAULT_USER_EMAIL) + def refresh_codes(self): + for _, code_model in self.get_models(): + code_model.update(self.DEFAULT_USER_EMAIL, refresh=True) + def update_submission_blockers(self): self.submission_blockers = list(self._check_submission_blockers()) @@ -343,7 +347,6 @@ def _render_code_widget( code_model.observe( self._on_code_resource_change, [ - "options", "selected", "num_cpus", "num_nodes", @@ -382,9 +385,6 @@ def update(self): default_calc_job_plugin = code_model.default_calc_job_plugin if default_calc_job_plugin in self.global_codes: code_resources: dict = self.global_codes[default_calc_job_plugin] # type: ignore - options = code_resources.get("options", []) - if options != code_model.options: - code_model.update(self.DEFAULT_USER_EMAIL, refresh=True) code_model.set_model_state(code_resources) def get_model_state(self): @@ -491,11 +491,6 @@ def _link_override_to_widget_disable(self, code_model, code_widget): (code_widget.num_nodes, "disabled"), lambda override: not override, ) - ipw.dlink( - (code_model, "override"), - (code_widget.code_selection.btn_setup_new_code, "disabled"), - lambda override: not override, - ) ipw.dlink( (code_model, "override"), (code_widget.btn_setup_resource_detail, "disabled"), diff --git a/src/aiidalab_qe/common/widgets.py b/src/aiidalab_qe/common/widgets.py index 8f014a070..5d5d1c02f 100644 --- a/src/aiidalab_qe/common/widgets.py +++ b/src/aiidalab_qe/common/widgets.py @@ -669,7 +669,11 @@ def __init__(self, **kwargs): """Widget to setup the compute resources, which include the code, the number of nodes and the number of cpus. """ - self.code_selection = ComputationalResourcesWidget(**kwargs) + self.code_selection = ComputationalResourcesWidget( + include_setup_widget=False, + fetch_codes=True, # TODO resolve testing issues when set to `False` + **kwargs, + ) self.code_selection.layout.width = "80%" self.num_nodes = ipw.BoundedIntText(