Skip to content

Commit

Permalink
Clean up panel classes (#1014)
Browse files Browse the repository at this point in the history
This PR addresses preliminary modifications in the panel module required by follow-up PRs.
  • Loading branch information
edan-bainglass authored Dec 24, 2024
1 parent acf4fdb commit 987791c
Show file tree
Hide file tree
Showing 41 changed files with 104 additions and 139 deletions.
9 changes: 3 additions & 6 deletions src/aiidalab_qe/app/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _update_tabs(self):
for identifier, model in self._model.get_models():
if model.include:
settings = self.settings[identifier]
titles.append(settings.title)
titles.append(model.title)
children.append(settings)
if self.rendered:
self.tabs.selected_index = None
Expand All @@ -245,7 +245,6 @@ def _fetch_plugin_calculation_settings(self):
if key not in configuration:
raise ValueError(f"Entry {identifier} is missing the '{key}' key")

panel = configuration["panel"]
model: ConfigurationSettingsModel = configuration["model"]()
self._model.add_model(identifier, model)

Expand Down Expand Up @@ -287,7 +286,5 @@ def toggle_plugin(change, identifier=identifier, model=model, info=info):
)
)

self.settings[identifier] = panel(
identifier=identifier,
model=model,
)
panel: ConfigurationSettingsPanel = configuration["panel"](model=model)
self.settings[identifier] = panel
3 changes: 0 additions & 3 deletions src/aiidalab_qe/app/configuration/advanced/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
class AdvancedConfigurationSettingsPanel(
ConfigurationSettingsPanel[AdvancedConfigurationSettingsModel],
):
title = "Advanced Settings"
identifier = "advanced"

