Skip to content

Commit 84ba4b7

Browse files
committed
Remove AutoPopulate._job_key - no longer needed
1 parent 080b6c0 commit 84ba4b7

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/datajoint/autopopulate.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,6 @@ def jobs(self):
176176
self._jobs_table = JobsTable(self.target)
177177
return self._jobs_table
178178

179-
def _job_key(self, key):
180-
"""
181-
:param key: they key returned for the job from the key source
182-
:return: the dict to use to generate the job reservation hash
183-
This method allows subclasses to control the job reservation granularity.
184-
"""
185-
return key
186-
187179
def _jobs_to_do(self, restrictions):
188180
"""
189181
:return: the query yielding the keys to be computed (derived from self.key_source)
@@ -387,12 +379,11 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
387379

388380
# use the legacy `_make_tuples` callback.
389381
make = self._make_tuples if hasattr(self, "_make_tuples") else self.make
390-
job_key = self._job_key(key)
391382
start_time = time.time()
392383

393384
# Reserve the job (per-key, before make)
394385
if jobs is not None:
395-
jobs.reserve(job_key)
386+
jobs.reserve(key)
396387

397388
# if make is a generator, transaction can be delayed until the final stage
398389
is_generator = inspect.isgeneratorfunction(make)
@@ -404,7 +395,7 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
404395
self.connection.cancel_transaction()
405396
if jobs is not None:
406397
# Job already done - mark complete or delete
407-
jobs.complete(job_key, duration=0)
398+
jobs.complete(key, duration=0)
408399
return False
409400

410401
logger.debug(f"Making {key} -> {self.target.full_table_name}")
@@ -449,11 +440,11 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
449440
# This is not a real error, just coordination artifact
450441
logger.debug(f"Duplicate key collision for {key}, reverting job")
451442
# Delete the reservation, letting the job be picked up again or cleaned
452-
(jobs & job_key).delete_quick()
443+
(jobs & key).delete_quick()
453444
else:
454445
# Real error inside make() - log it
455446
jobs.error(
456-
job_key,
447+
key,
457448
error_message=error_message,
458449
error_stack=traceback.format_exc(),
459450
)
@@ -467,7 +458,7 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
467458
duration = time.time() - start_time
468459
logger.debug(f"Success making {key} -> {self.target.full_table_name}")
469460
if jobs is not None:
470-
jobs.complete(job_key, duration=duration)
461+
jobs.complete(key, duration=duration)
471462
return True
472463
finally:
473464
self.__class__._allow_insert = False

0 commit comments

Comments
 (0)