aiida.orm.utils package¶
Utilities related to the ORM.
-
aiida.orm.utils.
load_code
(identifier=None, pk=None, uuid=None, label=None, sub_classes=None, query_with_dashes=True)[source]¶ Load a Code instance by one of its identifiers: pk, uuid or label
If the type of the identifier is unknown simply pass it without a keyword and the loader will attempt to automatically infer the type.
Parameters: - identifier – pk (integer), uuid (string) or label (string) of a Code
- pk – pk of a Code
- uuid – uuid of a Code, or the beginning of the uuid
- label – label of a Code
- sub_classes – an optional tuple of orm classes to narrow the queryset. Each class should be a strict sub class of the ORM class of the given entity loader.
- query_with_dashes (bool) – allow to query for a uuid with dashes
Returns: the Code instance
Raises: - ValueError – if none or more than one of the identifiers are supplied
- TypeError – if the provided identifier has the wrong type
- aiida.common.NotExistent – if no matching Code is found
- aiida.common.MultipleObjectsError – if more than one Code was found
-
aiida.orm.utils.
load_computer
(identifier=None, pk=None, uuid=None, label=None, sub_classes=None, query_with_dashes=True)[source]¶ Load a Computer instance by one of its identifiers: pk, uuid or label
If the type of the identifier is unknown simply pass it without a keyword and the loader will attempt to automatically infer the type.
Parameters: - identifier – pk (integer), uuid (string) or label (string) of a Computer
- pk – pk of a Computer
- uuid – uuid of a Computer, or the beginning of the uuid
- label – label of a Computer
- sub_classes – an optional tuple of orm classes to narrow the queryset. Each class should be a strict sub class of the ORM class of the given entity loader.
- query_with_dashes (bool) – allow to query for a uuid with dashes
Returns: the Computer instance
Raises: - ValueError – if none or more than one of the identifiers are supplied
- TypeError – if the provided identifier has the wrong type
- aiida.common.NotExistent – if no matching Computer is found
- aiida.common.MultipleObjectsError – if more than one Computer was found
-
aiida.orm.utils.
load_group
(identifier=None, pk=None, uuid=None, label=None, sub_classes=None, query_with_dashes=True)[source]¶ Load a Group instance by one of its identifiers: pk, uuid or label
If the type of the identifier is unknown simply pass it without a keyword and the loader will attempt to automatically infer the type.
Parameters: - identifier – pk (integer), uuid (string) or label (string) of a Group
- pk – pk of a Group
- uuid – uuid of a Group, or the beginning of the uuid
- label – label of a Group
- sub_classes – an optional tuple of orm classes to narrow the queryset. Each class should be a strict sub class of the ORM class of the given entity loader.
- query_with_dashes (bool) – allow to query for a uuid with dashes
Returns: the Group instance
Raises: - ValueError – if none or more than one of the identifiers are supplied
- TypeError – if the provided identifier has the wrong type
- aiida.common.NotExistent – if no matching Group is found
- aiida.common.MultipleObjectsError – if more than one Group was found
-
aiida.orm.utils.
load_node
(identifier=None, pk=None, uuid=None, label=None, sub_classes=None, query_with_dashes=True)[source]¶ Load a node by one of its identifiers: pk or uuid. If the type of the identifier is unknown simply pass it without a keyword and the loader will attempt to infer the type
Parameters: - identifier – pk (integer) or uuid (string)
- pk – pk of a node
- uuid – uuid of a node, or the beginning of the uuid
- label – label of a Node
- sub_classes – an optional tuple of orm classes to narrow the queryset. Each class should be a strict sub class of the ORM class of the given entity loader.
- query_with_dashes (bool) – allow to query for a uuid with dashes
Returns: the node instance
Raises: - ValueError – if none or more than one of the identifiers are supplied
- TypeError – if the provided identifier has the wrong type
- aiida.common.NotExistent – if no matching Node is found
- aiida.common.MultipleObjectsError – if more than one Node was found
Subpackages¶
Submodules¶
Utilities to operate on CalcJobNode instances.
-
class
aiida.orm.utils.calcjob.
CalcJobResultManager
(node)[source]¶ Bases:
object
Utility class to easily access the contents of the ‘default output’ node of a CalcJobNode.
A CalcJob process can mark one of its outputs as the ‘default output’. The default output node will always be returned by the CalcJob and will always be a Dict node.
If a CalcJob defines such a default output node, this utility class will simplify retrieving the result of said node through the CalcJobNode instance produced by the execution of the CalcJob.
The default results are only defined if the CalcJobNode has a process_type that can be successfully used to load the corresponding CalcJob process class and if its process spec defines a default_output_node. If both these conditions are met, the results are defined as the dictionary contained within the default output node.
-
__dict__
= dict_proxy({'node': <property object>, 'get_results': <function get_results>, '__module__': 'aiida.orm.utils.calcjob', '__getitem__': <function __getitem__>, '_load_results': <function _load_results>, '__getattr__': <function __getattr__>, '__iter__': <function __iter__>, '__init__': <function __init__>, '__dict__': <attribute '__dict__' of 'CalcJobResultManager' objects>, '__weakref__': <attribute '__weakref__' of 'CalcJobResultManager' objects>, '__doc__': "\n Utility class to easily access the contents of the 'default output' node of a `CalcJobNode`.\n\n A `CalcJob` process can mark one of its outputs as the 'default output'. The default output node will always be\n returned by the `CalcJob` and will always be a `Dict` node.\n\n If a `CalcJob` defines such a default output node, this utility class will simplify retrieving the result of said\n node through the `CalcJobNode` instance produced by the execution of the `CalcJob`.\n\n The default results are only defined if the `CalcJobNode` has a `process_type` that can be successfully used\n to load the corresponding `CalcJob` process class *and* if its process spec defines a `default_output_node`.\n If both these conditions are met, the results are defined as the dictionary contained within the default\n output node.\n ", '__dir__': <function __dir__>})¶
-
__getattr__
(name)[source]¶ Return an attribute from the results dictionary.
Parameters: name – name of the result return Returns: value of the attribute Raises: AttributeError – if the results dictionary does not contain an attribute with the given name
-
__getitem__
(name)[source]¶ Return an attribute from the results dictionary.
Parameters: name – name of the result return Returns: value of the attribute Raises: AttributeError – if the results dictionary does not contain an attribute with the given name
-
__init__
(node)[source]¶ Construct an instance of the CalcJobResultManager.
Parameters: calc – the CalcJobNode instance.
-
__module__
= 'aiida.orm.utils.calcjob'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_load_results
()[source]¶ Try to load the results for the CalcJobNode of this result manager.
Raises: ValueError – if no default output node could be loaded
-
get_results
()[source]¶ Return the results dictionary of the default results node of the calculation node.
This property will lazily load the dictionary.
Returns: the dictionary of the default result node
-
node
¶ Return the CalcJobNode associated with this result manager instance.
-
Utilities for dealing with links between nodes.
-
class
aiida.orm.utils.links.
LinkPair
(link_type, link_label)¶ Bases:
tuple
-
__dict__
= dict_proxy({'__module__': 'aiida.orm.utils.links', '__getstate__': <function __getstate__>, '__new__': <staticmethod object>, '_make': <classmethod object>, '__doc__': 'LinkPair(link_type, link_label)', '_replace': <function _replace>, '__slots__': (), '_asdict': <function _asdict>, '__repr__': <function __repr__>, '__dict__': <property object>, '_fields': ('link_type', 'link_label'), '__getnewargs__': <function __getnewargs__>, 'link_label': <property object>, 'link_type': <property object>})¶
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__module__
= 'aiida.orm.utils.links'¶
-
static
__new__
(_cls, link_type, link_label)¶ Create new instance of LinkPair(link_type, link_label)
-
__repr__
()¶ Return a nicely formatted representation string
-
__slots__
= ()¶
-
_asdict
()¶ Return a new OrderedDict which maps field names to their values
-
_fields
= ('link_type', 'link_label')¶
-
classmethod
_make
(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new LinkPair object from a sequence or iterable
-
_replace
(**kwds)¶ Return a new LinkPair object replacing specified fields with new values
-
link_label
¶ Alias for field number 1
-
link_type
¶ Alias for field number 0
-
-
class
aiida.orm.utils.links.
LinkTriple
(node, link_type, link_label)¶ Bases:
tuple
-
__dict__
= dict_proxy({'node': <property object>, '__module__': 'aiida.orm.utils.links', '__getstate__': <function __getstate__>, '__new__': <staticmethod object>, '_make': <classmethod object>, '__doc__': 'LinkTriple(node, link_type, link_label)', '_replace': <function _replace>, '__slots__': (), '_asdict': <function _asdict>, '__repr__': <function __repr__>, '__dict__': <property object>, '_fields': ('node', 'link_type', 'link_label'), '__getnewargs__': <function __getnewargs__>, 'link_label': <property object>, 'link_type': <property object>})¶
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__module__
= 'aiida.orm.utils.links'¶
-
static
__new__
(_cls, node, link_type, link_label)¶ Create new instance of LinkTriple(node, link_type, link_label)
-
__repr__
()¶ Return a nicely formatted representation string
-
__slots__
= ()¶
-
_asdict
()¶ Return a new OrderedDict which maps field names to their values
-
_fields
= ('node', 'link_type', 'link_label')¶
-
classmethod
_make
(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new LinkTriple object from a sequence or iterable
-
_replace
(**kwds)¶ Return a new LinkTriple object replacing specified fields with new values
-
link_label
¶ Alias for field number 2
-
link_type
¶ Alias for field number 1
-
node
¶ Alias for field number 0
-
-
class
aiida.orm.utils.links.
LinkManager
(link_triples)[source]¶ Bases:
object
Class to convert a list of LinkTriple tuples into an iterator.
It defines convenience methods to retrieve certain subsets of LinkTriple while checking for consistency. For example:
LinkManager.one(): returns the only entry in the list or it raises an exception LinkManager.first(): returns the first entry from the list LinkManager.all(): returns all entries from list
The methods all_nodes and all_link_labels are syntactic sugar wrappers around all to get a list of only the incoming nodes or link labels, respectively.
-
__dict__
= dict_proxy({'all_link_pairs': <function all_link_pairs>, '__module__': 'aiida.orm.utils.links', 'get_node_by_label': <function get_node_by_label>, 'all_nodes': <function all_nodes>, '__next__': <function __next__>, 'all': <function all>, 'next': <function next>, '__iter__': <function __iter__>, 'all_link_labels': <function all_link_labels>, '__dict__': <attribute '__dict__' of 'LinkManager' objects>, 'one': <function one>, '__weakref__': <attribute '__weakref__' of 'LinkManager' objects>, '__doc__': '\n Class to convert a list of LinkTriple tuples into an iterator.\n\n It defines convenience methods to retrieve certain subsets of LinkTriple while checking for consistency.\n For example::\n\n LinkManager.one(): returns the only entry in the list or it raises an exception\n LinkManager.first(): returns the first entry from the list\n LinkManager.all(): returns all entries from list\n\n The methods `all_nodes` and `all_link_labels` are syntactic sugar wrappers around `all` to get a list of only the\n incoming nodes or link labels, respectively.\n ', '__init__': <function __init__>, 'first': <function first>})¶
-
__iter__
()[source]¶ Return an iterator of LinkTriple instances.
Returns: iterator of LinkTriple instances
-
__module__
= 'aiida.orm.utils.links'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
first
()[source]¶ Return the first entry from the iterator.
Returns: LinkTriple instance Raises: ValueError – if the iterator contains anything but one entry
-
get_node_by_label
(label)[source]¶ Return the node from list for given label.
Returns: node that corresponds to the given label Raises: aiida.common.NotExistent – if the label is not present among the link_triples
-
-
aiida.orm.utils.links.
validate_link
(source, target, link_type, link_label)[source]¶ Validate adding a link of the given type and label from a given node to ourself.
This function will first validate the class types of the inputs and will subsequently validate whether a link of the specified type is allowed at all between the nodes types of the source and target.
Subsequently, the validity of the “indegree” and “outdegree” of the proposed link is validated, which means validating that the uniqueness constraints of the incoming links into the target node and the outgoing links from the source node are not violated. In AiiDA’s provenance graph each link type has one of the following three types of “degree” character:
* unique * unique pair * unique triple
Each degree character has a different unique constraint on its links, here defined for the indegree:
* unique: any target node, it can only have a single incoming link of this type, regardless of the link label. * unique pair: a node can have an infinite amount of incoming links of this type, as long as the labels within that sub set, are unique. In short, it is the link pair, i.e. the tuple of the link type and label, that has a uniquess constraint for the incoming links to a given node. * unique triple: a node can have an infinite amount of incoming links of this type, as long as the triple tuple of source node, link type and link label is unique. In other words, it is the link triple that has a uniqueness constraint for the incoming links.
The same holds for outdegree, but then it concerns outgoing links from the source node to the target node.
For illustration purposes, consider the following example provenance graphs that are considered legal, where WN, DN and CN represent a WorkflowNode, a DataNode and a CalculationNode, respectively:
1 2 3 ______ ______ ______ ______ ______ | | | | | | | | | | | WN | | DN | | DN | | WN | | WN | |______| |______| |______| |______| |______| | / | | | / a | / a a | | b a | / a _|___/ |___|_ _|___/ | | | | | | | CN | | CN | | DN | |______| |______| |______|
In example 1, the link uniqueness constraint is not violated because despite the labels having the same label a, their link types, CALL_CALC and INPUT_CALC, respectively, are different and their unique_pair indegree is not violated.
Similarly, in the second example, the constraint is not violated, because despite both links having the same link type INPUT_CALC, the have different labels, so the unique_pair indegree of the INPUT_CALC is not violated.
Finally, in the third example, we see two WorkflowNodes both returning the same DataNode and with the same label. Despite the two incoming links here having both the same type as well as the same label, the uniqueness constraint is not violated, because the indegree for RETURN links is unique_triple which means that the triple of source node and link type and label should be unique.
Parameters: - source – the node from which the link is coming
- target – the node to which the link is going
- link_type – the type of link
- link_label – link label
Raises: - TypeError – if source or target is not a Node instance, or link_type is not a LinkType enum
- ValueError – if the proposed link is invalid
Module with OrmEntityLoader and its sub classes that simplify loading entities through their identifiers.
-
aiida.orm.utils.loaders.
get_loader
(orm_class)[source]¶ Return the correct OrmEntityLoader for the given orm class.
Parameters: orm_class – the orm class Returns: a subclass of OrmEntityLoader Raises: ValueError – if no OrmEntityLoader subclass can be found for the given orm class
-
class
aiida.orm.utils.loaders.
OrmEntityLoader
[source]¶ Bases:
object
Base class for entity loaders.
-
__abstractmethods__
= frozenset(['_get_query_builder_label_identifier'])¶
-
__dict__
= dict_proxy({'_abc_cache': <_weakrefset.WeakSet object>, '__module__': 'aiida.orm.utils.loaders', '__dict__': <attribute '__dict__' of 'OrmEntityLoader' objects>, '__weakref__': <attribute '__weakref__' of 'OrmEntityLoader' objects>, '_abc_registry': <_weakrefset.WeakSet object>, '__abstractmethods__': frozenset(['_get_query_builder_label_identifier']), 'get_query_builder': <classmethod object>, 'label_ambiguity_breaker': '!', 'load_entity': <classmethod object>, '_get_query_builder_uuid_identifier': <classmethod object>, 'orm_base_class': <aiida.common.lang.classproperty object>, '_abc_negative_cache_version': 102, '_get_query_builder_id_identifier': <classmethod object>, '_abc_negative_cache': <_weakrefset.WeakSet object>, '_get_query_builder_label_identifier': <aiida.common.lang.abstractclassmethod object>, 'infer_identifier_type': <classmethod object>, '__doc__': 'Base class for entity loaders.', 'get_query_classes': <classmethod object>})¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_id_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as an ID like identifier
Parameters: - identifier – the ID identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
classmethod
_get_query_builder_uuid_identifier
(identifier, classes, query_with_dashes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a UUID like identifier
Parameters: - identifier – the UUID identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance
-
classmethod
get_query_builder
(identifier, identifier_type=None, sub_classes=None, query_with_dashes=True)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, inferring the identifier type if it is not defined.
Parameters: - identifier – the identifier
- identifier_type – the type of the identifier
- sub_classes – an optional tuple of orm classes, that should each be strict sub classes of the base orm class of the loader, that will narrow the queryset
Returns: the query builder instance and a dictionary of used query parameters
-
classmethod
get_query_classes
(sub_classes=None)[source]¶ Get the tuple of classes to be used for the entity query. If sub_classes is defined, each class will be validated by verifying that it is a sub class of the loader’s orm base class. Validate a tuple of classes if a user passes in a specific one when attempting to load an entity. Each class should be a sub class of the entity loader’s orm base class
Parameters: sub_classes – an optional tuple of orm classes, that should each be strict sub classes of the base orm class of the loader, that will narrow the queryset Returns: the tuple of orm classes to be used for the entity query Raises: ValueError – if any of the classes are not a sub class of the entity loader’s orm base class
-
classmethod
infer_identifier_type
(value)[source]¶ This method will attempt to automatically distinguish which identifier type is implied for the given value, if the value itself has no type from which it can be inferred.
The strategy is to first attempt to convert the value to an integer. If successful, it is assumed that the value represents an ID. If that fails, we attempt to interpret the value as a base 16 encoded integer, after having removed any dashes from the string. If that succeeds, it is most likely a UUID. If it seems to be neither an ID nor a UUID, it is assumed to be a LABEL like identifier.
With this approach there is the possibility for ambiguity. Since it is allowed to pass a partial UUID, it is possible that the partial UUID is also a valid ID. Likewise, a LABEL identifier might also be a valid ID, or a valid (partial) UUID. Fortunately, these ambiguities can be solved though:
- ID/UUID: can always be solved by passing a partial UUID with at least one dash
- ID/LABEL: appending an exclamation point ! to the identifier, will force LABEL interpretation
- UUID/LABEL: appending an exclamation point ! to the identifier, will force LABEL interpretation
As one can see, the user will always be able to include at least one dash of the UUID identifier to prevent it from being interpreted as an ID. For the potential ambiguities in LABEL identifiers, we had to introduce a special marker to provide a surefire way of breaking any ambiguity that may arise. Adding an exclamation point will break the normal strategy and the identifier will directly be interpreted as a LABEL identifier.
Parameters: value – the value of the identifier Returns: the identifier and identifier type Raises: ValueError – if the value is an invalid identifier
-
label_ambiguity_breaker
= '!'¶
-
classmethod
load_entity
(identifier, identifier_type=None, sub_classes=None, query_with_dashes=True)[source]¶ Load an entity that uniquely corresponds to the provided identifier of the identifier type.
Parameters: - identifier – the identifier
- identifier_type – the type of the identifier
- sub_classes – an optional tuple of orm classes, that should each be strict sub classes of the base orm class of the loader, that will narrow the queryset
Returns: the loaded entity
Raises: - aiida.common.MultipleObjectsError – if the identifier maps onto multiple entities
- aiida.common.NotExistent – if the identifier maps onto not a single entity
-
orm_base_class
¶ A class that, when used as a decorator, works as if the two decorators @property and @classmethod where applied together (i.e., the object works as a property, both for the Class and for any of its instance; and is called with the class cls rather than with the instance as its first argument).
-
-
class
aiida.orm.utils.loaders.
CalculationEntityLoader
[source]¶ Bases:
aiida.orm.utils.loaders.OrmEntityLoader
Loader for the Calculation entity and sub classes.
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance that should retrieve the entity corresponding to the identifier
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
orm_base_class
¶ alias of
aiida.orm.nodes.process.calculation.calculation.CalculationNode
-
-
class
aiida.orm.utils.loaders.
CodeEntityLoader
[source]¶ Bases:
aiida.orm.utils.loaders.OrmEntityLoader
Loader for the Code entity and sub classes.
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance that should retrieve the entity corresponding to the identifier
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
orm_base_class
¶ alias of
aiida.orm.nodes.data.code.Code
-
-
class
aiida.orm.utils.loaders.
ComputerEntityLoader
[source]¶ Bases:
aiida.orm.utils.loaders.OrmEntityLoader
Loader for the Computer entity and sub classes.
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance that should retrieve the entity corresponding to the identifier
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
orm_base_class
¶ alias of
aiida.orm.computers.Computer
-
-
class
aiida.orm.utils.loaders.
GroupEntityLoader
[source]¶ Bases:
aiida.orm.utils.loaders.OrmEntityLoader
Loader for the Group entity and sub classes.
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance that should retrieve the entity corresponding to the identifier
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
orm_base_class
¶ alias of
aiida.orm.groups.Group
-
-
class
aiida.orm.utils.loaders.
NodeEntityLoader
[source]¶ Bases:
aiida.orm.utils.loaders.OrmEntityLoader
Loader for the Node entity and sub classes.
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.utils.loaders'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
classmethod
_get_query_builder_label_identifier
(identifier, classes)[source]¶ Return the query builder instance that attempts to map the identifier onto an entity of the orm class, defined for this loader class, interpreting the identifier as a LABEL like identifier
Parameters: - identifier – the LABEL identifier
- classes – a tuple of orm classes to which the identifier should be mapped
Returns: the query builder instance that should retrieve the entity corresponding to the identifier
Raises: - ValueError – if the identifier is invalid
- aiida.common.NotExistent – if the orm base class does not support a LABEL like identifier
-
orm_base_class
¶ alias of
aiida.orm.nodes.node.Node
-
Module for logging methods/classes that need the ORM.
-
class
aiida.orm.utils.log.
DBLogHandler
(level=0)[source]¶ Bases:
logging.Handler
A custom db log handler for writing logs tot he database
-
__module__
= 'aiida.orm.utils.log'¶
-
-
aiida.orm.utils.log.
create_logger_adapter
(logger, node)[source]¶ Create a logger adapter for the given Node instance.
Parameters: - logger – the logger to adapt
- node – the node instance to create the adapter for
Returns: the logger adapter
Return type: logging.LoggerAdapter
-
aiida.orm.utils.log.
get_dblogger_extra
(node)[source]¶ Return the additional information necessary to attach any log records to the given node instance.
Parameters: node – a Node instance
Contain utility classes for “managers”, i.e., classes that act allow to access members of other classes via TAB-completable attributes (e.g. the class underlying calculation.inputs to allow to do calculation.inputs.<label>).
-
class
aiida.orm.utils.managers.
NodeLinksManager
(node, link_type, incoming)[source]¶ Bases:
object
A manager that allows to inspect, with tab-completion, nodes linked to a given one. See an example of its use in CalculationNode.inputs.
-
__dict__
= dict_proxy({'__module__': 'aiida.orm.utils.managers', '_get_keys': <function _get_keys>, '__getitem__': <function __getitem__>, '__str__': <function __str__>, '__getattr__': <function __getattr__>, '_get_node_by_link_label': <function _get_node_by_link_label>, '__iter__': <function __iter__>, '__dir__': <function __dir__>, '__dict__': <attribute '__dict__' of 'NodeLinksManager' objects>, '__weakref__': <attribute '__weakref__' of 'NodeLinksManager' objects>, '__doc__': '\n A manager that allows to inspect, with tab-completion, nodes linked to a given one.\n See an example of its use in `CalculationNode.inputs`.\n ', '__init__': <function __init__>, '__repr__': <function __repr__>})¶
-
__getattr__
(name)[source]¶ Parameters: name – name of the attribute to be asked to the parser results.
-
__getitem__
(name)[source]¶ interface to get to the parser results as a dictionary.
Parameters: name – name of the attribute to be asked to the parser results.
-
__init__
(node, link_type, incoming)[source]¶ Initialise the link manager.
Parameters: - node – the reference node object
- link_type – the link_type to inspect
- incoming – if True, inspect incoming links, otherwise inspect outgoing links
-
__module__
= 'aiida.orm.utils.managers'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
aiida.orm.utils.managers.
AttributeManager
(node)[source]¶ Bases:
object
An object used internally to return the attributes as a dictionary. This is currently used in
Dict
, for instance.Note: Important! It cannot be used to change variables, just to read them. To change values (of unstored nodes), use the proper Node methods. -
__dict__
= dict_proxy({'__module__': 'aiida.orm.utils.managers', '__getitem__': <function __getitem__>, '__getattr__': <function __getattr__>, '__iter__': <function __iter__>, '__dir__': <function __dir__>, '__dict__': <attribute '__dict__' of 'AttributeManager' objects>, '_get_dict': <function _get_dict>, '__weakref__': <attribute '__weakref__' of 'AttributeManager' objects>, '__doc__': '\n An object used internally to return the attributes as a dictionary.\n This is currently used in :py:class:`~aiida.orm.nodes.data.dict.Dict`,\n for instance.\n\n :note: Important! It cannot be used to change variables, just to read\n them. To change values (of unstored nodes), use the proper Node methods.\n ', '__init__': <function __init__>})¶
-
__getattr__
(name)[source]¶ Interface to get to dictionary values, using the key as an attribute.
Note: it works only for attributes that only contain letters, numbers and underscores, and do not start with a number. Parameters: name – name of the key whose value is required.
-
__getitem__
(name)[source]¶ Interface to get to dictionary values as a dictionary.
Parameters: name – name of the key whose value is required.
-
__module__
= 'aiida.orm.utils.managers'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
Mixin classes for ORM classes.
-
class
aiida.orm.utils.mixins.
FunctionCalculationMixin
[source]¶ Bases:
object
This mixin should be used for ProcessNode subclasses that are used to record the execution of a python function. For example the process nodes that are used for a function that was wrapped by the workfunction or calcfunction function decorators. The store_source_info method can then be called with the wrapped function to store information about that function in the calculation node through the inspect module. Various property getters are defined to later retrieve that information from the node
-
FUNCTION_NAMESPACE_KEY
= 'function_namespace'¶
-
FUNCTION_NAME_KEY
= 'function_name'¶
-
FUNCTION_SOURCE_FILE_PATH
= 'source_file'¶
-
FUNCTION_STARTING_LINE_KEY
= 'function_starting_line_number'¶
-
__dict__
= dict_proxy({'__module__': 'aiida.orm.utils.mixins', '_set_function_namespace': <function _set_function_namespace>, 'FUNCTION_STARTING_LINE_KEY': 'function_starting_line_number', '_set_function_starting_line_number': <function _set_function_starting_line_number>, 'FUNCTION_SOURCE_FILE_PATH': 'source_file', '__weakref__': <attribute '__weakref__' of 'FunctionCalculationMixin' objects>, '_set_function_name': <function _set_function_name>, 'store_source_info': <function store_source_info>, 'function_namespace': <property object>, 'function_starting_line_number': <property object>, 'FUNCTION_NAME_KEY': 'function_name', '__dict__': <attribute '__dict__' of 'FunctionCalculationMixin' objects>, 'FUNCTION_NAMESPACE_KEY': 'function_namespace', 'get_function_source_code': <function get_function_source_code>, '_set_source_file': <function _set_source_file>, '__doc__': '\n This mixin should be used for ProcessNode subclasses that are used to record the execution\n of a python function. For example the process nodes that are used for a function that\n was wrapped by the `workfunction` or `calcfunction` function decorators. The `store_source_info`\n method can then be called with the wrapped function to store information about that function\n in the calculation node through the inspect module. Various property getters are defined to\n later retrieve that information from the node\n ', 'function_name': <property object>})¶
-
__module__
= 'aiida.orm.utils.mixins'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_set_function_name
(function_name)[source]¶ Set the function name of the wrapped function
Parameters: function_name – the function name
-
_set_function_namespace
(function_namespace)[source]¶ Set the function namespace of the wrapped function
Parameters: function_namespace – the function namespace
-
_set_function_starting_line_number
(function_starting_line_number)[source]¶ Set the starting line number of the wrapped function in its source file
Parameters: function_starting_line_number – the starting line number
-
_set_source_file
(source_file_handle)[source]¶ Store a copy of the source file from source_file_handle in the repository
Parameters: source_file_handle – a file like object with the source file
-
function_name
¶ Return the function name of the wrapped function
Returns: the function name or None
-
function_namespace
¶ Return the function namespace of the wrapped function
Returns: the function namespace or None
-
function_starting_line_number
¶ Return the starting line number of the wrapped function in its source file
Returns: the starting line number or None
-
get_function_source_code
()[source]¶ Return the absolute path to the source file in the repository
Returns: the absolute path of the source file in the repository, or None if it does not exist
-
store_source_info
(func)[source]¶ Retrieve source information about the wrapped function func through the inspect module, and store it in the attributes and repository of the node. The function name, namespace and the starting line number in the source file will be stored in the attributes. The source file itself will be copied into the repository
Parameters: func – the function to inspect and whose information to store in the node
-
-
class
aiida.orm.utils.mixins.
Sealable
[source]¶ Bases:
object
Mixin to mark a Node as sealable.
-
SEALED_KEY
= 'sealed'¶
-
__dict__
= dict_proxy({'_updatable_attributes': <aiida.common.lang.classproperty object>, '__module__': 'aiida.orm.utils.mixins', 'delete_attribute': <function delete_attribute>, 'validate_outgoing': <function validate_outgoing>, 'is_sealed': <property object>, 'set_attribute': <function set_attribute>, '__dict__': <attribute '__dict__' of 'Sealable' objects>, 'SEALED_KEY': 'sealed', 'seal': <function seal>, 'validate_incoming': <function validate_incoming>, '__weakref__': <attribute '__weakref__' of 'Sealable' objects>, '__doc__': 'Mixin to mark a Node as `sealable`.'})¶
-
__module__
= 'aiida.orm.utils.mixins'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_updatable_attributes
= ('sealed',)¶
-
delete_attribute
(key)[source]¶ Delete an attribute
Parameters: key – attribute name
Raises: - AttributeError – if key does not exist
- aiida.common.ModificationNotAllowed – if the node is already sealed or if the node is already stored and the attribute is not updatable
-
is_sealed
¶ Returns whether the node is sealed, i.e. whether the sealed attribute has been set to True
-
set_attribute
(key, value, **kwargs)[source]¶ Set a new attribute
Parameters: - key – attribute name
- value – attribute value
Raises: aiida.common.ModificationNotAllowed – if the node is already sealed or if the node is already stored and the attribute is not updatable
-
validate_incoming
(source, link_type, link_label)[source]¶ Validate adding a link of the given type from a given node to ourself.
Adding an incoming link to a sealed node is forbidden.
Parameters: - source – the node from which the link is coming
- link_type – the link type
- link_label – the link label
Raises: aiida.common.ModificationNotAllowed – if the target node (self) is sealed
-
validate_outgoing
(target, link_type, link_label)[source]¶ Validate adding a link of the given type from ourself to a given node.
Adding an outgoing link from a sealed node is forbidden.
Parameters: - target – the node to which the link is going
- link_type – the link type
- link_label – the link label
Raises: aiida.common.ModificationNotAllowed – if the source node (self) is sealed
-
Utilities to operate on Node classes.
-
aiida.orm.utils.node.
load_node_class
(type_string)[source]¶ Return the Node sub class that corresponds to the given type string.
Parameters: type_string – the type string of the node Returns: a sub class of Node
-
aiida.orm.utils.node.
get_type_string_from_class
(class_module, class_name)[source]¶ Given the module and name of a class, determine the orm_class_type string, which codifies the orm class that is to be used. The returned string will always have a terminating period, which is required to query for the string in the database
Parameters: - class_module – module of the class
- class_name – name of the class
-
aiida.orm.utils.node.
get_query_type_from_type_string
(type_string)[source]¶ Take the type string of a Node and create the queryable type string
Parameters: type_string – the plugin_type_string attribute of a Node Returns: the type string that can be used to query for
-
class
aiida.orm.utils.node.
AbstractNodeMeta
[source]¶ Bases:
abc.ABCMeta
Some python black magic to set correctly the logger also in subclasses.
-
__module__
= 'aiida.orm.utils.node'¶
-
-
aiida.orm.utils.node.
clean_value
(value)[source]¶ Get value from input and (recursively) replace, if needed, all occurrences of BaseType AiiDA data nodes with their value, and List with a standard list. It also makes a deep copy of everything The purpose of this function is to convert data to a type which can be serialized and deserialized for storage in the DB without its value changing.
Note however that there is no logic to avoid infinite loops when the user passes some perverse recursive dictionary or list. In any case, however, this would not be storable by AiiDA…
Parameters: value – A value to be set as an attribute or an extra Returns: a “cleaned” value, potentially identical to value, but with values replaced where needed.
-
aiida.orm.utils.remote.
clean_remote
(transport, path)[source]¶ Recursively remove a remote folder, with the given absolute path, and all its contents. The path should be made accessible through the transport channel, which should already be open
Parameters: - transport – an open Transport channel
- path – an absolute path on the remote made available through the transport
-
aiida.orm.utils.remote.
get_calcjob_remote_paths
(pks=None, past_days=None, older_than=None, computers=None, user=None)[source]¶ Return a mapping of computer uuids to a list of remote paths, for a given set of calcjobs. The set of calcjobs will be determined by a query with filters based on the pks, past_days, older_than, computers and user arguments.
Parameters: - pks – onlu include calcjobs with a pk in this list
- past_days – only include calcjobs created since past_days
- older_than – only include calcjobs older than
- computers – only include calcjobs that were ran on these computers
- user – only include calcjobs of this user
Returns: mapping of computer uuid and list of remote paths, or None
Class that represents the repository of a Node instance.
-
class
aiida.orm.utils.repository.
File
(name, type)¶ Bases:
tuple
-
__dict__
= dict_proxy({'__module__': 'aiida.orm.utils.repository', '__getstate__': <function __getstate__>, '__new__': <staticmethod object>, '_make': <classmethod object>, '_replace': <function _replace>, '__slots__': (), '_asdict': <function _asdict>, '__repr__': <function __repr__>, '__dict__': <property object>, '_fields': ('name', 'type'), '__getnewargs__': <function __getnewargs__>, 'type': <property object>, '__doc__': 'File(name, type)', 'name': <property object>})¶
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__module__
= 'aiida.orm.utils.repository'¶
-
static
__new__
(_cls, name, type)¶ Create new instance of File(name, type)
-
__repr__
()¶ Return a nicely formatted representation string
-
__slots__
= ()¶
-
_asdict
()¶ Return a new OrderedDict which maps field names to their values
-
_fields
= ('name', 'type')¶
-
classmethod
_make
(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new File object from a sequence or iterable
-
_replace
(**kwds)¶ Return a new File object replacing specified fields with new values
-
name
¶ Alias for field number 0
-
type
¶ Alias for field number 1
-
-
class
aiida.orm.utils.repository.
FileType
[source]¶ Bases:
enum.Enum
-
DIRECTORY
= 0¶
-
FILE
= 1¶
-
__module__
= 'aiida.orm.utils.repository'¶
-
-
class
aiida.orm.utils.repository.
Repository
(uuid, is_stored, base_path=None)[source]¶ Bases:
object
Class that represents the repository of a Node instance.
-
__dict__
= dict_proxy({'restore': <function restore>, '__module__': 'aiida.orm.utils.repository', '_section_name': 'node', 'delete_object': <function delete_object>, 'list_objects': <function list_objects>, '__del__': <function __del__>, 'put_object_from_file': <function put_object_from_file>, 'put_object_from_tree': <function put_object_from_tree>, 'erase': <function erase>, '__dict__': <attribute '__dict__' of 'Repository' objects>, 'open': <function open>, '__init__': <function __init__>, '_get_temp_folder': <function _get_temp_folder>, 'get_object_content': <function get_object_content>, 'validate_mutability': <function validate_mutability>, '__weakref__': <attribute '__weakref__' of 'Repository' objects>, '_get_base_folder': <function _get_base_folder>, 'list_object_names': <function list_object_names>, 'get_object': <function get_object>, 'put_object_from_filelike': <function put_object_from_filelike>, '__doc__': 'Class that represents the repository of a `Node` instance.', 'store': <function store>, 'validate_object_key': <staticmethod object>})¶
-
__init__
(uuid, is_stored, base_path=None)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__module__
= 'aiida.orm.utils.repository'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_get_temp_folder
()[source]¶ Return the temporary sandbox folder.
Returns: a SandboxFolder object mapping the node in the repository.
-
_section_name
= 'node'¶
-
delete_object
(key, force=False)[source]¶ Delete the object from the repository.
Warning
If the repository belongs to a stored node, a ModificationNotAllowed exception will be raised. This check can be avoided by using the force flag, but this should be used with extreme caution!
Parameters: - key – fully qualified identifier for the object within the repository
- force – boolean, if True, will skip the mutability check
Raises: aiida.common.ModificationNotAllowed – if repository is immutable and force=False
-
erase
(force=False)[source]¶ Delete the repository folder.
Warning
If the repository belongs to a stored node, a ModificationNotAllowed exception will be raised. This check can be avoided by using the force flag, but this should be used with extreme caution!
Parameters: force – boolean, if True, will skip the mutability check Raises: aiida.common.ModificationNotAllowed – if repository is immutable and force=False
-
get_object
(key)[source]¶ Return the object identified by key.
Parameters: key – fully qualified identifier for the object within the repository Returns: a File named tuple representing the object located at key
-
get_object_content
(key)[source]¶ Return the content of a object identified by key.
Parameters: key – fully qualified identifier for the object within the repository
-
list_object_names
(key=None)[source]¶ Return a list of the object names contained in this repository, optionally in the given sub directory.
Parameters: key – fully qualified identifier for the object within the repository Returns: a list of File named tuples representing the objects present in directory with the given key
-
list_objects
(key=None)[source]¶ Return a list of the objects contained in this repository, optionally in the given sub directory.
Parameters: key – fully qualified identifier for the object within the repository Returns: a list of File named tuples representing the objects present in directory with the given key
-
open
(key, mode='r')[source]¶ Open a file handle to an object stored under the given key.
Parameters: - key – fully qualified identifier for the object within the repository
- mode – the mode under which to open the handle
-
put_object_from_file
(path, key, mode='w', encoding='utf8', force=False)[source]¶ Store a new object under key with contents of the file located at path on this file system.
Warning
If the repository belongs to a stored node, a ModificationNotAllowed exception will be raised. This check can be avoided by using the force flag, but this should be used with extreme caution!
Parameters: - path – absolute path of file whose contents to copy to the repository
- key – fully qualified identifier for the object within the repository
- mode – the file mode with which the object will be written
- encoding – the file encoding with which the object will be written
- force – boolean, if True, will skip the mutability check
Raises: aiida.common.ModificationNotAllowed – if repository is immutable and force=False
-
put_object_from_filelike
(handle, key, mode='w', encoding='utf8', force=False)[source]¶ Store a new object under key with contents of filelike object handle.
Warning
If the repository belongs to a stored node, a ModificationNotAllowed exception will be raised. This check can be avoided by using the force flag, but this should be used with extreme caution!
Parameters: - handle – filelike object with the content to be stored
- key – fully qualified identifier for the object within the repository
- mode – the file mode with which the object will be written
- encoding – the file encoding with which the object will be written
- force – boolean, if True, will skip the mutability check
Raises: aiida.common.ModificationNotAllowed – if repository is immutable and force=False
-
put_object_from_tree
(path, key=None, contents_only=True, force=False)[source]¶ Store a new object under key with the contents of the directory located at path on this file system.
Warning
If the repository belongs to a stored node, a ModificationNotAllowed exception will be raised. This check can be avoided by using the force flag, but this should be used with extreme caution!
Parameters: - path – absolute path of directory whose contents to copy to the repository
- key – fully qualified identifier for the object within the repository
- contents_only – boolean, if True, omit the top level directory of the path and only copy its contents.
- force – boolean, if True, will skip the mutability check
Raises: aiida.common.ModificationNotAllowed – if repository is immutable and force=False
-
validate_mutability
()[source]¶ Raise if the repository is immutable.
Raises: aiida.common.ModificationNotAllowed – if repository is marked as immutable because the corresponding node is stored
-
Serialisation functions for AiiDA types
WARNING: Changing the representation of things here may break people’s current saved e.g. things like checkpoints and messages in the RabbitMQ queue so do so with caution. It is fine to add representers for new types though.
-
class
aiida.orm.utils.serialize.
AiiDADumper
(stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None)[source]¶ Bases:
yaml.dumper.Dumper
Custom AiiDA YAML dumper. Needed so that we don’t have to encode each type in the AiiDA graph hierarchy separately using a custom representer.
-
__module__
= 'aiida.orm.utils.serialize'¶
-
yaml_representers
= {None: <unbound method SafeRepresenter.represent_undefined>, <type 'classobj'>: <unbound method Representer.represent_name>, <type 'float'>: <unbound method SafeRepresenter.represent_float>, <type 'int'>: <unbound method SafeRepresenter.represent_int>, <type 'list'>: <unbound method SafeRepresenter.represent_list>, <type 'long'>: <unbound method Representer.represent_long>, <type 'dict'>: <unbound method SafeRepresenter.represent_dict>, <type 'module'>: <unbound method Representer.represent_module>, <type 'NoneType'>: <unbound method SafeRepresenter.represent_none>, <type 'set'>: <unbound method SafeRepresenter.represent_set>, <type 'str'>: <unbound method Representer.represent_str>, <type 'tuple'>: <unbound method Representer.represent_tuple>, <type 'type'>: <unbound method Representer.represent_name>, <type 'unicode'>: <unbound method Representer.represent_unicode>, <type 'bool'>: <unbound method SafeRepresenter.represent_bool>, <type 'complex'>: <unbound method Representer.represent_complex>, <type 'function'>: <unbound method Representer.represent_name>, <type 'builtin_function_or_method'>: <unbound method Representer.represent_name>, <class 'aiida.common.extendeddicts.AttributeDict'>: <functools.partial object>, <class 'plumpy.persistence.Bundle'>: <function represent_bundle>, <class 'plumpy.utils.AttributesFrozendict'>: <functools.partial object>, <type 'datetime.datetime'>: <unbound method SafeRepresenter.represent_datetime>, <type 'datetime.date'>: <unbound method SafeRepresenter.represent_date>}¶
-
-
class
aiida.orm.utils.serialize.
AiiDALoader
(stream)[source]¶ Bases:
yaml.loader.Loader
AiiDA specific YAML loader
-
__module__
= 'aiida.orm.utils.serialize'¶
-
yaml_constructors
= {None: <unbound method SafeConstructor.construct_undefined>, '!aiida_attributedict': <functools.partial object>, '!aiida_computer': <function computer_constructor>, '!aiida_group': <function group_constructor>, '!aiida_node': <function node_constructor>, u'!plumpy:Bundle': <function _bundle_constructor>, '!plumpy:attributes_frozendict': <functools.partial object>, '!plumpy:bundle': <function bundle_constructor>, u'tag:yaml.org,2002:binary': <unbound method SafeConstructor.construct_yaml_binary>, u'tag:yaml.org,2002:bool': <unbound method SafeConstructor.construct_yaml_bool>, u'tag:yaml.org,2002:float': <unbound method SafeConstructor.construct_yaml_float>, u'tag:yaml.org,2002:int': <unbound method SafeConstructor.construct_yaml_int>, u'tag:yaml.org,2002:map': <unbound method SafeConstructor.construct_yaml_map>, u'tag:yaml.org,2002:null': <unbound method SafeConstructor.construct_yaml_null>, u'tag:yaml.org,2002:omap': <unbound method SafeConstructor.construct_yaml_omap>, u'tag:yaml.org,2002:pairs': <unbound method SafeConstructor.construct_yaml_pairs>, u'tag:yaml.org,2002:python/bool': <unbound method Constructor.construct_yaml_bool>, u'tag:yaml.org,2002:python/complex': <unbound method Constructor.construct_python_complex>, u'tag:yaml.org,2002:python/dict': <unbound method Constructor.construct_yaml_map>, u'tag:yaml.org,2002:python/float': <unbound method Constructor.construct_yaml_float>, u'tag:yaml.org,2002:python/int': <unbound method Constructor.construct_yaml_int>, u'tag:yaml.org,2002:python/list': <unbound method Constructor.construct_yaml_seq>, u'tag:yaml.org,2002:python/long': <unbound method Constructor.construct_python_long>, u'tag:yaml.org,2002:python/none': <unbound method Constructor.construct_yaml_null>, u'tag:yaml.org,2002:python/str': <unbound method Constructor.construct_python_str>, u'tag:yaml.org,2002:python/tuple': <unbound method Constructor.construct_python_tuple>, u'tag:yaml.org,2002:python/unicode': <unbound method Constructor.construct_python_unicode>, u'tag:yaml.org,2002:seq': <unbound method SafeConstructor.construct_yaml_seq>, u'tag:yaml.org,2002:set': <unbound method SafeConstructor.construct_yaml_set>, u'tag:yaml.org,2002:str': <unbound method SafeConstructor.construct_yaml_str>, u'tag:yaml.org,2002:timestamp': <unbound method SafeConstructor.construct_yaml_timestamp>}¶
-
-
aiida.orm.utils.serialize.
bundle_constructor
(loader, mapping)[source]¶ Construct an AttributeDict from the representation
Parameters: - mapping – the class of the mapping to construct, must accept a dictionary as a sole constructor argument to be compatible
- loader (
yaml.loader.Loader
) – the yaml loader - mapping – the attribute dict representation
Returns: the mapping type
-
aiida.orm.utils.serialize.
computer_constructor
(loader, computer)[source]¶ Load an aiida computer from the yaml representation
Parameters: - loader – the yaml loader
- computer – the yaml representation
Returns: the aiida computer
Return type:
-
aiida.orm.utils.serialize.
deserialize
(serialized)[source]¶ Deserialize a string that represents a serialized data structure
Parameters: serialized – the string representation of serialized data Returns: the deserialized data structure
-
aiida.orm.utils.serialize.
group_constructor
(loader, group)[source]¶ Load an aiida group from the yaml representation
Parameters: - loader – the yaml loader
- group – the yaml representation
Returns: the aiida group
Return type:
-
aiida.orm.utils.serialize.
mapping_constructor
(mapping_type, loader, mapping)[source]¶ Construct an AttributeDict from the representation
Parameters: - mapping_type – the class of the mapping to construct, must accept a dictionary as a sole constructor argument to be compatible
- loader (
yaml.loader.Loader
) – the yaml loader - mapping – the attribute dict representation
Returns: the mapping type
-
aiida.orm.utils.serialize.
node_constructor
(loader, node)[source]¶ Load an aiida node from the yaml representation
Parameters: - loader – the yaml loader
- node – the yaml representation
Returns: the aiida node
Return type:
-
aiida.orm.utils.serialize.
represent_bundle
(dumper, bundle)[source]¶ Represent an AttributeDict in YAML
Parameters: - tag – the yaml tag to use
- dumper (
yaml.dumper.Dumper
) – the dumper to use - bundle – the attribute dict to represent
Returns: the representation
-
aiida.orm.utils.serialize.
represent_computer
(dumper, computer)[source]¶ Represent a group in YAML
Parameters: - dumper – the dumper to use
- computer (
aiida.orm.Computer
) – the computer to represent
Returns: the representation
-
aiida.orm.utils.serialize.
represent_group
(dumper, group)[source]¶ Represent a group in YAML
Parameters: - dumper – the dumper to use
- group (
aiida.orm.Group
) – the group to represent
Returns: the representation
-
aiida.orm.utils.serialize.
represent_mapping
(tag, dumper, mapping)[source]¶ Represent an AttributeDict in YAML
Parameters: - tag – the yaml tag to use
- dumper (
yaml.dumper.Dumper
) – the dumper to use - mapping – the attribute dict to represent
Returns: the representation
-
aiida.orm.utils.serialize.
represent_node
(dumper, node)[source]¶ Represent a node in YAML
Parameters: - dumper – the dumper to use
- node (
aiida.orm.nodes.node.Node
) – the node to represent
Returns: the representation
-
aiida.orm.utils.serialize.
serialize
(data, encoding=None)[source]¶ Serialize the given data structure into a string
The function supports standard data containers such as maps and lists as well as AiiDA nodes which will be serialized into strings, before the whole data structure is dumped into a string using YAML.
Parameters: - data – the general data to serialize
- encoding – optional encoding for the serialized string
Returns: string representation of the serialized data structure or byte array if specific encoding is specified