aiida.parsers package

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

class aiida.parsers.Parser(node)[source]

Bases: object

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

__dict__ = dict_proxy({'node': <property object>, '__module__': 'aiida.parsers.parser', 'retrieved': <property object>, 'parse': <function parse>, '__dict__': <attribute '__dict__' of 'Parser' objects>, 'exit_codes': <property object>, 'outputs': <property object>, 'parse_from_node': <classmethod object>, 'logger': <property object>, 'out': <function out>, '__weakref__': <attribute '__weakref__' of 'Parser' objects>, '__doc__': 'Base class for a Parser that can parse the outputs produced by a CalcJob process.', '__init__': <function __init__>, 'get_outputs_for_parsing': <function get_outputs_for_parsing>})
__init__(node)[source]

Construct the Parser instance.

Parameters:node – the CalcJobNode that contains the results of the executed CalcJob process.
__module__ = 'aiida.parsers.parser'
__weakref__

list of weak references to the object (if defined)

exit_codes

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

Returns:ExitCodesNamespace of ExitCode named tuples
get_outputs_for_parsing()[source]

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
logger

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

Returns:logging.Logger
node

Return the node instance

Returns:the CalcJobNode instance
out(link_label, node)[source]

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

outputs

Return the dictionary of outputs that have been registered.

Returns:an AttributeDict instance with the registered output nodes
parse(**kwargs)[source]

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
classmethod parse_from_node(node, store_provenance=True)[source]

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.

Parameters:
  • node – a CalcJobNode instance
  • store_provenance – bool, if True will store the parsing as a CalcFunctionNode in the provenance
Returns:

a tuple of the parsed results and the CalcFunctionNode

retrieved

Submodules

This module implements a generic output plugin, that is general enough to allow the reading of the outputs of a calculation.

class aiida.parsers.parser.Parser(node)[source]

Bases: object

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

__dict__ = dict_proxy({'node': <property object>, '__module__': 'aiida.parsers.parser', 'retrieved': <property object>, 'parse': <function parse>, '__dict__': <attribute '__dict__' of 'Parser' objects>, 'exit_codes': <property object>, 'outputs': <property object>, 'parse_from_node': <classmethod object>, 'logger': <property object>, 'out': <function out>, '__weakref__': <attribute '__weakref__' of 'Parser' objects>, '__doc__': 'Base class for a Parser that can parse the outputs produced by a CalcJob process.', '__init__': <function __init__>, 'get_outputs_for_parsing': <function get_outputs_for_parsing>})
__init__(node)[source]

Construct the Parser instance.

Parameters:node – the CalcJobNode that contains the results of the executed CalcJob process.
__module__ = 'aiida.parsers.parser'
__weakref__

list of weak references to the object (if defined)

exit_codes

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

Returns:ExitCodesNamespace of ExitCode named tuples
get_outputs_for_parsing()[source]

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
logger

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

Returns:logging.Logger
node

Return the node instance

Returns:the CalcJobNode instance
out(link_label, node)[source]

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

outputs

Return the dictionary of outputs that have been registered.

Returns:an AttributeDict instance with the registered output nodes
parse(**kwargs)[source]

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
classmethod parse_from_node(node, store_provenance=True)[source]

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.

Parameters:
  • node – a CalcJobNode instance
  • store_provenance – bool, if True will store the parsing as a CalcFunctionNode in the provenance
Returns:

a tuple of the parsed results and the CalcFunctionNode

retrieved