From b8eaffca3c448d1242eded845aa118b4bc1ae1a9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Tue, 28 May 2019 10:24:02 +0200 Subject: [PATCH] Drop the `nodeversion` and `public` columns of `DbNode` (#2937) These columns have been there from the initial model definition but have not been used at all. The adaptation of the import export format will be taken care of in another commit, that takes all the changes since v0.3 into account in one go. --- ...34_drop_node_columns_nodeversion_public.py | 44 ++++++++++++++ .../backends/djsite/db/migrations/__init__.py | 2 +- aiida/backends/djsite/db/models.py | 13 +--- aiida/backends/djsite/manage.py | 8 ++- ...31_drop_node_columns_nodeversion_public.py | 31 ++++++++++ aiida/backends/sqlalchemy/models/node.py | 2 - .../backends/sqlalchemy/tests/test_session.py | 4 -- .../fixtures/calcjob/arithmetic.add_old.aiida | Bin 11519 -> 10855 bytes .../tests/orm/implementation/test_nodes.py | 7 +-- aiida/backends/tests/test_nodes.py | 57 ------------------ aiida/orm/implementation/django/convert.py | 4 +- .../orm/implementation/django/dummy_model.py | 4 -- aiida/orm/implementation/django/nodes.py | 14 +---- aiida/orm/implementation/nodes.py | 29 +-------- aiida/orm/implementation/sqlalchemy/nodes.py | 22 +------ aiida/orm/importexport.py | 2 - aiida/orm/nodes/node.py | 24 +------- aiida/orm/querybuilder.py | 8 +-- 18 files changed, 93 insertions(+), 182 deletions(-) create mode 100644 aiida/backends/djsite/db/migrations/0034_drop_node_columns_nodeversion_public.py create mode 100644 aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py diff --git a/aiida/backends/djsite/db/migrations/0034_drop_node_columns_nodeversion_public.py b/aiida/backends/djsite/db/migrations/0034_drop_node_columns_nodeversion_public.py new file mode 100644 index 0000000000..3a0eb76a02 --- /dev/null +++ b/aiida/backends/djsite/db/migrations/0034_drop_node_columns_nodeversion_public.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +########################################################################### +# Copyright (c), The AiiDA team. All rights reserved. # +# This file is part of the AiiDA code. # +# # +# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core # +# For further information on the license, see the LICENSE.txt file # +# For further information please visit http://www.aiida.net # +########################################################################### +# pylint: disable=invalid-name,too-few-public-methods +"""Drop the columns `nodeversion` and `public` from the `DbNode` model.""" +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +from __future__ import absolute_import + +# Remove when https://github.com/PyCQA/pylint/issues/1931 is fixed +# pylint: disable=no-name-in-module,import-error,no-member +from django.db import migrations + +from aiida.backends.djsite.db.migrations import upgrade_schema_version + +REVISION = '1.0.34' +DOWN_REVISION = '1.0.33' + + +class Migration(migrations.Migration): + """Drop the columns `nodeversion` and `public` from the `DbNode` model.""" + + dependencies = [ + ('db', '0033_replace_text_field_with_json_field'), + ] + + operations = [ + migrations.RemoveField( + model_name='dbnode', + name='nodeversion', + ), + migrations.RemoveField( + model_name='dbnode', + name='public', + ), + upgrade_schema_version(REVISION, DOWN_REVISION) + ] diff --git a/aiida/backends/djsite/db/migrations/__init__.py b/aiida/backends/djsite/db/migrations/__init__.py index 5a60739520..7022211870 100644 --- a/aiida/backends/djsite/db/migrations/__init__.py +++ b/aiida/backends/djsite/db/migrations/__init__.py @@ -22,7 +22,7 @@ class DeserializationException(AiidaException): pass -LATEST_MIGRATION = '0033_replace_text_field_with_json_field' +LATEST_MIGRATION = '0034_drop_node_columns_nodeversion_public' def _update_schema_version(version, apps, schema_editor): diff --git a/aiida/backends/djsite/db/models.py b/aiida/backends/djsite/db/models.py index ea903afaf7..864eb997e9 100644 --- a/aiida/backends/djsite/db/models.py +++ b/aiida/backends/djsite/db/models.py @@ -156,8 +156,7 @@ class DbNode(m.Model): ctime = m.DateTimeField(default=timezone.now, db_index=True, editable=False) mtime = m.DateTimeField(auto_now=True, db_index=True, editable=False) # Cannot delete a user if something is associated to it - user = m.ForeignKey(AUTH_USER_MODEL, on_delete=m.PROTECT, - related_name='dbnodes') + user = m.ForeignKey(AUTH_USER_MODEL, on_delete=m.PROTECT, related_name='dbnodes') # Direct links outputs = m.ManyToManyField('self', symmetrical=False, @@ -166,15 +165,7 @@ class DbNode(m.Model): # Used only if dbnode is a calculation, or remotedata # Avoid that computers can be deleted if at least a node exists pointing # to it. - dbcomputer = m.ForeignKey('DbComputer', null=True, on_delete=m.PROTECT, - related_name='dbnodes') - - # Index that is incremented every time a modification is done on itself or on attributes. - # Managed by the aiida.orm.Node class. Do not modify - nodeversion = m.IntegerField(default=1, editable=False) - - # For the API: whether this node - public = m.BooleanField(default=False) + dbcomputer = m.ForeignKey('DbComputer', null=True, on_delete=m.PROTECT, related_name='dbnodes') objects = m.Manager() # Return aiida Node instances or their subclasses instead of DbNode instances diff --git a/aiida/backends/djsite/manage.py b/aiida/backends/djsite/manage.py index 4b5425ce3c..a499bb0414 100644 --- a/aiida/backends/djsite/manage.py +++ b/aiida/backends/djsite/manage.py @@ -34,8 +34,10 @@ # I remove the argument I just read actual_argv = [actual_argv[0]] + actual_argv[2:] - # Load the general load_dbenv. - from aiida.backends.utils import load_dbenv - load_dbenv(profile=profile_name) + # Load the profile + from aiida.manage.configuration import load_profile + from aiida.manage.manager import get_manager + load_profile(profile_name) + get_manager().get_backend() execute_from_command_line(actual_argv) diff --git a/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py b/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py new file mode 100644 index 0000000000..e460ef9c12 --- /dev/null +++ b/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +"""Drop the columns `nodeversion` and `public` from the `DbNode` model. + +Revision ID: 1830c8430131 +Revises: 1b8ed3425af9 +Create Date: 2019-05-27 15:35:37.404644 + +""" +# pylint: disable=invalid-name,no-member,import-error,no-name-in-module +from __future__ import division +from __future__ import print_function +from __future__ import absolute_import + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '1830c8430131' +down_revision = '1b8ed3425af9' +branch_labels = None +depends_on = None + + +def upgrade(): + op.drop_column('db_dbnode', 'nodeversion') + op.drop_column('db_dbnode', 'public') + + +def downgrade(): + op.add_column('db_dbnode', sa.Column('public', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('db_dbnode', sa.Column('nodeversion', sa.INTEGER(), autoincrement=False, nullable=True)) diff --git a/aiida/backends/sqlalchemy/models/node.py b/aiida/backends/sqlalchemy/models/node.py index 9fc00bb446..f9758e2d67 100644 --- a/aiida/backends/sqlalchemy/models/node.py +++ b/aiida/backends/sqlalchemy/models/node.py @@ -37,8 +37,6 @@ class DbNode(Base): description = Column(Text(), nullable=True, default='') ctime = Column(DateTime(timezone=True), default=timezone.now) mtime = Column(DateTime(timezone=True), default=timezone.now, onupdate=timezone.now) - nodeversion = Column(Integer, default=1) - public = Column(Boolean, default=False) attributes = Column(JSONB) extras = Column(JSONB) diff --git a/aiida/backends/sqlalchemy/tests/test_session.py b/aiida/backends/sqlalchemy/tests/test_session.py index c3896136ed..cca2467c8b 100644 --- a/aiida/backends/sqlalchemy/tests/test_session.py +++ b/aiida/backends/sqlalchemy/tests/test_session.py @@ -211,10 +211,6 @@ def do_value_checks(attr_name, original, changed): for str_attr in ['label', 'description']: do_value_checks(str_attr, 'original', 'changed') - # Since we already changed an attribute twice, the starting nodeversion is 3 and not 1 - do_value_checks('nodeversion', 3, 4) - do_value_checks('public', True, False) - for str_attr in ['ctime', 'mtime']: do_value_checks(str_attr, timezone.now(), timezone.now()) diff --git a/aiida/backends/tests/fixtures/calcjob/arithmetic.add_old.aiida b/aiida/backends/tests/fixtures/calcjob/arithmetic.add_old.aiida index a4da48050706f9f3230e79a2973cd05c07264e4e..272211b09f1862afaf23e2df4c8daf74a686e1f4 100644 GIT binary patch literal 10855 zcmb_h2|UyPAD$c`SA{4!%h}jz8xe9HflsTce&f6q7bdpL|u2!YuUFn~=I=yxa> z6o7^TXbcXDBEeu#0E2RY0sst7B)K4oWE_r78U(8}z5vyYO)k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ddt9Yw0*;ip345m0my7wjJN@XYV?XrrFe)we=b4{=GVbJ=^u(Gq$u~qt z^Yx@k9p5yrDdSgnkH=j`xOD|SpCOJ!qH}wDU2XRM>^(eT71!TH7}@y2x>D}pWb?!C zxiy77yx?NfV2?Sp4tQh%mz0SC6El>BwlfAUEN~2A!FPInGTNBn!HhD7u-bE&bopkq zVZlQ&Wej1X7sArzqtQkN56P4x329Q_4SEEf0KF3qW5LT0EnbdS1p=t9| z=c;IqpDy2xHY|0nzAc2M%ZHX1E?w=c;XvA8->GDf861+Qdzn)~rdv2r_l992X(4fU`qyuAVKIdRe)m zZ1{!73+VMwMpl>>54EUEPW=}@-OdkXgHr+li78eK=<`rUR#?+-1@c?25B)(otoa>v zsDq-@^PvOW4YAJ z+FncNip)n5l`hAK_Oz&TRkRS6E(eJ=GIg#d79p>IqePpUI#;B%3$y|zwIubjas^f( z&|_M7Pq(mbWrei@{M7ey|KT`Mwkrq=Uh*xxk>Q~#Y}W)K%e(S3F<=A#-wd)1_-O`W J65I%W`afVnB-{W1 diff --git a/aiida/backends/tests/orm/implementation/test_nodes.py b/aiida/backends/tests/orm/implementation/test_nodes.py index fa45592fd7..b1639665a3 100644 --- a/aiida/backends/tests/orm/implementation/test_nodes.py +++ b/aiida/backends/tests/orm/implementation/test_nodes.py @@ -52,8 +52,6 @@ def test_creation(self): self.assertTrue(isinstance(node.ctime, datetime)) self.assertIsNone(node.mtime) self.assertIsNone(node.process_type) - self.assertEqual(node.public, False) - self.assertEqual(node.version, 1) self.assertEqual(node.attributes, dict()) self.assertEqual(node.extras, dict()) self.assertEqual(node.node_type, self.node_type) @@ -81,8 +79,6 @@ def test_creation(self): self.assertTrue(isinstance(node.ctime, datetime)) self.assertTrue(isinstance(node.mtime, datetime)) self.assertIsNone(node.process_type) - self.assertEqual(node.public, False) - self.assertEqual(node.version, 1) self.assertEqual(node.attributes, dict()) self.assertEqual(node.extras, dict()) self.assertEqual(node.node_type, self.node_type) @@ -92,11 +88,10 @@ def test_creation(self): # Try to construct a UUID from the UUID value to prove that it has a valid UUID UUID(node.uuid) - # Change a column, which should trigger the save, update the mtime and version, but leave the ctime untouched + # Change a column, which should trigger the save, update the mtime but leave the ctime untouched node.label = 'test' self.assertEqual(node.ctime, node_ctime) self.assertTrue(node.mtime > node_mtime) - self.assertEqual(node.version, 2) def test_creation_with_time(self): """ diff --git a/aiida/backends/tests/test_nodes.py b/aiida/backends/tests/test_nodes.py index 918ad63cbb..03bada715f 100644 --- a/aiida/backends/tests/test_nodes.py +++ b/aiida/backends/tests/test_nodes.py @@ -949,44 +949,6 @@ def test_attr_listing(self): self.assertEquals(a.extras, all_extras) - def test_versioning(self): - """ - Test the versioning of the node when setting attributes and extras - """ - a = orm.Data() - attrs_to_set = { - 'bool': self.boolval, - 'integer': self.intval, - 'float': self.floatval, - 'string': self.stringval, - 'dict': self.dictval, - 'list': self.listval, - } - - for key, value in attrs_to_set.items(): - a.set_attribute(key, value) - self.assertEquals(a.get_attribute(key), value) - - a.store() - - # Check after storing - for key, value in attrs_to_set.items(): - self.assertEquals(a.get_attribute(key), value) - - # Even if I stored many attributes, this should stay at 1 - self.assertEquals(a.version, 1) - - # I check increment on new version - a.set_extra('a', 'b') - self.assertEquals(a.version, 2) - - # In both cases, the node version must increase - a.label = 'test' - self.assertEquals(a.version, 3) - - a.description = 'test description' - self.assertEquals(a.version, 4) - def test_delete_extras(self): """ Checks the ability of deleting extras, also when they are dictionaries @@ -1145,25 +1107,6 @@ def test_basetype_as_extra(self): self.assertEqual(n.get_extra('a')['b'][0], "sometext3") self.assertIsInstance(n.get_extra('a')['b'][0], six.string_types) - def test_versioning_lowlevel(self): - """ - Checks the versioning. - """ - a = orm.Data() - a.store() - - # Even if I stored many attributes, this should stay at 1 - self.assertEquals(a.version, 1) - - a.label = "label1" - a.label = "label2" - self.assertEquals(a.version, 3) - - a.description = "desc1" - a.description = "desc2" - a.description = "desc3" - self.assertEquals(a.version, 6) - def test_comments(self): # This is the best way to compare dates with the stored ones, instead # of directly loading datetime.datetime.now(), or you can get a diff --git a/aiida/orm/implementation/django/convert.py b/aiida/orm/implementation/django/convert.py index e372e1f894..fd99ca55fa 100644 --- a/aiida/orm/implementation/django/convert.py +++ b/aiida/orm/implementation/django/convert.py @@ -173,9 +173,7 @@ def _(dbmodel, backend): label=dbmodel.label, description=dbmodel.description, dbcomputer_id=dbmodel.dbcomputer_id, - user_id=dbmodel.user_id, - public=dbmodel.public, - nodeversion=dbmodel.nodeversion) + user_id=dbmodel.user_id) from . import nodes return nodes.DjangoNode.from_dbmodel(djnode_instance, backend) diff --git a/aiida/orm/implementation/django/dummy_model.py b/aiida/orm/implementation/django/dummy_model.py index dc977ee7f2..4475eeaf46 100644 --- a/aiida/orm/implementation/django/dummy_model.py +++ b/aiida/orm/implementation/django/dummy_model.py @@ -160,10 +160,6 @@ class DbNode(Base): user_id = Column(Integer, ForeignKey('db_dbuser.id', deferrable=True, initially="DEFERRED"), nullable=False) user = relationship('DbUser', backref='dbnodes') - public = Column(Boolean, default=False) - - nodeversion = Column(Integer, default=1) - attributes = relationship('DbAttribute', uselist=True, backref='dbnode') extras = relationship('DbExtra', uselist=True, backref='dbnode') diff --git a/aiida/orm/implementation/django/nodes.py b/aiida/orm/implementation/django/nodes.py index d14c5d8dc7..77d07271c8 100644 --- a/aiida/orm/implementation/django/nodes.py +++ b/aiida/orm/implementation/django/nodes.py @@ -176,7 +176,6 @@ def set_attribute(self, key, value): :param value: value of the attribute """ self.ATTRIBUTE_CLASS.set_value_for_node(self.dbmodel, key, value) - self._increment_version_number() def set_attributes(self, attributes): """Set attributes. @@ -187,7 +186,6 @@ def set_attributes(self, attributes): """ for key, value in attributes.items(): self.ATTRIBUTE_CLASS.set_value_for_node(self.dbmodel, key, value) - self._increment_version_number() def reset_attributes(self, attributes): """Reset the attributes. @@ -197,7 +195,6 @@ def reset_attributes(self, attributes): :param attributes: the new attributes to set """ self.ATTRIBUTE_CLASS.reset_values_for_node(self.dbmodel, attributes) - self._increment_version_number() def delete_attribute(self, key): """Delete an attribute. @@ -262,16 +259,13 @@ def get_extras(self, keys): """ raise NotImplementedError - def set_extra(self, key, value, increase_version=True): + def set_extra(self, key, value): """Set an extra to the given value. :param key: name of the extra :param value: value of the extra - :param increase_version: boolean, if True will increase the node version upon successfully setting the extra """ self.EXTRA_CLASS.set_value_for_node(self.dbmodel, key, value) - if increase_version: - self._increment_version_number() def set_extras(self, extras): """Set extras. @@ -282,7 +276,6 @@ def set_extras(self, extras): """ for key, value in extras.items(): self.EXTRA_CLASS.set_value_for_node(self.dbmodel, key, value) - self._increment_version_number() def reset_extras(self, extras): """Reset the extras. @@ -398,11 +391,6 @@ def store(self, attributes=None, links=None, with_transaction=True): return self - def _increment_version_number(self): - """Increment the node version number of this node by one directly in the database.""" - self._dbmodel.nodeversion = self.version + 1 - self._dbmodel.save() - class DjangoNodeCollection(BackendNodeCollection): """The collection of Node entries.""" diff --git a/aiida/orm/implementation/nodes.py b/aiida/orm/implementation/nodes.py index 4ab8acb2e7..7a15d777a2 100644 --- a/aiida/orm/implementation/nodes.py +++ b/aiida/orm/implementation/nodes.py @@ -68,8 +68,6 @@ def process_type(self, value): :param value: the new value to set """ self._dbmodel.process_type = value - if self.is_stored: - self._increment_version_number() @property def label(self): @@ -86,8 +84,6 @@ def label(self, value): :param value: the new value to set """ self._dbmodel.label = value - if self.is_stored: - self._increment_version_number() @property def description(self): @@ -104,8 +100,6 @@ def description(self, value): :param value: the new value to set """ self._dbmodel.description = value - if self.is_stored: - self._increment_version_number() @abc.abstractproperty def computer(self): @@ -155,22 +149,6 @@ def mtime(self): """ return self._dbmodel.mtime - @property - def version(self): - """Return the node version. - - :return: the version - """ - return self._dbmodel.nodeversion - - @property - def public(self): - """Return the node public attribute. - - :return: the public attribute - """ - return self._dbmodel.public - @property def attributes(self): """Return the attributes dictionary. @@ -295,12 +273,11 @@ def get_extras(self, keys): """ @abc.abstractmethod - def set_extra(self, key, value, increase_version=True): + def set_extra(self, key, value): """Set an extra to the given value. :param key: name of the extra :param value: value of the extra - :param increase_version: boolean, if True will increase the node version upon successfully setting the extra """ @abc.abstractmethod @@ -379,10 +356,6 @@ def store(self, attributes=None, links=None, with_transaction=True): :parameter with_transaction: if False, do not use a transaction because the caller will already have opened one. """ - @abc.abstractmethod - def _increment_version_number(self): - """Increment the node version number of this node by one directly in the database.""" - @six.add_metaclass(abc.ABCMeta) class BackendNodeCollection(backends.BackendCollection[BackendNode]): diff --git a/aiida/orm/implementation/sqlalchemy/nodes.py b/aiida/orm/implementation/sqlalchemy/nodes.py index 2614b80941..eb6be8c534 100644 --- a/aiida/orm/implementation/sqlalchemy/nodes.py +++ b/aiida/orm/implementation/sqlalchemy/nodes.py @@ -177,7 +177,6 @@ def set_attribute(self, key, value): """ try: self.dbmodel.set_attr(key, value) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -192,7 +191,6 @@ def set_attributes(self, attributes): """ try: self.dbmodel.set_attributes(attributes) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -207,7 +205,6 @@ def reset_attributes(self, attributes): """ try: self.dbmodel.reset_attributes(attributes) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -221,7 +218,6 @@ def delete_attribute(self, key): """ try: self._dbmodel.del_attr(key) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -279,17 +275,14 @@ def get_extras(self, keys): """ raise NotImplementedError - def set_extra(self, key, value, increase_version=True): + def set_extra(self, key, value): """Set an extra to the given value. :param key: name of the extra :param value: value of the extra - :param increase_version: boolean, if True will increase the node version upon successfully setting the extra """ try: self._dbmodel.set_extra(key, value) - if increase_version: - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -304,7 +297,6 @@ def set_extras(self, extras): """ try: self.dbmodel.set_extras(extras) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -319,7 +311,6 @@ def reset_extras(self, extras): """ try: self._dbmodel.reset_extras(extras) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -333,7 +324,6 @@ def delete_extra(self, key): """ try: self._dbmodel.del_extra(key) - self._increment_version_number() except Exception: # pylint: disable=bare-except session = get_scoped_session() session.rollback() @@ -436,16 +426,6 @@ def store(self, attributes=None, links=None, with_transaction=True): return self - def _increment_version_number(self): - """Increment the node version number of this node by one directly in the database.""" - self._dbmodel.nodeversion = self.version + 1 - try: - self._dbmodel.save() - except Exception: # pylint: disable=bare-except - session = get_scoped_session() - session.rollback() - raise - class SqlaNodeCollection(BackendNodeCollection): """The collection of Node entries.""" diff --git a/aiida/orm/importexport.py b/aiida/orm/importexport.py index 740b05f4db..67e0509797 100644 --- a/aiida/orm/importexport.py +++ b/aiida/orm/importexport.py @@ -238,13 +238,11 @@ def get_all_fields_info(): "convert_type": "date" }, "uuid": {}, - "public": {}, "mtime": { "convert_type": "date" }, "node_type": {}, "label": {}, - "nodeversion": {}, "user": { "requires": USER_ENTITY_NAME, "related_name": "dbnodes" diff --git a/aiida/orm/nodes/node.py b/aiida/orm/nodes/node.py index e5bf9e7c6d..31ff295989 100644 --- a/aiida/orm/nodes/node.py +++ b/aiida/orm/nodes/node.py @@ -319,22 +319,6 @@ def mtime(self): """ return self.backend_entity.mtime - @property - def version(self): - """Return the node version. - - :return: the version - """ - return self.backend_entity.version - - @property - def public(self): - """Return the node public attribute. - - :return: the public attribute - """ - return self.backend_entity.public - @property def attributes(self): """Return the attributes dictionary. @@ -1062,7 +1046,7 @@ def _store(self, with_transaction=True): self._attrs_cache = {} self._incoming_cache = list() - self._backend_entity.set_extra(_HASH_EXTRA_KEY, self.get_hash(), increase_version=False) + self._backend_entity.set_extra(_HASH_EXTRA_KEY, self.get_hash()) return self @@ -1274,12 +1258,6 @@ def get_schema(): "is_foreign_key": False, "type": "unicode" }, - "nodeversion": { - "display_name": "Node version", - "help_text": "Version of the node", - "is_foreign_key": False, - "type": "int" - }, "process_type": { "display_name": "Process type", "help_text": "Process type", diff --git a/aiida/orm/querybuilder.py b/aiida/orm/querybuilder.py index 38a4f2bc14..db97f9f327 100644 --- a/aiida/orm/querybuilder.py +++ b/aiida/orm/querybuilder.py @@ -1043,7 +1043,7 @@ def _add_process_type_filter(self, tagspec, classifiers, subclassing): def add_projection(self, tag_spec, projection_spec): - """ + r""" Adds a projection :param tag_spec: A valid specification for a tag @@ -1080,13 +1080,13 @@ def add_projection(self, tag_spec, projection_spec): print type(qb.first()[0]) # >>> aiida.orm.nodes.data.structure.StructureData - The double start *\*\** projects all possible projections of this entity: + The double star ``**`` projects all possible projections of this entity: QueryBuilder().append(StructureData,tag='s', project='**').limit(1).dict()[0]['s'].keys() - # >>> u'user_id, description, ctime, label, extras, mtime, id, attributes, dbcomputer_id, nodeversion, type, public, uuid' + # >>> u'user_id, description, ctime, label, extras, mtime, id, attributes, dbcomputer_id, type, uuid' - Be aware that the result of *\*\** depends on the backend implementation. + Be aware that the result of ``**`` depends on the backend implementation. """ tag = self._get_tag_from_specification(tag_spec)