From a61f2bfcf94cd5a757bbf391210091e6c93be034 Mon Sep 17 00:00:00 2001 From: Lorenzo <79980269+bastonero@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:03:56 +0100 Subject: [PATCH] `HpCalculation`: add more exit codes (#43) Two exit codes are added to `HpCalculation`. No handlers are at the moment available. --- .../calculations/hp.py | 4 +++ src/aiida_quantumespresso_hp/parsers/hp.py | 26 ++++++++++++++++--- .../parsers/parse_raw/hp.py | 2 ++ .../hp/failed_incompatible_fft_grid/aiida.out | 7 +++++ .../hp/failed_missing_chi_matrices/aiida.out | 7 +++++ tests/parsers/test_hp.py | 2 ++ 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 tests/parsers/fixtures/hp/failed_incompatible_fft_grid/aiida.out create mode 100644 tests/parsers/fixtures/hp/failed_missing_chi_matrices/aiida.out diff --git a/src/aiida_quantumespresso_hp/calculations/hp.py b/src/aiida_quantumespresso_hp/calculations/hp.py index f4b49aa..b2fd397 100644 --- a/src/aiida_quantumespresso_hp/calculations/hp.py +++ b/src/aiida_quantumespresso_hp/calculations/hp.py @@ -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 diff --git a/src/aiida_quantumespresso_hp/parsers/hp.py b/src/aiida_quantumespresso_hp/parsers/hp.py index 35ed8db..1c039f2 100644 --- a/src/aiida_quantumespresso_hp/parsers/hp.py +++ b/src/aiida_quantumespresso_hp/parsers/hp.py @@ -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` @@ -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 @@ -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) diff --git a/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py b/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py index b291af2..d26ddad 100644 --- a/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py +++ b/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py @@ -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' }, diff --git a/tests/parsers/fixtures/hp/failed_incompatible_fft_grid/aiida.out b/tests/parsers/fixtures/hp/failed_incompatible_fft_grid/aiida.out new file mode 100644 index 0000000..b8baff4 --- /dev/null +++ b/tests/parsers/fixtures/hp/failed_incompatible_fft_grid/aiida.out @@ -0,0 +1,7 @@ + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + Error in routine scale_sym_ops (3): + incompatible FFT grid + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + stopping ... diff --git a/tests/parsers/fixtures/hp/failed_missing_chi_matrices/aiida.out b/tests/parsers/fixtures/hp/failed_missing_chi_matrices/aiida.out new file mode 100644 index 0000000..12ae124 --- /dev/null +++ b/tests/parsers/fixtures/hp/failed_missing_chi_matrices/aiida.out @@ -0,0 +1,7 @@ + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + Error in routine reconstruct_full_chi (1): + Reconstruction problem: some chi were not found + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + stopping ... diff --git a/tests/parsers/test_hp.py b/tests/parsers/test_hp.py index bca62b5..55648e6 100644 --- a/tests/parsers/test_hp.py +++ b/tests/parsers/test_hp.py @@ -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,