Skip to content

Commit 4afa476

Browse files
Merge pull request #957 from dimitri-yatsenko/issue151
fix 151 and 374 - cascades to part tables must be from parent tables.
2 parents a91f239 + 741f451 commit 4afa476

File tree

10 files changed

+253
-116
lines changed

10 files changed

+253
-116
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Add - implement multiprocessing in populate (#695) PR #704, #969
99
* Bugfix - Dependencies not properly loaded on populate. (#902) PR #919
1010
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
11+
* Bugfix - Deletes and drops must include the master of each part. (#151, #374) PR #957
1112
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
1213
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
1314
* Bugfix - Fix regression issue with `DISTINCT` clause and `GROUP_BY` (#914) PR #963
@@ -134,7 +135,7 @@
134135
* Fix #628 - incompatibility with pyparsing 2.4.1
135136

136137
### 0.11.1 -- Nov 15, 2018
137-
* Fix ordering of attributes in proj (#483 and #516)
138+
* Fix ordering of attributes in proj (#483, #516)
138139
* Prohibit direct insert into auto-populated tables (#511)
139140

140141
### 0.11.0 -- Oct 25, 2018

datajoint/autopopulate.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def _rename_attributes(table, props):
6363
if props['aliased'] else table.proj())
6464

6565
if self._key_source is None:
66-
parents = self.target.parents(primary=True, as_objects=True, foreign_key_info=True)
66+
parents = self.target.parents(
67+
primary=True, as_objects=True, foreign_key_info=True)
6768
if not parents:
6869
raise DataJointError('A table must have dependencies '
6970
'from its primary key for auto-populate to work')
@@ -74,17 +75,19 @@ def _rename_attributes(table, props):
7475

7576
def make(self, key):
7677
"""
77-
Derived classes must implement method `make` that fetches data from tables that are
78-
above them in the dependency hierarchy, restricting by the given key, computes dependent
79-
attributes, and inserts the new tuples into self.
78+
Derived classes must implement method `make` that fetches data from tables
79+
above them in the dependency hierarchy, restricting by the given key,
80+
computes secondary attributes, and inserts the new tuples into self.
8081
"""
81-
raise NotImplementedError('Subclasses of AutoPopulate must implement the method `make`')
82+
raise NotImplementedError(
83+
'Subclasses of AutoPopulate must implement the method `make`')
8284

8385
@property
8486
def target(self):
8587
"""
8688
:return: table to be populated.
87-
In the typical case, dj.AutoPopulate is mixed into a dj.Table class by inheritance and the target is self.
89+
In the typical case, dj.AutoPopulate is mixed into a dj.Table class by
90+
inheritance and the target is self.
8891
"""
8992
return self
9093

@@ -111,11 +114,14 @@ def _jobs_to_do(self, restrictions):
111114

112115
if not isinstance(todo, QueryExpression):
113116
raise DataJointError('Invalid key_source value')
114-
# check if target lacks any attributes from the primary key of key_source
117+
115118
try:
119+
# check if target lacks any attributes from the primary key of key_source
116120
raise DataJointError(
117-
'The populate target lacks attribute %s from the primary key of key_source' % next(
118-
name for name in todo.heading.primary_key if name not in self.target.heading))
121+
'The populate target lacks attribute %s '
122+
'from the primary key of key_source' % next(
123+
name for name in todo.heading.primary_key
124+
if name not in self.target.heading))
119125
except StopIteration:
120126
pass
121127
return (todo & AndList(restrictions)).proj()
@@ -126,7 +132,8 @@ def populate(self, *restrictions, suppress_errors=False, return_exception_object
126132
"""
127133
table.populate() calls table.make(key) for every primary key in self.key_source
128134
for which there is not already a tuple in table.
129-
:param restrictions: a list of restrictions each restrict (table.key_source - target.proj())
135+
:param restrictions: a list of restrictions each restrict
136+
(table.key_source - target.proj())
130137
:param suppress_errors: if True, do not terminate execution.
131138
:param return_exception_objects: return error objects instead of just error messages
132139
:param reserve_jobs: if True, reserve jobs to populate in asynchronous fashion
@@ -259,5 +266,6 @@ def progress(self, *restrictions, display=True):
259266
print('%-20s' % self.__class__.__name__,
260267
'Completed %d of %d (%2.1f%%) %s' % (
261268
total - remaining, total, 100 - 100 * remaining / (total+1e-12),
262-
datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')), flush=True)
269+
datetime.datetime.strftime(datetime.datetime.now(),
270+
'%Y-%m-%d %H:%M:%S')), flush=True)
263271
return remaining, total

0 commit comments

Comments
 (0)