Skip to content

Commit

Permalink
Error handling when clean remote folder failed
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 14, 2024
1 parent 38e5ebd commit c1119bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/aiida_sssp_workflow/workflows/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from builtins import ConnectionError
from typing import Optional
from paramiko import ssh_exception


from aiida import orm

Expand Down Expand Up @@ -40,8 +43,12 @@ def clean_workdir(node: orm.CalcJobNode) -> Optional[int]:
# other subsequent calcjob as `parent_folder`, i.e PH calculation.
cached_from = node.base.extras.get("_aiida_cached_from", None)
if not cached_from:
node.outputs.remote_folder._clean() # pylint: disable=protected-access
return node.pk
try:
node.outputs.remote_folder._clean() # pylint: disable=protected-access
except ssh_exception.SSHException as exc:
raise ConnectionError("ssh error") from exc
else:
return node.pk
else:
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,15 @@ def finalize(self):
"""set ecutwfc and ecutrho"""

if self.inputs.clean_workdir.value is True:
cleaned_calcs = operate_calcjobs(
self.node, operator=clean_workdir, all_same_nodes=False
)

if cleaned_calcs:
try:
cleaned_calcs = operate_calcjobs(
self.node, operator=clean_workdir, all_same_nodes=False
)
except ConnectionError as exc:
self.logger.warning(
f"clean remote workdir folder {self.inputs.clean_workir} failed: {exc}"
)
else:
self.report(
f"cleaned remote folders of calculations: {' '.join(map(str, cleaned_calcs))}"
)
Expand Down

0 comments on commit c1119bd

Please sign in to comment.