aiida.backends.djsite.db.migrations package

exception aiida.backends.djsite.db.migrations.DeserializationException[source]

Bases: aiida.common.exceptions.AiidaException

__module__ = 'aiida.backends.djsite.db.migrations'
class aiida.backends.djsite.db.migrations.ModelModifierV0025(apps, model_class)[source]

Bases: object

AIIDA_ATTRIBUTE_SEP = '.'
__dict__ = dict_proxy({'__module__': 'aiida.backends.djsite.db.migrations', 'get_value_for_node': <function get_value_for_node>, 'validate_key': <function validate_key>, 'getvalue': <function getvalue>, 'AIIDA_ATTRIBUTE_SEP': '.', '__dict__': <attribute '__dict__' of 'ModelModifierV0025' objects>, '__weakref__': <attribute '__weakref__' of 'ModelModifierV0025' objects>, 'subspecifier_pk': <function subspecifier_pk>, '__init__': <function __init__>, 'set_value': <function set_value>, 'del_value_for_node': <function del_value_for_node>, 'create_value': <function create_value>, 'subspecifiers_dict': <function subspecifiers_dict>, 'apps': <property object>, '_sep': '.', 'set_value_for_node': <function set_value_for_node>, 'del_value': <function del_value>, '__doc__': None, '_subspecifier_field_name': 'dbnode'})
__init__(apps, model_class)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__module__ = 'aiida.backends.djsite.db.migrations'
__weakref__

list of weak references to the object (if defined)

_sep = '.'
_subspecifier_field_name = 'dbnode'
apps
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 self._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).

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 self._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)
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.
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
getvalue(attr)[source]

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