def __init__(self, model: AdvancedConfigurationSettingsModel, **kwargs):
super().__init__(
model=model,
Expand Down
2 changes: 0 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
class HubbardConfigurationSettingsPanel(
AdvancedConfigurationSubSettingsPanel[HubbardConfigurationSettingsModel],
):
identifier = "hubbard"

def __init__(self, model: HubbardConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)

Expand Down
2 changes: 2 additions & 0 deletions src/aiidalab_qe/app/configuration/advanced/hubbard/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class HubbardConfigurationSettingsModel(
AdvancedCalculationSubSettingsModel,
HasInputStructure,
):
identifier = "hubbard"

dependencies = [
"input_structure",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class MagnetizationConfigurationSettingsPanel(
input_structure(StructureData): trait that contains the input_structure (confirmed structure from previous step)
"""

identifier = "magnetization"

def __init__(self, model: MagnetizationConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class MagnetizationConfigurationSettingsModel(
AdvancedCalculationSubSettingsModel,
HasInputStructure,
):
identifier = "magnetization"

dependencies = [
"input_structure",
"electronic_type",
Expand Down
3 changes: 3 additions & 0 deletions src/aiidalab_qe/app/configuration/advanced/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class AdvancedConfigurationSettingsModel(
HasModels[AdvancedCalculationSubSettingsModel],
HasInputStructure,
):
title = "Advanced Settings"
identifier = "advanced"

dependencies = [
"input_structure",
"workchain.protocol",
Expand Down
2 changes: 2 additions & 0 deletions src/aiidalab_qe/app/configuration/advanced/pseudos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class PseudosConfigurationSettingsModel(
AdvancedCalculationSubSettingsModel,
HasInputStructure,
):
identifier = "pseudos"

dependencies = [
"input_structure",
"protocol",
Expand Down
2 changes: 0 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/pseudos/pseudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
class PseudosConfigurationSettingsPanel(
AdvancedConfigurationSubSettingsPanel[PseudosConfigurationSettingsModel],
):
identifier = "pseudos"

def __init__(self, model: PseudosConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)

Expand Down
2 changes: 2 additions & 0 deletions src/aiidalab_qe/app/configuration/advanced/smearing/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@


class SmearingConfigurationSettingsModel(AdvancedCalculationSubSettingsModel):
identifier = "smearing"

dependencies = [
"protocol",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
class SmearingConfigurationSettingsPanel(
AdvancedConfigurationSubSettingsPanel[SmearingConfigurationSettingsModel],
):
identifier = "smearing"

def __init__(self, model: SmearingConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)

Expand Down
3 changes: 3 additions & 0 deletions src/aiidalab_qe/app/configuration/basic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@


class BasicConfigurationSettingsModel(ConfigurationSettingsModel):
title = "Basic Settings"
identifier = "workchain"

dependencies = [
"input_structure",
]
Expand Down
3 changes: 0 additions & 3 deletions src/aiidalab_qe/app/configuration/basic/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
class BasicConfigurationSettingsPanel(
ConfigurationSettingsPanel[BasicConfigurationSettingsModel],
):
title = "Basic Settings"
identifier = "workchain"

def __init__(self, model: BasicConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)
self._model.observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


class StructureResultsModel(ResultsModel):
title = "Structure"
identifier = "structure"

_this_process_label = "PwRelaxWorkChain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@


class StructureResults(ResultsPanel[StructureResultsModel]):
title = "Final Geometry"
identifier = "structure"

def _render(self):
if not hasattr(self, "widget"):
self.widget = StructureDataViewer(structure=self._model.outputs.structure)
Expand Down
9 changes: 6 additions & 3 deletions src/aiidalab_qe/app/result/components/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ def _update_panels(self):
def _set_tabs(self):
children = []
titles = []
for results in self.panels.values():
titles.append(results.title)
for identifier, model in self._model.get_models():
if identifier not in self.panels:
continue
results = self.panels[identifier]
titles.append(model.title)
children.append(results)
self.tabs.children = children
for i, title in enumerate(titles):
Expand All @@ -80,7 +83,7 @@ def _add_structure_panel(self):
structure_model = StructureResultsModel()
structure_model.process_uuid = self._model.process_uuid
self.structure_results = StructureResults(model=structure_model)
identifier = self.structure_results.identifier
identifier = structure_model.identifier
self._model.add_model(identifier, structure_model)
self.panels = {
identifier: self.structure_results,
Expand Down
15 changes: 8 additions & 7 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from aiidalab_qe.common.code import PluginCodes, PwCodeModel
from aiidalab_qe.common.infobox import InAppGuide
from aiidalab_qe.common.mixins import DependentStep
from aiidalab_qe.common.panel import PluginResourceSettingsModel, ResourceSettingsPanel
from aiidalab_qe.common.panel import (
PluginResourceSettingsModel,
PluginResourceSettingsPanel,
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 @@ -310,7 +314,7 @@ def _update_tabs(self):
for identifier, model in self._model.get_models():
if model.include:
settings = self.settings[identifier]
titles.append(settings.title)
titles.append(model.title)
children.append(settings)
if self.rendered:
self.tabs.selected_index = None
Expand Down Expand Up @@ -343,7 +347,6 @@ def _fetch_plugin_resource_settings(self):
if key not in resources:
raise ValueError(f"Entry {identifier} is missing the '{key}' key")

panel = resources["panel"]
model: PluginResourceSettingsModel = resources["model"]()
model.observe(
self._on_plugin_overrides_change,
Expand All @@ -359,10 +362,8 @@ def _fetch_plugin_resource_settings(self):
)
self._model.add_model(identifier, model)

self.settings[identifier] = panel(
identifier=identifier,
model=model,
)
panel: PluginResourceSettingsPanel = resources["panel"](model=model)
self.settings[identifier] = panel

codes[identifier] = dict(model.get_models())

Expand Down
1 change: 1 addition & 0 deletions src/aiidalab_qe/app/submission/global_settings/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class GlobalResourceSettingsModel(
):
"""Model for the global code setting."""

title = "Global resources"
identifier = "global"

dependencies = [
Expand Down
3 changes: 0 additions & 3 deletions src/aiidalab_qe/app/submission/global_settings/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@


class GlobalResourceSettingsPanel(ResourceSettingsPanel[GlobalResourceSettingsModel]):
title = "Global resources"
identifier = "global"

def __init__(self, model: GlobalResourceSettingsModel, **kwargs):
super().__init__(model, **kwargs)

Expand Down
Loading

0 comments on commit 987791c

Please sign in to comment.