aiida.parsers

Module for classes and utilities to write parsers for calculation jobs.

Package Contents

Classes

Parser

Base class for a Parser that can parse the outputs produced by a CalcJob process.

API

class aiida.parsers.Parser(node: aiida.orm.CalcJobNode)

Bases: abc.ABC

Base class for a Parser that can parse the outputs produced by a CalcJob process.

Initialization

Construct the Parser instance.

Parameters:

node – the CalcJobNode that contains the results of the executed CalcJob process.

property logger

Return the logger preconfigured for the calculation node associated with this parser instance.

Returns:

logging.Logger

property node: aiida.orm.CalcJobNode

Return the node instance

Returns:

the CalcJobNode instance

property exit_codes: aiida.engine.ExitCodesNamespace

Return the exit codes defined for the process class of the node being parsed.

Returns:

ExitCodesNamespace of ExitCode named tuples

property retrieved: aiida.orm.FolderData
property outputs

Return the dictionary of outputs that have been registered.

Returns:

an AttributeDict instance with the registered output nodes

out(link_label: str, node: aiida.orm.Data) None

Register a node as an output with the given link label.

Parameters:
  • link_label – the name of the link label

  • node – the node to register as an output

Raises:

aiida.common.ModificationNotAllowed – if an output node was already registered with the same link label

get_outputs_for_parsing()

Return the dictionary of nodes that should be passed to the Parser.parse call.

Output nodes can be marked as being required by the parse method, by setting the pass_to_parser attribute, in the spec.output call in the process spec of the CalcJob, to True.

Returns:

dictionary of nodes that are required by the parse method

classmethod parse_from_node(node: aiida.orm.CalcJobNode, store_provenance=True, retrieved_temporary_folder=None) Tuple[Optional[Dict[str, Any]], aiida.orm.CalcFunctionNode]

Parse the outputs directly from the CalcJobNode.

If store_provenance is set to False, a CalcFunctionNode will still be generated, but it will not be stored. It’s storing method will also be disabled, making it impossible to store, because storing it afterwards would not have the expected effect, as the outputs it produced will not be stored with it.

This method is useful to test parsing in unit tests where a CalcJobNode can be mocked without actually having to run a CalcJob. It can also be useful to actually re-perform the parsing of a completed CalcJob with a different parser.

Parameters:
  • node – a CalcJobNode instance

  • store_provenance – bool, if True will store the parsing as a CalcFunctionNode in the provenance

  • retrieved_temporary_folder – absolute path to folder with contents of retrieved_temporary_list

Returns:

a tuple of the parsed results and the CalcFunctionNode representing the process of parsing

abstract parse(**kwargs) Optional[aiida.engine.ExitCode]

Parse the contents of the output files retrieved in the FolderData.

This method should be implemented in the sub class. Outputs can be registered through the out method. After the parse call finishes, the runner will automatically link them up to the underlying CalcJobNode.

Parameters:

kwargs – output nodes attached to the CalcJobNode of the parser instance.

Returns:

an instance of ExitCode or None