set_value(key, value, with_transaction=False, 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.
set_value_for_node(dbnode, key, value, with_transaction=False, 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).

subspecifier_pk(attr)[source]

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

subspecifiers_dict(attr)[source]

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

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:aiida.common.ValidationError – if the key is not valid
aiida.backends.djsite.db.migrations._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.migrations._update_schema_version(version, apps, schema_editor)[source]
aiida.backends.djsite.db.migrations.current_schema_version()[source]
aiida.backends.djsite.db.migrations.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"]}

aiida.backends.djsite.db.migrations.upgrade_schema_version(up_revision, down_revision)[source]

Submodules

class aiida.backends.djsite.db.migrations.0001_initial.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0001_initial'
dependencies = [(u'auth', u'0001_initial')]
operations = [<CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'password', <django.db.models.fields.CharField>), (u'last_login', <django.db.models.fields.DateTimeField>), (u'is_superuser', <django.db.models.fields.BooleanField>), (u'email', <django.db.models.fields.EmailField>), (u'first_name', <django.db.models.fields.CharField>), (u'last_name', <django.db.models.fields.CharField>), (u'institution', <django.db.models.fields.CharField>), (u'is_staff', <django.db.models.fields.BooleanField>), (u'is_active', <django.db.models.fields.BooleanField>), (u'date_joined', <django.db.models.fields.DateTimeField>), (u'groups', <django.db.models.fields.related.ManyToManyField>), (u'user_permissions', <django.db.models.fields.related.ManyToManyField>)], bases=(<class 'django.db.models.base.Model'>,), options={u'abstract': False}, name=u'DbUser'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'key', <django.db.models.fields.CharField>), (u'datatype', <django.db.models.fields.CharField>), (u'tval', <django.db.models.fields.TextField>), (u'fval', <django.db.models.fields.FloatField>), (u'ival', <django.db.models.fields.IntegerField>), (u'bval', <django.db.models.fields.NullBooleanField>), (u'dval', <django.db.models.fields.DateTimeField>)], bases=(<class 'django.db.models.base.Model'>,), options={u'abstract': False}, name=u'DbAttribute'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'auth_params', <django.db.models.fields.TextField>), (u'metadata', <django.db.models.fields.TextField>), (u'enabled', <django.db.models.fields.BooleanField>), (u'aiidauser', <django.db.models.fields.related.ForeignKey>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbAuthInfo'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'state', <django.db.models.fields.CharField>), (u'time', <django.db.models.fields.DateTimeField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbCalcState'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'uuid', <django.db.models.fields.CharField>), (u'ctime', <django.db.models.fields.DateTimeField>), (u'mtime', <django.db.models.fields.DateTimeField>), (u'content', <django.db.models.fields.TextField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbComment'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'uuid', <django.db.models.fields.CharField>), (u'name', <django.db.models.fields.CharField>), (u'hostname', <django.db.models.fields.CharField>), (u'description', <django.db.models.fields.TextField>), (u'enabled', <django.db.models.fields.BooleanField>), (u'transport_type', <django.db.models.fields.CharField>), (u'scheduler_type', <django.db.models.fields.CharField>), (u'transport_params', <django.db.models.fields.TextField>), (u'metadata', <django.db.models.fields.TextField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbComputer'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'key', <django.db.models.fields.CharField>), (u'datatype', <django.db.models.fields.CharField>), (u'tval', <django.db.models.fields.TextField>), (u'fval', <django.db.models.fields.FloatField>), (u'ival', <django.db.models.fields.IntegerField>), (u'bval', <django.db.models.fields.NullBooleanField>), (u'dval', <django.db.models.fields.DateTimeField>)], bases=(<class 'django.db.models.base.Model'>,), options={u'abstract': False}, name=u'DbExtra'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'uuid', <django.db.models.fields.CharField>), (u'name', <django.db.models.fields.CharField>), (u'type', <django.db.models.fields.CharField>), (u'time', <django.db.models.fields.DateTimeField>), (u'description', <django.db.models.fields.TextField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbGroup'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'label', <django.db.models.fields.CharField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbLink'>, <CreateModel fields=[(u'key', <django.db.models.fields.CharField>), (u'creation', <django.db.models.fields.DateTimeField>), (u'timeout', <django.db.models.fields.IntegerField>), (u'owner', <django.db.models.fields.CharField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbLock'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'time', <django.db.models.fields.DateTimeField>), (u'loggername', <django.db.models.fields.CharField>), (u'levelname', <django.db.models.fields.CharField>), (u'objname', <django.db.models.fields.CharField>), (u'objpk', <django.db.models.fields.IntegerField>), (u'message', <django.db.models.fields.TextField>), (u'metadata', <django.db.models.fields.TextField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbLog'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'uuid', <django.db.models.fields.CharField>), (u'type', <django.db.models.fields.CharField>), (u'label', <django.db.models.fields.CharField>), (u'description', <django.db.models.fields.TextField>), (u'ctime', <django.db.models.fields.DateTimeField>), (u'mtime', <django.db.models.fields.DateTimeField>), (u'nodeversion', <django.db.models.fields.IntegerField>), (u'public', <django.db.models.fields.BooleanField>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbNode'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'depth', <django.db.models.fields.IntegerField>), (u'entry_edge_id', <django.db.models.fields.IntegerField>), (u'direct_edge_id', <django.db.models.fields.IntegerField>), (u'exit_edge_id', <django.db.models.fields.IntegerField>), (u'child', <django.db.models.fields.related.ForeignKey>), (u'parent', <django.db.models.fields.related.ForeignKey>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbPath'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'key', <django.db.models.fields.CharField>), (u'datatype', <django.db.models.fields.CharField>), (u'tval', <django.db.models.fields.TextField>), (u'fval', <django.db.models.fields.FloatField>), (u'ival', <django.db.models.fields.IntegerField>), (u'bval', <django.db.models.fields.NullBooleanField>), (u'dval', <django.db.models.fields.DateTimeField>), (u'description', <django.db.models.fields.TextField>), (u'time', <django.db.models.fields.DateTimeField>)], bases=(<class 'django.db.models.base.Model'>,), options={u'abstract': False}, name=u'DbSetting'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'uuid', <django.db.models.fields.CharField>), (u'ctime', <django.db.models.fields.DateTimeField>), (u'mtime', <django.db.models.fields.DateTimeField>), (u'label', <django.db.models.fields.CharField>), (u'description', <django.db.models.fields.TextField>), (u'nodeversion', <django.db.models.fields.IntegerField>), (u'lastsyncedversion', <django.db.models.fields.IntegerField>), (u'state', <django.db.models.fields.CharField>), (u'report', <django.db.models.fields.TextField>), (u'module', <django.db.models.fields.TextField>), (u'module_class', <django.db.models.fields.TextField>), (u'script_path', <django.db.models.fields.TextField>), (u'script_md5', <django.db.models.fields.CharField>), (u'user', <django.db.models.fields.related.ForeignKey>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbWorkflow'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'name', <django.db.models.fields.CharField>), (u'time', <django.db.models.fields.DateTimeField>), (u'data_type', <django.db.models.fields.CharField>), (u'value_type', <django.db.models.fields.CharField>), (u'json_value', <django.db.models.fields.TextField>), (u'aiida_obj', <django.db.models.fields.related.ForeignKey>), (u'parent', <django.db.models.fields.related.ForeignKey>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbWorkflowData'>, <CreateModel fields=[(u'id', <django.db.models.fields.AutoField>), (u'name', <django.db.models.fields.CharField>), (u'time', <django.db.models.fields.DateTimeField>), (u'nextcall', <django.db.models.fields.CharField>), (u'state', <django.db.models.fields.CharField>), (u'calculations', <django.db.models.fields.related.ManyToManyField>), (u'parent', <django.db.models.fields.related.ForeignKey>), (u'sub_workflows', <django.db.models.fields.related.ManyToManyField>), (u'user', <django.db.models.fields.related.ForeignKey>)], bases=(<class 'django.db.models.base.Model'>,), options={}, name=u'DbWorkflowStep'>, <AlterUniqueTogether unique_together=set([(u'parent', u'name')]), name=u'dbworkflowstep'>, <AlterUniqueTogether unique_together=set([(u'parent', u'name', u'data_type')]), name=u'dbworkflowdata'>, <AlterUniqueTogether unique_together=set([(u'key',)]), name=u'dbsetting'>, <AddField field=<django.db.models.fields.related.ManyToManyField>, preserve_default=True, name=u'children', model_name=u'dbnode'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbcomputer', model_name=u'dbnode'>, <AddField field=<django.db.models.fields.related.ManyToManyField>, preserve_default=True, name=u'outputs', model_name=u'dbnode'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'user', model_name=u'dbnode'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'input', model_name=u'dblink'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'output', model_name=u'dblink'>, <AlterUniqueTogether unique_together=set([(u'input', u'output'), (u'output', u'label')]), name=u'dblink'>, <AddField field=<django.db.models.fields.related.ManyToManyField>, preserve_default=True, name=u'dbnodes', model_name=u'dbgroup'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'user', model_name=u'dbgroup'>, <AlterUniqueTogether unique_together=set([(u'name', u'type')]), name=u'dbgroup'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbnode', model_name=u'dbextra'>, <AlterUniqueTogether unique_together=set([(u'dbnode', u'key')]), name=u'dbextra'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbnode', model_name=u'dbcomment'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'user', model_name=u'dbcomment'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbnode', model_name=u'dbcalcstate'>, <AlterUniqueTogether unique_together=set([(u'dbnode', u'state')]), name=u'dbcalcstate'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbcomputer', model_name=u'dbauthinfo'>, <AlterUniqueTogether unique_together=set([(u'aiidauser', u'dbcomputer')]), name=u'dbauthinfo'>, <AddField field=<django.db.models.fields.related.ForeignKey>, preserve_default=True, name=u'dbnode', model_name=u'dbattribute'>, <AlterUniqueTogether unique_together=set([(u'dbnode', u'key')]), name=u'dbattribute'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0002_db_state_change.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0002_db_state_change'
dependencies = [(u'db', u'0001_initial')]
operations = [<AlterField field=<django.db.models.fields.CharField>, preserve_default=True, name=u'state', model_name=u'dbcalcstate'>, <RunPython <function fix_calc_states>>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0002_db_state_change.fix_calc_states(apps, schema_editor)[source]

Bases: django.db.migrations.migration.Migration

class aiida.backends.djsite.db.migrations.0004_add_daemon_and_uuid_indices.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0004_add_daemon_and_uuid_indices'
dependencies = [(u'db', u'0003_add_link_type')]
operations = [<RunSQL u'\n CREATE INDEX tval_idx_for_daemon\n ON db_dbattribute (tval)\n WHERE ("db_dbattribute"."tval"\n IN (\'COMPUTED\', \'WITHSCHEDULER\', \'TOSUBMIT\'))'>, <AlterField field=<django.db.models.fields.CharField>, preserve_default=True, name=u'uuid', model_name=u'dbnode'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0005_add_cmtime_indices.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0005_add_cmtime_indices'
dependencies = [(u'db', u'0004_add_daemon_and_uuid_indices')]
operations = [<AlterField field=<django.db.models.fields.DateTimeField>, preserve_default=True, name=u'ctime', model_name=u'dbnode'>, <AlterField field=<django.db.models.fields.DateTimeField>, preserve_default=True, name=u'mtime', model_name=u'dbnode'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0006_delete_dbpath.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0006_delete_dbpath'
dependencies = [(u'db', u'0005_add_cmtime_indices')]
operations = [<RemoveField name=u'child', model_name=u'dbpath'>, <RemoveField name=u'parent', model_name=u'dbpath'>, <RemoveField name=u'children', model_name=u'dbnode'>, <DeleteModel name=u'DbPath'>, <RunSQL u'\n DROP TRIGGER IF EXISTS autoupdate_tc ON db_dblink;\n DROP FUNCTION IF EXISTS update_tc();\n '>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0007_update_linktypes.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0007_update_linktypes'
dependencies = [(u'db', u'0006_delete_dbpath')]
operations = [<RunSQL u"\n UPDATE db_dblink set type='createlink' WHERE db_dblink.id IN (\n SELECT db_dblink_1.id \n FROM db_dbnode AS db_dbnode_1\n JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id\n JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id\n WHERE db_dbnode_1.type LIKE 'calculation.inline.%'\n AND db_dbnode_2.type LIKE 'data.%'\n AND db_dblink_1.type = 'returnlink'\n );\n ">, <RunSQL u"\n UPDATE db_dblink set type='inputlink' where id in (\n SELECT db_dblink_1.id\n FROM db_dbnode AS db_dbnode_1\n JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id\n JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id \n WHERE ( db_dbnode_1.type LIKE 'data.%' or db_dbnode_1.type = 'code.Code.' )\n AND db_dbnode_2.type LIKE 'calculation.%'\n AND ( db_dblink_1.type = null OR db_dblink_1.type = '')\n );\n ">, <RunSQL u"\n UPDATE db_dblink set type='createlink' where id in (\n SELECT db_dblink_1.id\n FROM db_dbnode AS db_dbnode_1\n JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id\n JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id \n WHERE db_dbnode_2.type LIKE 'data.%'\n AND (\n db_dbnode_1.type LIKE 'calculation.job.%'\n OR\n db_dbnode_1.type = 'calculation.inline.InlineCalculation.'\n )\n AND ( db_dblink_1.type = null OR db_dblink_1.type = '')\n );\n ">, <RunSQL u"\n UPDATE db_dblink set type='returnlink' where id in (\n SELECT db_dblink_1.id\n FROM db_dbnode AS db_dbnode_1\n JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id\n JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id \n WHERE db_dbnode_2.type LIKE 'data.%'\n AND db_dbnode_1.type = 'calculation.work.WorkCalculation.'\n AND ( db_dblink_1.type = null OR db_dblink_1.type = '')\n );\n ">, <RunSQL u"\n UPDATE db_dblink set type='calllink' where id in (\n SELECT db_dblink_1.id\n FROM db_dbnode AS db_dbnode_1\n JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id\n JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id \n WHERE db_dbnode_1.type = 'calculation.work.WorkCalculation.'\n AND db_dbnode_2.type LIKE 'calculation.%'\n AND ( db_dblink_1.type = null OR db_dblink_1.type = '')\n );\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0008_code_hidden_to_extra.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0008_code_hidden_to_extra'
dependencies = [(u'db', u'0007_update_linktypes')]
operations = [<RunSQL u"\n INSERT INTO db_dbextra (key, datatype, tval, fval, ival, bval, dval, dbnode_id) (\n SELECT db_dbattribute.key, db_dbattribute.datatype, db_dbattribute.tval, db_dbattribute.fval, db_dbattribute.ival, db_dbattribute.bval, db_dbattribute.dval, db_dbattribute.dbnode_id\n FROM db_dbattribute JOIN db_dbnode ON db_dbnode.id = db_dbattribute.dbnode_id\n WHERE db_dbattribute.key = 'hidden'\n AND db_dbnode.type = 'code.Code.'\n );\n ">, <RunSQL u"\n DELETE FROM db_dbattribute\n WHERE id in (\n SELECT db_dbattribute.id\n FROM db_dbattribute \n JOIN db_dbnode ON db_dbnode.id = db_dbattribute.dbnode_id\n WHERE db_dbattribute.key = 'hidden' AND db_dbnode.type = 'code.Code.'\n );\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0009_base_data_plugin_type_string.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0009_base_data_plugin_type_string'
dependencies = [(u'db', u'0008_code_hidden_to_extra')]
operations = [<RunSQL u"\n UPDATE db_dbnode SET type = 'data.bool.Bool.' WHERE type = 'data.base.Bool.';\n UPDATE db_dbnode SET type = 'data.float.Float.' WHERE type = 'data.base.Float.';\n UPDATE db_dbnode SET type = 'data.int.Int.' WHERE type = 'data.base.Int.';\n UPDATE db_dbnode SET type = 'data.str.Str.' WHERE type = 'data.base.Str.';\n UPDATE db_dbnode SET type = 'data.list.List.' WHERE type = 'data.base.List.';\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0010_process_type.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0010_process_type'
dependencies = [(u'db', u'0009_base_data_plugin_type_string')]
operations = [<AddField field=<django.db.models.fields.CharField>, name=u'process_type', model_name=u'dbnode'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0011_delete_kombu_tables.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0011_delete_kombu_tables'
dependencies = [(u'db', u'0010_process_type')]
operations = [<RunSQL u"\n DROP TABLE IF EXISTS kombu_message;\n DROP TABLE IF EXISTS kombu_queue;\n DELETE FROM db_dbsetting WHERE key = 'daemon|user';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_stop|retriever';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_start|retriever';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_stop|updater';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_start|updater';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_stop|submitter';\n DELETE FROM db_dbsetting WHERE key = 'daemon|task_start|submitter';\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0012_drop_dblock.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0012_drop_dblock'
dependencies = [(u'db', u'0011_delete_kombu_tables')]
operations = [<DeleteModel name=u'DbLock'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0013_django_1_8.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0013_django_1_8'
dependencies = [(u'db', u'0012_drop_dblock')]
operations = [<AlterField field=<django.db.models.fields.DateTimeField>, name=u'last_login', model_name=u'dbuser'>, <AlterField field=<django.db.models.fields.EmailField>, name=u'email', model_name=u'dbuser'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Add a uniqueness constraint to the uuid column of DbNode table.

class aiida.backends.djsite.db.migrations.0014_add_node_uuid_unique_constraint.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Add a uniqueness constraint to the uuid column of DbNode table.

__module__ = 'aiida.backends.djsite.db.migrations.0014_add_node_uuid_unique_constraint'
dependencies = [(u'db', u'0013_django_1_8')]
operations = [<RunPython <function verify_node_uuid_uniqueness> reverse_code=<function reverse_code>>, <AlterField field=<django.db.models.fields.CharField>, name=u'uuid', model_name=u'dbnode'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0014_add_node_uuid_unique_constraint.reverse_code(apps, schema_editor)[source]
aiida.backends.djsite.db.migrations.0014_add_node_uuid_unique_constraint.verify_node_uuid_uniqueness(apps, schema_editor)[source]

Check whether the database contains nodes with duplicate UUIDS.

Note that we have to redefine this method from aiida.manage.database.integrity.verify_node_uuid_uniqueness because the migrations.RunPython command that will invoke this function, will pass two arguments and therefore this wrapper needs to have a different function signature.

Raises:IntegrityError if database contains nodes with duplicate UUIDS.
class aiida.backends.djsite.db.migrations.0015_invalidating_node_hash.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Invalidating node hash - User should rehash nodes for caching

__module__ = 'aiida.backends.djsite.db.migrations.0015_invalidating_node_hash'
dependencies = [(u'db', u'0014_add_node_uuid_unique_constraint')]
operations = [<RunPython <function notify_user> reverse_code=<function notify_user>>, <RunSQL u" DELETE FROM db_dbextra WHERE key='_aiida_hash';" reverse_sql=u" DELETE FROM db_dbextra WHERE key='_aiida_hash';">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0015_invalidating_node_hash.notify_user(apps, schema_editor)[source]
class aiida.backends.djsite.db.migrations.0016_code_sub_class_of_data.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0016_code_sub_class_of_data'
dependencies = [(u'db', u'0015_invalidating_node_hash')]
operations = [<RunSQL reverse_sql=u"UPDATE db_dbnode SET type = 'code.Code.' WHERE type = 'data.code.Code.';", sql=u"UPDATE db_dbnode SET type = 'data.code.Code.' WHERE type = 'code.Code.';">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
class aiida.backends.djsite.db.migrations.0017_drop_dbcalcstate.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

__module__ = 'aiida.backends.djsite.db.migrations.0017_drop_dbcalcstate'
dependencies = [(u'db', u'0016_code_sub_class_of_data')]
operations = [<DeleteModel name=u'DbCalcState'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Migration for upgrade to django 1.11

class aiida.backends.djsite.db.migrations.0018_django_1_11.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration for upgrade to django 1.11

This migration switches from the django_extensions UUID field to the native UUIDField of django 1.11

It also introduces unique constraints on all uuid columns (previously existed only on dbnode).

__module__ = 'aiida.backends.djsite.db.migrations.0018_django_1_11'
dependencies = [(u'db', u'0017_drop_dbcalcstate')]
operations = [<RunPython <function _verify_uuid_uniqueness> reverse_code=<function reverse_code>>, <AlterField field=<django.db.models.fields.UUIDField>, name=u'uuid', model_name=u'dbcomment'>, <AlterField field=<django.db.models.fields.UUIDField>, name=u'uuid', model_name=u'dbcomputer'>, <AlterField field=<django.db.models.fields.UUIDField>, name=u'uuid', model_name=u'dbgroup'>, <AlterField field=<django.db.models.fields.CharField>, name=u'uuid', model_name=u'dbnode'>, <AlterField field=<django.db.models.fields.UUIDField>, name=u'uuid', model_name=u'dbnode'>, <AlterField field=<django.db.models.fields.EmailField>, name=u'email', model_name=u'dbuser'>, <AlterField field=<django.db.models.fields.related.ManyToManyField>, name=u'groups', model_name=u'dbuser'>, <AlterField field=<django.db.models.fields.UUIDField>, name=u'uuid', model_name=u'dbworkflow'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0018_django_1_11._verify_uuid_uniqueness(apps, schema_editor)[source]

Check whether the respective tables contain rows with duplicate UUIDS.

Note that we have to redefine this method from aiida.manage.database.integrity because the migrations.RunPython command that will invoke this function, will pass two arguments and therefore this wrapper needs to have a different function signature.

Raises:IntegrityError if database contains rows with duplicate UUIDS.
aiida.backends.djsite.db.migrations.0018_django_1_11.reverse_code(apps, schema_editor)[source]

Migration to reflect the name change of the built in calculation entry points in the database.

class aiida.backends.djsite.db.migrations.0019_migrate_builtin_calculations.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration to remove entry point groups from process type strings and prefix unknown types with a marker.

__module__ = 'aiida.backends.djsite.db.migrations.0019_migrate_builtin_calculations'
dependencies = [(u'db', u'0018_django_1_11')]
operations = [<RunSQL reverse_sql=u"\n UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.arithmetic.add.ArithmeticAddCalculation.'\n WHERE type = 'calculation.job.arithmetic.add.ArithmeticAddCalculation.';\n\n UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.templatereplacer.TemplatereplacerCalculation.'\n WHERE type = 'calculation.job.templatereplacer.TemplatereplacerCalculation.';\n\n UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.arithmetic.add'\n WHERE process_type = 'aiida.calculations:arithmetic.add';\n\n UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.templatereplacer'\n WHERE process_type = 'aiida.calculations:templatereplacer';\n\n UPDATE db_dbattribute AS a SET tval = 'simpleplugins.arithmetic.add'\n FROM db_dbnode AS n WHERE a.dbnode_id = n.id\n AND a.key = 'input_plugin'\n AND a.tval = 'arithmetic.add'\n AND n.type = 'data.code.Code.';\n\n UPDATE db_dbattribute AS a SET tval = 'simpleplugins.templatereplacer'\n FROM db_dbnode AS n WHERE a.dbnode_id = n.id\n AND a.key = 'input_plugin'\n AND a.tval = 'templatereplacer'\n AND n.type = 'data.code.Code.';\n ", sql=u"\n UPDATE db_dbnode SET type = 'calculation.job.arithmetic.add.ArithmeticAddCalculation.'\n WHERE type = 'calculation.job.simpleplugins.arithmetic.add.ArithmeticAddCalculation.';\n\n UPDATE db_dbnode SET type = 'calculation.job.templatereplacer.TemplatereplacerCalculation.'\n WHERE type = 'calculation.job.simpleplugins.templatereplacer.TemplatereplacerCalculation.';\n\n UPDATE db_dbnode SET process_type = 'aiida.calculations:arithmetic.add'\n WHERE process_type = 'aiida.calculations:simpleplugins.arithmetic.add';\n\n UPDATE db_dbnode SET process_type = 'aiida.calculations:templatereplacer'\n WHERE process_type = 'aiida.calculations:simpleplugins.templatereplacer';\n\n UPDATE db_dbattribute AS a SET tval = 'arithmetic.add'\n FROM db_dbnode AS n WHERE a.dbnode_id = n.id\n AND a.key = 'input_plugin'\n AND a.tval = 'simpleplugins.arithmetic.add'\n AND n.type = 'data.code.Code.';\n\n UPDATE db_dbattribute AS a SET tval = 'templatereplacer'\n FROM db_dbnode AS n WHERE a.dbnode_id = n.id\n AND a.key = 'input_plugin'\n AND a.tval = 'simpleplugins.templatereplacer'\n AND n.type = 'data.code.Code.';\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Migration after the provenance redesign

class aiida.backends.djsite.db.migrations.0020_provenance_redesign.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration to effectuate changes introduced by the provenance redesign

This includes in order:

  • Rename the type column of process nodes
  • Remove illegal links
  • Rename link types

The exact reverse operation is not possible because the renaming of the type string of JobCalculation nodes is done in a lossy way. Originally this type string contained the exact sub class of the JobCalculation but in the migration this is changed to always be node.process.calculation.calcjob.CalcJobNode.. In the reverse operation, this can then only be reset to calculation.job.JobCalculation. but the information on the exact sub class is lost.

__module__ = 'aiida.backends.djsite.db.migrations.0020_provenance_redesign'
dependencies = [(u'db', u'0019_migrate_builtin_calculations')]
operations = [<RunPython <function migrate_infer_calculation_entry_point> reverse_code=<function reverse_code>, atomic=True>, <RunPython <function detect_unexpected_links> reverse_code=<function reverse_code>, atomic=True>, <RunSQL u"\n DELETE FROM db_dblink WHERE db_dblink.id IN (\n SELECT db_dblink.id FROM db_dblink\n INNER JOIN db_dbnode ON db_dblink.input_id = db_dbnode.id\n WHERE\n (db_dbnode.type LIKE 'calculation.job%' OR db_dbnode.type LIKE 'calculation.inline%')\n AND db_dblink.type = 'returnlink'\n ); -- Delete all outgoing RETURN links from JobCalculation and InlineCalculation nodes\n\n DELETE FROM db_dblink WHERE db_dblink.id IN (\n SELECT db_dblink.id FROM db_dblink\n INNER JOIN db_dbnode ON db_dblink.input_id = db_dbnode.id\n WHERE\n (db_dbnode.type LIKE 'calculation.job%' OR db_dbnode.type LIKE 'calculation.inline%')\n AND db_dblink.type = 'calllink'\n ); -- Delete all outgoing CALL links from JobCalculation and InlineCalculation nodes\n\n DELETE FROM db_dblink WHERE db_dblink.id IN (\n SELECT db_dblink.id FROM db_dblink\n INNER JOIN db_dbnode ON db_dblink.input_id = db_dbnode.id\n WHERE\n (db_dbnode.type LIKE 'calculation.function%' OR db_dbnode.type LIKE 'calculation.work%')\n AND db_dblink.type = 'createlink'\n ); -- Delete all outgoing CREATE links from FunctionCalculation and WorkCalculation nodes\n\n UPDATE db_dbnode SET type = 'calculation.work.WorkCalculation.'\n WHERE type = 'calculation.process.ProcessCalculation.';\n -- First migrate very old `ProcessCalculation` to `WorkCalculation`\n\n UPDATE db_dbnode SET type = 'node.process.workflow.workfunction.WorkFunctionNode.' FROM db_dbattribute\n WHERE db_dbattribute.dbnode_id = db_dbnode.id\n AND type = 'calculation.work.WorkCalculation.'\n AND db_dbattribute.key = 'function_name';\n -- WorkCalculations that have a `function_name` attribute are FunctionCalculations\n\n UPDATE db_dbnode SET type = 'node.process.workflow.workchain.WorkChainNode.'\n WHERE type = 'calculation.work.WorkCalculation.';\n -- Update type for `WorkCalculation` nodes - all what is left should be `WorkChainNodes`\n\n UPDATE db_dbnode SET type = 'node.process.calculation.calcjob.CalcJobNode.'\n WHERE type LIKE 'calculation.job.%'; -- Update type for JobCalculation nodes\n\n UPDATE db_dbnode SET type = 'node.process.calculation.calcfunction.CalcFunctionNode.'\n WHERE type = 'calculation.inline.InlineCalculation.'; -- Update type for InlineCalculation nodes\n\n UPDATE db_dbnode SET type = 'node.process.workflow.workfunction.WorkFunctionNode.'\n WHERE type = 'calculation.function.FunctionCalculation.'; -- Update type for FunctionCalculation nodes\n\n UPDATE db_dblink SET type = 'create' WHERE type = 'createlink'; -- Rename `createlink` to `create`\n UPDATE db_dblink SET type = 'return' WHERE type = 'returnlink'; -- Rename `returnlink` to `return`\n\n UPDATE db_dblink SET type = 'input_calc' FROM db_dbnode\n WHERE db_dblink.output_id = db_dbnode.id AND db_dbnode.type LIKE 'node.process.calculation%'\n AND db_dblink.type = 'inputlink';\n -- Rename `inputlink` to `input_calc` if the target node is a calculation type node\n\n UPDATE db_dblink SET type = 'input_work' FROM db_dbnode\n WHERE db_dblink.output_id = db_dbnode.id AND db_dbnode.type LIKE 'node.process.workflow%'\n AND db_dblink.type = 'inputlink';\n -- Rename `inputlink` to `input_work` if the target node is a workflow type node\n\n UPDATE db_dblink SET type = 'call_calc' FROM db_dbnode\n WHERE db_dblink.output_id = db_dbnode.id AND db_dbnode.type LIKE 'node.process.calculation%'\n AND db_dblink.type = 'calllink';\n -- Rename `calllink` to `call_calc` if the target node is a calculation type node\n\n UPDATE db_dblink SET type = 'call_work' FROM db_dbnode\n WHERE db_dblink.output_id = db_dbnode.id AND db_dbnode.type LIKE 'node.process.workflow%'\n AND db_dblink.type = 'calllink';\n -- Rename `calllink` to `call_work` if the target node is a workflow type node\n\n " reverse_sql=u"\n UPDATE db_dbnode SET type = 'calculation.job.JobCalculation.'\n WHERE type = 'node.process.calculation.calcjob.CalcJobNode.';\n\n UPDATE db_dbnode SET type = 'calculatison.inline.InlineCalculation.'\n WHERE type = 'node.process.calculation.calcfunction.CalcFunctionNode.';\n\n UPDATE db_dbnode SET type = 'calculation.function.FunctionCalculation.'\n WHERE type = 'node.process.workflow.workfunction.WorkFunctionNode.';\n\n UPDATE db_dbnode SET type = 'calculation.work.WorkCalculation.'\n WHERE type = 'node.process.workflow.workchain.WorkChainNode.';\n\n\n UPDATE db_dblink SET type = 'inputlink'\n WHERE type = 'input_call' OR type = 'input_work';\n\n UPDATE db_dblink SET type = 'calllink'\n WHERE type = 'call_call' OR type = 'call_work';\n\n UPDATE db_dblink SET type = 'createlink'\n WHERE type = 'create';\n\n UPDATE db_dblink SET type = 'returnlink'\n WHERE type = 'return';\n\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Scan the database for any links that are unexpected.

The checks will verify that there are no outgoing call or return links from calculation nodes and that if a workflow node has a create link, it has at least an accompanying return link to the same data node, or it has a call link to a calculation node that takes the created data node as input.

aiida.backends.djsite.db.migrations.0020_provenance_redesign.migrate_infer_calculation_entry_point(apps, schema_editor)[source]

Set the process type for calculation nodes by inferring it from their type string.

aiida.backends.djsite.db.migrations.0020_provenance_redesign.reverse_code(apps, schema_editor)[source]

Reversing the inference of the process type is not possible and not necessary.

Migration that renames name and type columns to label and type_string

class aiida.backends.djsite.db.migrations.0021_dbgroup_name_to_label_type_to_type_string.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration that renames name and type columns to label and type_string

__module__ = 'aiida.backends.djsite.db.migrations.0021_dbgroup_name_to_label_type_to_type_string'
dependencies = [(u'db', u'0020_provenance_redesign')]
operations = [<RenameField new_name=u'label', model_name=u'dbgroup', old_name=u'name'>, <RenameField new_name=u'type_string', model_name=u'dbgroup', old_name=u'type'>, <AlterUniqueTogether unique_together=set([(u'label', u'type_string')]), name=u'dbgroup'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Migration after the update of group_types

class aiida.backends.djsite.db.migrations.0022_dbgroup_type_string_change_content.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration after the update of group_types

__module__ = 'aiida.backends.djsite.db.migrations.0022_dbgroup_type_string_change_content'
dependencies = [(u'db', u'0021_dbgroup_name_to_label_type_to_type_string')]
operations = [<RunSQL reverse_sql=u"UPDATE db_dbgroup SET type_string = '' WHERE type_string = 'user';\nUPDATE db_dbgroup SET type_string = 'data.upf.family' WHERE type_string = 'data.upf';\nUPDATE db_dbgroup SET type_string = 'aiida.import' WHERE type_string = 'auto.import';\nUPDATE db_dbgroup SET type_string = 'autogroup.run' WHERE type_string = 'auto.run';", sql=u"UPDATE db_dbgroup SET type_string = 'user' WHERE type_string = '';\nUPDATE db_dbgroup SET type_string = 'data.upf' WHERE type_string = 'data.upf.family';\nUPDATE db_dbgroup SET type_string = 'auto.import' WHERE type_string = 'aiida.import';\nUPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'autogroup.run';">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Migration of CalcJobNode attributes for metadata options whose key changed.

class aiida.backends.djsite.db.migrations.0023_calc_job_option_attribute_keys.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Migration of CalcJobNode attributes for metadata options whose key changed.

Renamed attribute keys:

  • custom_environment_variables -> environment_variables
  • jobresource_params -> resources
  • _process_label -> process_label
  • parser -> parser_name
Deleted attributes:
  • linkname_retrieved (We do not actually delete it just in case some relies on it)
__module__ = 'aiida.backends.djsite.db.migrations.0023_calc_job_option_attribute_keys'
dependencies = [(u'db', u'0022_dbgroup_type_string_change_content')]
operations = [<RunSQL reverse_sql=u"\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^environment_variables', 'custom_environment_variables')\n FROM db_dbnode AS node\n WHERE\n (\n attribute.key = 'environment_variables' OR\n attribute.key LIKE 'environment\\_variables.%'\n ) AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- environment_variables -> custom_environment_variables\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^resources', 'jobresource_params')\n FROM db_dbnode AS node\n WHERE\n (\n attribute.key = 'resources' OR\n attribute.key LIKE 'resources.%'\n ) AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- resources -> jobresource_params\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^process_label', '_process_label')\n FROM db_dbnode AS node\n WHERE\n attribute.key = 'process_label' AND\n node.type LIKE 'node.process.%';\n -- process_label -> _process_label\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^parser_name', 'parser')\n FROM db_dbnode AS node\n WHERE\n attribute.key = 'parser_name' AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- parser_name -> parser\n ", sql=u"\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^custom_environment_variables', 'environment_variables')\n FROM db_dbnode AS node\n WHERE\n (\n attribute.key = 'custom_environment_variables' OR\n attribute.key LIKE 'custom\\_environment\\_variables.%'\n ) AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- custom_environment_variables -> environment_variables\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^jobresource_params', 'resources')\n FROM db_dbnode AS node\n WHERE\n (\n attribute.key = 'jobresource_params' OR\n attribute.key LIKE 'jobresource\\_params.%'\n ) AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- jobresource_params -> resources\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^_process_label', 'process_label')\n FROM db_dbnode AS node\n WHERE\n attribute.key = '_process_label' AND\n node.type LIKE 'node.process.%';\n -- _process_label -> process_label\n\n UPDATE db_dbattribute AS attribute\n SET key = regexp_replace(attribute.key, '^parser', 'parser_name')\n FROM db_dbnode AS node\n WHERE\n attribute.key = 'parser' AND\n node.type = 'node.process.calculation.calcjob.CalcJobNode.';\n -- parser -> parser_name\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Data migration for Data nodes after it was moved in the aiida.orm.node module changing the type string.

class aiida.backends.djsite.db.migrations.0025_move_data_within_node_module.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Data migration for Data nodes after it was moved in the aiida.orm.node module changing the type string.

__module__ = 'aiida.backends.djsite.db.migrations.0025_move_data_within_node_module'
dependencies = [(u'db', u'0024_dblog_update')]
operations = [<RunSQL reverse_sql=u"\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^node.data.', 'data.')\n WHERE type LIKE 'node.data.%'\n ", sql=u"\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^data.', 'node.data.')\n WHERE type LIKE 'data.%'\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Data migration for TrajectoryData nodes where symbol lists are moved from repository array to attribute.

This process has to be done in two separate consecutive migrations to prevent data loss in between.

class aiida.backends.djsite.db.migrations.0026_trajectory_symbols_to_attribute.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Storing symbols in TrajectoryData nodes as attributes, while keeping numpy arrays. TrajectoryData symbols arrays are deleted in the next migration. We split the migration into two because every migration is wrapped in an atomic transaction and we want to avoid to delete the data while it is written in the database

__module__ = 'aiida.backends.djsite.db.migrations.0026_trajectory_symbols_to_attribute'
dependencies = [(u'db', u'0025_move_data_within_node_module')]
operations = [<RunPython <function create_trajectory_symbols_attribute> reverse_code=<function delete_trajectory_symbols_attribute>>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0026_trajectory_symbols_to_attribute.create_trajectory_symbols_attribute(apps, _)[source]

Create the symbols attribute from the repository array for all TrajectoryData nodes.

aiida.backends.djsite.db.migrations.0026_trajectory_symbols_to_attribute.delete_trajectory_symbols_attribute(apps, _)[source]

Delete the symbols attribute for all TrajectoryData nodes.

Data migration for TrajectoryData nodes where symbol lists are moved from repository array to attribute.

This process has to be done in two separate consecutive migrations to prevent data loss in between.

class aiida.backends.djsite.db.migrations.0027_delete_trajectory_symbols_array.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Deleting duplicated information stored in TrajectoryData symbols numpy arrays

__module__ = 'aiida.backends.djsite.db.migrations.0027_delete_trajectory_symbols_array'
dependencies = [(u'db', u'0026_trajectory_symbols_to_attribute')]
operations = [<RunPython <function delete_trajectory_symbols_array> reverse_code=<function create_trajectory_symbols_array>>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]
aiida.backends.djsite.db.migrations.0027_delete_trajectory_symbols_array.create_trajectory_symbols_array(apps, _)[source]

Create the symbols array for all TrajectoryData nodes.

aiida.backends.djsite.db.migrations.0027_delete_trajectory_symbols_array.delete_trajectory_symbols_array(apps, _)[source]

Delete the symbols array from all TrajectoryData nodes.

Final data migration for Nodes after aiida.orm.nodes reorganization was finalized to remove the node. prefix

class aiida.backends.djsite.db.migrations.0028_remove_node_prefix.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Now all node sub classes live in aiida.orm.nodes so now the node. prefix can be removed.

__module__ = 'aiida.backends.djsite.db.migrations.0028_remove_node_prefix'
dependencies = [(u'db', u'0027_delete_trajectory_symbols_array')]
operations = [<RunSQL reverse_sql=u"\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^data.', 'node.data.')\n WHERE type LIKE 'data.%';\n\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^process.', 'node.process.')\n WHERE type LIKE 'process.%';\n ", sql=u"\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^node.data.', 'data.')\n WHERE type LIKE 'node.data.%';\n\n UPDATE db_dbnode\n SET type = regexp_replace(type, '^node.process.', 'process.')\n WHERE type LIKE 'node.process.%';\n ">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Data migration for after ParameterData was renamed to Dict.

class aiida.backends.djsite.db.migrations.0029_rename_parameter_data_to_dict.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Data migration for after ParameterData was renamed to Dict.

__module__ = 'aiida.backends.djsite.db.migrations.0029_rename_parameter_data_to_dict'
dependencies = [(u'db', u'0028_remove_node_prefix')]
operations = [<RunSQL reverse_sql=u"UPDATE db_dbnode SET type = 'data.parameter.ParameterData.' WHERE type = 'data.dict.Dict.';", sql=u"UPDATE db_dbnode SET type = 'data.dict.Dict.' WHERE type = 'data.parameter.ParameterData.';">, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]

Renaming DbNode.type to DbNode.node_type

class aiida.backends.djsite.db.migrations.0030_dbnode_type_to_dbnode_node_type.Migration(name, app_label)[source]

Bases: django.db.migrations.migration.Migration

Renaming DbNode.type to DbNode.node_type

__module__ = 'aiida.backends.djsite.db.migrations.0030_dbnode_type_to_dbnode_node_type'
dependencies = [(u'db', u'0029_rename_parameter_data_to_dict')]
operations = [<RenameField new_name=u'node_type', model_name=u'dbnode', old_name=u'type'>, <RunPython <functools.partial object> reverse_code=<functools.partial object>>]