From e7c8943705b512bc04289c8e26398849be4c3fd9 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Fri, 13 Jun 2025 13:36:05 -0500 Subject: [PATCH 1/3] fix: improve error handling when `make_fetch` referential integrity fails --- datajoint/autopopulate.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/datajoint/autopopulate.py b/datajoint/autopopulate.py index d5cabe06..c8889104 100644 --- a/datajoint/autopopulate.py +++ b/datajoint/autopopulate.py @@ -412,11 +412,10 @@ def _populate1( != deepdiff.DeepHash(fetched_data, ignore_iterable_order=False)[ fetched_data ] - ): # rollback due to referential integrity fail - self.connection.cancel_transaction() - logger.warning( - f"Referential integrity failed for {key} -> {self.target.full_table_name}") - return False + ): # raise error if fetched data has changed + raise DataJointError( + "Referential integrity failed - the `make_fetch` data has changed." + ) gen.send(computed_result) # insert except (KeyboardInterrupt, SystemExit, Exception) as error: From e55bbcb6e935ec72e3cfe8c7f6e3cbd5e023c2f4 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Fri, 13 Jun 2025 13:38:33 -0500 Subject: [PATCH 2/3] style: black format --- datajoint/autopopulate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datajoint/autopopulate.py b/datajoint/autopopulate.py index c8889104..1b0e6c12 100644 --- a/datajoint/autopopulate.py +++ b/datajoint/autopopulate.py @@ -105,8 +105,8 @@ def make(self, key): The method can be implemented either as: (a) Regular method: All three steps are performed in a single database transaction. The method must return None. - (b) Generator method: - The make method is split into three functions: + (b) Generator method: + The make method is split into three functions: - `make_fetch`: Fetches data from the parent tables. - `make_compute`: Computes secondary attributes based on the fetched data. - `make_insert`: Inserts the computed data into the current table. @@ -124,7 +124,7 @@ def make(self, key): self.make_insert(key, *computed_result) commit_transaction - + Importantly, the output of make_fetch is a tuple that serves as the input into `make_compute`. The output of `make_compute` is a tuple that serves as the input into `make_insert`. From 964743efdb45f43bce9564cb625b7c890454daa6 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Fri, 13 Jun 2025 13:40:11 -0500 Subject: [PATCH 3/3] style: format --- datajoint/autopopulate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datajoint/autopopulate.py b/datajoint/autopopulate.py index 1b0e6c12..461972cf 100644 --- a/datajoint/autopopulate.py +++ b/datajoint/autopopulate.py @@ -414,7 +414,7 @@ def _populate1( ] ): # raise error if fetched data has changed raise DataJointError( - "Referential integrity failed - the `make_fetch` data has changed." + "Referential integrity failed! The `make_fetch` data has changed" ) gen.send(computed_result) # insert