aiida.orm.implementation.sqlalchemy package¶
Submodules¶
SqlAlchemy implementations for the AuthInfo entity and collection.
-
class
aiida.orm.implementation.sqlalchemy.authinfos.
SqlaAuthInfo
(backend, computer, user)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.authinfos.BackendAuthInfo
AuthInfo implementation for SQLAlchemy.
-
MODEL_CLASS
¶ alias of
aiida.backends.sqlalchemy.models.authinfo.DbAuthInfo
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, computer, user)[source]¶ Construct an SqlaAuthInfo
Parameters: - computer – a Computer instance
- user – a User instance
Returns: an AuthInfo object associated with the given computer and user
-
__module__
= 'aiida.orm.implementation.sqlalchemy.authinfos'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.authinfo.DbAuthInfo], <class 'aiida.orm.implementation.authinfos.BackendAuthInfo'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926333796219¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaAuthInfo
-
computer
¶
-
dbauthinfo
¶
-
enabled
¶
-
id
¶
-
is_stored
¶ Return whether the AuthInfo is stored
Returns: True if stored, False otherwise
-
set_auth_params
(auth_params)[source]¶ Replace the auth_params dictionary in the DB with the provided dictionary
-
set_metadata
(metadata)[source]¶ Replace the metadata dictionary in the DB with the provided dictionary
-
user
¶
-
-
class
aiida.orm.implementation.sqlalchemy.authinfos.
SqlaAuthInfoCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.authinfos.BackendAuthInfoCollection
Collection of AuthInfo instances.
-
ENTITY_CLASS
¶ alias of
SqlaAuthInfo
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.authinfos'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.authinfos.BackendAuthInfoCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334020639¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaAuthInfoCollection
-
delete
(authinfo_id)[source]¶ Remove an AuthInfo from the collection with the given id :param authinfo_id: The ID of the authinfo to delete
-
get
(computer, user)[source]¶ Return a SqlaAuthInfo given a computer and a user
Parameters: - computer – a Computer instance
- user – a User instance
Returns: an AuthInfo object associated with the given computer and user
Raises: - aiida.common.NotExistent – if the user is not configured to use computer
- sqlalchemy.orm.exc.MultipleResultsFound – if the user is configured more than once to use the computer! Should never happen
-
SqlAlchemy implementation of aiida.orm.implementation.backends.Backend.
-
class
aiida.orm.implementation.sqlalchemy.backend.
SqlaBackend
[source]¶ Bases:
aiida.orm.implementation.sql.backends.SqlBackend
SqlAlchemy implementation of aiida.orm.implementation.backends.Backend.
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.backend'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sql.backends.SqlBackend[sqlalchemy.ext.declarative.api.Model],)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926333483846¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaBackend
-
authinfos
¶
-
comments
¶
-
computers
¶
-
cursor
(**kwds)[source]¶ Return a psycopg cursor to be used in a context manager.
Returns: a psycopg cursor Return type: psycopg2.extensions.cursor
-
static
execute_raw
(query)[source]¶ Execute a raw SQL statement and return the result.
Parameters: query – a string containing a raw SQL statement Returns: the result of the query
-
static
get_connection
()[source]¶ Get the SQLA database connection
Returns: the SQLA database connection
-
groups
¶
-
logs
¶
-
nodes
¶
-
query
()[source]¶ Return an instance of a query builder implementation for this backend
Returns: a new query builder instance Return type: aiida.orm.implementation.BackendQueryBuilder
-
query_manager
¶
-
users
¶
-
Sqla implementations for the Comment entity and collection.
-
class
aiida.orm.implementation.sqlalchemy.comments.
SqlaComment
(backend, node, user, content=None, ctime=None, mtime=None)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.comments.BackendComment
Comment implementation for Sqla.
-
MODEL_CLASS
¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, node, user, content=None, ctime=None, mtime=None)[source]¶ Construct a SqlaComment.
Parameters: - node – a Node instance
- user – a User instance
- content – the comment content
- ctime – The creation time as datetime object
- mtime – The modification time as datetime object
Returns: a Comment object associated to the given node and user
-
__module__
= 'aiida.orm.implementation.sqlalchemy.comments'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.comment.DbComment], <class 'aiida.orm.implementation.comments.BackendComment'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926333901643¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaComment
-
content
¶
-
ctime
¶
-
mtime
¶
-
node
¶
-
user
¶
-
-
class
aiida.orm.implementation.sqlalchemy.comments.
SqlaCommentCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.comments.BackendCommentCollection
SqlAlchemy implementation for the CommentCollection.
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.comments'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.comments.BackendCommentCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334003104¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaCommentCollection
-
create
(node, user, content=None, **kwargs)[source]¶ Create a Comment for a given node and user
Parameters: - node – a Node instance
- user – a User instance
- content – the comment content
Returns: a Comment object associated to the given node and user
-
SqlAlchemy implementations for the Computer entity and collection.
-
class
aiida.orm.implementation.sqlalchemy.computers.
SqlaComputer
(backend, **kwargs)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.computers.BackendComputer
SqlAlchemy implementation for BackendComputer.
-
MODEL_CLASS
¶ alias of
aiida.backends.sqlalchemy.models.computer.DbComputer
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.computers'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.computer.DbComputer], <class 'aiida.orm.implementation.computers.BackendComputer'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334025759¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaComputer
-
description
¶
-
hostname
¶
-
id
¶
-
is_stored
¶
-
name
¶
-
pk
¶
-
set_hostname
(val)[source]¶ Set the hostname of this computer :param val: The new hostname :type val: str
-
uuid
¶
-
-
class
aiida.orm.implementation.sqlalchemy.computers.
SqlaComputerCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.computers.BackendComputerCollection
Collection of Computer instances.
-
ENTITY_CLASS
¶ alias of
SqlaComputer
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.computers'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.computers.BackendComputerCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334015932¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaComputerCollection
-
Module to get the backend instance from the Models instance
-
aiida.orm.implementation.sqlalchemy.convert.
get_backend_entity
(*args, **kw)[source]¶ Default get_backend_entity
Classes and methods for Django specific backend entities
-
class
aiida.orm.implementation.sqlalchemy.entities.
SqlaModelEntity
(*args, **kwargs)[source]¶ Bases:
typing.Generic
A mixin that adds some common SQLA backend entity methods
-
MODEL_CLASS
= None¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__dict__
= dict_proxy({'__module__': 'aiida.orm.implementation.sqlalchemy.entities', 'from_dbmodel': <classmethod object>, u'__origin__': None, 'is_stored': <property object>, '__dict__': <attribute '__dict__' of 'SqlaModelEntity' objects>, 'dbmodel': <property object>, '__weakref__': <attribute '__weakref__' of 'SqlaModelEntity' objects>, 'id': <property object>, '__init__': <function __init__>, '_dbmodel': None, '_abc_generic_negative_cache_version': 102, '__abstractmethods__': frozenset([]), 'pk': <property object>, '__orig_bases__': (typing.Generic[~ModelType],), '_class_check': <classmethod object>, '__doc__': 'A mixin that adds some common SQLA backend entity methods', 'store': <function store>, '_abc_cache': <_weakrefset.WeakSet object>, '__tree_hash__': 5926333590608, '__args__': None, 'get_dbmodel_attribute_name': <classmethod object>, '__next_in_mro__': <type 'object'>, '__parameters__': (~ModelType,), '_gorg': aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity, 'MODEL_CLASS': None, u'__extra__': None, '_abc_registry': <_weakrefset.WeakSet object>, '_abc_generic_negative_cache': <_weakrefset.WeakSet object>})¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.entities'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (typing.Generic[~ModelType],)¶
-
__origin__
= None¶
-
__parameters__
= (~ModelType,)¶
-
__tree_hash__
= 5926333590608¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_dbmodel
= None¶
-
_gorg
¶ alias of
SqlaModelEntity
-
dbmodel
¶ Get the underlying database model instance
Returns: the database model instance
-
classmethod
from_dbmodel
(dbmodel, backend)[source]¶ Create a DjangoEntity from the corresponding db model class
Parameters: - dbmodel – the model to create the entity from
- backend – the corresponding backend
Returns: the Django entity
-
classmethod
get_dbmodel_attribute_name
(attr_name)[source]¶ Given the name of an attribute of the entity class give the corresponding name of the attribute in the db model. It if doesn’t exit this raises a ValueError
Parameters: attr_name – Returns: the dbmodel attribute name Return type: str
-
id
¶ Get the id of this entity
Returns: the entity id
-
is_stored
¶ Is this entity stored?
Returns: True if stored, False otherwise
-
pk
¶ Get the principal key for this entry
Returns: the principal key
-
SQLA groups
-
class
aiida.orm.implementation.sqlalchemy.groups.
SqlaGroup
(backend, label, user, description='', type_string='')[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.groups.BackendGroup
The SQLAlchemy Group object
-
MODEL_CLASS
¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, label, user, description='', type_string='')[source]¶ Construct a new SQLA group
Parameters: - backend – the backend to use
- label – the group label
- user – the owner of the group
- description – an optional group description
- type_string – an optional type for the group to contain
-
__int__
()[source]¶ Convert the class to an integer. This is needed to allow querying with Django. Be careful, though, not to pass it to a wrong field! This only returns the local DB principal key (pk) value.
Returns: the integer pk of the node or None if not stored.
-
__module__
= 'aiida.orm.implementation.sqlalchemy.groups'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.group.DbGroup], <class 'aiida.orm.implementation.groups.BackendGroup'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334030336¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
add_nodes
(nodes, **kwargs)[source]¶ Add a node or a set of nodes to the group.
Note: all the nodes and the group itself have to be stored.
Parameters: - nodes – a list of BackendNode instance to be added to this group
- kwargs – skip_orm: When the flag is on, the SQLA ORM is skipped and SQLA is used to create a direct SQL INSERT statement to the group-node relationship table (to improve speed).
-
count
()[source]¶ Return the number of entities in this group.
Returns: integer number of entities contained within the group
-
description
¶
-
is_stored
¶
-
label
¶
-
nodes
¶ Get an iterator to all the nodes in the group
-
pk
¶
-
remove_nodes
(nodes)[source]¶ Remove a node or a set of nodes from the group.
Note: all the nodes and the group itself have to be stored. Parameters: nodes – a list of BackendNode instance to be added to this group
-
type_string
¶
-
user
¶
-
uuid
¶
-
-
class
aiida.orm.implementation.sqlalchemy.groups.
SqlaGroupCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.groups.BackendGroupCollection
The SLQA collection of groups
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.groups'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.groups.BackendGroupCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334032036¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaGroupCollection
-
query
(label=None, type_string=None, pk=None, uuid=None, nodes=None, user=None, node_attributes=None, past_days=None, label_filters=None, **kwargs)[source]¶ Query for groups.
Note: By default, query for user-defined groups only (type_string==”“). If you want to query for all type of groups, pass type_string=None. If you want to query for a specific type of groups, pass a specific string as the type_string argument.
Parameters: - name – the name of the group
- nodes – a node or list of nodes that belongs to the group (alternatively, you can also pass a DbNode or list of DbNodes)
- pk – the pk of the group
- uuid – the uuid of the group
- type_string – the string for the type of node; by default, look only for user-defined groups (see note above).
- user – by default, query for groups of all users; if specified, must be a DbUser object, or a string for the user email.
- past_days – by default, query for all groups; if specified, query the groups created in the last past_days. Must be a datetime object.
- name_filters – dictionary that can contain ‘startswith’, ‘endswith’ or ‘contains’ as keys
- node_attributes – if not None, must be a dictionary with format {k: v}. It will filter and return only groups where there is at least a node with an attribute with key=k and value=v. Different keys of the dictionary are joined with AND (that is, the group should satisfy all requirements. v can be a base data type (str, bool, int, float, …) If it is a list or iterable, that the condition is checked so that there should be at least a node in the group with key=k and value=each of the values of the iterable.
- kwargs –
any other filter to be passed to DbGroup.objects.filter
- Example: if
node_attributes = {'elements': ['Ba', 'Ti'], 'md5sum': 'xxx'}
, - it will find groups that contain the node with md5sum = ‘xxx’, and moreover contain at least one node for element ‘Ba’ and one node for element ‘Ti’.
- Example: if
-
SQLA Log and LogCollection module
-
class
aiida.orm.implementation.sqlalchemy.logs.
SqlaLog
(backend, time, loggername, levelname, dbnode_id, message='', metadata=None)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.logs.BackendLog
SQLA Log backend entity
-
MODEL_CLASS
¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, time, loggername, levelname, dbnode_id, message='', metadata=None)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__module__
= 'aiida.orm.implementation.sqlalchemy.logs'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.log.DbLog], <class 'aiida.orm.implementation.logs.BackendLog'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334033354¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
dbnode_id
¶ Get the id of the object that created the log entry
-
levelname
¶ The name of the log level
-
loggername
¶ The name of the logger that created this entry
-
message
¶ Get the message corresponding to the entry
-
metadata
¶ Get the metadata corresponding to the entry
-
time
¶ Get the time corresponding to the entry
-
uuid
¶ Get the UUID of the log entry
-
-
class
aiida.orm.implementation.sqlalchemy.logs.
SqlaLogCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.logs.BackendLogCollection
The SQLA collection for logs
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.logs'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.logs.BackendLogCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334033414¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaLogCollection
-
SqlAlchemy implementation of the BackendNode and BackendNodeCollection classes.
-
class
aiida.orm.implementation.sqlalchemy.nodes.
SqlaNode
(backend, node_type, user, computer=None, process_type=None, label='', description='', ctime=None, mtime=None)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.nodes.BackendNode
SQLA Node backend entity
-
MODEL_CLASS
¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, node_type, user, computer=None, process_type=None, label='', description='', ctime=None, mtime=None)[source]¶ Construct a new BackendNode instance wrapping a new DbNode instance.
Parameters: - backend – the backend
- node_type – the node type string
- user – associated BackendUser
- computer – associated BackendComputer
- label – string label
- description – string description
- ctime – The creation time as datetime object
- mtime – The modification time as datetime object
-
__module__
= 'aiida.orm.implementation.sqlalchemy.nodes'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.node.DbNode], <class 'aiida.orm.implementation.nodes.BackendNode'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334030234¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_add_link
(source, link_type, link_label)[source]¶ Add a link of the given type from a given node to ourself.
Parameters: - source – the node from which the link is coming
- link_type – the link type
- link_label – the link label
-
_increment_version_number
()[source]¶ Increment the node version number of this node by one directly in the database.
-
add_incoming
(source, link_type, link_label)[source]¶ Add a link of the given type from a given node to ourself.
Parameters: - source – the node from which the link is coming
- link_type – the link type
- link_label – the link label
Returns: True if the proposed link is allowed, False otherwise
Raises: aiida.common.ModificationNotAllowed – if either source or target node is not stored
-
attributes_items
()[source]¶ Return an iterator over the attribute items.
Returns: an iterator with attribute key value pairs
-
attributes_keys
()[source]¶ Return an iterator over the attribute keys.
Returns: an iterator with attribute keys
-
clone
()[source]¶ Return an unstored clone of ourselves.
Returns: an unstored BackendNode with the exact same attributes and extras as self
-
computer
¶ Return the computer of this node.
Returns: the computer or None Return type: BackendComputer or None
-
delete_attribute
(key)[source]¶ Delete an attribute.
Parameters: key – name of the attribute Raises: AttributeError – if the attribute does not exist
-
delete_attributes
(keys)[source]¶ Delete multiple attributes.
Note
The implementation should guarantee that all the keys that are to be deleted actually exist or the entire operation should be canceled without any change and an
AttributeError
should be raised.Parameters: keys – names of the attributes to delete Raises: AttributeError – if at least on of the attribute does not exist
-
delete_extra
(key)[source]¶ Delete an extra.
Parameters: key – name of the extra Raises: AttributeError – if the extra does not exist
-
delete_extras
(keys)[source]¶ Delete multiple extras.
Note
The implementation should guarantee that all the keys that are to be deleted actually exist or the entire operation should be canceled without any change and an
AttributeError
should be raised.Parameters: keys – names of the extras to delete Raises: AttributeError – if at least on of the extra does not exist
-
extras_items
()[source]¶ Return an iterator over the extra items.
Returns: an iterator with extra key value pairs
-
extras_keys
()[source]¶ Return an iterator over the extras keys.
Returns: an iterator with extras keys
-
get_attribute
(key)[source]¶ Return an attribute.
Parameters: key – name of the attribute Returns: the value of the attribute Raises: AttributeError – if the attribute does not exist
-
get_attributes
(keys)[source]¶ Return a set of attributes.
Parameters: keys – names of the attributes Returns: the values of the attributes Raises: AttributeError – if at least one attribute does not exist
-
get_extra
(key)[source]¶ Return an extra.
Parameters: key – name of the extra Returns: the value of the extra Raises: AttributeError – if the extra does not exist
-
get_extras
(keys)[source]¶ Return a set of extras.
Parameters: keys – names of the extras Returns: the values of the extras Raises: AttributeError – if at least one extra does not exist
-
reset_attributes
(attributes)[source]¶ Reset the attributes.
Note
This will completely reset any existing attributes and replace them with the new dictionary.
Parameters: attributes – the new attributes to set
-
reset_extras
(extras)[source]¶ Reset the extras.
Note
This will completely reset any existing extras and replace them with the new dictionary.
Parameters: extras – the new extras to set
-
set_attribute
(key, value)[source]¶ Set an attribute to the given value.
Parameters: - key – name of the attribute
- value – value of the attribute
-
set_attributes
(attributes)[source]¶ Set attributes.
Note
This will override any existing attributes that are present in the new dictionary.
Parameters: attributes – the new attributes to set
-
set_extra
(key, value, increase_version=True)[source]¶ Set an extra to the given value.
Parameters: - key – name of the extra
- value – value of the extra
- increase_version – boolean, if True will increase the node version upon successfully setting the extra
-
set_extras
(extras)[source]¶ Set extras.
Note
This will override any existing extras that are present in the new dictionary.
Parameters: extras – the new extras to set
-
store
(attributes=None, links=None, with_transaction=True)[source]¶ Store the node in the database.
Parameters: - attributes – optional attributes to set before storing, will override any existing attributes
- links – optional links to add before storing
-
user
¶ Return the user of this node.
Returns: the user Return type: BackendUser
-
-
class
aiida.orm.implementation.sqlalchemy.nodes.
SqlaNodeCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.nodes.BackendNodeCollection
The collection of Node entries.
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.nodes'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.nodes.BackendNodeCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334023047¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaNodeCollection
-
Sqla query builder implementation
-
class
aiida.orm.implementation.sqlalchemy.querybuilder.
SqlaQueryBuilder
(backend)[source]¶ Bases:
aiida.orm.implementation.querybuilder.BackendQueryBuilder
QueryBuilder to use with SQLAlchemy-backend and schema defined in backends.sqlalchemy.models
-
AuthInfo
¶
-
Comment
¶
-
Computer
¶
-
Group
¶
-
Link
¶
-
Log
¶
-
Node
¶
-
User
¶
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.querybuilder'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
first
(query)[source]¶ Executes query in the backend asking for one instance.
Returns: One row of aiida results
-
get_aiida_res
(key, res)[source]¶ Some instance returned by ORM (django or SA) need to be converted to Aiida instances (eg nodes). Choice (sqlalchemy_utils) will return their value
Parameters: - key – The key
- res – the result returned by the query
Returns: an aiida-compatible instance
-
get_filter_expr
(operator, value, attr_key, is_attribute, alias=None, column=None, column_name=None)[source]¶ Applies a filter on the alias given. Expects the alias of the ORM-class on which to filter, and filter_spec. Filter_spec contains the specification on the filter. Expects:
Parameters: - operator – The operator to apply, see below for further details
- value – The value for the right side of the expression, the value you want to compare with.
- path – The path leading to the value
- attr_key – Boolean, whether the value is in a json-column, or in an attribute like table.
Implemented and valid operators:
for any type: * == (compare single value, eg: ‘==’:5.0) * in (compare whether in list, eg: ‘in’:[5, 6, 34]
- for floats and integers:
- >
- <
- <=
- >=
- for strings:
- like (case - sensitive), for example ‘like’:’node.calc.%’ will match node.calc.relax and node.calc.RELAX and node.calc. but not node.CALC.relax
- ilike (case - unsensitive) will also match node.CaLc.relax in the above example
Note
The character % is a reserved special character in SQL, and acts as a wildcard. If you specifically want to capture a
%
in the string, use:_%
for arrays and dictionaries (only for the SQLAlchemy implementation):
- contains: pass a list with all the items that the array should contain, or that should be among the keys, eg: ‘contains’: [‘N’, ‘H’])
- has_key: pass an element that the list has to contain or that has to be a key, eg: ‘has_key’:’N’)
- for arrays only (SQLAlchemy version):
- of_length
- longer
- shorter
All the above filters invoke a negation of the expression if preceded by ~:
# first example: filter_spec = { 'name' : { '~in':[ 'halle', 'lujah' ] } # Name not 'halle' or 'lujah' } # second example: filter_spec = { 'id' : { '~==': 2 } } # id is not 2
-
get_filter_expr_from_attributes
(operator, value, attr_key, column=None, column_name=None, alias=None)[source]¶ Returns an valid SQLAlchemy expression.
Parameters: - operator – The operator provided by the user (‘==’, ‘>’, …)
- value – The value to compare with, e.g. (5.0, ‘foo’, [‘a’,’b’])
- attr_key (str) – The path to that attribute as a tuple of values. I.e. if that attribute I want to filter by is the 2nd element in a list stored under the key ‘mylist’, this is (‘mylist’, ‘2’).
- column – Optional, an instance of sqlalchemy.orm.attributes.InstrumentedAttribute or
- column_name (str) – The name of the column, and the backend should get the InstrumentedAttribute.
- alias – The aliased class.
Returns: An instance of sqlalchemy.sql.elements.BinaryExpression
-
get_projectable_attribute
(alias, column_name, attrpath, cast=None, **kwargs)[source]¶ Returns: An attribute store in a JSON field of the give column
-
iterall
(query, batch_size, tag_to_index_dict)[source]¶ Returns: An iterator over all the results of a list of lists.
-
iterdict
(query, batch_size, tag_to_projected_entity_dict)[source]¶ Returns: An iterator over all the results of a list of dictionaries.
-
modify_expansions
(alias, expansions)[source]¶ For sqlalchemy, there are no additional expansions for now, so I am returning an empty list
-
table_groups_nodes
¶
-
-
class
aiida.orm.implementation.sqlalchemy.querybuilder.
array_length
(*clauses, **kwargs)[source]¶ Bases:
sqlalchemy.sql.functions.FunctionElement
-
__module__
= 'aiida.orm.implementation.sqlalchemy.querybuilder'¶
-
_compiler_dispatch
(**kw)¶
-
_compiler_dispatcher
= <sqlalchemy.ext.compiler._dispatcher object>¶
-
name
= 'array_len'¶
-
-
aiida.orm.implementation.sqlalchemy.querybuilder.
compile
(element, compiler, **_kw)[source]¶ Get length of array defined in a JSONB column
-
class
aiida.orm.implementation.sqlalchemy.querybuilder.
jsonb_array_length
(*clauses, **kwargs)[source]¶ Bases:
sqlalchemy.sql.functions.FunctionElement
-
__module__
= 'aiida.orm.implementation.sqlalchemy.querybuilder'¶
-
_compiler_dispatch
(**kw)¶
-
_compiler_dispatcher
= <sqlalchemy.ext.compiler._dispatcher object>¶
-
name
= 'jsonb_array_len'¶
-
-
class
aiida.orm.implementation.sqlalchemy.querybuilder.
jsonb_typeof
(*clauses, **kwargs)[source]¶ Bases:
sqlalchemy.sql.functions.FunctionElement
-
__module__
= 'aiida.orm.implementation.sqlalchemy.querybuilder'¶
-
_compiler_dispatch
(**kw)¶
-
_compiler_dispatcher
= <sqlalchemy.ext.compiler._dispatcher object>¶
-
name
= 'jsonb_typeof'¶
-
SQLA user
-
class
aiida.orm.implementation.sqlalchemy.users.
SqlaUserCollection
(backend)[source]¶ Bases:
aiida.orm.implementation.users.BackendUserCollection
Collection of SQLA Users
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sqlalchemy.users'¶
-
__next_in_mro__
¶ alias of
__builtin__.object
-
__orig_bases__
= (aiida.orm.implementation.users.BackendUserCollection,)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926333990738¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlaUserCollection
-
create
(email, first_name='', last_name='', institution='')[source]¶ Create a user with the provided email address
Returns: A new user object Return type: aiida.orm.User
-
-
class
aiida.orm.implementation.sqlalchemy.users.
SqlaUser
(backend, email, first_name, last_name, institution)[source]¶ Bases:
aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity
,aiida.orm.implementation.users.BackendUser
SQLA user
-
MODEL_CLASS
¶
-
__abstractmethods__
= frozenset([])¶
-
__args__
= None¶
-
__extra__
= None¶
-
__init__
(backend, email, first_name, last_name, institution)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__module__
= 'aiida.orm.implementation.sqlalchemy.users'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (aiida.orm.implementation.sqlalchemy.entities.SqlaModelEntity[aiida.backends.sqlalchemy.models.user.DbUser], <class 'aiida.orm.implementation.users.BackendUser'>)¶
-
__origin__
= None¶
-
__parameters__
= ()¶
-
__tree_hash__
= 5926334004656¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
date_joined
¶
-
email
¶
-
first_name
¶
-
institution
¶
-
is_active
¶
-
last_login
¶
-
last_name
¶
-