diff --git a/datajoint/autopopulate.py b/datajoint/autopopulate.py index 9e9615144..c32297028 100644 --- a/datajoint/autopopulate.py +++ b/datajoint/autopopulate.py @@ -39,8 +39,8 @@ def _rename_attributes(table, props): if self._key_source is None: parents = self.target.parents(primary=True, as_objects=True, foreign_key_info=True) if not parents: - raise DataJointError( - 'A relation must have primary dependencies for auto-populate to work') + raise DataJointError('A table must have dependencies ' + 'from its primary key for auto-populate to work') self._key_source = _rename_attributes(*parents[0]) for q in parents[1:]: self._key_source *= _rename_attributes(*q) diff --git a/datajoint/schemas.py b/datajoint/schemas.py index d108caef2..ab2fc03af 100644 --- a/datajoint/schemas.py +++ b/datajoint/schemas.py @@ -23,7 +23,6 @@ def ordered_dir(class_): """ List (most) attributes of the class including inherited ones, similar to `dir` build-in function, but respects order of attribute declaration as much as possible. - This becomes unnecessary in Python 3.6+ as dicts became ordered. :param class_: class to list members for :return: a list of attributes declared in class_ and its superclasses """ @@ -186,6 +185,7 @@ def _decorate_table(self, table_class, context, assert_declared=False): if not self.create_tables or assert_declared: raise DataJointError('Table `%s` not declared' % instance.table_name) instance.declare(context) + self.connection.dependencies.clear() is_declared = is_declared or instance.is_declared # add table definition to the doc string diff --git a/tests/test_autopopulate.py b/tests/test_autopopulate.py index b10216a37..081787670 100644 --- a/tests/test_autopopulate.py +++ b/tests/test_autopopulate.py @@ -86,6 +86,7 @@ class Image(dj.Imported): def make(self, key): self.insert1(dict(key, image_data=dict())) + Image.populate() @schema @@ -98,4 +99,5 @@ class Crop(dj.Computed): def make(self, key): self.insert1(dict(key, crop_image=dict())) + Crop.populate() diff --git a/tests/test_erd.py b/tests/test_erd.py index 6c4ae24b7..d1905e418 100644 --- a/tests/test_erd.py +++ b/tests/test_erd.py @@ -26,6 +26,7 @@ def test_decorator(): @staticmethod def test_dependencies(): deps = schema.connection.dependencies + deps.load() assert_true(all(cls.full_table_name in deps for cls in (A, B, B.C, D, E, E.F, L))) assert_true(set(A().children()) == set([B.full_table_name, D.full_table_name])) assert_true(set(D().parents(primary=True)) == set([A.full_table_name])) diff --git a/tests/test_schema_keywords.py b/tests/test_schema_keywords.py index 577524511..50cb25558 100644 --- a/tests/test_schema_keywords.py +++ b/tests/test_schema_keywords.py @@ -3,7 +3,7 @@ from nose.tools import assert_true -schema = dj.Schema(PREFIX + '_keywords', locals(), connection=dj.conn(**CONN_INFO)) +schema = dj.Schema(PREFIX + '_keywords', connection=dj.conn(**CONN_INFO)) @schema