From 92b829908e3df9f6497c5b81eb48daf3f8657ab5 Mon Sep 17 00:00:00 2001 From: Edan Bainglass <45081142+edan-bainglass@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:58:14 +0100 Subject: [PATCH] Add layer of abstraction in `Panel` classes (#945) This PR adds a layer of abstraction for settings panels though the new ConfigurationSettingsPanel and ResourceSettingsPanel classes and their respective Model classes. The rest of the codebase has been renamed for clarity. --- src/aiidalab_qe/app/configuration/__init__.py | 39 +++++++++------ .../app/configuration/advanced/__init__.py | 8 ++-- .../app/configuration/advanced/advanced.py | 48 ++++++++++++------- .../advanced/hubbard/__init__.py | 8 ++-- .../configuration/advanced/hubbard/hubbard.py | 12 +++-- .../configuration/advanced/hubbard/model.py | 7 ++- .../advanced/magnetization/__init__.py | 8 ++-- .../advanced/magnetization/magnetization.py | 12 +++-- .../advanced/magnetization/model.py | 7 ++- .../app/configuration/advanced/model.py | 44 +++++++++-------- .../advanced/pseudos/__init__.py | 8 ++-- .../configuration/advanced/pseudos/model.py | 7 ++- .../configuration/advanced/pseudos/pseudos.py | 12 +++-- .../advanced/smearing/__init__.py | 8 ++-- .../configuration/advanced/smearing/model.py | 4 +- .../advanced/smearing/smearing.py | 10 ++-- .../app/configuration/advanced/subsettings.py | 6 +-- .../app/configuration/basic/__init__.py | 8 ++-- .../app/configuration/basic/model.py | 4 +- .../app/configuration/basic/workflow.py | 10 ++-- src/aiidalab_qe/app/configuration/model.py | 6 +-- .../app/result/summary/__init__.py | 8 ++-- src/aiidalab_qe/app/result/summary/model.py | 2 +- src/aiidalab_qe/app/result/summary/summary.py | 4 +- src/aiidalab_qe/app/result/viewer/viewer.py | 8 ++-- src/aiidalab_qe/app/submission/__init__.py | 15 +++--- .../submission/global_settings/__init__.py | 8 ++-- .../app/submission/global_settings/model.py | 10 ++-- .../app/submission/global_settings/setting.py | 9 ++-- src/aiidalab_qe/app/submission/model.py | 10 ++-- src/aiidalab_qe/common/__init__.py | 4 +- src/aiidalab_qe/common/panel.py | 35 +++++++++++--- src/aiidalab_qe/plugins/bands/__init__.py | 28 +++++------ src/aiidalab_qe/plugins/bands/code.py | 6 +-- src/aiidalab_qe/plugins/bands/model.py | 4 +- .../plugins/bands/result/__init__.py | 4 +- .../plugins/bands/result/result.py | 2 +- src/aiidalab_qe/plugins/bands/setting.py | 8 ++-- .../plugins/electronic_structure/__init__.py | 4 +- .../electronic_structure/result/__init__.py | 4 +- .../electronic_structure/result/result.py | 2 +- src/aiidalab_qe/plugins/pdos/__init__.py | 28 +++++------ src/aiidalab_qe/plugins/pdos/code.py | 6 +-- src/aiidalab_qe/plugins/pdos/model.py | 4 +- .../plugins/pdos/result/__init__.py | 4 +- src/aiidalab_qe/plugins/pdos/result/result.py | 2 +- src/aiidalab_qe/plugins/pdos/setting.py | 10 ++-- src/aiidalab_qe/plugins/xas/__init__.py | 28 +++++------ src/aiidalab_qe/plugins/xas/code.py | 6 +-- src/aiidalab_qe/plugins/xas/model.py | 4 +- .../plugins/xas/result/__init__.py | 4 +- src/aiidalab_qe/plugins/xas/result/result.py | 2 +- src/aiidalab_qe/plugins/xas/setting.py | 12 +++-- src/aiidalab_qe/plugins/xps/__init__.py | 20 ++++---- src/aiidalab_qe/plugins/xps/model.py | 4 +- .../plugins/xps/result/__init__.py | 4 +- src/aiidalab_qe/plugins/xps/result/result.py | 2 +- src/aiidalab_qe/plugins/xps/setting.py | 12 +++-- src/aiidalab_qe/workflows/__init__.py | 1 - tests/configuration/test_advanced.py | 37 +++++++------- tests/conftest.py | 19 +++++--- tests/test_panel.py | 4 +- tests/test_plugins_bands.py | 4 +- tests/test_plugins_electronic_structure.py | 4 +- tests/test_plugins_pdos.py | 4 +- tests/test_pseudo.py | 8 ++-- tests/test_result.py | 8 ++-- 67 files changed, 386 insertions(+), 306 deletions(-) diff --git a/src/aiidalab_qe/app/configuration/__init__.py b/src/aiidalab_qe/app/configuration/__init__.py index 2d10f0c18..5551da9b1 100644 --- a/src/aiidalab_qe/app/configuration/__init__.py +++ b/src/aiidalab_qe/app/configuration/__init__.py @@ -10,11 +10,17 @@ from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.app.utils import get_entry_items -from aiidalab_qe.common.panel import SettingsModel, SettingsPanel +from aiidalab_qe.common.panel import ( + ConfigurationSettingsModel, + ConfigurationSettingsPanel, +) from aiidalab_widgets_base import WizardAppWidgetStep -from .advanced import AdvancedModel, AdvancedSettings -from .basic import WorkChainModel, WorkChainSettings +from .advanced import ( + AdvancedConfigurationSettingsModel, + AdvancedConfigurationSettingsPanel, +) +from .basic import BasicConfigurationSettingsModel, BasicConfigurationSettingsPanel from .model import ConfigurationStepModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore @@ -56,12 +62,14 @@ def __init__(self, model: ConfigurationStepModel, **kwargs): """, ) - workchain_model = WorkChainModel() - self.workchain_settings = WorkChainSettings(model=workchain_model) + workchain_model = BasicConfigurationSettingsModel() + self.workchain_settings = BasicConfigurationSettingsPanel(model=workchain_model) self._model.add_model("workchain", workchain_model) - advanced_model = AdvancedModel() - self.advanced_settings = AdvancedSettings(model=advanced_model) + advanced_model = AdvancedConfigurationSettingsModel() + self.advanced_settings = AdvancedConfigurationSettingsPanel( + model=advanced_model + ) self._model.add_model("advanced", advanced_model) self.settings = { @@ -71,7 +79,7 @@ def __init__(self, model: ConfigurationStepModel, **kwargs): self.property_children = [] - self._fetch_plugin_settings() + self._fetch_plugin_calculation_settings() def render(self): if self.rendered: @@ -178,7 +186,7 @@ def _on_previous_step_state_change(self, _): def _on_tab_change(self, change): if (tab_index := change["new"]) is None: return - tab: SettingsPanel = self.tabs.children[tab_index] # type: ignore + tab: ConfigurationSettingsPanel = self.tabs.children[tab_index] # type: ignore tab.render() tab.update() @@ -214,15 +222,16 @@ def _update_state(self, _=None): else: self.state = self.State.INIT - def _fetch_plugin_settings(self): + def _fetch_plugin_calculation_settings(self): outlines = get_entry_items("aiidalab_qe.properties", "outline") - entries = get_entry_items("aiidalab_qe.properties", "setting") - for identifier, entry in entries.items(): + entries = get_entry_items("aiidalab_qe.properties", "configuration") + for identifier, configuration in entries.items(): for key in ("panel", "model"): - if key not in entry: + if key not in configuration: raise ValueError(f"Entry {identifier} is missing the '{key}' key") - panel = entry["panel"] - model: SettingsModel = entry["model"]() + + panel = configuration["panel"] + model: ConfigurationSettingsModel = configuration["model"]() self._model.add_model(identifier, model) outline = outlines[identifier]() diff --git a/src/aiidalab_qe/app/configuration/advanced/__init__.py b/src/aiidalab_qe/app/configuration/advanced/__init__.py index 93bc2dbf5..8a7778e2f 100644 --- a/src/aiidalab_qe/app/configuration/advanced/__init__.py +++ b/src/aiidalab_qe/app/configuration/advanced/__init__.py @@ -1,7 +1,7 @@ -from .advanced import AdvancedSettings -from .model import AdvancedModel +from .advanced import AdvancedConfigurationSettingsPanel +from .model import AdvancedConfigurationSettingsModel __all__ = [ - "AdvancedModel", - "AdvancedSettings", + "AdvancedConfigurationSettingsModel", + "AdvancedConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/advanced.py b/src/aiidalab_qe/app/configuration/advanced/advanced.py index 15c698d15..5779d707d 100644 --- a/src/aiidalab_qe/app/configuration/advanced/advanced.py +++ b/src/aiidalab_qe/app/configuration/advanced/advanced.py @@ -5,20 +5,34 @@ import ipywidgets as ipw -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel -from .hubbard import HubbardModel, HubbardSettings -from .magnetization import MagnetizationModel, MagnetizationSettings -from .model import AdvancedModel -from .pseudos import PseudoSettings, PseudosModel -from .smearing import SmearingModel, SmearingSettings +from .hubbard import ( + HubbardConfigurationSettingsModel, + HubbardConfigurationSettingsPanel, +) +from .magnetization import ( + MagnetizationConfigurationSettingsModel, + MagnetizationConfigurationSettingsPanel, +) +from .model import AdvancedConfigurationSettingsModel +from .pseudos import ( + PseudosConfigurationSettingsModel, + PseudosConfigurationSettingsPanel, +) +from .smearing import ( + SmearingConfigurationSettingsModel, + SmearingConfigurationSettingsPanel, +) -class AdvancedSettings(SettingsPanel[AdvancedModel]): +class AdvancedConfigurationSettingsPanel( + ConfigurationSettingsPanel[AdvancedConfigurationSettingsModel], +): title = "Advanced Settings" identifier = "advanced" - def __init__(self, model: AdvancedModel, **kwargs): + def __init__(self, model: AdvancedConfigurationSettingsModel, **kwargs): super().__init__( model=model, layout={"justify_content": "space-between", **kwargs.get("layout", {})}, @@ -42,20 +56,22 @@ def __init__(self, model: AdvancedModel, **kwargs): "kpoints_distance", ) - smearing_model = SmearingModel() - self.smearing = SmearingSettings(model=smearing_model) + smearing_model = SmearingConfigurationSettingsModel() + self.smearing = SmearingConfigurationSettingsPanel(model=smearing_model) model.add_model("smearing", smearing_model) - magnetization_model = MagnetizationModel() - self.magnetization = MagnetizationSettings(model=magnetization_model) + magnetization_model = MagnetizationConfigurationSettingsModel() + self.magnetization = MagnetizationConfigurationSettingsPanel( + model=magnetization_model, + ) model.add_model("magnetization", magnetization_model) - hubbard_model = HubbardModel() - self.hubbard = HubbardSettings(model=hubbard_model) + hubbard_model = HubbardConfigurationSettingsModel() + self.hubbard = HubbardConfigurationSettingsPanel(model=hubbard_model) model.add_model("hubbard", hubbard_model) - pseudos_model = PseudosModel() - self.pseudos = PseudoSettings(model=pseudos_model) + pseudos_model = PseudosConfigurationSettingsModel() + self.pseudos = PseudosConfigurationSettingsPanel(model=pseudos_model) model.add_model("pseudos", pseudos_model) def render(self): diff --git a/src/aiidalab_qe/app/configuration/advanced/hubbard/__init__.py b/src/aiidalab_qe/app/configuration/advanced/hubbard/__init__.py index 269e51e35..ad7485063 100644 --- a/src/aiidalab_qe/app/configuration/advanced/hubbard/__init__.py +++ b/src/aiidalab_qe/app/configuration/advanced/hubbard/__init__.py @@ -1,7 +1,7 @@ -from .hubbard import HubbardSettings -from .model import HubbardModel +from .hubbard import HubbardConfigurationSettingsPanel +from .model import HubbardConfigurationSettingsModel __all__ = [ - "HubbardSettings", - "HubbardModel", + "HubbardConfigurationSettingsModel", + "HubbardConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py b/src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py index 9628bfaca..6016fa455 100644 --- a/src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py +++ b/src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py @@ -1,13 +1,15 @@ import ipywidgets as ipw -from ..subsettings import AdvancedSubSettings -from .model import HubbardModel +from ..subsettings import AdvancedConfigurationSubSettingsPanel +from .model import HubbardConfigurationSettingsModel -class HubbardSettings(AdvancedSubSettings[HubbardModel]): +class HubbardConfigurationSettingsPanel( + AdvancedConfigurationSubSettingsPanel[HubbardConfigurationSettingsModel], +): identifier = "hubbard" - def __init__(self, model: HubbardModel, **kwargs): + def __init__(self, model: HubbardConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( @@ -100,7 +102,7 @@ def _update(self, specific=""): if self.updated: return self._show_loading() - if not self._model.loaded_from_process or specific and specific != "widgets": + if not self._model.loaded_from_process or (specific and specific != "widgets"): self._model.update(specific) self._build_hubbard_widget() self._toggle_hubbard_widget() diff --git a/src/aiidalab_qe/app/configuration/advanced/hubbard/model.py b/src/aiidalab_qe/app/configuration/advanced/hubbard/model.py index a0da5b21f..b54038bd1 100644 --- a/src/aiidalab_qe/app/configuration/advanced/hubbard/model.py +++ b/src/aiidalab_qe/app/configuration/advanced/hubbard/model.py @@ -9,10 +9,13 @@ from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData from aiidalab_qe.common.mixins import HasInputStructure -from ..subsettings import AdvancedSubModel +from ..subsettings import AdvancedCalculationSubSettingsModel -class HubbardModel(AdvancedSubModel, HasInputStructure): +class HubbardConfigurationSettingsModel( + AdvancedCalculationSubSettingsModel, + HasInputStructure, +): dependencies = [ "input_structure", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/magnetization/__init__.py b/src/aiidalab_qe/app/configuration/advanced/magnetization/__init__.py index a9ac4eb41..a5196d724 100644 --- a/src/aiidalab_qe/app/configuration/advanced/magnetization/__init__.py +++ b/src/aiidalab_qe/app/configuration/advanced/magnetization/__init__.py @@ -1,7 +1,7 @@ -from .magnetization import MagnetizationSettings -from .model import MagnetizationModel +from .magnetization import MagnetizationConfigurationSettingsPanel +from .model import MagnetizationConfigurationSettingsModel __all__ = [ - "MagnetizationModel", - "MagnetizationSettings", + "MagnetizationConfigurationSettingsModel", + "MagnetizationConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/magnetization/magnetization.py b/src/aiidalab_qe/app/configuration/advanced/magnetization/magnetization.py index 620736659..d4405b47f 100644 --- a/src/aiidalab_qe/app/configuration/advanced/magnetization/magnetization.py +++ b/src/aiidalab_qe/app/configuration/advanced/magnetization/magnetization.py @@ -1,10 +1,12 @@ import ipywidgets as ipw -from ..subsettings import AdvancedSubSettings -from .model import MagnetizationModel +from ..subsettings import AdvancedConfigurationSubSettingsPanel +from .model import MagnetizationConfigurationSettingsModel -class MagnetizationSettings(AdvancedSubSettings[MagnetizationModel]): +class MagnetizationConfigurationSettingsPanel( + AdvancedConfigurationSubSettingsPanel[MagnetizationConfigurationSettingsModel], +): """Widget to set the type of magnetization used in the calculation: 1) Tot_magnetization: Total majority spin charge - minority spin charge. 2) Starting magnetization: Starting spin polarization on atomic type 'i' in a spin polarized (LSDA or noncollinear/spin-orbit) calculation. @@ -20,7 +22,7 @@ class MagnetizationSettings(AdvancedSubSettings[MagnetizationModel]): identifier = "magnetization" - def __init__(self, model: MagnetizationModel, **kwargs): + def __init__(self, model: MagnetizationConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( @@ -111,7 +113,7 @@ def _update(self, specific=""): if self.updated: return self._show_loading() - if not self._model.loaded_from_process or specific and specific != "widgets": + if not self._model.loaded_from_process or (specific and specific != "widgets"): self._model.update(specific) self._build_kinds_widget() self._switch_widgets() diff --git a/src/aiidalab_qe/app/configuration/advanced/magnetization/model.py b/src/aiidalab_qe/app/configuration/advanced/magnetization/model.py index 27e8ef060..82f403024 100644 --- a/src/aiidalab_qe/app/configuration/advanced/magnetization/model.py +++ b/src/aiidalab_qe/app/configuration/advanced/magnetization/model.py @@ -4,10 +4,13 @@ from aiidalab_qe.common.mixins import HasInputStructure -from ..subsettings import AdvancedSubModel +from ..subsettings import AdvancedCalculationSubSettingsModel -class MagnetizationModel(AdvancedSubModel, HasInputStructure): +class MagnetizationConfigurationSettingsModel( + AdvancedCalculationSubSettingsModel, + HasInputStructure, +): dependencies = [ "input_structure", "electronic_type", diff --git a/src/aiidalab_qe/app/configuration/advanced/model.py b/src/aiidalab_qe/app/configuration/advanced/model.py index c40b780be..745165887 100644 --- a/src/aiidalab_qe/app/configuration/advanced/model.py +++ b/src/aiidalab_qe/app/configuration/advanced/model.py @@ -13,23 +13,23 @@ from aiida_quantumespresso.workflows.pw.base import PwBaseWorkChain from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.common.mixins import HasInputStructure, HasModels -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel from aiidalab_qe.setup.pseudos import PseudoFamily -from .subsettings import AdvancedSubModel +from .subsettings import AdvancedCalculationSubSettingsModel if t.TYPE_CHECKING: - from .hubbard.hubbard import HubbardModel - from .magnetization import MagnetizationModel - from .pseudos.pseudos import PseudosModel - from .smearing import SmearingModel + from .hubbard.hubbard import HubbardConfigurationSettingsModel + from .magnetization import MagnetizationConfigurationSettingsModel + from .pseudos.pseudos import PseudosConfigurationSettingsModel + from .smearing import SmearingConfigurationSettingsModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore -class AdvancedModel( - SettingsModel, - HasModels[AdvancedSubModel], +class AdvancedConfigurationSettingsModel( + ConfigurationSettingsModel, + HasModels[AdvancedCalculationSubSettingsModel], HasInputStructure, ): dependencies = [ @@ -115,7 +115,7 @@ def get_model_state(self): "kpoints_distance": self.kpoints_distance, } - hubbard: HubbardModel = self.get_model("hubbard") # type: ignore + hubbard: HubbardConfigurationSettingsModel = self.get_model("hubbard") # type: ignore if hubbard.is_active: parameters["hubbard_parameters"] = {"hubbard_u": hubbard.parameters} if hubbard.has_eigenvalues: @@ -123,7 +123,7 @@ def get_model_state(self): "starting_ns_eigenvalue": hubbard.get_active_eigenvalues() } - pseudos: PseudosModel = self.get_model("pseudos") # type: ignore + pseudos: PseudosConfigurationSettingsModel = self.get_model("pseudos") # type: ignore parameters["pseudo_family"] = pseudos.family if pseudos.dictionary: parameters["pw"]["pseudos"] = pseudos.dictionary @@ -138,14 +138,16 @@ def get_model_state(self): self.dftd3_version[self.van_der_waals] ) - smearing: SmearingModel = self.get_model("smearing") # type: ignore + smearing: SmearingConfigurationSettingsModel = self.get_model("smearing") # type: ignore if self.electronic_type == "metal": # smearing type setting parameters["pw"]["parameters"]["SYSTEM"]["smearing"] = smearing.type # smearing degauss setting parameters["pw"]["parameters"]["SYSTEM"]["degauss"] = smearing.degauss - magnetization: MagnetizationModel = self.get_model("magnetization") # type: ignore + magnetization: MagnetizationConfigurationSettingsModel = self.get_model( + "magnetization" + ) # type: ignore if self.spin_type == "collinear": parameters["initial_magnetic_moments"] = magnetization.moments @@ -175,7 +177,7 @@ def get_model_state(self): return parameters def set_model_state(self, parameters): - pseudos: PseudosModel = self.get_model("pseudos") # type: ignore + pseudos: PseudosConfigurationSettingsModel = self.get_model("pseudos") # type: ignore if "pseudo_family" in parameters: pseudo_family = PseudoFamily.from_string(parameters["pseudo_family"]) library = pseudo_family.library @@ -194,7 +196,9 @@ def set_model_state(self, parameters): if (pw_parameters := parameters.get("pw", {}).get("parameters")) is not None: self._set_pw_parameters(pw_parameters) - magnetization: MagnetizationModel = self.get_model("magnetization") # type: ignore + magnetization: MagnetizationConfigurationSettingsModel = self.get_model( + "magnetization" + ) # type: ignore if magnetic_moments := parameters.get("initial_magnetic_moments"): if isinstance(magnetic_moments, (int, float)): magnetic_moments = [magnetic_moments] @@ -207,7 +211,7 @@ def set_model_state(self, parameters): ) magnetization.moments = magnetic_moments - hubbard: HubbardModel = self.get_model("hubbard") # type: ignore + hubbard: HubbardConfigurationSettingsModel = self.get_model("hubbard") # type: ignore if parameters.get("hubbard_parameters"): hubbard.is_active = True hubbard.parameters = parameters["hubbard_parameters"]["hubbard_u"] @@ -238,7 +242,7 @@ def reset(self): def _get_default(self, trait): return self._defaults.get(trait, self.traits()[trait].default_value) - def _link_model(self, model: AdvancedSubModel): + def _link_model(self, model: AdvancedCalculationSubSettingsModel): ipw.dlink( (self, "loaded_from_process"), (model, "loaded_from_process"), @@ -322,13 +326,15 @@ def _set_pw_parameters(self, pw_parameters): system_params.get("vdw_corr", "none"), ) - smearing: SmearingModel = self.get_model("smearing") # type: ignore + smearing: SmearingConfigurationSettingsModel = self.get_model("smearing") # type: ignore if "degauss" in system_params: smearing.degauss = system_params["degauss"] if "smearing" in system_params: smearing.type = system_params["smearing"] - magnetization: MagnetizationModel = self.get_model("magnetization") # type: ignore + magnetization: MagnetizationConfigurationSettingsModel = self.get_model( + "magnetization" + ) # type: ignore if "tot_magnetization" in system_params: magnetization.type = "tot_magnetization" diff --git a/src/aiidalab_qe/app/configuration/advanced/pseudos/__init__.py b/src/aiidalab_qe/app/configuration/advanced/pseudos/__init__.py index 799a9e1d8..65b81b376 100644 --- a/src/aiidalab_qe/app/configuration/advanced/pseudos/__init__.py +++ b/src/aiidalab_qe/app/configuration/advanced/pseudos/__init__.py @@ -1,8 +1,8 @@ -from .model import PseudosModel -from .pseudos import PseudoSettings, PseudoUploadWidget +from .model import PseudosConfigurationSettingsModel +from .pseudos import PseudosConfigurationSettingsPanel, PseudoUploadWidget __all__ = [ - "PseudosModel", - "PseudoSettings", "PseudoUploadWidget", + "PseudosConfigurationSettingsModel", + "PseudosConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/pseudos/model.py b/src/aiidalab_qe/app/configuration/advanced/pseudos/model.py index 4907d2cf6..959048e31 100644 --- a/src/aiidalab_qe/app/configuration/advanced/pseudos/model.py +++ b/src/aiidalab_qe/app/configuration/advanced/pseudos/model.py @@ -13,7 +13,7 @@ from aiidalab_qe.common.mixins import HasInputStructure from aiidalab_qe.setup.pseudos import PSEUDODOJO_VERSION, SSSP_VERSION, PseudoFamily -from ..subsettings import AdvancedSubModel +from ..subsettings import AdvancedCalculationSubSettingsModel SsspFamily = GroupFactory("pseudo.family.sssp") PseudoDojoFamily = GroupFactory("pseudo.family.pseudo_dojo") @@ -22,7 +22,10 @@ DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore -class PseudosModel(AdvancedSubModel, HasInputStructure): +class PseudosConfigurationSettingsModel( + AdvancedCalculationSubSettingsModel, + HasInputStructure, +): dependencies = [ "input_structure", "protocol", diff --git a/src/aiidalab_qe/app/configuration/advanced/pseudos/pseudos.py b/src/aiidalab_qe/app/configuration/advanced/pseudos/pseudos.py index 012bb3b5e..b496a53f1 100644 --- a/src/aiidalab_qe/app/configuration/advanced/pseudos/pseudos.py +++ b/src/aiidalab_qe/app/configuration/advanced/pseudos/pseudos.py @@ -10,8 +10,8 @@ from aiidalab_qe.common.widgets import LoadingWidget from aiidalab_widgets_base.utils import StatusHTML -from ..subsettings import AdvancedSubSettings -from .model import PseudosModel +from ..subsettings import AdvancedConfigurationSubSettingsPanel +from .model import PseudosConfigurationSettingsModel UpfData = DataFactory("pseudo.upf") SsspFamily = GroupFactory("pseudo.family.sssp") @@ -19,10 +19,12 @@ CutoffsPseudoPotentialFamily = GroupFactory("pseudo.family.cutoffs") -class PseudoSettings(AdvancedSubSettings[PseudosModel]): +class PseudosConfigurationSettingsPanel( + AdvancedConfigurationSubSettingsPanel[PseudosConfigurationSettingsModel], +): identifier = "pseudos" - def __init__(self, model: PseudosModel, **kwargs): + def __init__(self, model: PseudosConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( @@ -243,7 +245,7 @@ def _update(self, specific=""): if self.updated: return self._show_loading() - if not self._model.loaded_from_process or specific and specific != "widgets": + if not self._model.loaded_from_process or (specific and specific != "widgets"): self._model.update(specific) self._build_setter_widgets() self._model.update_library_options() diff --git a/src/aiidalab_qe/app/configuration/advanced/smearing/__init__.py b/src/aiidalab_qe/app/configuration/advanced/smearing/__init__.py index 598982922..915be9149 100644 --- a/src/aiidalab_qe/app/configuration/advanced/smearing/__init__.py +++ b/src/aiidalab_qe/app/configuration/advanced/smearing/__init__.py @@ -1,7 +1,7 @@ -from .model import SmearingModel -from .smearing import SmearingSettings +from .model import SmearingConfigurationSettingsModel +from .smearing import SmearingConfigurationSettingsPanel __all__ = [ - "SmearingModel", - "SmearingSettings", + "SmearingConfigurationSettingsModel", + "SmearingConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/smearing/model.py b/src/aiidalab_qe/app/configuration/advanced/smearing/model.py index b592e59ff..6de8da0d9 100644 --- a/src/aiidalab_qe/app/configuration/advanced/smearing/model.py +++ b/src/aiidalab_qe/app/configuration/advanced/smearing/model.py @@ -4,10 +4,10 @@ from aiida_quantumespresso.workflows.pw.base import PwBaseWorkChain -from ..subsettings import AdvancedSubModel +from ..subsettings import AdvancedCalculationSubSettingsModel -class SmearingModel(AdvancedSubModel): +class SmearingConfigurationSettingsModel(AdvancedCalculationSubSettingsModel): dependencies = [ "protocol", ] diff --git a/src/aiidalab_qe/app/configuration/advanced/smearing/smearing.py b/src/aiidalab_qe/app/configuration/advanced/smearing/smearing.py index 6d723448a..a85fbaaae 100644 --- a/src/aiidalab_qe/app/configuration/advanced/smearing/smearing.py +++ b/src/aiidalab_qe/app/configuration/advanced/smearing/smearing.py @@ -1,13 +1,15 @@ import ipywidgets as ipw -from ..subsettings import AdvancedSubSettings -from .model import SmearingModel +from ..subsettings import AdvancedConfigurationSubSettingsPanel +from .model import SmearingConfigurationSettingsModel -class SmearingSettings(AdvancedSubSettings[SmearingModel]): +class SmearingConfigurationSettingsPanel( + AdvancedConfigurationSubSettingsPanel[SmearingConfigurationSettingsModel], +): identifier = "smearing" - def __init__(self, model: SmearingModel, **kwargs): + def __init__(self, model: SmearingConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( diff --git a/src/aiidalab_qe/app/configuration/advanced/subsettings.py b/src/aiidalab_qe/app/configuration/advanced/subsettings.py index 77bc4cf07..5a588d6b5 100644 --- a/src/aiidalab_qe/app/configuration/advanced/subsettings.py +++ b/src/aiidalab_qe/app/configuration/advanced/subsettings.py @@ -7,7 +7,7 @@ from aiidalab_qe.common.mvc import Model -class AdvancedSubModel(Model): +class AdvancedCalculationSubSettingsModel(Model): dependencies = [] loaded_from_process = tl.Bool(False) @@ -29,10 +29,10 @@ def reset(self): raise NotImplementedError() -M = t.TypeVar("M", bound=AdvancedSubModel) +M = t.TypeVar("M", bound=AdvancedCalculationSubSettingsModel) -class AdvancedSubSettings(ipw.VBox, t.Generic[M]): +class AdvancedConfigurationSubSettingsPanel(ipw.VBox, t.Generic[M]): identifier = "sub" def __init__(self, model: M, **kwargs): diff --git a/src/aiidalab_qe/app/configuration/basic/__init__.py b/src/aiidalab_qe/app/configuration/basic/__init__.py index 9ce65d685..bc488a8c0 100644 --- a/src/aiidalab_qe/app/configuration/basic/__init__.py +++ b/src/aiidalab_qe/app/configuration/basic/__init__.py @@ -1,7 +1,7 @@ -from .model import WorkChainModel -from .workflow import WorkChainSettings +from .model import BasicConfigurationSettingsModel +from .workflow import BasicConfigurationSettingsPanel __all__ = [ - "WorkChainModel", - "WorkChainSettings", + "BasicConfigurationSettingsModel", + "BasicConfigurationSettingsPanel", ] diff --git a/src/aiidalab_qe/app/configuration/basic/model.py b/src/aiidalab_qe/app/configuration/basic/model.py index cd9bd90df..ffc7690f4 100644 --- a/src/aiidalab_qe/app/configuration/basic/model.py +++ b/src/aiidalab_qe/app/configuration/basic/model.py @@ -2,12 +2,12 @@ from aiida import orm from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore -class WorkChainModel(SettingsModel): +class BasicConfigurationSettingsModel(ConfigurationSettingsModel): dependencies = [ "input_structure", ] diff --git a/src/aiidalab_qe/app/configuration/basic/workflow.py b/src/aiidalab_qe/app/configuration/basic/workflow.py index 8ed825aa7..4e4147b25 100644 --- a/src/aiidalab_qe/app/configuration/basic/workflow.py +++ b/src/aiidalab_qe/app/configuration/basic/workflow.py @@ -5,15 +5,17 @@ import ipywidgets as ipw -from aiidalab_qe.app.configuration.basic.model import WorkChainModel -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.app.configuration.basic.model import BasicConfigurationSettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel -class WorkChainSettings(SettingsPanel[WorkChainModel]): +class BasicConfigurationSettingsPanel( + ConfigurationSettingsPanel[BasicConfigurationSettingsModel], +): title = "Basic Settings" identifier = "workchain" - def __init__(self, model: WorkChainModel, **kwargs): + def __init__(self, model: BasicConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( self._on_input_structure_change, diff --git a/src/aiidalab_qe/app/configuration/model.py b/src/aiidalab_qe/app/configuration/model.py index 8d8f987a8..5c3949eeb 100644 --- a/src/aiidalab_qe/app/configuration/model.py +++ b/src/aiidalab_qe/app/configuration/model.py @@ -11,14 +11,14 @@ HasModels, ) from aiidalab_qe.common.mvc import Model -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore class ConfigurationStepModel( Model, - HasModels[SettingsModel], + HasModels[ConfigurationSettingsModel], HasInputStructure, Confirmable, ): @@ -115,7 +115,7 @@ def reset(self): if identifier not in self._default_models: model.include = False - def _link_model(self, model: SettingsModel): + def _link_model(self, model: ConfigurationSettingsModel): ipw.link( (self, "confirmed"), (model, "confirmed"), diff --git a/src/aiidalab_qe/app/result/summary/__init__.py b/src/aiidalab_qe/app/result/summary/__init__.py index b57eab187..b4ece5f76 100644 --- a/src/aiidalab_qe/app/result/summary/__init__.py +++ b/src/aiidalab_qe/app/result/summary/__init__.py @@ -1,7 +1,7 @@ -from .model import WorkChainSummaryModel -from .summary import WorkChainSummary +from .model import WorkChainSummaryResultsModel +from .summary import WorkChainSummaryResultsPanel __all__ = [ - "WorkChainSummaryModel", - "WorkChainSummary", + "WorkChainSummaryResultsModel", + "WorkChainSummaryResultsPanel", ] diff --git a/src/aiidalab_qe/app/result/summary/model.py b/src/aiidalab_qe/app/result/summary/model.py index d44f027b4..900ab8fd8 100644 --- a/src/aiidalab_qe/app/result/summary/model.py +++ b/src/aiidalab_qe/app/result/summary/model.py @@ -35,7 +35,7 @@ } -class WorkChainSummaryModel(ResultsModel): +class WorkChainSummaryResultsModel(ResultsModel): identifier = "summary" @property diff --git a/src/aiidalab_qe/app/result/summary/summary.py b/src/aiidalab_qe/app/result/summary/summary.py index 8ee839ac8..890c38779 100644 --- a/src/aiidalab_qe/app/result/summary/summary.py +++ b/src/aiidalab_qe/app/result/summary/summary.py @@ -2,10 +2,10 @@ from aiidalab_qe.common.panel import ResultsPanel -from .model import WorkChainSummaryModel +from .model import WorkChainSummaryResultsModel -class WorkChainSummary(ResultsPanel[WorkChainSummaryModel]): +class WorkChainSummaryResultsPanel(ResultsPanel[WorkChainSummaryResultsModel]): title = "Workflow Summary" identifier = "summary" diff --git a/src/aiidalab_qe/app/result/viewer/viewer.py b/src/aiidalab_qe/app/result/viewer/viewer.py index 731263fcf..d9228301b 100644 --- a/src/aiidalab_qe/app/result/viewer/viewer.py +++ b/src/aiidalab_qe/app/result/viewer/viewer.py @@ -3,13 +3,13 @@ import ipywidgets as ipw import traitlets as tl -from aiidalab_qe.app.result.summary.model import WorkChainSummaryModel +from aiidalab_qe.app.result.summary.model import WorkChainSummaryResultsModel from aiidalab_qe.app.utils import get_entry_items from aiidalab_qe.common.panel import ResultsPanel from aiidalab_widgets_base import register_viewer_widget from ..structure import StructureResults, StructureResultsModel -from ..summary import WorkChainSummary +from ..summary import WorkChainSummaryResultsPanel from .model import WorkChainViewerModel from .outputs import WorkChainOutputs @@ -31,9 +31,9 @@ def __init__(self, node, model: WorkChainViewerModel, **kwargs): self.rendered = False - summary_model = WorkChainSummaryModel() + summary_model = WorkChainSummaryResultsModel() summary_model.process_uuid = node.uuid - self.summary = WorkChainSummary(model=summary_model) + self.summary = WorkChainSummaryResultsPanel(model=summary_model) self._model.add_model("summary", summary_model) self.results: dict[str, ResultsPanel] = { diff --git a/src/aiidalab_qe/app/submission/__init__.py b/src/aiidalab_qe/app/submission/__init__.py index 3dc88dc42..d9176b9ab 100644 --- a/src/aiidalab_qe/app/submission/__init__.py +++ b/src/aiidalab_qe/app/submission/__init__.py @@ -10,12 +10,12 @@ from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.app.utils import get_entry_items -from aiidalab_qe.common.panel import SettingsModel, SettingsPanel +from aiidalab_qe.common.panel import ResourceSettingsModel, ResourceSettingsPanel from aiidalab_qe.common.setup_codes import QESetupWidget from aiidalab_qe.common.setup_pseudos import PseudosInstallWidget from aiidalab_widgets_base import WizardAppWidgetStep -from .global_settings import GlobalCodeModel, GlobalCodeSettings +from .global_settings import GlobalResourceSettingsModel, GlobalResourceSettingsPanel from .model import SubmissionStepModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore @@ -77,8 +77,8 @@ def __init__(self, model: SubmissionStepModel, qe_auto_setup=True, **kwargs): self.rendered = False - global_code_model = GlobalCodeModel() - self.global_code_settings = GlobalCodeSettings(model=global_code_model) + 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( self._on_plugin_submission_blockers_change, @@ -190,6 +190,7 @@ def render(self): ] self.rendered = True + self._update_tabs() def submit(self, _=None): @@ -207,9 +208,8 @@ def _on_previous_step_state_change(self, _): def _on_tab_change(self, change): if (tab_index := change["new"]) is None: return - tab: SettingsPanel = self.tabs.children[tab_index] # type: ignore + tab: ResourceSettingsPanel = self.tabs.children[tab_index] # type: ignore tab.render() - tab.update() def _on_input_structure_change(self, _): """""" @@ -326,14 +326,13 @@ def _update_state(self, _=None): self.state = self.state.CONFIGURED def _fetch_plugin_settings(self): - # Load codes from plugins eps = get_entry_items("aiidalab_qe.properties", "code") for identifier, data in eps.items(): for key in ("panel", "model"): if key not in data: raise ValueError(f"Entry {identifier} is missing the '{key}' key") panel = data["panel"] - model: SettingsModel = data["model"]() + model: ResourceSettingsModel = data["model"]() model.observe( self._on_plugin_submission_blockers_change, ["submission_blockers"], diff --git a/src/aiidalab_qe/app/submission/global_settings/__init__.py b/src/aiidalab_qe/app/submission/global_settings/__init__.py index 9a44d03de..31b5c95cd 100644 --- a/src/aiidalab_qe/app/submission/global_settings/__init__.py +++ b/src/aiidalab_qe/app/submission/global_settings/__init__.py @@ -1,7 +1,7 @@ -from .model import GlobalCodeModel -from .setting import GlobalCodeSettings +from .model import GlobalResourceSettingsModel +from .setting import GlobalResourceSettingsPanel __all__ = [ - "GlobalCodeModel", - "GlobalCodeSettings", + "GlobalResourceSettingsModel", + "GlobalResourceSettingsPanel", ] diff --git a/src/aiidalab_qe/app/submission/global_settings/model.py b/src/aiidalab_qe/app/submission/global_settings/model.py index bf7838337..0345cc6ab 100644 --- a/src/aiidalab_qe/app/submission/global_settings/model.py +++ b/src/aiidalab_qe/app/submission/global_settings/model.py @@ -8,16 +8,14 @@ from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.common.code import CodeModel, PwCodeModel from aiidalab_qe.common.mixins import HasInputStructure -from aiidalab_qe.common.panel import SettingsModel -from aiidalab_qe.common.widgets import ( - QEAppComputationalResourcesWidget, -) +from aiidalab_qe.common.panel import ResourceSettingsModel +from aiidalab_qe.common.widgets import QEAppComputationalResourcesWidget DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore -class GlobalCodeModel( - SettingsModel, +class GlobalResourceSettingsModel( + ResourceSettingsModel, HasInputStructure, ): """Model for the global code setting.""" diff --git a/src/aiidalab_qe/app/submission/global_settings/setting.py b/src/aiidalab_qe/app/submission/global_settings/setting.py index 27d7b475f..a2df3bbc2 100644 --- a/src/aiidalab_qe/app/submission/global_settings/setting.py +++ b/src/aiidalab_qe/app/submission/global_settings/setting.py @@ -10,23 +10,22 @@ from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.app.utils import get_entry_items from aiidalab_qe.common.code import CodeModel, PluginCodes, PwCodeModel -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.common.panel import ResourceSettingsPanel from aiidalab_qe.common.widgets import ( LoadingWidget, PwCodeResourceSetupWidget, QEAppComputationalResourcesWidget, ) -from .model import GlobalCodeModel +from .model import GlobalResourceSettingsModel DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore -class GlobalCodeSettings(SettingsPanel[GlobalCodeModel]): - title = "Global settings" +class GlobalResourceSettingsPanel(ResourceSettingsPanel[GlobalResourceSettingsModel]): identifier = "global" - def __init__(self, model: GlobalCodeModel, **kwargs): + def __init__(self, model: GlobalResourceSettingsModel, **kwargs): super().__init__(model, **kwargs) self._set_up_codes() self._model.observe( diff --git a/src/aiidalab_qe/app/submission/model.py b/src/aiidalab_qe/app/submission/model.py index 911f2e91a..c47c93ed6 100644 --- a/src/aiidalab_qe/app/submission/model.py +++ b/src/aiidalab_qe/app/submission/model.py @@ -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 SettingsModel +from aiidalab_qe.common.panel import ResourceSettingsModel from aiidalab_qe.workflows import QeAppWorkChain DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore @@ -19,7 +19,7 @@ class SubmissionStepModel( Model, - HasModels[SettingsModel], + HasModels[ResourceSettingsModel], HasInputStructure, Confirmable, ): @@ -212,11 +212,7 @@ def _submit(self): ) self.process_node = process_node - def _link_model(self, model: SettingsModel): - ipw.link( - (self, "confirmed"), - (model, "confirmed"), - ) + def _link_model(self, model: ResourceSettingsModel): for dependency in model.dependencies: dependency_parts = dependency.split(".") if len(dependency_parts) == 1: # from parent, e.g. input_structure diff --git a/src/aiidalab_qe/common/__init__.py b/src/aiidalab_qe/common/__init__.py index 8e275bf41..70dc6de9f 100644 --- a/src/aiidalab_qe/common/__init__.py +++ b/src/aiidalab_qe/common/__init__.py @@ -4,9 +4,9 @@ from .widgets import AddingTagsEditor, LazyLoadedOptimade, LazyLoadedStructureBrowser __all__ = [ - "WorkChainSelector", - "QeAppWorkChainSelector", "AddingTagsEditor", "LazyLoadedOptimade", "LazyLoadedStructureBrowser", + "QeAppWorkChainSelector", + "WorkChainSelector", ] diff --git a/src/aiidalab_qe/common/panel.py b/src/aiidalab_qe/common/panel.py index 5ae8a4cfa..3cca22ab0 100644 --- a/src/aiidalab_qe/common/panel.py +++ b/src/aiidalab_qe/common/panel.py @@ -57,7 +57,7 @@ def __init__(self, parent=None, identifier=None, **kwargs): ) -class SettingsOutline(ipw.HBox): +class PluginOutline(ipw.HBox): title = "Outline" description = "" @@ -81,7 +81,7 @@ def __init__(self, **kwargs): ) -class SettingsModel(Model, Confirmable): +class SettingsModel(Model): title = "Model" dependencies: list[str] = [] @@ -140,6 +140,27 @@ def __init__(self, model: SM, **kwargs): def render(self): raise NotImplementedError() + +class ConfigurationSettingsModel(SettingsModel, Confirmable): + """Base model for configuration settings models.""" + + def update(self, specific=""): + """Updates the model. + + Parameters + ---------- + `specific` : `str`, optional + If provided, specifies the level of update. + """ + pass + + +CSM = t.TypeVar("CSM", bound=ConfigurationSettingsModel) + + +class ConfigurationSettingsPanel(SettingsPanel[CSM], t.Generic[CSM]): + """Base class for configuration settings panels.""" + def refresh(self, specific=""): """Refreshes the settings panel. @@ -188,7 +209,7 @@ def _reset(self): self._model.reset() -class CodeSettingsModel(SettingsModel): +class ResourceSettingsModel(SettingsModel): """Base model for plugin code setting models.""" dependencies = ["global.global_codes"] @@ -241,9 +262,11 @@ def reset(self): code_model.reset() -class CodeSettingsPanel(SettingsPanel[CodeSettingsModel], t.Generic[SM]): - title = "Plugin Name" # To be overridden by subclasses - identifier = "plugin_identifier" # To be overridden by subclasses +RSM = t.TypeVar("RSM", bound=ResourceSettingsModel) + + +class ResourceSettingsPanel(SettingsPanel[RSM], t.Generic[RSM]): + """Base class for plugin code setting panels.""" def __init__(self, model, **kwargs): super().__init__(model, **kwargs) diff --git a/src/aiidalab_qe/plugins/bands/__init__.py b/src/aiidalab_qe/plugins/bands/__init__.py index 1275477a6..0c8b86ad6 100644 --- a/src/aiidalab_qe/plugins/bands/__init__.py +++ b/src/aiidalab_qe/plugins/bands/__init__.py @@ -1,29 +1,29 @@ # from aiidalab_qe.bands.result import Result -from aiidalab_qe.common.panel import SettingsOutline +from aiidalab_qe.common.panel import PluginOutline -from .code import BandsCodeModel, BandsCodeSettings -from .model import BandsModel -from .result import BandsResults, BandsResultsModel -from .setting import BandsSettings +from .code import BandsResourceSettingsModel, BandsResourceSettingsPanel +from .model import BandsConfigurationSettingsModel +from .result import BandsResultsModel, BandsResultsPanel +from .setting import BandsConfigurationSettingsPanel from .workchain import workchain_and_builder -class BandsOutline(SettingsOutline): +class BandsPluginOutline(PluginOutline): title = "Electronic band structure" bands = { - "outline": BandsOutline, - "code": { - "panel": BandsCodeSettings, - "model": BandsCodeModel, + "outline": BandsPluginOutline, + "configuration": { + "panel": BandsConfigurationSettingsPanel, + "model": BandsConfigurationSettingsModel, }, - "setting": { - "panel": BandsSettings, - "model": BandsModel, + "code": { + "panel": BandsResourceSettingsPanel, + "model": BandsResourceSettingsModel, }, "result": { - "panel": BandsResults, + "panel": BandsResultsPanel, "model": BandsResultsModel, }, "workchain": workchain_and_builder, diff --git a/src/aiidalab_qe/plugins/bands/code.py b/src/aiidalab_qe/plugins/bands/code.py index cfcf98239..79571a00f 100644 --- a/src/aiidalab_qe/plugins/bands/code.py +++ b/src/aiidalab_qe/plugins/bands/code.py @@ -1,10 +1,10 @@ """Panel for Bands plugin.""" from aiidalab_qe.common.code.model import CodeModel, PwCodeModel -from aiidalab_qe.common.panel import CodeSettingsModel, CodeSettingsPanel +from aiidalab_qe.common.panel import ResourceSettingsModel, ResourceSettingsPanel -class BandsCodeModel(CodeSettingsModel): +class BandsResourceSettingsModel(ResourceSettingsModel): """Model for the band structure plugin.""" codes = { @@ -21,6 +21,6 @@ class BandsCodeModel(CodeSettingsModel): } -class BandsCodeSettings(CodeSettingsPanel[BandsCodeModel]): +class BandsResourceSettingsPanel(ResourceSettingsPanel[BandsResourceSettingsModel]): title = "Band Structure" identifier = "bands" diff --git a/src/aiidalab_qe/plugins/bands/model.py b/src/aiidalab_qe/plugins/bands/model.py index 59392947f..ef1492f7c 100644 --- a/src/aiidalab_qe/plugins/bands/model.py +++ b/src/aiidalab_qe/plugins/bands/model.py @@ -1,9 +1,9 @@ import traitlets as tl -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel -class BandsModel(SettingsModel): +class BandsConfigurationSettingsModel(ConfigurationSettingsModel): """Model for the band structure plugin.""" projwfc_bands = tl.Bool(False) diff --git a/src/aiidalab_qe/plugins/bands/result/__init__.py b/src/aiidalab_qe/plugins/bands/result/__init__.py index ebec511be..6d4e06a46 100644 --- a/src/aiidalab_qe/plugins/bands/result/__init__.py +++ b/src/aiidalab_qe/plugins/bands/result/__init__.py @@ -1,7 +1,7 @@ from .model import BandsResultsModel -from .result import BandsResults +from .result import BandsResultsPanel __all__ = [ "BandsResultsModel", - "BandsResults", + "BandsResultsPanel", ] diff --git a/src/aiidalab_qe/plugins/bands/result/result.py b/src/aiidalab_qe/plugins/bands/result/result.py index 7a4625314..9e27a5330 100644 --- a/src/aiidalab_qe/plugins/bands/result/result.py +++ b/src/aiidalab_qe/plugins/bands/result/result.py @@ -8,7 +8,7 @@ from .model import BandsResultsModel -class BandsResults(ResultsPanel[BandsResultsModel]): +class BandsResultsPanel(ResultsPanel[BandsResultsModel]): title = "Bands" identifier = "bands" workchain_labels = ["bands"] diff --git a/src/aiidalab_qe/plugins/bands/setting.py b/src/aiidalab_qe/plugins/bands/setting.py index d2487bf7c..efbbdb37b 100644 --- a/src/aiidalab_qe/plugins/bands/setting.py +++ b/src/aiidalab_qe/plugins/bands/setting.py @@ -2,11 +2,13 @@ import ipywidgets as ipw -from aiidalab_qe.common.panel import SettingsPanel -from aiidalab_qe.plugins.bands.model import BandsModel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel +from aiidalab_qe.plugins.bands.model import BandsConfigurationSettingsModel -class BandsSettings(SettingsPanel[BandsModel]): +class BandsConfigurationSettingsPanel( + ConfigurationSettingsPanel[BandsConfigurationSettingsModel], +): title = "Bands Structure" identifier = "bands" diff --git a/src/aiidalab_qe/plugins/electronic_structure/__init__.py b/src/aiidalab_qe/plugins/electronic_structure/__init__.py index 9fb9631a7..bd0bc1cae 100644 --- a/src/aiidalab_qe/plugins/electronic_structure/__init__.py +++ b/src/aiidalab_qe/plugins/electronic_structure/__init__.py @@ -1,8 +1,8 @@ -from .result import ElectronicStructureResults, ElectronicStructureResultsModel +from .result import ElectronicStructureResultsModel, ElectronicStructureResultsPanel electronic_structure = { "result": { - "panel": ElectronicStructureResults, + "panel": ElectronicStructureResultsPanel, "model": ElectronicStructureResultsModel, }, } diff --git a/src/aiidalab_qe/plugins/electronic_structure/result/__init__.py b/src/aiidalab_qe/plugins/electronic_structure/result/__init__.py index b78cb362d..1634b9cd0 100644 --- a/src/aiidalab_qe/plugins/electronic_structure/result/__init__.py +++ b/src/aiidalab_qe/plugins/electronic_structure/result/__init__.py @@ -1,7 +1,7 @@ from .model import ElectronicStructureResultsModel -from .result import ElectronicStructureResults +from .result import ElectronicStructureResultsPanel __all__ = [ "ElectronicStructureResultsModel", - "ElectronicStructureResults", + "ElectronicStructureResultsPanel", ] diff --git a/src/aiidalab_qe/plugins/electronic_structure/result/result.py b/src/aiidalab_qe/plugins/electronic_structure/result/result.py index 8ee22734d..252e575c5 100644 --- a/src/aiidalab_qe/plugins/electronic_structure/result/result.py +++ b/src/aiidalab_qe/plugins/electronic_structure/result/result.py @@ -8,7 +8,7 @@ from .model import ElectronicStructureResultsModel -class ElectronicStructureResults(ResultsPanel[ElectronicStructureResultsModel]): +class ElectronicStructureResultsPanel(ResultsPanel[ElectronicStructureResultsModel]): title = "Electronic Structure" identifier = "electronic_structure" workchain_labels = ["bands", "pdos"] diff --git a/src/aiidalab_qe/plugins/pdos/__init__.py b/src/aiidalab_qe/plugins/pdos/__init__.py index 1efbe8f84..280a90c39 100644 --- a/src/aiidalab_qe/plugins/pdos/__init__.py +++ b/src/aiidalab_qe/plugins/pdos/__init__.py @@ -1,28 +1,28 @@ -from aiidalab_qe.common.panel import SettingsOutline +from aiidalab_qe.common.panel import PluginOutline -from .code import PdosCodeModel, PdosCodeSettings -from .model import PdosModel -from .result import PdosResults, PdosResultsModel -from .setting import PdosSettings +from .code import PdosResourceSettingsModel, PdosResourceSettingsPanel +from .model import PdosConfigurationSettingsModel +from .result import PdosResultsModel, PdosResultsPanel +from .setting import PdosConfigurationSettingPanel from .workchain import workchain_and_builder -class PdosOutline(SettingsOutline): +class PdosPluginOutline(PluginOutline): title = "Projected Density of States (PDOS)" pdos = { - "outline": PdosOutline, - "code": { - "panel": PdosCodeSettings, - "model": PdosCodeModel, + "outline": PdosPluginOutline, + "configuration": { + "panel": PdosConfigurationSettingPanel, + "model": PdosConfigurationSettingsModel, }, - "setting": { - "panel": PdosSettings, - "model": PdosModel, + "code": { + "panel": PdosResourceSettingsPanel, + "model": PdosResourceSettingsModel, }, "result": { - "panel": PdosResults, + "panel": PdosResultsPanel, "model": PdosResultsModel, }, "workchain": workchain_and_builder, diff --git a/src/aiidalab_qe/plugins/pdos/code.py b/src/aiidalab_qe/plugins/pdos/code.py index 091fe8c82..1e2095a25 100644 --- a/src/aiidalab_qe/plugins/pdos/code.py +++ b/src/aiidalab_qe/plugins/pdos/code.py @@ -1,10 +1,10 @@ """Panel for PDOS plugin.""" from aiidalab_qe.common.code.model import CodeModel, PwCodeModel -from aiidalab_qe.common.panel import CodeSettingsModel, CodeSettingsPanel +from aiidalab_qe.common.panel import ResourceSettingsModel, ResourceSettingsPanel -class PdosCodeModel(CodeSettingsModel): +class PdosResourceSettingsModel(ResourceSettingsModel): """Model for the pdos code setting plugin.""" codes = { @@ -26,6 +26,6 @@ class PdosCodeModel(CodeSettingsModel): } -class PdosCodeSettings(CodeSettingsPanel[PdosCodeModel]): +class PdosResourceSettingsPanel(ResourceSettingsPanel[PdosResourceSettingsModel]): title = "PDOS" identifier = "pdos" diff --git a/src/aiidalab_qe/plugins/pdos/model.py b/src/aiidalab_qe/plugins/pdos/model.py index a3989e4ac..6d0d5188d 100644 --- a/src/aiidalab_qe/plugins/pdos/model.py +++ b/src/aiidalab_qe/plugins/pdos/model.py @@ -6,10 +6,10 @@ ) from aiida_quantumespresso.workflows.pdos import PdosWorkChain from aiidalab_qe.common.mixins import HasInputStructure -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel -class PdosModel(SettingsModel, HasInputStructure): +class PdosConfigurationSettingsModel(ConfigurationSettingsModel, HasInputStructure): dependencies = [ "input_structure", "workchain.protocol", diff --git a/src/aiidalab_qe/plugins/pdos/result/__init__.py b/src/aiidalab_qe/plugins/pdos/result/__init__.py index f47a39b8b..30069fbb8 100644 --- a/src/aiidalab_qe/plugins/pdos/result/__init__.py +++ b/src/aiidalab_qe/plugins/pdos/result/__init__.py @@ -1,7 +1,7 @@ from .model import PdosResultsModel -from .result import PdosResults +from .result import PdosResultsPanel __all__ = [ "PdosResultsModel", - "PdosResults", + "PdosResultsPanel", ] diff --git a/src/aiidalab_qe/plugins/pdos/result/result.py b/src/aiidalab_qe/plugins/pdos/result/result.py index 6b433a308..e8e3c4f9f 100644 --- a/src/aiidalab_qe/plugins/pdos/result/result.py +++ b/src/aiidalab_qe/plugins/pdos/result/result.py @@ -8,7 +8,7 @@ from .model import PdosResultsModel -class PdosResults(ResultsPanel[PdosResultsModel]): +class PdosResultsPanel(ResultsPanel[PdosResultsModel]): title = "PDOS" identifier = "pdos" workchain_labels = ["pdos"] diff --git a/src/aiidalab_qe/plugins/pdos/setting.py b/src/aiidalab_qe/plugins/pdos/setting.py index 095e2d91c..1c354fd63 100644 --- a/src/aiidalab_qe/plugins/pdos/setting.py +++ b/src/aiidalab_qe/plugins/pdos/setting.py @@ -2,18 +2,20 @@ import ipywidgets as ipw -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel -from .model import PdosModel +from .model import PdosConfigurationSettingsModel RYDBERG_TO_EV = 13.605703976 -class PdosSettings(SettingsPanel[PdosModel]): +class PdosConfigurationSettingPanel( + ConfigurationSettingsPanel[PdosConfigurationSettingsModel], +): title = "PDOS" identifier = "pdos" - def __init__(self, model: PdosModel, **kwargs): + def __init__(self, model: PdosConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( diff --git a/src/aiidalab_qe/plugins/xas/__init__.py b/src/aiidalab_qe/plugins/xas/__init__.py index 905ed8380..76a4af001 100644 --- a/src/aiidalab_qe/plugins/xas/__init__.py +++ b/src/aiidalab_qe/plugins/xas/__init__.py @@ -2,34 +2,34 @@ import yaml -from aiidalab_qe.common.panel import SettingsOutline +from aiidalab_qe.common.panel import PluginOutline from aiidalab_qe.plugins import xas as xas_folder -from .code import XasCodeModel, XasCodeSettings -from .model import XasModel -from .result import XasResults, XasResultsModel -from .setting import XasSettings +from .code import XasResourceSettingsModel, XasResourceSettingsPanel +from .model import XasConfigurationSettingsModel +from .result import XasResultsModel, XasResultsPanel +from .setting import XasConfigurationSettingsPanel from .workchain import workchain_and_builder PSEUDO_TOC = yaml.safe_load(resources.read_text(xas_folder, "pseudo_toc.yaml")) -class XasOutline(SettingsOutline): +class XasPluginOutline(PluginOutline): title = "X-ray absorption spectroscopy (XAS)" xas = { - "outline": XasOutline, - "code": { - "panel": XasCodeSettings, - "model": XasCodeModel, + "outline": XasPluginOutline, + "configuration": { + "panel": XasConfigurationSettingsPanel, + "model": XasConfigurationSettingsModel, }, - "setting": { - "panel": XasSettings, - "model": XasModel, + "code": { + "panel": XasResourceSettingsPanel, + "model": XasResourceSettingsModel, }, "result": { - "panel": XasResults, + "panel": XasResultsPanel, "model": XasResultsModel, }, "workchain": workchain_and_builder, diff --git a/src/aiidalab_qe/plugins/xas/code.py b/src/aiidalab_qe/plugins/xas/code.py index 0f0164639..ff07fb8f9 100644 --- a/src/aiidalab_qe/plugins/xas/code.py +++ b/src/aiidalab_qe/plugins/xas/code.py @@ -1,10 +1,10 @@ """Panel for XAS plugin.""" from aiidalab_qe.common.code.model import CodeModel, PwCodeModel -from aiidalab_qe.common.panel import CodeSettingsModel, CodeSettingsPanel +from aiidalab_qe.common.panel import ResourceSettingsModel, ResourceSettingsPanel -class XasCodeModel(CodeSettingsModel): +class XasResourceSettingsModel(ResourceSettingsModel): """Model for the XAS plugin.""" codes = { @@ -21,6 +21,6 @@ class XasCodeModel(CodeSettingsModel): } -class XasCodeSettings(CodeSettingsPanel[XasCodeModel]): +class XasResourceSettingsPanel(ResourceSettingsPanel[XasResourceSettingsModel]): title = "XAS Structure" identifier = "xas" diff --git a/src/aiidalab_qe/plugins/xas/model.py b/src/aiidalab_qe/plugins/xas/model.py index 8dfb0f88e..1afdff0ca 100644 --- a/src/aiidalab_qe/plugins/xas/model.py +++ b/src/aiidalab_qe/plugins/xas/model.py @@ -9,11 +9,11 @@ from aiida import orm from aiidalab_qe.common.mixins import HasInputStructure -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel from aiidalab_qe.plugins import xas as xas_folder -class XasModel(SettingsModel, HasInputStructure): +class XasConfigurationSettingsModel(ConfigurationSettingsModel, HasInputStructure): dependencies = [ "input_structure", ] diff --git a/src/aiidalab_qe/plugins/xas/result/__init__.py b/src/aiidalab_qe/plugins/xas/result/__init__.py index d0c0fa06e..6c48b4a27 100644 --- a/src/aiidalab_qe/plugins/xas/result/__init__.py +++ b/src/aiidalab_qe/plugins/xas/result/__init__.py @@ -1,7 +1,7 @@ from .model import XasResultsModel -from .result import XasResults +from .result import XasResultsPanel __all__ = [ "XasResultsModel", - "XasResults", + "XasResultsPanel", ] diff --git a/src/aiidalab_qe/plugins/xas/result/result.py b/src/aiidalab_qe/plugins/xas/result/result.py index 75ffb406b..dc108e65f 100644 --- a/src/aiidalab_qe/plugins/xas/result/result.py +++ b/src/aiidalab_qe/plugins/xas/result/result.py @@ -10,7 +10,7 @@ from .utils import write_csv -class XasResults(ResultsPanel[XasResultsModel]): +class XasResultsPanel(ResultsPanel[XasResultsModel]): title = "XAS" identifier = "xas" workchain_labels = ["xas"] diff --git a/src/aiidalab_qe/plugins/xas/setting.py b/src/aiidalab_qe/plugins/xas/setting.py index f9f874717..79c93dae9 100644 --- a/src/aiidalab_qe/plugins/xas/setting.py +++ b/src/aiidalab_qe/plugins/xas/setting.py @@ -2,18 +2,20 @@ import ipywidgets as ipw -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel -from .model import XasModel +from .model import XasConfigurationSettingsModel -class XasSettings(SettingsPanel[XasModel]): +class XasConfigurationSettingsPanel( + ConfigurationSettingsPanel[XasConfigurationSettingsModel], +): title = "XAS" identifier = "xas" # TODO: The element selection should lock the "Confirm" button if no elements have been selected for XAS calculation. - def __init__(self, model: XasModel, **kwargs): + def __init__(self, model: XasConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( @@ -133,7 +135,7 @@ def update(self, specific=""): if self.updated: return self._show_loading() - if not self._model.loaded_from_process or specific and specific != "widgets": + if not self._model.loaded_from_process or (specific and specific != "widgets"): self._model.update(specific) self._build_core_hole_treatments_widget() self.updated = True diff --git a/src/aiidalab_qe/plugins/xps/__init__.py b/src/aiidalab_qe/plugins/xps/__init__.py index 6c4260ff7..31cd62324 100644 --- a/src/aiidalab_qe/plugins/xps/__init__.py +++ b/src/aiidalab_qe/plugins/xps/__init__.py @@ -1,23 +1,23 @@ -from aiidalab_qe.common.panel import SettingsOutline +from aiidalab_qe.common.panel import PluginOutline -from .model import XpsModel -from .result import XpsResults, XpsResultsModel -from .setting import XpsSettings +from .model import XpsConfigurationSettingsModel +from .result import XpsResultsModel, XpsResultsPanel +from .setting import XpsConfigurationSettingsPanel from .workchain import workchain_and_builder -class XpsOutline(SettingsOutline): +class XpsPluginOutline(PluginOutline): title = "X-ray photoelectron spectroscopy (XPS)" xps = { - "outline": XpsOutline, - "setting": { - "panel": XpsSettings, - "model": XpsModel, + "outline": XpsPluginOutline, + "configuration": { + "panel": XpsConfigurationSettingsPanel, + "model": XpsConfigurationSettingsModel, }, "result": { - "panel": XpsResults, + "panel": XpsResultsPanel, "model": XpsResultsModel, }, "workchain": workchain_and_builder, diff --git a/src/aiidalab_qe/plugins/xps/model.py b/src/aiidalab_qe/plugins/xps/model.py index f48686d58..a8e0540dc 100644 --- a/src/aiidalab_qe/plugins/xps/model.py +++ b/src/aiidalab_qe/plugins/xps/model.py @@ -3,12 +3,12 @@ from aiida.common import NotExistent from aiida.orm import Group, QueryBuilder, load_group from aiidalab_qe.common.mixins import HasInputStructure -from aiidalab_qe.common.panel import SettingsModel +from aiidalab_qe.common.panel import ConfigurationSettingsModel BASE_URL = "https://github.com/superstar54/xps-data/raw/main/pseudo_demo/" -class XpsModel(SettingsModel, HasInputStructure): +class XpsConfigurationSettingsModel(ConfigurationSettingsModel, HasInputStructure): dependencies = [ "input_structure", ] diff --git a/src/aiidalab_qe/plugins/xps/result/__init__.py b/src/aiidalab_qe/plugins/xps/result/__init__.py index 9d81a99ee..4c11f6dd0 100644 --- a/src/aiidalab_qe/plugins/xps/result/__init__.py +++ b/src/aiidalab_qe/plugins/xps/result/__init__.py @@ -1,7 +1,7 @@ from .model import XpsResultsModel -from .result import XpsResults +from .result import XpsResultsPanel __all__ = [ "XpsResultsModel", - "XpsResults", + "XpsResultsPanel", ] diff --git a/src/aiidalab_qe/plugins/xps/result/result.py b/src/aiidalab_qe/plugins/xps/result/result.py index 767c9bf99..bdd10b894 100644 --- a/src/aiidalab_qe/plugins/xps/result/result.py +++ b/src/aiidalab_qe/plugins/xps/result/result.py @@ -8,7 +8,7 @@ from .model import XpsResultsModel -class XpsResults(ResultsPanel[XpsResultsModel]): +class XpsResultsPanel(ResultsPanel[XpsResultsModel]): title = "XPS" identifier = "xps" workchain_labels = ["xps"] diff --git a/src/aiidalab_qe/plugins/xps/setting.py b/src/aiidalab_qe/plugins/xps/setting.py index c681c4da4..a0583a4c7 100644 --- a/src/aiidalab_qe/plugins/xps/setting.py +++ b/src/aiidalab_qe/plugins/xps/setting.py @@ -2,16 +2,18 @@ import ipywidgets as ipw -from aiidalab_qe.common.panel import SettingsPanel +from aiidalab_qe.common.panel import ConfigurationSettingsPanel -from .model import BASE_URL, XpsModel +from .model import BASE_URL, XpsConfigurationSettingsModel -class XpsSettings(SettingsPanel[XpsModel]): +class XpsConfigurationSettingsPanel( + ConfigurationSettingsPanel[XpsConfigurationSettingsModel], +): title = "XPS" identifier = "xps" - def __init__(self, model: XpsModel, **kwargs): + def __init__(self, model: XpsConfigurationSettingsModel, **kwargs): super().__init__(model, **kwargs) self._model.observe( @@ -130,7 +132,7 @@ def update(self, specific=""): if self.updated: return self._show_loading() - if not self._model.loaded_from_process or specific and specific != "widgets": + if not self._model.loaded_from_process or (specific and specific != "widgets"): self._model.update(specific) self._build_core_levels_widget() self.updated = True diff --git a/src/aiidalab_qe/workflows/__init__.py b/src/aiidalab_qe/workflows/__init__.py index dd2836913..95dde34d7 100644 --- a/src/aiidalab_qe/workflows/__init__.py +++ b/src/aiidalab_qe/workflows/__init__.py @@ -175,7 +175,6 @@ def get_builder_from_protocol( "base_final_scf": parameters["advanced"], } protocol = parameters["workchain"]["protocol"] - print("codes: ", codes["global"]["codes"].get("quantumespresso.pw")) relax_builder = PwRelaxWorkChain.get_builder_from_protocol( code=codes["global"]["codes"].get("quantumespresso.pw")["code"], structure=structure, diff --git a/tests/configuration/test_advanced.py b/tests/configuration/test_advanced.py index 13081f84a..2a1c0ca68 100644 --- a/tests/configuration/test_advanced.py +++ b/tests/configuration/test_advanced.py @@ -1,10 +1,13 @@ -from aiidalab_qe.app.configuration.advanced import AdvancedModel, AdvancedSettings +from aiidalab_qe.app.configuration.advanced import ( + AdvancedConfigurationSettingsModel, + AdvancedConfigurationSettingsPanel, +) def test_advanced_default(): """Test default behavior of advanced setting.""" - model = AdvancedModel() - _ = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + _ = AdvancedConfigurationSettingsPanel(model=model) smearing_model = model.get_model("smearing") # Test override functionality in advanced settings @@ -25,8 +28,8 @@ def test_advanced_default(): def test_advanced_smearing_settings(): """Test Smearing Settings.""" - model = AdvancedModel() - advanced = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + advanced = AdvancedConfigurationSettingsPanel(model=model) advanced.render() smearing_model = model.get_model("smearing") @@ -59,8 +62,8 @@ def test_advanced_smearing_settings(): def test_advanced_kpoints_settings(): """Test kpoints setting of advanced setting widget.""" - model = AdvancedModel() - advanced = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + advanced = AdvancedConfigurationSettingsPanel(model=model) advanced.render() # Check the disable of is bind to override switch @@ -84,8 +87,8 @@ def test_advanced_kpoints_settings(): def test_advanced_molecule_settings(generate_structure_data): """Test kpoints setting of advanced setting widget.""" - model = AdvancedModel() - advanced = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + advanced = AdvancedConfigurationSettingsPanel(model=model) advanced.render() model.override = True @@ -114,8 +117,8 @@ def test_advanced_molecule_settings(generate_structure_data): def test_advanced_tot_charge_settings(): """Test TotCharge widget.""" - model = AdvancedModel() - advanced = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + advanced = AdvancedConfigurationSettingsPanel(model=model) advanced.render() # Check the disable of is bind to override switch @@ -135,8 +138,8 @@ def test_advanced_tot_charge_settings(): def test_advanced_kpoints_mesh(generate_structure_data): """Test Mesh Grid HTML widget.""" - model = AdvancedModel() - _ = AdvancedSettings(model=model) + model = AdvancedConfigurationSettingsModel() + _ = AdvancedConfigurationSettingsPanel(model=model) structure = generate_structure_data(name="silicon") model.input_structure = structure @@ -152,12 +155,12 @@ def test_advanced_kpoints_mesh(generate_structure_data): def test_advanced_hubbard_settings(generate_structure_data): """Test Hubbard widget.""" from aiidalab_qe.app.configuration.advanced.hubbard import ( - HubbardModel, - HubbardSettings, + HubbardConfigurationSettingsModel, + HubbardConfigurationSettingsPanel, ) - model = HubbardModel() - hubbard = HubbardSettings(model=model) + model = HubbardConfigurationSettingsModel() + hubbard = HubbardConfigurationSettingsPanel(model=model) hubbard.render() structure = generate_structure_data(name="LiCoO2") diff --git a/tests/conftest.py b/tests/conftest.py index 094a6ccb4..bacfeb26c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,6 @@ import pytest from aiida import orm -from aiidalab_qe.app.configuration.model import ConfigurationStepModel from aiidalab_qe.app.main import App from aiidalab_qe.setup.pseudos import PSEUDODOJO_VERSION, SSSP_VERSION @@ -386,11 +385,14 @@ def projwfc_bands_code(aiida_local_code_factory): @pytest.fixture() def workchain_settings_generator(): """Return a function that generates a workchain settings dictionary.""" - from aiidalab_qe.app.configuration.basic.workflow import BasicSettings + from aiidalab_qe.app.configuration.basic.workflow import ( + BasicConfigurationSettingsModel, + BasicConfigurationSettingsPanel, + ) def _workchain_settings_generator(**kwargs): - model = ConfigurationStepModel() - workchain_settings = BasicSettings(config_model=model) + model = BasicConfigurationSettingsModel() + workchain_settings = BasicConfigurationSettingsPanel(model=model) workchain_settings._update_settings(**kwargs) return workchain_settings @@ -400,11 +402,14 @@ def _workchain_settings_generator(**kwargs): @pytest.fixture() def smearing_settings_generator(): """Return a function that generates a smearing settings dictionary.""" - from aiidalab_qe.app.configuration.advanced.smearing import SmearingSettings + from aiidalab_qe.app.configuration.advanced.smearing import ( + SmearingConfigurationSettingsModel, + SmearingConfigurationSettingsPanel, + ) def _smearing_settings_generator(**kwargs): - model = ConfigurationStepModel() - smearing_settings = SmearingSettings(model=model) + model = SmearingConfigurationSettingsModel() + smearing_settings = SmearingConfigurationSettingsPanel(model=model) smearing_settings.update_settings(**kwargs) return smearing_settings diff --git a/tests/test_panel.py b/tests/test_panel.py index b4216438e..a2a2d9193 100644 --- a/tests/test_panel.py +++ b/tests/test_panel.py @@ -1,8 +1,8 @@ def test_panel_outline(): """Test PanelOutline class.""" - from aiidalab_qe.common.panel import SettingsOutline + from aiidalab_qe.common.panel import PluginOutline - outline = SettingsOutline() + outline = PluginOutline() assert not outline.include.value outline.include.value = True assert outline.include.value diff --git a/tests/test_plugins_bands.py b/tests/test_plugins_bands.py index 15e038e65..10d9bf902 100644 --- a/tests/test_plugins_bands.py +++ b/tests/test_plugins_bands.py @@ -2,12 +2,12 @@ def test_result(generate_qeapp_workchain): import plotly.graph_objects as go from aiidalab_qe.common.bands_pdos import BandsPdosWidget - from aiidalab_qe.plugins.bands.result import BandsResults, BandsResultsModel + from aiidalab_qe.plugins.bands.result import BandsResultsModel, BandsResultsPanel workchain = generate_qeapp_workchain() model = BandsResultsModel() model.process_uuid = workchain.node.uuid - result = BandsResults(model=model) + result = BandsResultsPanel(model=model) result.render() widget = result.children[0] diff --git a/tests/test_plugins_electronic_structure.py b/tests/test_plugins_electronic_structure.py index 307edcb43..93cc910fb 100644 --- a/tests/test_plugins_electronic_structure.py +++ b/tests/test_plugins_electronic_structure.py @@ -3,14 +3,14 @@ def test_electronic_structure(generate_qeapp_workchain): from aiidalab_qe.common.bands_pdos import BandsPdosWidget from aiidalab_qe.plugins.electronic_structure.result import ( - ElectronicStructureResults, ElectronicStructureResultsModel, + ElectronicStructureResultsPanel, ) workchain = generate_qeapp_workchain() model = ElectronicStructureResultsModel() model.process_uuid = workchain.node.uuid - result = ElectronicStructureResults(model=model) + result = ElectronicStructureResultsPanel(model=model) result.render() widget = result.children[0] diff --git a/tests/test_plugins_pdos.py b/tests/test_plugins_pdos.py index 574c4a591..f2e0c79da 100644 --- a/tests/test_plugins_pdos.py +++ b/tests/test_plugins_pdos.py @@ -2,12 +2,12 @@ def test_result(generate_qeapp_workchain): import plotly.graph_objects as go from aiidalab_qe.common.bands_pdos import BandsPdosWidget - from aiidalab_qe.plugins.pdos.result import PdosResults, PdosResultsModel + from aiidalab_qe.plugins.pdos.result import PdosResultsModel, PdosResultsPanel workchain = generate_qeapp_workchain() model = PdosResultsModel() model.process_uuid = workchain.node.uuid - result = PdosResults(model=model) + result = PdosResultsPanel(model=model) result.render() widget = result.children[0] diff --git a/tests/test_pseudo.py b/tests/test_pseudo.py index 166fcecbf..e71830960 100644 --- a/tests/test_pseudo.py +++ b/tests/test_pseudo.py @@ -144,12 +144,12 @@ def test_download_and_install_pseudo_from_file(tmp_path): def test_pseudos_settings(generate_structure_data, generate_upf_data): from aiidalab_qe.app.configuration.advanced.pseudos import ( - PseudoSettings, - PseudosModel, + PseudosConfigurationSettingsModel, + PseudosConfigurationSettingsPanel, ) - model = PseudosModel() - pseudos = PseudoSettings(model=model) + model = PseudosConfigurationSettingsModel() + pseudos = PseudosConfigurationSettingsPanel(model=model) assert model.override is False diff --git a/tests/test_result.py b/tests/test_result.py index 0fd4c6796..101670675 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -1,7 +1,7 @@ from bs4 import BeautifulSoup from aiidalab_qe.app.main import App -from aiidalab_qe.app.result.summary import WorkChainSummaryModel +from aiidalab_qe.app.result.summary import WorkChainSummaryResultsModel from aiidalab_qe.app.result.viewer import WorkChainViewer, WorkChainViewerModel @@ -42,7 +42,7 @@ def test_workchainview(generate_qeapp_workchain): def test_summary_report(data_regression, generate_qeapp_workchain): """Test the summary report can be properly generated.""" workchain = generate_qeapp_workchain() - model = WorkChainSummaryModel() + model = WorkChainSummaryResultsModel() model.process_uuid = workchain.node.uuid report_parameters = model._generate_report_parameters() data_regression.check(report_parameters) @@ -53,7 +53,7 @@ def test_summary_report_advanced_settings(data_regression, generate_qeapp_workch workchain = generate_qeapp_workchain( spin_type="collinear", electronic_type="metal", initial_magnetic_moments=0.1 ) - model = WorkChainSummaryModel() + model = WorkChainSummaryResultsModel() model.process_uuid = workchain.node.uuid report_parameters = model._generate_report_parameters() assert report_parameters["initial_magnetic_moments"]["Si"] == 0.1 @@ -62,7 +62,7 @@ def test_summary_report_advanced_settings(data_regression, generate_qeapp_workch def test_summary_view(generate_qeapp_workchain): """Test the report html can be properly generated.""" workchain = generate_qeapp_workchain() - model = WorkChainSummaryModel() + model = WorkChainSummaryResultsModel() model.process_uuid = workchain.node.uuid report_html = model.generate_report_html() parsed = BeautifulSoup(report_html, "html.parser")