Skip to content

Commit e14544d

Browse files
authored
Merge pull request #989 from dimitri-yatsenko/key_populate
Key populate
2 parents b9d8488 + b85c959 commit e14544d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

datajoint/autopopulate.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def _initialize_populate(table, jobs, populate_kwargs):
2525
"""
26-
Initialize the process for mulitprocessing.
26+
Initialize the process for multiprocessing.
2727
Saves the unpickled copy of the table to the current process and reconnects.
2828
"""
2929
process = mp.current_process()
@@ -153,6 +153,7 @@ def _jobs_to_do(self, restrictions):
153153
def populate(
154154
self,
155155
*restrictions,
156+
keys=None,
156157
suppress_errors=False,
157158
return_exception_objects=False,
158159
reserve_jobs=False,
@@ -169,6 +170,8 @@ def populate(
169170
170171
:param restrictions: a list of restrictions each restrict
171172
(table.key_source - target.proj())
173+
:param keys: The list of keys (dicts) to send to self.make().
174+
If None (default), then use self.key_source to query they keys.
172175
:param suppress_errors: if True, do not terminate execution.
173176
:param return_exception_objects: return error objects instead of just error messages
174177
:param reserve_jobs: if True, reserve jobs to populate in asynchronous fashion
@@ -206,7 +209,10 @@ def handler(signum, frame):
206209

207210
old_handler = signal.signal(signal.SIGTERM, handler)
208211

209-
keys = (self._jobs_to_do(restrictions) - self.target).fetch("KEY", limit=limit)
212+
if keys is None:
213+
keys = (self._jobs_to_do(restrictions) - self.target).fetch(
214+
"KEY", limit=limit
215+
)
210216

211217
# exclude "error", "ignore" or "reserved" jobs
212218
if reserve_jobs:
@@ -295,6 +301,7 @@ def _populate1(
295301
:return: (key, error) when suppress_errors=True,
296302
True if successfully invoke one `make()` call, otherwise False
297303
"""
304+
# use the legacy `_make_tuples` callback.
298305
make = self._make_tuples if hasattr(self, "_make_tuples") else self.make
299306

300307
if jobs is not None and not jobs.reserve(

datajoint/table.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ def cascade(table):
644644
logger.warn("Nothing to delete.")
645645
if transaction:
646646
self.connection.cancel_transaction()
647+
elif not transaction:
648+
logger.info("Delete completed")
647649
else:
648650
if not safemode or user_choice("Commit deletes?", default="no") == "yes":
649651
if transaction:

0 commit comments

Comments
 (0)