aiida.parsers package#
Module for classes and utilities to write parsers for calculation jobs.
Subpackages#
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: CalcJobNode)[source]#
Bases:
ABC
Base class for a Parser that can parse the outputs produced by a CalcJob process.
- __abstractmethods__ = frozenset({'parse'})#
- __annotations__ = {'CACHE_VERSION': 'int | None'}#
- __dict__ = mappingproxy({'__module__': 'aiida.parsers.parser', '__annotations__': {'CACHE_VERSION': 'int | None'}, '__doc__': 'Base class for a Parser that can parse the outputs produced by a CalcJob process.', 'CACHE_VERSION': None, '__init__': <function Parser.__init__>, 'logger': <property object>, 'node': <property object>, 'exit_codes': <property object>, 'retrieved': <property object>, 'outputs': <property object>, 'out': <function Parser.out>, 'get_outputs_for_parsing': <function Parser.get_outputs_for_parsing>, 'parse_from_node': <classmethod(<function Parser.parse_from_node>)>, 'parse': <function Parser.parse>, '__dict__': <attribute '__dict__' of 'Parser' objects>, '__weakref__': <attribute '__weakref__' of 'Parser' objects>, '__abstractmethods__': frozenset({'parse'}), '_abc_impl': <_abc._abc_data object>})#
- __init__(node: CalcJobNode)[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
- _abc_impl = <_abc._abc_data object>#
- property exit_codes: ExitCodesNamespace#
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
- property logger#
Return the logger preconfigured for the calculation node associated with this parser instance.
- Returns:
logging.Logger
- property node: CalcJobNode#
Return the node instance
- Returns:
the CalcJobNode instance
- out(link_label: str, node: Data) None [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
- property outputs#
Return the dictionary of outputs that have been registered.
- Returns:
an AttributeDict instance with the registered output nodes
- abstract parse(**kwargs) ExitCode | None [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: CalcJobNode, store_provenance=True, retrieved_temporary_folder=None) Tuple[Dict[str, Any] | None, 'orm.CalcFunctionNode'] [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.
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
- property retrieved: FolderData#