aiida_quantumespresso.parsers.base#

Defines a Parser base class for aiida-quantumespresso.

All Parser implementations in aiida-quantumespresso must use this base class, not aiida.parsers.Parser.

Module Contents#

Classes#

BaseParser

Custom Parser class for aiida-quantumespresso parser implementations.

class aiida_quantumespresso.parsers.base.BaseParser(node: aiida.orm.CalcJobNode)[source]#

Bases: aiida.parsers.Parser

Custom Parser class for aiida-quantumespresso parser implementations.

class_error_map[source]#
class_warning_map[source]#
base_error_map[source]#
base_warning_map[source]#
success_string = 'JOB DONE'[source]#
classmethod get_error_map()[source]#

The full error map of the parser class.

classmethod get_warning_map()[source]#

The full warning map of the parser class.

parse_stdout_from_retrieved(logs: aiida.common.AttributeDict) Tuple[str, dict, aiida.common.AttributeDict][source]#

Read and parse the stdout content of a Quantum ESPRESSO calculation.

Parameters:

logs – Logging container that will be updated during parsing.

Returns:

size 3 tuple: (stdout content, parsed data, updated logs).

emit_logs(logs: list[aiida.common.AttributeDict] | tuple[aiida.common.AttributeDict] | aiida.common.AttributeDict, ignore: list = None) None[source]#

Emit the messages in one or multiple “log dictionaries” through the logger of the parser.

A log dictionary is expected to have the following structure: each key must correspond to a log level of the python logging module, e.g. error or warning and its values must be a list of string messages. The method will loop over all log dictionaries and emit the messages it contains with the log level indicated by the key.

Example log dictionary structure:

logs = {
    'warning': ['Could not parse the `etot_threshold` variable from the stdout.'],
    'error': ['Self-consistency was not achieved']
}
Parameters:
  • logs – log dictionaries

  • ignore – list of log messages to ignore

check_base_errors(logs: aiida.common.AttributeDict) aiida.engine.ExitCode | None[source]#

Check the logs for the following “basic” parsing error and return a (formatted) version:

  • ERROR_OUTPUT_STDOUT_MISSING

  • ERROR_OUTPUT_STDOUT_READ

  • ERROR_OUTPUT_STDOUT_PARSE

These errors mean that there is no stdout to parse.

The ERROR_OUTPUT_STDOUT_INCOMPLETE error is not checked here because in this case there might still be useful information in the stdout.

exit(exit_code: aiida.engine.ExitCode | None = None, logs: aiida.common.AttributeDict | None = None) aiida.engine.ExitCode[source]#

Log all messages in the logs as well as the exit_code message and return the correct exit code.

This is a utility function if one wants to return from the parse method and automically add the logs and exit message associated to and exit code as a log message to the node: e.g. return self._exit(self.exit_codes.LABEL))

If no exit_code is provided, the method will check if an exit_status has already been set on the node and return the corresponding ExitCode in this case. If not, ExitCode(0) is returned.

Parameters:
  • logs – log dictionaries

  • exit_code – an ExitCode

Returns:

The correct exit code

classmethod _parse_stdout_base(stdout: str, logs: aiida.common.AttributeDict) Tuple[dict, aiida.common.AttributeDict][source]#

Parse the stdout content of a Quantum ESPRESSO calculation.

This function only checks for basic content like JOB DONE, errors with %%%%% etc, but can be overridden to parse more data from the stdout.

Parameters:

stdout – the stdout content as a string.

Returns:

tuple of two dictionaries, with the parsed data and log messages, respectively.