From 18f8754719878e0b48d9d10fa1ea5c6d749ada9c Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Thu, 19 Feb 2026 09:48:45 -0800 Subject: [PATCH 1/3] apply updates to unrestricted external --- src/spyglass/utils/dj_helper_fn.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/spyglass/utils/dj_helper_fn.py b/src/spyglass/utils/dj_helper_fn.py index 6a824c115..7586dcd4e 100644 --- a/src/spyglass/utils/dj_helper_fn.py +++ b/src/spyglass/utils/dj_helper_fn.py @@ -14,7 +14,6 @@ import numpy as np from datajoint.table import Table from datajoint.user_tables import TableMeta, UserTable - from spyglass.utils.logging import logger from spyglass.utils.nwb_helper_fn import file_from_dandi, get_nwb_file @@ -105,9 +104,9 @@ def declare_all_merge_tables() -> Tuple[Type[dj.Table]]: from spyglass.decoding.decoding_merge import DecodingOutput # noqa: F401 from spyglass.lfp.lfp_merge import LFPOutput # noqa: F401 from spyglass.position.position_merge import PositionOutput # noqa: F401 - from spyglass.spikesorting.spikesorting_merge import ( # noqa: F401 + from spyglass.spikesorting.spikesorting_merge import ( SpikeSortingOutput, - ) + ) # noqa: F401 return DecodingOutput, LFPOutput, PositionOutput, SpikeSortingOutput @@ -492,6 +491,7 @@ def _resolve_external_table( file_restr = f"filepath LIKE '%{file_name}'" to_updates = [] + table_to_update = [] if location == "analysis": # Update for each custom Analysis external for external in AnalysisRegistry().get_externals(): restr_external = external & file_restr @@ -503,10 +503,12 @@ def _resolve_external_table( + f"{file_name}, cannot resolve." ) to_updates.append(restr_external) + table_to_update.append(external) elif location == "raw": restr_external = common_schema.external["raw"] & file_restr to_updates.append(restr_external) + table_to_update.append(common_schema.external["raw"]) if not to_updates: logger.warning( @@ -518,10 +520,10 @@ def _resolve_external_table( size=Path(filepath).stat().st_size, contents_hash=dj.hash.uuid_from_file(filepath), ) - for to_update in to_updates: + for to_update, table in zip(to_updates, table_to_update): key = to_update.fetch1() key.update(update_vals) - to_update.update1(key) + table.update1(key) def make_file_obj_id_unique(nwb_path: str): From 582cc7f4ec6684327e45652f0304d7eace93e690 Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Thu, 19 Feb 2026 09:52:43 -0800 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64242f2c4..4ff6d41dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -139,6 +139,7 @@ for label, interval_data in results.groupby("interval_labels"): - Upgrade to pynwb>=3.1 #1506 - Remove imports of ndx extensions in main package to prevent errors in nwb io #1506 - Add `analysis_table` property to mixin for custom pipelines #1525 +- Fix update bug in `_resolve_external_tables` #1536 ### Pipelines From 25154cf9277a64d9c19c0593d1e383d28eabcb6f Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Wed, 25 Feb 2026 10:54:23 -0800 Subject: [PATCH 3/3] review suggestions --- src/spyglass/utils/dj_helper_fn.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/spyglass/utils/dj_helper_fn.py b/src/spyglass/utils/dj_helper_fn.py index 7586dcd4e..f39f60f84 100644 --- a/src/spyglass/utils/dj_helper_fn.py +++ b/src/spyglass/utils/dj_helper_fn.py @@ -491,7 +491,7 @@ def _resolve_external_table( file_restr = f"filepath LIKE '%{file_name}'" to_updates = [] - table_to_update = [] + tables_to_update = [] if location == "analysis": # Update for each custom Analysis external for external in AnalysisRegistry().get_externals(): restr_external = external & file_restr @@ -503,12 +503,22 @@ def _resolve_external_table( + f"{file_name}, cannot resolve." ) to_updates.append(restr_external) - table_to_update.append(external) + tables_to_update.append(external) elif location == "raw": restr_external = common_schema.external["raw"] & file_restr + if not bool(restr_external): + logger.warning( + f"No entries found in common_schema.external['raw'] for file: {file_name}" + ) + return + if len(restr_external) > 1: + raise ValueError( + "Multiple entries found in common_schema.external['raw'] for file: " + + f"{file_name}, cannot resolve." + ) to_updates.append(restr_external) - table_to_update.append(common_schema.external["raw"]) + tables_to_update.append(common_schema.external["raw"]) if not to_updates: logger.warning( @@ -520,7 +530,7 @@ def _resolve_external_table( size=Path(filepath).stat().st_size, contents_hash=dj.hash.uuid_from_file(filepath), ) - for to_update, table in zip(to_updates, table_to_update): + for to_update, table in zip(to_updates, tables_to_update): key = to_update.fetch1() key.update(update_vals) table.update1(key)