Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5a2f6b6
fix issue 151 - cascades to part tables should be from parent tables …
dimitri-yatsenko Sep 9, 2021
4a2e1af
Fix issue #374
dimitri-yatsenko Sep 10, 2021
bc12b11
use regex to identify part tables in utils.get_master
dimitri-yatsenko Sep 10, 2021
6d7d934
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko Sep 10, 2021
5929f95
resolve merge conflicts
dimitri-yatsenko Sep 10, 2021
d8d8936
add tests for issues #151 and #374
dimitri-yatsenko Sep 10, 2021
ce3e4ab
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko Sep 14, 2021
d1dd910
add type hinting in `utils.get_master`
dimitri-yatsenko Sep 14, 2021
9e13c21
Merge branch 'issue151' of https://github.com/dimitri-yatsenko/datajo…
dimitri-yatsenko Sep 14, 2021
bd16e0f
minor cleanup in tests
dimitri-yatsenko Sep 14, 2021
17d3bb4
switch from nosetest to pytest asserts in test_stepwise_delete
dimitri-yatsenko Sep 14, 2021
24ba679
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko Sep 14, 2021
f505335
add random seed to faker in tests.schema_simple to make tests determi…
dimitri-yatsenko Sep 14, 2021
07ab459
Merge branch 'master' of https://github.com/datajoint/datajoint-pytho…
dimitri-yatsenko Sep 15, 2021
58a294b
set RNG seed for faker in tests
dimitri-yatsenko Sep 15, 2021
67dda6c
docstring improvement in datajoint/table.py
dimitri-yatsenko Sep 15, 2021
a56d634
fix grammar in docstring
dimitri-yatsenko Sep 15, 2021
54d4e46
Apply suggestions from code review
dimitri-yatsenko Sep 15, 2021
33be384
Merge branch 'master' into issue151
dimitri-yatsenko Jan 19, 2022
f0d5530
Merge branch 'master' into issue151
dimitri-yatsenko Jan 19, 2022
71adede
Merge branch 'master' into issue151
dimitri-yatsenko Jan 19, 2022
e674d38
set random seed for faker tests
dimitri-yatsenko Jan 19, 2022
c14a07c
Merge branch 'master' into issue151
dimitri-yatsenko Jan 20, 2022
ad5cf90
style improvments
dimitri-yatsenko Jan 20, 2022
1cd5d7c
Merge branch 'mp'
dimitri-yatsenko Jan 20, 2022
bd5b35f
Merge branch 'master' into issue151
dimitri-yatsenko Jan 20, 2022
741f451
convert some nosetest asserts into python asserts in tests
dimitri-yatsenko Jan 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Add - implement multiprocessing in populate (#695) PR #704, #969
* Bugfix - Dependencies not properly loaded on populate. (#902) PR #919
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
* Bugfix - Deletes and drops must include the master of each part. (#151, #374) PR #957
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
* Bugfix - Fix regression issue with `DISTINCT` clause and `GROUP_BY` (#914) PR #963
Expand Down Expand Up @@ -134,7 +135,7 @@
* Fix #628 - incompatibility with pyparsing 2.4.1

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

### 0.11.0 -- Oct 25, 2018
Expand Down
30 changes: 19 additions & 11 deletions datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def _rename_attributes(table, props):
if props['aliased'] else table.proj())

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

def make(self, key):
"""
Derived classes must implement method `make` that fetches data from tables that are
above them in the dependency hierarchy, restricting by the given key, computes dependent
attributes, and inserts the new tuples into self.
Derived classes must implement method `make` that fetches data from tables
above them in the dependency hierarchy, restricting by the given key,
computes secondary attributes, and inserts the new tuples into self.
"""
raise NotImplementedError('Subclasses of AutoPopulate must implement the method `make`')
raise NotImplementedError(
'Subclasses of AutoPopulate must implement the method `make`')

@property
def target(self):
"""
:return: table to be populated.
In the typical case, dj.AutoPopulate is mixed into a dj.Table class by inheritance and the target is self.
In the typical case, dj.AutoPopulate is mixed into a dj.Table class by
inheritance and the target is self.
"""
return self

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

if not isinstance(todo, QueryExpression):
raise DataJointError('Invalid key_source value')
# check if target lacks any attributes from the primary key of key_source

try:
# check if target lacks any attributes from the primary key of key_source
raise DataJointError(
'The populate target lacks attribute %s from the primary key of key_source' % next(
name for name in todo.heading.primary_key if name not in self.target.heading))
'The populate target lacks attribute %s '
'from the primary key of key_source' % next(
name for name in todo.heading.primary_key
if name not in self.target.heading))
except StopIteration:
pass
return (todo & AndList(restrictions)).proj()
Expand All @@ -126,7 +132,8 @@ def populate(self, *restrictions, suppress_errors=False, return_exception_object
"""
table.populate() calls table.make(key) for every primary key in self.key_source
for which there is not already a tuple in table.
:param restrictions: a list of restrictions each restrict (table.key_source - target.proj())
:param restrictions: a list of restrictions each restrict
(table.key_source - target.proj())
:param suppress_errors: if True, do not terminate execution.
:param return_exception_objects: return error objects instead of just error messages
:param reserve_jobs: if True, reserve jobs to populate in asynchronous fashion
Expand Down Expand Up @@ -259,5 +266,6 @@ def progress(self, *restrictions, display=True):
print('%-20s' % self.__class__.__name__,
'Completed %d of %d (%2.1f%%) %s' % (
total - remaining, total, 100 - 100 * remaining / (total+1e-12),
datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')), flush=True)
datetime.datetime.strftime(datetime.datetime.now(),
'%Y-%m-%d %H:%M:%S')), flush=True)
return remaining, total
Loading