Skip to content

Commit

Permalink
HpCalculation: add more exit codes (#43)
Browse files Browse the repository at this point in the history
Two exit codes are added to `HpCalculation`.
No handlers are at the moment available.
  • Loading branch information
bastonero authored Dec 6, 2023
1 parent 4f8f185 commit a61f2bf
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/aiida_quantumespresso_hp/calculations/hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def define(cls, spec):
message='The electronic minimization cycle did not reach self-consistency.')
spec.exit_code(462, 'ERROR_COMPUTING_CHOLESKY',
message='The code failed during the cholesky factorization.')
spec.exit_code(490, 'ERROR_MISSING_CHI_MATRICES',
message='The code failed to reconstruct the full chi matrix as some chi matrices were missing')
spec.exit_code(495, 'ERROR_INCOMPATIBLE_FFT_GRID',
message='The code failed due to incompatibility between the FFT grid and the parallelization options.')

@classproperty
def filename_output_hubbard_chi(cls): # pylint: disable=no-self-argument
Expand Down
26 changes: 22 additions & 4 deletions src/aiida_quantumespresso_hp/parsers/hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@ class HpParser(Parser):

def parse(self, **kwargs):
"""Parse the contents of the output files retrieved in the `FolderData`."""
self.exit_code_stdout = None # pylint: disable=attribute-defined-outside-init

try:
self.retrieved
except exceptions.NotExistent:
return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER

# The stdout is always parsed by default.
exit_code = self.parse_stdout()
logs = self.parse_stdout()

# Check for specific known problems that can cause a pre-mature termination of the calculation
exit_code = self.validate_premature_exit(logs)
if exit_code:
return exit_code

if self.exit_code_stdout:
return self.exit_code_stdout

# If it only initialized, then we do NOT parse the `{prefix}.Hubbard_parameters.dat``
# and the {prefix}.chi.dat files.
# This check is needed since the `hp.x` routine will print the `{prefix}.Hubbard_parameters.dat`
Expand Down Expand Up @@ -88,7 +96,7 @@ def parse_stdout(self):
Parse the output parameters from the output of a Hp calculation written to standard out.
:return: optional exit code in case of an error
:return: log messages
"""
from .parse_raw.hp import parse_raw_output

Expand All @@ -109,14 +117,24 @@ def parse_stdout(self):
else:
self.out('parameters', orm.Dict(parsed_data))

# If the stdout was incomplete, most likely the job was interrupted before it could cleanly finish, so the
# output files are most likely corrupt and cannot be restarted from
if 'ERROR_OUTPUT_STDOUT_INCOMPLETE' in logs['error']:
self.exit_code_stdout = self.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE # pylint: disable=attribute-defined-outside-init

return logs

def validate_premature_exit(self, logs):
"""Analyze problems that will cause a pre-mature termination of the calculation, controlled or not."""
for exit_status in [
'ERROR_OUT_OF_WALLTIME',
'ERROR_INVALID_NAMELIST',
'ERROR_INCORRECT_ORDER_ATOMIC_POSITIONS',
'ERROR_MISSING_PERTURBATION_FILE',
'ERROR_CONVERGENCE_NOT_REACHED',
'ERROR_OUT_OF_WALLTIME',
'ERROR_COMPUTING_CHOLESKY',
'ERROR_OUTPUT_STDOUT_INCOMPLETE',
'ERROR_MISSING_CHI_MATRICES',
'ERROR_INCOMPATIBLE_FFT_GRID',
]:
if exit_status in logs['error']:
return self.exit_codes.get(exit_status)
Expand Down
2 changes: 2 additions & 0 deletions src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def detect_important_message(logs, line):
'Maximum CPU time exceeded': 'ERROR_OUT_OF_WALLTIME',
'reading inputhp namelist': 'ERROR_INVALID_NAMELIST',
'problems computing cholesky': 'ERROR_COMPUTING_CHOLESKY',
'Reconstruction problem: some chi were not found': 'ERROR_MISSING_CHI_MATRICES',
'incompatible FFT grid': 'ERROR_INCOMPATIBLE_FFT_GRID',
REG_ERROR_CONVERGENCE_NOT_REACHED: 'ERROR_CONVERGENCE_NOT_REACHED',
ERROR_POSITIONS: 'ERROR_INCORRECT_ORDER_ATOMIC_POSITIONS'
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error in routine scale_sym_ops (3):
incompatible FFT grid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

stopping ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error in routine reconstruct_full_chi (1):
Reconstruction problem: some chi were not found
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

stopping ...
2 changes: 2 additions & 0 deletions tests/parsers/test_hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def test_hp_failed_invalid_namelist(aiida_localhost, generate_calc_job_node, gen
('failed_out_of_walltime', HpCalculation.exit_codes.ERROR_OUT_OF_WALLTIME.status),
('failed_stdout_incomplete', HpCalculation.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE.status),
('failed_computing_cholesky', HpCalculation.exit_codes.ERROR_COMPUTING_CHOLESKY.status),
('failed_missing_chi_matrices', HpCalculation.exit_codes.ERROR_MISSING_CHI_MATRICES.status),
('failed_incompatible_fft_grid', HpCalculation.exit_codes.ERROR_INCOMPATIBLE_FFT_GRID.status),
))
def test_failed_calculation(
generate_calc_job_node,
Expand Down

0 comments on commit a61f2bf

Please sign in to comment.