Skip to content

Commit

Permalink
Abstract plugin resource panels
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Dec 9, 2024
1 parent 9c12a9e commit fca8140
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS
from aiidalab_qe.app.utils import get_entry_items
from aiidalab_qe.common.code import PluginCodes, PwCodeModel
from aiidalab_qe.common.panel import ResourceSettingsModel, ResourceSettingsPanel
from aiidalab_qe.common.panel import PluginResourceSettingsModel, ResourceSettingsPanel
from aiidalab_qe.common.setup_codes import QESetupWidget
from aiidalab_qe.common.setup_pseudos import PseudosInstallWidget
from aiidalab_widgets_base import WizardAppWidgetStep
Expand Down Expand Up @@ -337,7 +337,7 @@ def _fetch_plugin_resource_settings(self):
raise ValueError(f"Entry {identifier} is missing the '{key}' key")

panel = resources["panel"]
model: ResourceSettingsModel = resources["model"]()
model: PluginResourceSettingsModel = resources["model"]()
model.observe(
self._on_plugin_overrides_change,
"override",
Expand Down
2 changes: 0 additions & 2 deletions src/aiidalab_qe/app/submission/global_settings/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def __init__(self, *args, **kwargs):

self.plugin_mapping: dict[str, list[str]] = {}

self.override = True

def update_global_codes(self):
self.global_codes = self.get_model_state()["codes"]

Expand Down
5 changes: 2 additions & 3 deletions src/aiidalab_qe/app/submission/global_settings/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ def set_up_codes(self, codes: PluginCodes):
self._on_code_selection_change,
"selected",
)
self._model.update_global_codes()

def reset(self):
with self.hold_trait_notifications():
self._model.reset()
self._model.set_selected_codes()
self._model.set_selected_codes()

def _on_input_parameters_change(self, _):
self._model.update_active_codes()
Expand Down
6 changes: 4 additions & 2 deletions src/aiidalab_qe/app/submission/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS
from aiidalab_qe.common.mixins import Confirmable, HasInputStructure, HasModels
from aiidalab_qe.common.mvc import Model
from aiidalab_qe.common.panel import ResourceSettingsModel
from aiidalab_qe.common.panel import PluginResourceSettingsModel, ResourceSettingsModel
from aiidalab_qe.workflows import QeAppWorkChain

DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore
Expand Down Expand Up @@ -131,7 +131,9 @@ def update_plugin_overrides(self):
self.plugin_overrides = [
identifier
for identifier, model in self.get_models()
if identifier != "global" and model.include and model.override
if isinstance(model, PluginResourceSettingsModel)
and model.include
and model.override
]

def update_submission_blockers(self):
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/common/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_models(self) -> t.Iterable[tuple[str, T]]:
return self._models.items()

def _link_model(self, model: T):
raise NotImplementedError()
pass


class HasProcess(tl.HasTraits):
Expand Down
Loading

0 comments on commit fca8140

Please sign in to comment.