aiida_quantumespresso.utils.mapping
#
Utilities to deal with various mapping data structures.
Module Contents#
Functions#
Return an AttributeDict that can be used to map logging messages to certain log levels. |
|
|
Update a nested dictionary with another optionally nested dictionary. |
|
Prepare the inputs for submission for the given process, according to its spec. |
|
Wrap bare dictionaries in inputs in a Dict node if dictated by the corresponding port in given namespace. |
- aiida_quantumespresso.utils.mapping.get_logging_container()[source]#
Return an AttributeDict that can be used to map logging messages to certain log levels.
This datastructure is useful to add log messages in a function that does not have access to the right logger. Once returned, the caller who does have access to the logger can then easily loop over the contents and pipe the messages through the actual logger.
- Returns:
- aiida_quantumespresso.utils.mapping.update_mapping(original, source)[source]#
Update a nested dictionary with another optionally nested dictionary.
The dictionaries may be plain Mapping objects or Dict nodes. If the original dictionary is an instance of Dict the returned dictionary will also be wrapped in Dict.
- Parameters:
original – Mapping object or Dict instance
source – Mapping object or Dict instance
- Returns:
the original dictionary updated with the source dictionary
- aiida_quantumespresso.utils.mapping.prepare_process_inputs(process, inputs)[source]#
Prepare the inputs for submission for the given process, according to its spec.
That is to say that when an input is found in the inputs that corresponds to an input port in the spec of the process that expects a Dict, yet the value in the inputs is a plain dictionary, the value will be wrapped in by the Dict class to create a valid input.
- Parameters:
process – sub class of Process for which to prepare the inputs dictionary
inputs – a dictionary of inputs intended for submission of the process
- Returns:
a dictionary with all bare dictionaries wrapped in Dict if dictated by the process spec
- aiida_quantumespresso.utils.mapping.wrap_bare_dict_inputs(port_namespace, inputs)[source]#
Wrap bare dictionaries in inputs in a Dict node if dictated by the corresponding port in given namespace.
- Parameters:
port_namespace – a PortNamespace
inputs – a dictionary of inputs intended for submission of the process
- Returns:
a dictionary with all bare dictionaries wrapped in Dict if dictated by the port namespace