Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/process labels #836

Merged
merged 7 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,33 @@ def _update_process_label(self) -> dict:
"""Generate a label for the work chain based on the input parameters."""
if not self.input_structure:
return ""
formula = self.input_structure.get_formula()
structure_label = (
self.input_structure.label
if len(self.input_structure.label) > 0
else self.input_structure.get_formula()
)
workchain_data = self.input_parameters.get("workchain", {"properties": []})
properties = [p for p in workchain_data["properties"] if p != "relax"]
# relax_info
relax_type = workchain_data.get("relax_type", "none")
relax_info = "relax: none"
if relax_type != "none":
relax_info = "structure is relaxed"
else:
relax_info = "structure is not relaxed"
if not properties:
properties_info = ""
else:
properties_info = f", properties on {', '.join(properties)}"

label = f"{formula} {relax_info} {properties_info}"
relax_info = (
relax_info.replace("none", "atoms+cell")
if "cell" in relax_type
else relax_info.replace("none", "atoms only")
)
# protocol_info
protocol_and_magnetic_info = f"{workchain_data['protocol']} protocol"
# magnetic_info
if workchain_data["spin_type"] != "none":
protocol_and_magnetic_info += ", magnetic"
# properties_info
properties_info = ""
if properties:
properties_info = f"→ {', '.join(properties)}"

label = f"{structure_label} [{relax_info}, {protocol_and_magnetic_info}] {properties_info}".strip()
self.process_label.value = label

def _create_builder(self) -> ProcessBuilderNamespace:
Expand Down
29 changes: 29 additions & 0 deletions tests/test_submit_qe_workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ def test_create_builder_default(
# In the future, we will check the builder parameters using regresion test


@pytest.mark.usefixtures("sssp")
def test_create_process_label(
submit_app_generator,
):
""" "Test the creation of the correct process label"""

app = submit_app_generator(properties=["bands", "pdos"])
submit_step = app.submit_step
submit_step._update_process_label()
assert (
submit_step.process_label.value
== "Si2 [relax: atoms+cell, moderate protocol] → bands, pdos"
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add an extra test , where the structure has a label ?

# suppose we change the label of the structure:
submit_step.input_structure.label = "Si2, unit cell"
submit_step._update_process_label()
assert (
submit_step.process_label.value
== "Si2, unit cell [relax: atoms+cell, moderate protocol] → bands, pdos"
)
# suppose by mistake we provide an empty label, we then fallback to use the formula:
submit_step.input_structure.label = ""
submit_step._update_process_label()
assert (
submit_step.process_label.value
== "Si2 [relax: atoms+cell, moderate protocol] → bands, pdos"
)


@pytest.mark.usefixtures("sssp")
def test_create_builder_insulator(
submit_app_generator,
Expand Down
Loading