Skip to content

Commit 269c4af

Browse files
committed
chore: code cleanup
1 parent 9d3a9e4 commit 269c4af

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

datajoint/autopopulate.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -601,20 +601,15 @@ def cleanup_jobs(self):
601601
602602
This cleanup should not need to run very often, but helps maintain database consistency.
603603
"""
604-
invalid_removed = 0
605-
606-
incomplete_query = (
607-
self.jobs & {"table_name": self.target.table_name} & "status != 'success'"
608-
)
609-
if incomplete_query:
604+
removed = 0
605+
if len(self.jobs):
610606
keys2do = self._jobs_to_do({}).fetch("KEY")
611-
invalid_incomplete = len(incomplete_query) - len(keys2do)
612-
if invalid_incomplete > 0:
613-
for key, job_key in zip(*incomplete_query.fetch("KEY", "key")):
607+
if len(self.jobs) - len(keys2do) > 0:
608+
for key, job_key in zip(*self.jobs.fetch("KEY", "key")):
614609
if job_key not in keys2do:
615610
(self.jobs & key).delete()
616-
invalid_removed += 1
611+
removed += 1
617612

618613
logger.info(
619-
f"{invalid_removed} invalid jobs removed for `{to_camel_case(self.target.table_name)}`"
614+
f"{removed} invalid jobs removed for `{to_camel_case(self.target.table_name)}`"
620615
)

0 commit comments

Comments
 (0)