Skip to content

Commit

Permalink
Add missing features in resource settings tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Nov 28, 2024
1 parent 92b8299 commit 888d042
Show file tree
Hide file tree
Showing 18 changed files with 471 additions and 469 deletions.
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, model: ConfigurationStepModel, **kwargs):
lambda structure: ""
if structure
else """
<div class="alert alert-info">
<div class="alert alert-danger">
<b>Please set the input structure first.</b>
</div>
""",
Expand Down
66 changes: 31 additions & 35 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def __init__(self, model: SubmissionStepModel, qe_auto_setup=True, **kwargs):
self._on_submission,
"confirmed",
)
self._model.observe(
self._on_input_structure_change,
"input_structure",
)
self._model.observe(
self._on_input_parameters_change,
"input_parameters",
Expand Down Expand Up @@ -77,22 +73,28 @@ def __init__(self, model: SubmissionStepModel, qe_auto_setup=True, **kwargs):

self.rendered = False

global_code_model = GlobalResourceSettingsModel()
self.global_code_settings = GlobalResourceSettingsPanel(model=global_code_model)
self._model.add_model("global", global_code_model)
global_code_model.observe(
global_resources_model = GlobalResourceSettingsModel()
self.global_resources = GlobalResourceSettingsPanel(
model=global_resources_model
)
self._model.add_model("global", global_resources_model)
ipw.dlink(
(self._model, "plugin_overrides"),
(global_resources_model, "plugin_overrides"),
)
global_resources_model.observe(
self._on_plugin_submission_blockers_change,
["submission_blockers"],
)
global_code_model.observe(
global_resources_model.observe(
self._on_plugin_submission_warning_messages_change,
["submission_warning_messages"],
)

self.settings = {
"global": self.global_code_settings,
"global": self.global_resources,
}
self._fetch_plugin_settings()
self._fetch_plugin_resource_settings()

self._install_sssp(qe_auto_setup)
self._set_up_qe(qe_auto_setup)
Expand Down Expand Up @@ -211,14 +213,15 @@ def _on_tab_change(self, change):
tab: ResourceSettingsPanel = self.tabs.children[tab_index] # type: ignore
tab.render()

def _on_input_structure_change(self, _):
""""""

def _on_input_parameters_change(self, _):
self._model.update_active_models()
self._update_tabs()
self._model.update_process_label()
self._model.update_plugin_inclusion()
self._model.update_plugin_overrides()
self._model.update_submission_blockers()
self._update_tabs()

def _on_plugin_overrides_change(self, _):
self._model.update_plugin_overrides()

def _on_plugin_submission_blockers_change(self, _):
self._model.update_submission_blockers()
Expand All @@ -237,16 +240,13 @@ def _on_submission_blockers_change(self, _):
self._model.update_submission_blocker_message()
self._update_state()

def _on_submission_warning_change(self, _):
self._model.update_submission_warning_message()

def _on_installation_change(self, _):
self._model.update_submission_blockers()

def _on_qe_installed(self, _):
self._toggle_qe_installation_widget()
if self._model.qe_installed:
self._model.refresh_codes()
self._model.update()

def _on_sssp_installed(self, _):
self._toggle_sssp_installation_widget()
Expand Down Expand Up @@ -325,14 +325,19 @@ def _update_state(self, _=None):
else:
self.state = self.state.CONFIGURED

def _fetch_plugin_settings(self):
eps = get_entry_items("aiidalab_qe.properties", "code")
for identifier, data in eps.items():
def _fetch_plugin_resource_settings(self):
entries = get_entry_items("aiidalab_qe.properties", "resources")
for identifier, resources in entries.items():
for key in ("panel", "model"):
if key not in data:
if key not in resources:
raise ValueError(f"Entry {identifier} is missing the '{key}' key")
panel = data["panel"]
model: ResourceSettingsModel = data["model"]()

panel = resources["panel"]
model: ResourceSettingsModel = resources["model"]()
model.observe(
self._on_plugin_overrides_change,
"override",
)
model.observe(
self._on_plugin_submission_blockers_change,
["submission_blockers"],
Expand All @@ -343,15 +348,6 @@ def _fetch_plugin_settings(self):
)
self._model.add_model(identifier, model)

def toggle_plugin(_, model=model):
model.update()
self._update_tabs()

model.observe(
toggle_plugin,
"include",
)

self.settings[identifier] = panel(
identifier=identifier,
model=model,
Expand Down
Loading

0 comments on commit 888d042

Please sign in to comment.