Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key populate #989

Merged
merged 9 commits into from
Sep 12, 2024
11 changes: 9 additions & 2 deletions datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def _initialize_populate(table, jobs, populate_kwargs):
"""
Initialize the process for mulitprocessing.
Initialize the process for multiprocessing.
Saves the unpickled copy of the table to the current process and reconnects.
"""
process = mp.current_process()
Expand Down Expand Up @@ -153,6 +153,7 @@ def _jobs_to_do(self, restrictions):
def populate(
self,
*restrictions,
keys=None,
suppress_errors=False,
return_exception_objects=False,
reserve_jobs=False,
Expand All @@ -169,6 +170,8 @@ def populate(

:param restrictions: a list of restrictions each restrict
(table.key_source - target.proj())
:param keys: The list of keys (dicts) to send to self.make().
If None (default), then use self.key_source to query they keys.
: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 @@ -206,7 +209,10 @@ def handler(signum, frame):

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

keys = (self._jobs_to_do(restrictions) - self.target).fetch("KEY", limit=limit)
if keys is None:
keys = (self._jobs_to_do(restrictions) - self.target).fetch(
"KEY", limit=limit
)

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

if jobs is not None and not jobs.reserve(
Expand Down
2 changes: 2 additions & 0 deletions datajoint/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ def cascade(table):
logger.warn("Nothing to delete.")
if transaction:
self.connection.cancel_transaction()
elif not transaction:
logger.info("Delete completed")
else:
if not safemode or user_choice("Commit deletes?", default="no") == "yes":
if transaction:
Expand Down
Loading