Skip to content

Commit 53e38f7

Browse files
Merge pull request #1245 from ttngu207/bugfix-three-part-make
fix: improve error handling when `make_fetch` referential integrity fails
2 parents 5f37f83 + 964743e commit 53e38f7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

datajoint/autopopulate.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def make(self, key):
105105
The method can be implemented either as:
106106
(a) Regular method: All three steps are performed in a single database transaction.
107107
The method must return None.
108-
(b) Generator method:
109-
The make method is split into three functions:
108+
(b) Generator method:
109+
The make method is split into three functions:
110110
- `make_fetch`: Fetches data from the parent tables.
111111
- `make_compute`: Computes secondary attributes based on the fetched data.
112112
- `make_insert`: Inserts the computed data into the current table.
@@ -124,7 +124,7 @@ def make(self, key):
124124
self.make_insert(key, *computed_result)
125125
commit_transaction
126126
<pseudocode>
127-
127+
128128
Importantly, the output of make_fetch is a tuple that serves as the input into `make_compute`.
129129
The output of `make_compute` is a tuple that serves as the input into `make_insert`.
130130
@@ -412,11 +412,10 @@ def _populate1(
412412
!= deepdiff.DeepHash(fetched_data, ignore_iterable_order=False)[
413413
fetched_data
414414
]
415-
): # rollback due to referential integrity fail
416-
self.connection.cancel_transaction()
417-
logger.warning(
418-
f"Referential integrity failed for {key} -> {self.target.full_table_name}")
419-
return False
415+
): # raise error if fetched data has changed
416+
raise DataJointError(
417+
"Referential integrity failed! The `make_fetch` data has changed"
418+
)
420419
gen.send(computed_result) # insert
421420

422421
except (KeyboardInterrupt, SystemExit, Exception) as error:

0 commit comments

Comments
 (0)