Skip to content

Commit

Permalink
Redesign summary view
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Dec 29, 2024
1 parent 80655e4 commit 69de3fa
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/result/components/summary/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def generate_report_html(self):
from aiidalab_qe.app.static import styles, templates

def _fmt_yes_no(truthy):
return "Yes" if truthy else "No"
return "yes" if truthy else "no"

env = Environment()
env.filters.update(
Expand Down
38 changes: 35 additions & 3 deletions src/aiidalab_qe/app/result/components/summary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,44 @@ def _render(self):
def _render_summary(self):
if not self._model.has_process:
return
report = self._model.generate_report_html()
self.children = [ipw.HTML(report)]

settings_summary = ipw.HTML(
value=self._model.generate_report_html(),
)
settings_summary.add_class("summary-panel")

self.output_download_container = ipw.VBox(
children=[
ipw.HTML("""
<div style="line-height: 140%; margin: 0; margin-bottom: 10px;">
<h2>Download the data</h2>
Once the workflow is finished, you can download raw data
(i.e. input and output files) and/or the AiiDA archive
(ready to be shared or imported into another AiiDA profile).
</div>
"""),
ipw.HTML("Download buttons will appear here when available."),
],
)
self.output_download_container.add_class("summary-panel")

self.container = ipw.HBox(
children=[
settings_summary,
self.output_download_container,
],
)
self.container.add_class("workflow-summary-container")
self.children = [self.container]
self.has_report = True

def _render_output(self):
process_node = self._model.fetch_process_node()
if process_node and process_node.is_terminated:
self.children += (WorkChainOutputs(node=process_node),)
output_download_widget = WorkChainOutputs(node=process_node)
output_download_widget.layout.width = "100%"
self.output_download_container.children = [
self.output_download_container.children[0], # type: ignore
output_download_widget,
]
self.has_output = True
44 changes: 44 additions & 0 deletions src/aiidalab_qe/app/static/styles/summary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.workflow-summary-container {
width: 75%;
margin: 0 auto;
gap: 10px;
}

@media (max-width: 1199px) {
.workflow-summary-container {
width: 92%;
}
}

@media (max-width: 991px) {
.workflow-summary-container {
width: 100%;
}
}

.summary-panel {
width: 100%;
border: 1px solid #9e9e9e;
padding: 0 20px 10px;
margin: 0;
}

.settings-summary {
margin: 2px;
font-family: Arial, sans-serif;
line-height: 1.6;
}

.settings-summary ul {
list-style-type: none;
padding: 0;
margin: 0;
}

.settings-summary ul ul {
margin-left: 20px;
}

.settings-summary a {
text-decoration: none;
}
188 changes: 79 additions & 109 deletions src/aiidalab_qe/app/static/templates/workflow_summary.jinja
Original file line number Diff line number Diff line change
@@ -1,130 +1,100 @@
<body>

<div class="row">
<div class="column">
<h3>Standard settings</h3>
<table>
<tr>
<td>Structure geometry optimized</td>
<td>{{ relaxed | fmt_yes_no }}</td>
</tr>
<div class="settings-summary">
<h2>Main settings</h2>
<ul>
<li>
<strong>Structure geometry optimized:</strong> {{ relaxed | fmt_yes_no }}
</li>
{% if relaxed %}
<tr>
<td>Optimization method</td>
<td>{{ relax_method }}</td>
</tr>
<li>
<strong>Optimization method:</strong> {{ relax_method }}
</li>
{% endif %}
<tr>
<td>Protocol</td>
<td>{{ protocol }}</td>
</tr>
<tr>
<td>Magnetism</td>
<td>{{ material_magnetic }}</td>
</tr>
<tr>
<td>Electronic type</td>
<td>{{ electronic_type }}</td>
</tr>
<tr>
<td>Periodicity</td>
<td>{{ periodicity }}</td>
</tr>
<li>
<strong>Protocol:</strong> {{ protocol }}
</li>
<li>
<strong>Magnetism:</strong> {{ material_magnetic }}
</li>
<li>
<strong>Electronic type:</strong> {{ electronic_type }}
</li>
<li>
<strong>Periodicity:</strong> {{ periodicity }}
</li>
</ul>

</table>
</div>
<div class="column">
<h3>Advanced settings</h3>
<table>
<tr>
<td>Functional</td>
<td>
<a href="{{ functional_link }}" target="_blank">
{{ functional }}
</a>
</td>
</tr>
<tr>
<td>Pseudopotential library</td>
<td>
<a href="{{ pseudo_link }}" target="_blank">
{{ pseudo_library }} {{ pseudo_protocol }} v{{ pseudo_version }}
</a>
</td>
</tr>
<tr>
<td>Energy cutoff (wave functions)</td>
<td>{{ energy_cutoff_wfc }} Ry</td>
</tr>
<tr>
<td>Energy cutoff (charge density)</td>
<td>{{ energy_cutoff_rho }} Ry</td>
</tr>
<tr>
<td>Occupation type (SCF)</td>
<td>{{ occupation_type }}</td>
</tr>
<h2>Advanced settings</h2>
<ul>
<li>
<strong>Functional:</strong>
<a href="{{ functional_link }}" target="_blank">{{ functional }}</a>
</li>
<li>
<strong>Pseudopotential library:</strong>
<a href="{{ pseudo_link }}" target="_blank">{{ pseudo_library }} {{ pseudo_protocol }} v{{ pseudo_version }}</a>
</li>
<li>
<strong>Energy cutoff (wave functions):</strong> {{ energy_cutoff_wfc }} Ry
</li>
<li>
<strong>Energy cutoff (charge density):</strong> {{ energy_cutoff_rho }} Ry
</li>
<li>
<strong>Occupation type (SCF):</strong> {{ occupation_type }}
</li>
{% if occupation_type == "smearing" %}
<tr>
<td>Smearing width (degauss)</td>
<td>{{ degauss }} Ry</td>
</tr>
<tr>
<td>Smearing type</td>
<td>{{ smearing }}</td>
</tr>
<ul>
<li>
<strong>Smearing width (degauss):</strong> {{ degauss }} Ry
</li>
<li>
<strong>Smearing type:</strong> {{ smearing }}
</li>
</ul>
{% endif %}
<tr>
<td>K-point mesh distance (SCF)</td>
<td>{{ scf_kpoints_distance }} &#8491;<sup>-1</sup></td>
</tr>
<li>
<strong>K-point mesh distance (SCF):</strong> {{ scf_kpoints_distance }} &#8491;<sup>-1</sup>
</li>
{% if bands_computed %}
<tr>
<td>K-point line distance (Bands)</td>
<td>{{ bands_kpoints_distance }} &#8491;<sup>-1</sup></td>
</tr>
<li>
<strong>K-point line distance (Bands):</strong> {{ bands_kpoints_distance }} &#8491;<sup>-1</sup>
</li>
{% endif %}
{% if pdos_computed %}
<tr>
<td>K-point mesh distance (NSCF)</td>
<td>{{ nscf_kpoints_distance }} &#8491;<sup>-1</sup></td>
</tr>
<li>
<strong>K-point mesh distance (NSCF):</strong> {{ nscf_kpoints_distance }} &#8491;<sup>-1</sup>
</li>
{% endif %}
<tr>
<td>Total charge</td>
<td>{{ tot_charge }}</td>
</tr>
<tr>
<td>Van der Waals correction</td>
<td>{{ vdw_corr }}</td>
</tr>

<li>
<strong>Total charge:</strong> {{ tot_charge }}
</li>
<li>
<strong>Van der Waals correction:</strong> {{ vdw_corr }}
</li>
{% if material_magnetic == "collinear" %}
{% if tot_magnetization %}
<tr>
<td>Total magnetization</td>
<td>{{ tot_magnetization }} </td>
</tr>
<li>
<strong>Total magnetization:</strong> {{ tot_magnetization }}
</li>
{% else %}
<tr>
<td>Initial magnetic moments</td>
<td>{{ initial_magnetic_moments }}</td>
</tr>
<li>
<strong>Initial magnetic moments:</strong> {{ initial_magnetic_moments }}
</li>
{% endif %}
{% endif %}
{% if hubbard_u %}
<tr>
<td>DFT+U</td>
<td>{{ hubbard_u }}</td>
</tr>
<li>
<strong>DFT+U:</strong> {{ hubbard_u }}
</li>
{% endif %}
{% if spin_orbit %}
<tr>
<td>Spin-orbit coupling</td>
<td>{{ spin_orbit }}</td>
</tr>
<li>
<strong>Spin-orbit coupling:</strong> {{ spin_orbit }}
</li>
{% endif %}

</table>
</ul>
</div>
</div>

</body>
6 changes: 2 additions & 4 deletions tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,13 @@ def test_summary_view(generate_qeapp_workchain):
model.process_uuid = workchain.node.uuid
report_html = model.generate_report_html()
parsed = BeautifulSoup(report_html, "html.parser")
# find the td with the text "Initial Magnetic Moments"
parameters = {
"Energy cutoff (wave functions)": "30.0 Ry",
"Total charge": "0.0",
"Initial magnetic moments": "",
}
for key, value in parameters.items():
td = parsed.find("td", text=key).find_next_sibling("td")
assert td.text == value
li = parsed.find_all(lambda tag, key=key: tag.name == "li" and key in tag.text)
assert value in li[0].text


def test_structure_results_panel(generate_qeapp_workchain):
Expand Down

0 comments on commit 69de3fa

Please sign in to comment.