Skip to content

Commit

Permalink
add label and description for the job (#670)
Browse files Browse the repository at this point in the history
This PR supports users in labeling their jobs and providing a brief description. These details help identify the job later and make the search process easier. The placeholder for the label is generated based on the job. The description is default empty.
  • Loading branch information
superstar54 authored Apr 23, 2024
1 parent 5cc3952 commit 26889ea
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class SubmitQeAppWorkChainStep(ipw.VBox, WizardAppWidgetStep):
configure new ones on potentially more powerful machines by clicking on
"Setup new code".</div>"""
)
process_label_help = ipw.HTML(
"""<div style="padding-top: 0px; padding-bottom: 0px">
<h4>Labeling Your Job</h4>
<p style="line-height: 140%; padding-top: 0px; padding-bottom:
10px"> Label your job and provide a brief description. These details help identify the job later and make the search process easier. While optional, adding a description is recommended for better clarity.</p>
</div>"""
)

# This number provides a rough estimate for how many MPI tasks are needed
# for a given structure.
Expand Down Expand Up @@ -89,6 +96,13 @@ def __init__(self, qe_auto_setup=True, **kwargs):
self.code_children.append(self.codes[name])
# set default codes
self.set_selected_codes(DEFAULT_PARAMETERS["codes"])
# set process label and description
self.process_label = ipw.Text(
description="Label:", layout=ipw.Layout(width="auto", indent="0px")
)
self.process_description = ipw.Textarea(
description="Description", layout=ipw.Layout(width="auto", indent="0px")
)
#
self.submit_button = ipw.Button(
description="Submit",
Expand Down Expand Up @@ -130,6 +144,9 @@ def __init__(self, qe_auto_setup=True, **kwargs):
self.sssp_installation_status,
self.qe_setup_status,
self._submission_blocker_messages,
self.process_label_help,
self.process_label,
self.process_description,
self.submit_button,
]
)
Expand Down Expand Up @@ -313,6 +330,7 @@ def _observe_state(self, change):
def _observe_input_structure(self, _):
self._update_state()
self.update_codes_display()
self._update_process_label()

@tl.observe("process")
def _observe_process(self, change):
Expand Down Expand Up @@ -376,16 +394,21 @@ def submit(self, _=None):
with self.hold_trait_notifications():
process = submit(builder)

process.label = self._generate_label()
process.label = self.process_label.value
process.description = self.process_description.value
# since AiiDA data node may exist in the ui_parameters,
# we serialize it to yaml
process.base.extras.set("ui_parameters", serialize(self.ui_parameters))
# store the workchain name in extras, this will help to filter the workchain in the future
process.base.extras.set("workchain", self.ui_parameters["workchain"])
self.process = process

self._update_state()

def _generate_label(self) -> dict:
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()
properties = [
p for p in self.input_parameters["workchain"]["properties"] if p != "realx"
Expand All @@ -398,10 +421,10 @@ def _generate_label(self) -> dict:
if not properties:
properties_info = ""
else:
properties_info = f"properties on {', '.join(properties)}"
properties_info = f", properties on {', '.join(properties)}"

label = "{} {} {}".format(formula, relax_info, properties_info)
return label
self.process_label.value = label

def _create_builder(self) -> ProcessBuilderNamespace:
"""Create the builder for the `QeAppWorkChain` submit."""
Expand Down Expand Up @@ -449,6 +472,10 @@ def _update_builder(self, buildy, max_mpi_per_pool):
def set_submission_parameters(self, parameters):
self.set_resources(parameters["resources"])
self.set_selected_codes(parameters["codes"])
# label and description are not stored in the parameters, but in the process directly
if self.process:
self.process_label.value = self.process.label
self.process_description.value = self.process.description

def get_submission_parameters(self):
"""Get the parameters for the submission step."""
Expand Down

0 comments on commit 26889ea

Please sign in to comment.