Skip to content

Commit

Permalink
Move out call before exit code return when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mbercx committed Jan 28, 2022
1 parent 3864bdd commit 92d7bf3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions aiida_quantumespresso/parsers/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ class DosParser(BaseParser):
def parse(self, **kwargs):
"""Parse the retrieved files of a ``DosCalculation`` into output nodes."""
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', Dict(dict=parsed_stdout))

for exit_code in ['ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ', 'ERROR_OUTPUT_STDOUT_INCOMPLETE']:
if exit_code in logs_stdout.error:
return self._exit(self.exit_codes.get(exit_code))

self.out('output_parameters', Dict(dict=parsed_stdout))

# Parse the DOS
try:
with self.retrieved.open(self.node.process_class._DOS_FILENAME, 'r') as handle:
Expand Down
4 changes: 3 additions & 1 deletion aiida_quantumespresso/parsers/matdyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class MatdynParser(BaseParser):
def parse(self, **kwargs):
"""Parse the retrieved files from a ``MatdynCalculation`` into output nodes."""
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', orm.Dict(dict=parsed_stdout))

for exit_code in ['ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ', 'ERROR_OUTPUT_STDOUT_INCOMPLETE']:
if exit_code in logs_stdout.error:
Expand Down Expand Up @@ -48,7 +51,6 @@ def parse(self, **kwargs):
for message in parsed_data['warnings']:
self.logger.error(message)

self.out('output_parameters', orm.Dict(dict=parsed_stdout))
self.out('output_phonon_bands', output_bands)


Expand Down
2 changes: 1 addition & 1 deletion aiida_quantumespresso/parsers/parse_raw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from aiida.orm import StructureData

__all__ = ('convert_qe_time_to_sec', 'convert_qe2aiida_structure', 'convert_qe_to_kpoints')
__all__ = ('convert_qe_time_to_sec', 'convert_qe_to_aiida_structure', 'convert_qe_to_kpoints')


def convert_qe_time_to_sec(timestr):
Expand Down
4 changes: 2 additions & 2 deletions aiida_quantumespresso/parsers/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def parse(self, **kwargs):
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', orm.Dict(dict=parsed_stdout))

for exit_code in [
'ERROR_PARENT_XML_MISSING', 'ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ',
'ERROR_OUTPUT_STDOUT_INCOMPLETE'
Expand Down Expand Up @@ -141,8 +143,6 @@ def get_key_from_filename(filename):
else:
self.out('output_data_multiple', dict(data_parsed))

self.out('output_parameters', orm.Dict(dict=parsed_stdout))

def parse_stdout(self, stdout):
"""Parse the ``stdout`` content of a Quantum ESPRESSO ``pp.x`` calculation.
Expand Down
4 changes: 1 addition & 3 deletions aiida_quantumespresso/parsers/projwfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from aiida.plugins import OrbitalFactory

from aiida_quantumespresso.parsers import QEOutputParsingError
from aiida_quantumespresso.parsers.parse_raw.base import (
convert_qe_to_aiida_structure, convert_qe_to_kpoints
)
from aiida_quantumespresso.parsers.parse_raw.base import (convert_qe_to_aiida_structure, convert_qe_to_kpoints)
from aiida_quantumespresso.utils.mapping import get_logging_container

from .base import BaseParser
Expand Down
4 changes: 2 additions & 2 deletions aiida_quantumespresso/parsers/pw2gw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def parse(self, **kwargs):
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', Dict(dict=parsed_stdout))

for exit_code in ['ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ', 'ERROR_OUTPUT_STDOUT_INCOMPLETE']:
if exit_code in logs_stdout.error:
return self._exit(self.exit_codes.get(exit_code))

self.out('output_parameters', Dict(dict=parsed_stdout))

self.exit_code_eps = None
eps = self.parse_eps_files()

Expand Down
4 changes: 2 additions & 2 deletions aiida_quantumespresso/parsers/pw2wannier90.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def parse(self, **kwargs):
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', Dict(dict=parsed_stdout))

for exit_code in ['ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ', 'ERROR_OUTPUT_STDOUT_INCOMPLETE']:
if exit_code in logs_stdout.error:
return self._exit(self.exit_codes.get(exit_code))

self.out('output_parameters', Dict(dict=parsed_stdout))
4 changes: 2 additions & 2 deletions aiida_quantumespresso/parsers/q2r.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ def parse(self, **kwargs):
parsed_stdout, logs_stdout = self._retrieve_parse_stdout()
self._emit_logs(logs_stdout)

self.out('output_parameters', Dict(dict=parsed_stdout))

for exit_code in ['ERROR_OUTPUT_STDOUT_MISSING', 'ERROR_OUTPUT_STDOUT_READ', 'ERROR_OUTPUT_STDOUT_INCOMPLETE']:
if exit_code in logs_stdout.error:
return self._exit(self.exit_codes.get(exit_code))

self.out('output_parameters', Dict(dict=parsed_stdout))

filename_force_constants = self.node.process_class._FORCE_CONSTANTS_NAME

if filename_force_constants not in self.retrieved.list_object_names():
Expand Down

0 comments on commit 92d7bf3

Please sign in to comment.