Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 13, 2025
1 parent 2faebaf commit c47bdf1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
43 changes: 17 additions & 26 deletions src/aiidalab_qe/app/result/components/status/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,27 @@ def _collapse_all(self, _):


class ProcessTreeNode(ipw.VBox, t.Generic[ProcessNodeType]):
_MAPPING = {
_TITLE_MAPPING = {
"QeAppWorkChain": "Quantum ESPRESSO app workflow",
"BandsWorkChain": "Electronic band structure workflow",
"PwBandsWorkChain": "Electronic band structure workflow",
"ProjwfcBandsWorkChain": "Electronic band structure workflow",
"PwRelaxWorkChain": "Structure relaxation workflow",
"PdosWorkChain": "Projected density of states workflow",
"DosCalculation": "Compute density of states",
"ProjwfcCalculation": "Compute projections",
"XpsWorkChain": "X-ray photoelectron spectroscopy workflow",
"XspectraCrystalWorkChain": "X-ray absorption spectroscopy workflow",
}

_PW_MAPPING = {
"scf": {
"PwBaseWorkChain": "SCF workflow",
"PwCalculation": "Run SCF cycle",
},
"nscf": {
"PwBaseWorkChain": "NSCF workflow",
"PwCalculation": "Run NSCF cycle",
"PwBaseWorkChain": {
"scf": "SCF workflow",
"nscf": "NSCF workflow",
"bands": "Bands workflow",
"relax": "Structure relaxation workflow",
},
"bands": {
"PwBaseWorkChain": "Bands workflow",
"PwCalculation": "Compute bands",
},
"relax": {
"PwBaseWorkChain": "Structure relaxation workflow",
"PwCalculation": "Optimize structure geometry",
"PwCalculation": {
"scf": "Run SCF cycle",
"nscf": "Run NSCF cycle",
"bands": "Compute bands",
"relax": "Optimize structure geometry",
},
"DosCalculation": "Compute density of states",
"ProjwfcCalculation": "Compute projections",
}

def __init__(
Expand Down Expand Up @@ -192,10 +185,8 @@ def _get_human_readable_title(self):
if label in ("PwBaseWorkChain", "PwCalculation"):
inputs = node.inputs.pw if label == "PwBaseWorkChain" else node.inputs
calculation: str = inputs.parameters.get_dict()["CONTROL"]["calculation"]
mapping = self._PW_MAPPING[calculation]
else:
mapping = self._MAPPING
return mapping.get(label, label)
return self._TITLE_MAPPING.get(label, {}).get(calculation, label)
return self._TITLE_MAPPING.get(label, label)


class ProcessTreeBranches(ipw.VBox):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_render(self):
def test_update_on_process_change(self, mock_qeapp_workchain):
self.model.process_uuid = mock_qeapp_workchain.uuid
assert self.tree.rendered
human_label = ProcessTreeNode._MAPPING["QeAppWorkChain"]
human_label = ProcessTreeNode._TITLE_MAPPING["QeAppWorkChain"]
assert self.tree.trunk.label.value == human_label
assert not self.tree.trunk.collapsed
assert len(self.tree.trunk.branches) == 1
Expand All @@ -146,7 +146,7 @@ def test_workchain_node(self):
assert workchain_node.level == 1
assert workchain_node.emoji.value == "✅"
assert workchain_node.state.value == "finished"
human_label = ProcessTreeNode._PW_MAPPING["relax"]["PwBaseWorkChain"]
human_label = ProcessTreeNode._TITLE_MAPPING["PwBaseWorkChain"]["relax"]
assert workchain_node.label.value == human_label
assert isinstance(workchain_node.label, ipw.HTML)
assert workchain_node.collapsed
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_calculation_node(self):
assert calculation_node.level == 2
assert calculation_node.emoji.value == "✅"
assert calculation_node.state.value == "finished"
human_label = ProcessTreeNode._PW_MAPPING["relax"]["PwCalculation"]
human_label = ProcessTreeNode._TITLE_MAPPING["PwCalculation"]["relax"]
assert isinstance(calculation_node.label, ipw.Button)
assert calculation_node.label.description == human_label

Expand Down

0 comments on commit c47bdf1

Please sign in to comment.