aiida.backends.djsite.db package

Submodules

class aiida.backends.djsite.db.models.AiidaObjectManager[source]

Bases: django.db.models.manager.Manager

__module__ = 'aiida.backends.djsite.db.models'
get_query_set(**kwargs)
get_queryset()[source]

Returns a new QuerySet object. Subclasses can override this method to easily customize the behavior of the Manager.

class aiida.backends.djsite.db.models.AiidaQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: django.db.models.query.QuerySet

__module__ = 'aiida.backends.djsite.db.models'
iterator()[source]

An iterator over the results from applying this QuerySet to the database.

class aiida.backends.djsite.db.models.DbAttribute(*args, **kwargs)[source]

Bases: aiida.backends.djsite.db.models.DbAttributeBaseClass

This table stores attributes that uniquely define the content of the node. Therefore, their modification corrupts the data.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbAttribute>
dbnode
get_datatype_display(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbAttributeBaseClass(*args, **kwargs)[source]

Bases: aiida.backends.djsite.db.models.DbMultipleValueAttributeBaseClass

Abstract base class for tables storing element-attribute-value data. Element is the dbnode; attribute is the key name. Value is the specific value to store.

This table had different SQL columns to store different types of data, and a datatype field to know the actual datatype.

Moreover, this class unpacks dictionaries and lists when possible, so that it is possible to query inside recursive lists and dicts.

class Meta[source]
__module__ = 'aiida.backends.djsite.db.models'
abstract = False
unique_together = ('dbnode', 'key')
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_meta = <Options for DbAttributeBaseClass>
_subspecifier_field_name = 'dbnode'
dbnode
classmethod del_value_for_node(dbnode, key)[source]

Delete an attribute from the database for the given dbnode.

Note:

no exception is raised if no attribute with the given key is found in the DB.

Parameters:
  • dbnode – the dbnode for which you want to delete the key.
  • key – the key to delete.
classmethod get_all_values_for_node(dbnode)[source]

Return a dictionary with all attributes for the given dbnode.

Returns:a dictionary where each key is a level-0 attribute stored in the Db table, correctly converted to the right type.
classmethod get_all_values_for_nodepk(dbnodepk)[source]

Return a dictionary with all attributes for the dbnode with given PK.

Returns:a dictionary where each key is a level-0 attribute stored in the Db table, correctly converted to the right type.
get_datatype_display(**morekwargs)
classmethod get_value_for_node(dbnode, key)[source]

Get an attribute from the database for the given dbnode.

Returns:the value stored in the Db table, correctly converted to the right type.
Raises:AttributeError – if no key is found for the given dbnode
classmethod has_key(dbnode, key)[source]

Return True if the given dbnode has an attribute with the given key, False otherwise.

classmethod list_all_node_elements(dbnode)[source]

Return a django queryset with the attributes of the given node, only at deepness level zero (i.e., keys not containing the separator).

classmethod reset_values_for_node(dbnode, attributes, with_transaction=True, return_not_store=False)[source]
classmethod set_value_for_node(dbnode, key, value, with_transaction=True, stop_if_existing=False)[source]

This is the raw-level method that accesses the DB. No checks are done to prevent the user from (re)setting a valid key. To be used only internally.

Todo:

there may be some error on concurrent write; not checked in this unlucky case!

Parameters:
  • dbnode – the dbnode for which the attribute should be stored; in an integer is passed, this is used as the PK of the dbnode, without any further check (for speed reasons)
  • key – the key of the attribute to store; must be a level-zero attribute (i.e., no separators in the key)
  • value – the value of the attribute to store
  • with_transaction – if True (default), do this within a transaction, so that nothing gets stored if a subitem cannot be created. Otherwise, if this parameter is False, no transaction management is performed.
  • stop_if_existing – if True, it will stop with an UniquenessError exception if the key already exists for the given node. Otherwise, it will first delete the old value, if existent. The use with True is useful if you want to use a given attribute as a “locking” value, e.g. to avoid to perform an action twice on the same node. Note that, if you are using transactions, you may get the error only when the transaction is committed.
Raises:

ValueError – if the key contains the separator symbol used internally to unpack dictionaries and lists (defined in cls._sep).

class aiida.backends.djsite.db.models.DbAuthInfo(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Table that pairs aiida users and computers, with all required authentication information.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbAuthInfo>
aiidauser
dbcomputer
get_auth_params()[source]
get_transport()[source]

Given a computer and an aiida user (as entries of the DB) return a configured transport to connect to the computer.

get_workdir()[source]
objects = <django.db.models.manager.Manager object>
set_auth_params(auth_params)[source]
class aiida.backends.djsite.db.models.DbCalcState(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Store the state of calculations.

The advantage of a table (with uniqueness constraints) is that this disallows entering twice in the same state (e.g., retrieving twice).

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbCalcState>
calc_states = CalcState(['RETRIEVALFAILED', 'COMPUTED', 'RETRIEVING', 'WITHSCHEDULER', 'SUBMISSIONFAILED', 'PARSING', 'FAILED', 'FINISHED', 'TOSUBMIT', 'SUBMITTING', 'IMPORTED', 'NEW', 'PARSINGFAILED'])
dbnode
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
get_state_display(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbComment(id, uuid, dbnode_id, ctime, mtime, user_id, content)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbComment>
dbnode
get_next_by_ctime(**morekwargs)
get_next_by_mtime(**morekwargs)
get_previous_by_ctime(**morekwargs)
get_previous_by_mtime(**morekwargs)
objects = <django.db.models.manager.Manager object>
user
class aiida.backends.djsite.db.models.DbComputer(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Table of computers or clusters.

Attributes: * name: A name to be used to refer to this computer. Must be unique. * hostname: Fully-qualified hostname of the host * transport_type: a string with a valid transport type

Note: other things that may be set in the metadata:

  • mpirun command
  • num cores per node
  • max num cores
  • workdir: Full path of the aiida folder on the host. It can contain the string {username} that will be substituted by the username of the user on that machine. The actual workdir is then obtained as workdir.format(username=THE_ACTUAL_USERNAME) Example: workdir = “/scratch/{username}/aiida/”
  • allocate full node = True or False
  • … (further limits per user etc.)
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_get_val_from_metadata(key)[source]
_meta = <Options for DbComputer>
dbauthinfo_set
dbnodes
get_aiida_class()[source]
classmethod get_dbcomputer(computer)[source]

Return a DbComputer from its name (or from another Computer or DbComputer instance)

get_shebang()[source]

Return the shebang line

get_workdir()[source]
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbExtra(*args, **kwargs)[source]

Bases: aiida.backends.djsite.db.models.DbAttributeBaseClass

This table stores extra data, still in the key-value format, that the user can attach to a node. Therefore, their modification simply changes the user-defined data, but does not corrupt the node (it will still be loadable without errors). Could be useful to add “duplicate” information for easier querying, or for tagging nodes.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbExtra>
dbnode
get_datatype_display(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbGroup(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A group of nodes.

Any group of nodes can be created, but some groups may have specific meaning if they satisfy specific rules (for instance, groups of UpdData objects are pseudopotential families - if no two pseudos are included for the same atomic element).

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbGroup>
dbnodes
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
objects = <django.db.models.manager.Manager object>
user

Bases: django.db.models.base.Model

Direct connection between two dbnodes. The label is identifying the link type.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbLink>
input
objects = <django.db.models.manager.Manager object>
output
class aiida.backends.djsite.db.models.DbLock(key, creation, timeout, owner)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbLock>
get_next_by_creation(**morekwargs)
get_previous_by_creation(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbLog(id, time, loggername, levelname, objname, objpk, message, metadata)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbLog>
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbMultipleValueAttributeBaseClass(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Abstract base class for tables storing attribute + value data, of different data types (without any association to a Node).

class Meta[source]
__module__ = 'aiida.backends.djsite.db.models'
abstract = False
unique_together = (('key',),)
__module__ = 'aiida.backends.djsite.db.models'
_meta = <Options for DbMultipleValueAttributeBaseClass>
_sep = '.'
_subspecifier_field_name = None
classmethod create_value(key, value, subspecifier_value=None, other_attribs={})[source]

Create a new list of attributes, without storing them, associated with the current key/value pair (and to the given subspecifier, e.g. the DbNode for DbAttributes and DbExtras).

Note:

No hits are done on the DB, in particular no check is done on the existence of the given nodes.

Parameters:
  • key – a string with the key to create (can contain the separator cls._sep if this is a sub-attribute: indeed, this function calls itself recursively)
  • value – the value to store (a basic data type or a list or a dict)
  • subspecifier_value – must be None if this class has no subspecifier set (e.g., the DbSetting class). Must be the value of the subspecifier (e.g., the dbnode) for classes that define it (e.g. DbAttribute and DbExtra)
  • other_attribs – a dictionary of other parameters, to store only on the level-zero attribute (e.g. for description in DbSetting).
Returns:

always a list of class instances; it is the user responsibility to store such entries (typically with a Django bulk_create() call).

classmethod del_value(key, only_children=False, subspecifier_value=None)[source]

Delete a value associated with the given key (if existing).

Note:

No exceptions are raised if no entry is found.

Parameters:
  • key – the key to delete. Can contain the separator cls._sep if you want to delete a subkey.
  • only_children – if True, delete only children and not the entry itself.
  • subspecifier_value – must be None if this class has no subspecifier set (e.g., the DbSetting class). Must be the value of the subspecifier (e.g., the dbnode) for classes that define it (e.g. DbAttribute and DbExtra)
get_datatype_display(**morekwargs)
classmethod get_query_dict(value)[source]

Return a dictionary that can be used in a django filter to query for a specific value. This takes care of checking the type of the input parameter ‘value’ and to convert it to the right query.

Parameters:value – The value that should be queried. Note: can only be base datatype, not a list or dict. For those, query directly for one of the sub-elements.
Todo:see if we want to give the possibility to query for the existence of a (possibly empty) dictionary or list, of for their length.
Note:this will of course not find a data if this was stored in the DB as a serialized JSON.
Returns:a dictionary to be used in the django .filter() method. For instance, if ‘value’ is a string, it will return the dictionary {'datatype': 'txt', 'tval': value}.
Raise:ValueError if value is not of a base datatype (string, integer, float, bool, None, or date)
getvalue()[source]

This can be called on a given row and will get the corresponding value, casting it correctly.

long_field_length()

Return the length of “long” fields. This is used, for instance, for the ‘key’ field of attributes. This returns 1024 typically, but it returns 255 if the backend is mysql.

Note:Call this function only AFTER having called load_dbenv!
classmethod set_value(key, value, with_transaction=True, subspecifier_value=None, other_attribs={}, stop_if_existing=False)[source]

Set a new value in the DB, possibly associated to the given subspecifier.

Note:

This method also stored directly in the DB.

Parameters:
  • key – a string with the key to create (must be a level-0 attribute, that is it cannot contain the separator cls._sep).
  • value – the value to store (a basic data type or a list or a dict)
  • subspecifier_value – must be None if this class has no subspecifier set (e.g., the DbSetting class). Must be the value of the subspecifier (e.g., the dbnode) for classes that define it (e.g. DbAttribute and DbExtra)
  • with_transaction – True if you want this function to be managed with transactions. Set to False if you already have a manual management of transactions in the block where you are calling this function (useful for speed improvements to avoid recursive transactions)
  • other_attribs – a dictionary of other parameters, to store only on the level-zero attribute (e.g. for description in DbSetting).
  • stop_if_existing – if True, it will stop with an UniquenessError exception if the new entry would violate an uniqueness constraint in the DB (same key, or same key+node, depending on the specific subclass). Otherwise, it will first delete the old value, if existent. The use with True is useful if you want to use a given attribute as a “locking” value, e.g. to avoid to perform an action twice on the same node. Note that, if you are using transactions, you may get the error only when the transaction is committed.
subspecifier_pk

Return the subspecifier PK in the database (or None, if no subspecifier should be used)

subspecifiers_dict

Return a dict to narrow down the query to only those matching also the subspecifier.

classmethod validate_key(key)[source]

Validate the key string to check if it is valid (e.g., if it does not contain the separator symbol.).

Returns:None if the key is valid
Raises:ValidationError – if the key is not valid
class aiida.backends.djsite.db.models.DbNode(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Generic node: data or calculation or code.

Nodes can be linked (DbLink table) Naming convention for Node relationships: A –> C –> B.

  • A is ‘input’ of C.
  • C is ‘output’ of A.

Internal attributes, that define the node itself, are stored in the DbAttribute table; further user-defined attributes, called ‘extra’, are stored in the DbExtra table (same schema and methods of the DbAttribute table, but the code does not rely on the content of the table, therefore the user can use it at his will to tag or annotate nodes.

Note:Attributes in the DbAttribute table have to be thought as belonging to the DbNode, (this is the reason for which there is no ‘user’ field in the DbAttribute field). Moreover, Attributes define uniquely the Node so should be immutable
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbNode>
aiidaobjects = <aiida.backends.djsite.db.models.AiidaObjectManager object>
attributes

Return all attributes of the given node as a single dictionary.

dbattributes
dbcomments
dbcomputer
dbextras
dbgroups
dbstates
dbworkflowdata_set
extras

Return all extras of the given node as a single dictionary.

get_aiida_class()[source]

Return the corresponding aiida instance of class aiida.orm.Node or a appropriate subclass.

get_next_by_ctime(**morekwargs)
get_next_by_mtime(**morekwargs)
get_previous_by_ctime(**morekwargs)
get_previous_by_mtime(**morekwargs)
get_simple_name(invalid_result=None)[source]

Return a string with the last part of the type name.

If the type is empty, use ‘Node’. If the type is invalid, return the content of the input variable invalid_result.

Parameters:invalid_result – The value to be returned if the node type is not recognized.
inputs
objects = <django.db.models.manager.Manager object>
outputs
user
workflow_step
class aiida.backends.djsite.db.models.DbSetting(*args, **kwargs)[source]

Bases: aiida.backends.djsite.db.models.DbMultipleValueAttributeBaseClass

This will store generic settings that should be database-wide.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbSetting>
get_datatype_display(**morekwargs)
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
objects = <django.db.models.manager.Manager object>
class aiida.backends.djsite.db.models.DbUser(*args, **kwargs)[source]

Bases: django.contrib.auth.models.AbstractBaseUser, django.contrib.auth.models.PermissionsMixin

This class replaces the default User class of Django

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
REQUIRED_FIELDS = ['first_name', 'last_name', 'institution']
USERNAME_FIELD = 'email'
__module__ = 'aiida.backends.djsite.db.models'
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <aiida.backends.djsite.db.models.DbUserManager object>
_meta = <Options for DbUser>
dbauthinfo_set
dbcomment_set
dbgroups
dbnodes
dbworkflow_set
dbworkflowstep_set
get_aiida_class()[source]
get_full_name()[source]
get_next_by_date_joined(**morekwargs)
get_next_by_last_login(**morekwargs)
get_previous_by_date_joined(**morekwargs)
get_previous_by_last_login(**morekwargs)
get_short_name()[source]
groups
objects = <aiida.backends.djsite.db.models.DbUserManager object>
user_permissions
class aiida.backends.djsite.db.models.DbUserManager[source]

Bases: django.contrib.auth.models.BaseUserManager

__module__ = 'aiida.backends.djsite.db.models'
create_superuser(email, password, **extra_fields)[source]
create_user(email, password=None, **extra_fields)[source]

Creates and saves a User with the given email (that is the username) and password.

class aiida.backends.djsite.db.models.DbWorkflow(id, uuid, ctime, mtime, user_id, label, description, nodeversion, lastsyncedversion, state, report, module, module_class, script_path, script_md5)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbWorkflow>
add_attribute(name, value)[source]
add_attributes(dict)[source]
add_data(dict, d_type)[source]
add_parameter(name, value)[source]
add_parameters(dict, force=False)[source]
add_result(name, value)[source]
add_results(dict)[source]
aiidaobjects = <aiida.backends.djsite.db.models.AiidaObjectManager object>
append_to_report(_text)[source]
clear_report()[source]
data
finish()[source]
get_aiida_class()[source]

Return the corresponding aiida instance of class aiida.workflow

get_attribute(name)[source]
get_attributes()[source]
get_calculations()[source]
get_data(d_type)[source]
get_next_by_ctime(**morekwargs)
get_next_by_mtime(**morekwargs)
get_parameter(name)[source]
get_parameters()[source]
get_previous_by_ctime(**morekwargs)
get_previous_by_mtime(**morekwargs)
get_result(name)[source]
get_results()[source]
get_state_display(**morekwargs)
get_sub_workflows()[source]
is_subworkflow()[source]

Return True if this is a subworkflow, False if it is a root workflow, launched by the user.

objects = <django.db.models.manager.Manager object>
parent_workflow_step
set_script_md5(_md5)[source]
set_state(_state)[source]
steps
user
wf_states = WorkflowState(['CREATED', 'FINISHED', 'RUNNING', 'SLEEP', 'ERROR', 'INITIALIZED'])
class aiida.backends.djsite.db.models.DbWorkflowData(id, parent_id, name, time, data_type, value_type, json_value, aiida_obj_id)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbWorkflowData>
aiida_obj
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
get_value()[source]
objects = <django.db.models.manager.Manager object>
parent
set_value(arg)[source]
wf_data_types = WorkflowDataType(['ATTRIBUTE', 'PARAMETER', 'RESULT'])
wf_data_value_types = WorkflowDataValueType(['NONE', 'JSON', 'AIIDA'])
class aiida.backends.djsite.db.models.DbWorkflowStep(id, parent_id, name, user_id, time, nextcall, state)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

__module__ = 'aiida.backends.djsite.db.models'
__reduce__()

helper for pickle

__setstate__(args)
__module__ = 'aiida.backends.djsite.db.models'
__str__()
__unicode__()
_base_manager = <django.db.models.manager.Manager object>
_default_manager = <django.db.models.manager.Manager object>
_meta = <Options for DbWorkflowStep>
add_calculation(step_calculation)[source]
add_sub_workflow(sub_wf)[source]
calculations
finish()[source]
get_calculations(state=None)[source]
get_next_by_time(**morekwargs)
get_previous_by_time(**morekwargs)
get_state_display(**morekwargs)
get_sub_workflows()[source]
is_finished()[source]
objects = <django.db.models.manager.Manager object>
parent
reinitialize()[source]
remove_calculations()[source]
remove_sub_workflows()[source]
set_nextcall(_nextcall)[source]
set_state(_state)[source]
sub_workflows
user
wf_default_call = 'none'
wf_states = WorkflowState(['CREATED', 'FINISHED', 'RUNNING', 'SLEEP', 'ERROR', 'INITIALIZED'])
exception aiida.backends.djsite.db.models.DeserializationException[source]

Bases: aiida.common.exceptions.AiidaException

__module__ = 'aiida.backends.djsite.db.models'
aiida.backends.djsite.db.models._deserialize_attribute(mainitem, subitems, sep, original_class=None, original_pk=None, lesserrors=False)[source]

Deserialize a single attribute.

Parameters:
  • mainitem – the main item (either the attribute itself for base types (None, string, …) or the main item for lists and dicts. Must contain the ‘key’ key and also the following keys: datatype, tval, fval, ival, bval, dval. NOTE that a type check is not performed! tval is expected to be a string, dval a date, etc.
  • subitems – must be a dictionary of dictionaries. In the top-level dictionary, the key must be the key of the attribute, stripped of all prefixes (i.e., if the mainitem has key ‘a.b’ and we pass subitems ‘a.b.0’, ‘a.b.1’, ‘a.b.1.c’, their keys must be ‘0’, ‘1’, ‘1.c’). It must be None if the value is not iterable (int, str, float, …). It is an empty dictionary if there are no subitems.
  • sep – a string, the separator between subfields (to separate the name of a dictionary from the keys it contains, for instance)
  • original_class – if these elements come from a specific subclass of DbMultipleValueAttributeBaseClass, pass here the class (note: the class, not the instance!). This is used only in case the wrong number of elements is found in the raw data, to print a more meaningful message (if the class has a dbnode associated to it)
  • original_pk – if the elements come from a specific subclass of DbMultipleValueAttributeBaseClass that has a dbnode associated to it, pass here the PK integer. This is used only in case the wrong number of elements is found in the raw data, to print a more meaningful message
  • lesserrors – If set to True, in some cases where the content of the DB is not consistent but data is still recoverable, it will just log the message rather than raising an exception (e.g. if the number of elements of a dictionary is different from the number declared in the ival field).
Returns:

the deserialized value

Raises:

aiida.backends.djsite.db.models.DeserializationException – if an error occurs

aiida.backends.djsite.db.models.deserialize_attributes(data, sep, original_class=None, original_pk=None)[source]

Deserialize the attributes from the format internally stored in the DB to the actual format (dictionaries, lists, integers, …

Parameters:
  • data – must be a dictionary of dictionaries. In the top-level dictionary, the key must be the key of the attribute. The value must be a dictionary with the following keys: datatype, tval, fval, ival, bval, dval. Other keys are ignored. NOTE that a type check is not performed! tval is expected to be a string, dval a date, etc.
  • sep – a string, the separator between subfields (to separate the name of a dictionary from the keys it contains, for instance)
  • original_class – if these elements come from a specific subclass of DbMultipleValueAttributeBaseClass, pass here the class (note: the class, not the instance!). This is used only in case the wrong number of elements is found in the raw data, to print a more meaningful message (if the class has a dbnode associated to it)
  • original_pk – if the elements come from a specific subclass of DbMultipleValueAttributeBaseClass that has a dbnode associated to it, pass here the PK integer. This is used only in case the wrong number of elements is found in the raw data, to print a more meaningful message
Returns:

a dictionary, where for each entry the corresponding value is returned, deserialized back to lists, dictionaries, etc. Example: if data = {'a': {'datatype': "list", "ival": 2, ...}, 'a.0': {'datatype': "int", "ival": 2, ...}, 'a.1': {'datatype': "txt", "tval":  "yy"}], it will return {"a": [2, "yy"]}

Base class for AiiDA tests

class aiida.backends.djsite.db.testbase.DjangoTests[source]

Bases: aiida.backends.testimplbase.AiidaTestImplementation

Automatically takes care of the setUpClass and TearDownClass, when needed.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.backends.djsite.db.testbase'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 39
_abc_registry = <_weakrefset.WeakSet object>
clean_db()[source]

This method implements the logic to fully clean the DB.

insert_data()[source]

Insert default data into the DB.

setUpClass_method()[source]

This class prepares the database (cleans it up and installs some basic entries). You have also to set a self.computer and a self.user_email as explained in the docstring of the AiidaTestImplemention docstring.

setUp_method()[source]
tearDownClass_method()[source]

This class implements the tear down methods (e.g. cleans up the DB).

tearDown_method()[source]