diff --git a/aiida_aimall/calculations.py b/aiida_aimall/calculations.py index 3671140..c430ab1 100644 --- a/aiida_aimall/calculations.py +++ b/aiida_aimall/calculations.py @@ -99,6 +99,11 @@ def define(cls, spec): ) spec.default_output_node = "output_parameters" + spec.exit_code( + 210, + "ERROR_OUTPUT_MISSING", + message="The retrieved folder did not contain the output file.", + ) spec.outputs.dynamic = True # would put error codes here diff --git a/aiida_aimall/parsers.py b/aiida_aimall/parsers.py index bebee95..6533b33 100644 --- a/aiida_aimall/parsers.py +++ b/aiida_aimall/parsers.py @@ -63,8 +63,7 @@ def parse(self, **kwargs): self.logger.error( f"Found files '{files_retrieved}', expected to find '{files_expected}'" ) - # return self.exit_codes.ERROR_MISSING_OUTPUT_FILES - return + return self.exit_codes.ERROR_MISSING_OUTPUT_FILES # parse output file self.logger.info(f"Parsing '{output_filename}'") @@ -85,7 +84,7 @@ def parse(self, **kwargs): # store in node self.outputs.output_parameters = Dict(out_dict) - return # ExitCode(0) + return ExitCode(0) def _parse_ldm(self, sum_lines): return qt.get_ldm(sum_lines.split("\n")) diff --git a/tests/parsers/test_aimqbbaseparser.py b/tests/parsers/test_aimqbbaseparser.py index 5e91441..2d3af88 100644 --- a/tests/parsers/test_aimqbbaseparser.py +++ b/tests/parsers/test_aimqbbaseparser.py @@ -76,6 +76,35 @@ def test_aimqb_parser_default( # pylint:disable=too-many-arguments assert "cc_properties" in results_dict +def test_empty_outfolder_returns_exitcode( # pylint:disable=too-many-arguments + fixture_localhost, + generate_calc_job_node, + generate_parser, + generate_aimqb_inputs, + fixture_code, + filepath_tests, +): + """Test an aimqb calculation""" + name = "empty" + entry_point_calc_job = "aimall.aimqb" + entry_point_parser = "aimall.base" + + node = generate_calc_job_node( + entry_point_calc_job, + fixture_localhost, + name, + generate_aimqb_inputs(fixture_code, filepath_tests), + ) + + parser = generate_parser(entry_point_parser) + + _, calcfunction = parser.parse_from_node(node, store_provenance=False) + assert ( + calcfunction.exit_status + == node.process_class.exit_codes.ERROR_MISSING_OUTPUT_FILES.status + ) + + def test_gaussiannode_returns_error( # pylint:disable=too-many-arguments fixture_localhost, generate_calc_job_node,