Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, model: ConfigurationStepModel, **kwargs):

self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)

self.settings = {
Expand Down Expand Up @@ -254,7 +254,7 @@ def _fetch_plugin_calculation_settings(self):

if identifier == "bands":
ipw.dlink(
(self._model, "input_structure"),
(self._model, "structure_uuid"),
(outline.include, "disabled"),
lambda _: not self._model.has_pbc,
)
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, model: AdvancedConfigurationSettingsModel, **kwargs):

self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)
self._model.observe(
self._on_spin_type_change,
Expand Down Expand Up @@ -150,7 +150,7 @@ def _update_tabs(self):
self.advanced_tabs.selected_index = 0

def _on_advanced_tab_change(self, change):
tab: ConfigurationSettingsPanel = self.advanced_tabs.children[change["new"]]
tab: ConfigurationSettingsPanel = self.advanced_tabs.children[change["new"]] # type: ignore
tab.render()

def _on_reset_to_defaults_button_click(self, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def __init__(self, model: ConvergenceConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)

self._model.observe(
self._on_structure_change,
"input_structure",
self._on_input_structure_change,
"structure_uuid",
)
self._model.observe(
self._on_protocol_change,
Expand Down Expand Up @@ -107,7 +107,7 @@ def render(self):
(self.kpoints_distance, "value"),
)
ipw.dlink(
(self._model, "input_structure"),
(self._model, "structure_uuid"),
(self.kpoints_distance, "disabled"),
lambda _: not self._model.has_pbc,
)
Expand Down Expand Up @@ -239,7 +239,7 @@ def render(self):

self.rendered = True

def _on_structure_change(self, _):
def _on_input_structure_change(self, _):
self.refresh(specific="structure")

def _on_protocol_change(self, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConvergenceConfigurationSettingsModel(
identifier = "convergence"

dependencies = [
"input_structure",
"structure_uuid",
"protocol",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, model: HubbardConfigurationSettingsModel, **kwargs):

self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)
self._model.observe(
self._on_hubbard_activation,
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/hubbard/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HubbardConfigurationSettingsModel(
identifier = "hubbard"

dependencies = [
"input_structure",
"structure_uuid",
]

is_active = tl.Bool(False)
Expand Down Expand Up @@ -95,7 +95,7 @@ def set_active_eigenvalues(self, eigenvalues: list):
self.has_eigenvalues = True

def get_parameters_from_hubbard_structure(self):
hubbard_parameters = self.input_structure.hubbard.dict()["parameters"]
hubbard_parameters = self.input_structure.hubbard.model_dump()["parameters"]
sites = self.input_structure.sites
return {
f"{sites[hp['atom_index']].kind_name} - {hp['atom_manifold']}": hp["value"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, model: MagnetizationConfigurationSettingsModel, **kwargs):

self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)
self._model.observe(
self._on_electronic_type_change,
Expand Down Expand Up @@ -151,7 +151,7 @@ def _build_kinds_widget(self):

kind_names = (
self._model.input_structure.get_kind_names()
if self._model.input_structure
if self._model.has_structure
else []
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MagnetizationConfigurationSettingsModel(
identifier = "magnetization"

dependencies = [
"input_structure",
"structure_uuid",
"electronic_type",
"spin_type",
"pseudos.dictionary",
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AdvancedConfigurationSettingsModel(
identifier = "advanced"

dependencies = [
"input_structure",
"structure_uuid",
"workchain.protocol",
"workchain.spin_type",
"workchain.electronic_type",
Expand Down Expand Up @@ -233,7 +233,7 @@ def _set_pw_parameters(self, pw_parameters):
control_params: dict = pw_parameters.get("CONTROL", {})
electron_params: dict = pw_parameters.get("ELECTRONS", {})

num_atoms = len(self.input_structure.sites) if self.input_structure else 1
num_atoms = len(self.input_structure.sites) if self.has_structure else 1

general = t.cast(
GeneralConfigurationSettingsModel,
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/pseudos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PseudosConfigurationSettingsModel(
identifier = "pseudos"

dependencies = [
"input_structure",
"structure_uuid",
"protocol",
"spin_orbit",
]
Expand Down Expand Up @@ -249,7 +249,7 @@ def update_cutoffs(self):
if self.locked or not self.dictionary:
return

kinds = self.input_structure.kinds if self.input_structure else []
kinds = self.input_structure.kinds if self.has_structure else []
self.status_message = ""

if self.family:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, model: PseudosConfigurationSettingsModel, **kwargs):

self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)
self._model.observe(
self._on_protocol_change,
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/configuration/basic/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, model: BasicConfigurationSettingsModel, **kwargs):
super().__init__(model, **kwargs)
self._model.observe(
self._on_input_structure_change,
"input_structure",
"structure_uuid",
)

def render(self):
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/configuration/basic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BasicConfigurationSettingsModel(
identifier = "workchain"

dependencies = [
"input_structure",
"structure_uuid",
]

protocol_options = tl.List(
Expand Down
23 changes: 10 additions & 13 deletions src/aiidalab_qe/app/result/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _post_render(self):

self.toggle_controls.value = (
"Results"
if (process := self._model.fetch_process_node()) and process.is_finished_ok
if self._model.has_process and self._model.process.is_finished_ok
else "Status"
)

Expand Down Expand Up @@ -152,10 +152,9 @@ def _on_state_change(self, change):

def _on_previous_step_state_change(self, _):
if self.previous_step_state is WizardAppWidgetStep.State.SUCCESS:
process_node = self._model.fetch_process_node()
message = (
"Loading results"
if process_node and process_node.is_finished
if self._model.has_process and self._model.process.is_finished
else "Submitting calculation"
)
self.children = [LoadingWidget(message)]
Expand Down Expand Up @@ -203,11 +202,10 @@ def _toggle_view(self, panel: ResultsComponent):
def _update_kill_button_layout(self):
if not self.rendered:
return
process_node = self._model.fetch_process_node()
if (
not process_node
or process_node.is_finished
or process_node.is_excepted
not self._model.has_process
or self._model.process.is_finished
or self._model.process.is_excepted
or self.state
in (
self.State.SUCCESS,
Expand All @@ -221,8 +219,7 @@ def _update_kill_button_layout(self):
def _update_clean_scratch_button_layout(self):
if not self.rendered:
return
process_node = self._model.fetch_process_node()
if process_node and process_node.is_terminated:
if self._model.has_process and self._model.process.is_terminated:
self.clean_scratch_button.layout.display = "block"
else:
self.clean_scratch_button.layout.display = "none"
Expand All @@ -231,12 +228,12 @@ def _update_status(self):
self._model.monitor_counter += 1

def _update_state(self):
if not (process_node := self._model.fetch_process_node()):
if not self._model.has_process:
self.state = self.State.INIT
self._update_controls()
return

if process_state := process_node.process_state:
if process_state := self._model.process.process_state:
status = self._get_process_status(process_state.value)
else:
status = "Unknown"
Expand All @@ -254,9 +251,9 @@ def _update_state(self):
ProcessState.KILLED,
):
self.state = self.State.FAIL
elif process_node.is_failed:
elif self._model.process.is_failed:
self.state = self.State.FAIL
elif process_node.is_finished_ok:
elif self._model.process.is_finished_ok:
self.state = self.State.SUCCESS

self._model.process_info = self.STATUS_TEMPLATE.format(status)
Expand Down
26 changes: 12 additions & 14 deletions src/aiidalab_qe/app/result/components/summary/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,15 @@ def generate_report_text(self, report_dict):

def generate_failure_report(self):
"""Generate a html for reporting the failure of the `QeAppWorkChain`."""
process_node = self.fetch_process_node()
if not (process_node and process_node.exit_status):
if not (self.has_process and self.process.exit_status):
return
final_calcjob = self._get_final_calcjob(process_node)
final_calcjob = self._get_final_calcjob(self.process)
env = Environment()
template = files(templates).joinpath("workflow_failure.jinja").read_text()
style = files(styles).joinpath("style.css").read_text()
self.failed_calculation_report = env.from_string(template).render(
style=style,
process_report=get_workchain_report(process_node, "REPORT"),
process_report=get_workchain_report(self.process, "REPORT"),
calcjob_exit_message=final_calcjob.exit_message,
)
self.has_failure_report = True
Expand All @@ -151,29 +150,28 @@ def _generate_report_parameters(self):
"""
from aiida.orm.utils.serialize import deserialize_unsafe

qeapp_wc = self.fetch_process_node()

ui_parameters = qeapp_wc.base.extras.get("ui_parameters", {})
ui_parameters = self.process.base.extras.get("ui_parameters", {})
if isinstance(ui_parameters, str):
ui_parameters = deserialize_unsafe(ui_parameters)
# Construct the report parameters needed for the report
# drop support for old ui parameters
if "workchain" not in ui_parameters:
return {}

inputs = qeapp_wc.inputs
inputs = self.inputs
assert inputs.structure, "BUG! Missing structure input" # shouldn't happen!
structure: orm.StructureData = inputs.structure
basic = ui_parameters["workchain"]
advanced = ui_parameters["advanced"]
ctime = qeapp_wc.ctime
mtime = qeapp_wc.mtime
ctime = self.process.ctime
mtime = self.process.mtime

report = {
"workflow_properties": {
"pk": qeapp_wc.pk,
"uuid": str(qeapp_wc.uuid),
"label": qeapp_wc.label,
"description": qeapp_wc.description,
"pk": self.process.pk,
"uuid": str(self.process.uuid),
"label": self.process.label,
"description": self.process.description,
"creation_time": f"{format_time(ctime)} ({relative_time(ctime)})",
"modification_time": f"{format_time(mtime)} ({relative_time(mtime)})",
},
Expand Down
5 changes: 2 additions & 3 deletions src/aiidalab_qe/app/result/components/summary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ def _render_summary(self):
self.has_settings_report = True

def _render_download_widget(self):
process_node = self._model.fetch_process_node()
if process_node and process_node.is_terminated:
output_download_widget = WorkChainOutputs(node=process_node)
if self._model.has_process and self._model.process.is_terminated:
output_download_widget = WorkChainOutputs(node=self._model.process)
output_download_widget.layout.width = "100%"
self.output_download_container.children = [
self.output_download_help,
Expand Down
13 changes: 6 additions & 7 deletions src/aiidalab_qe/app/result/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def update(self):
self._update_process_remote_folder_state()

def kill_process(self):
if process_node := self.fetch_process_node():
control.kill_processes([process_node])
if self.has_process:
control.kill_processes([self.process])

def clean_remote_data(self):
if not (process_node := self.fetch_process_node()):
if not self.has_process:
return
for called_descendant in process_node.called_descendants:
for called_descendant in self.process.called_descendants:
if isinstance(called_descendant, orm.CalcJobNode):
with contextlib.suppress(Exception):
called_descendant.outputs.remote_folder._clean()
Expand All @@ -43,11 +43,10 @@ def reset(self):
self.process_info = ""

def _update_process_remote_folder_state(self):
process_node = self.fetch_process_node()
if not (process_node and process_node.called_descendants):
if not (self.has_process and self.process.called_descendants):
return
cleaned = []
for called_descendant in process_node.called_descendants:
for called_descendant in self.process.called_descendants:
if isinstance(called_descendant, orm.CalcJobNode):
with contextlib.suppress(Exception):
cleaned.append(called_descendant.outputs.remote_folder.is_empty)
Expand Down
Loading
Loading