Skip to content

Commit 214891c

Browse files
authored
Merge pull request #1107 from ttngu207/exclude_reserved_jobs
exclude "reserved" jobs in `Autopopulate.populate`
2 parents b63900b + 4680325 commit 214891c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Fixed - Updated set_password to work on MySQL 8 - PR [#1106](https://github.com/datajoint/datajoint-python/pull/1106)
99
- Added - Missing tests for set_password - PR [#1106](https://github.com/datajoint/datajoint-python/pull/1106)
1010
- Changed - Returning success count after the .populate() call - PR [#1050](https://github.com/datajoint/datajoint-python/pull/1050)
11+
- Fixed - `Autopopulate.populate` excludes `reserved` jobs in addition to `ignore` and `error` jobs
1112

1213
### 0.14.1 -- Jun 02, 2023
1314
- Fixed - Fix altering a part table that uses the "master" keyword - PR [#991](https://github.com/datajoint/datajoint-python/pull/991)

datajoint/autopopulate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ def handler(signum, frame):
207207

208208
keys = (self._jobs_to_do(restrictions) - self.target).fetch("KEY", limit=limit)
209209

210-
# exclude "error" or "ignore" jobs
210+
# exclude "error", "ignore" or "reserved" jobs
211211
if reserve_jobs:
212212
exclude_key_hashes = (
213213
jobs
214214
& {"table_name": self.target.table_name}
215-
& 'status in ("error", "ignore")'
215+
& 'status in ("error", "ignore", "reserved")'
216216
).fetch("key_hash")
217217
keys = [key for key in keys if key_hash(key) not in exclude_key_hashes]
218218

tests_old/test_autopopulate.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,19 @@ def test_populate_exclude_error_and_ignore_jobs(self):
7575
assert_true(self.subject, "root tables are empty")
7676
assert_false(self.experiment, "table already filled?")
7777

78-
keys = self.experiment.key_source.fetch("KEY", limit=2)
78+
keys = self.experiment.key_source.fetch("KEY", limit=3)
7979
for idx, key in enumerate(keys):
8080
if idx == 0:
8181
schema.schema.jobs.ignore(self.experiment.table_name, key)
82-
else:
82+
elif idx == 1:
8383
schema.schema.jobs.error(self.experiment.table_name, key, "")
84+
else:
85+
schema.schema.jobs.reserve(self.experiment.table_name, key)
8486

8587
self.experiment.populate(reserve_jobs=True)
8688
assert_equal(
8789
len(self.experiment.key_source & self.experiment),
88-
len(self.experiment.key_source) - 2,
90+
len(self.experiment.key_source) - 3,
8991
)
9092

9193
def test_allow_direct_insert(self):

0 commit comments

Comments
 (0)