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

add label and description for the job #670

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Changes from all 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
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
Loading