diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f3ce4cc5..01774e0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,6 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop() - Move cleanup of `IntervalList` orphan entries to cron job cleanup process #1195 - Add mixin method `get_fully_defined_key` #1198 - ### Pipelines - Common @@ -58,7 +57,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop() - Export fixes #1164 - Allow `get_abs_path` to add selection entry. #1164 - Log restrictions and joins. #1164 - - Check if querying table inherits mixin in `fetch_nwb`. #1192 + - Check if querying table inherits mixin in `fetch_nwb`. #1192, #1201 - Ensure externals entries before adding to export. #1192 - Error specificity in `LabMemberInfo` #1192 diff --git a/src/spyglass/utils/dj_helper_fn.py b/src/spyglass/utils/dj_helper_fn.py index de07de85b..890ac496e 100644 --- a/src/spyglass/utils/dj_helper_fn.py +++ b/src/spyglass/utils/dj_helper_fn.py @@ -280,6 +280,8 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs): nwb_objects : list List of dicts containing fetch results and NWB objects. """ + from spyglass.utils.dj_mixin import SpyglassMixin + kwargs["as_dict"] = True # force return as dictionary tbl, attr_name = nwb_master @@ -301,8 +303,16 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs): # This also opens the file and stores the file object get_nwb_file(file_path) + # logging arg only if instanced table inherits Mixin + inst = ( # instancing may not be necessary + query_expression() + if isinstance(query_expression, type) + and issubclass(query_expression, dj.Table) + else query_expression + ) + arg = dict(log_export=False) if isinstance(inst, SpyglassMixin) else dict() query_table = query_expression.join( - tbl.proj(nwb2load_filepath=attr_name), log_export=False + tbl.proj(nwb2load_filepath=attr_name), **arg ) rec_dicts = query_table.fetch(*attrs, **kwargs) # get filepath for each. Use datajoint for checksum if local