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#
Custom |
- class aiida_quantumespresso.parsers.base.BaseParser(node: aiida.orm.CalcJobNode)[source]#
Bases:
aiida.parsers.ParserCustom
Parserclass foraiida-quantumespressoparser implementations.- parse_stdout_from_retrieved(logs: aiida.common.AttributeDict) Tuple[str, dict, aiida.common.AttributeDict][source]#
Read and parse the
stdoutcontent of a Quantum ESPRESSO calculation.- Parameters:
logs – Logging container that will be updated during parsing.
- Returns:
size 3 tuple: (
stdoutcontent, 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
logsfor the following “basic” parsing error and return a (formatted) version:ERROR_OUTPUT_STDOUT_MISSINGERROR_OUTPUT_STDOUT_READERROR_OUTPUT_STDOUT_PARSE
These errors mean that there is no
stdoutto parse.The
ERROR_OUTPUT_STDOUT_INCOMPLETEerror is not checked here because in this case there might still be useful information in thestdout.
- exit(exit_code: aiida.engine.ExitCode | None = None, logs: aiida.common.AttributeDict | None = None) aiida.engine.ExitCode[source]#
Log all messages in the
logsas well as theexit_codemessage and return the correct exit code.This is a utility function if one wants to return from the parse method and automically add the
logsand 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_codeis provided, the method will check if anexit_statushas already been set on the node and return the correspondingExitCodein 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
stdoutcontent 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.