Skip to content

Commit 36bd132

Browse files
authored
fetch_nwb non-mixin compatability (#1201)
* check if mixin clas in fetch_nwb * update changelog
1 parent 11f7cfc commit 36bd132

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop()
4747
- Move cleanup of `IntervalList` orphan entries to cron job cleanup process #1195
4848
- Add mixin method `get_fully_defined_key` #1198
4949

50-
5150
### Pipelines
5251

5352
- Common
@@ -58,7 +57,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop()
5857
- Export fixes #1164
5958
- Allow `get_abs_path` to add selection entry. #1164
6059
- Log restrictions and joins. #1164
61-
- Check if querying table inherits mixin in `fetch_nwb`. #1192
60+
- Check if querying table inherits mixin in `fetch_nwb`. #1192, #1201
6261
- Ensure externals entries before adding to export. #1192
6362
- Error specificity in `LabMemberInfo` #1192
6463

src/spyglass/utils/dj_helper_fn.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs):
280280
nwb_objects : list
281281
List of dicts containing fetch results and NWB objects.
282282
"""
283+
from spyglass.utils.dj_mixin import SpyglassMixin
284+
283285
kwargs["as_dict"] = True # force return as dictionary
284286

285287
tbl, attr_name = nwb_master
@@ -301,8 +303,16 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs):
301303
# This also opens the file and stores the file object
302304
get_nwb_file(file_path)
303305

306+
# logging arg only if instanced table inherits Mixin
307+
inst = ( # instancing may not be necessary
308+
query_expression()
309+
if isinstance(query_expression, type)
310+
and issubclass(query_expression, dj.Table)
311+
else query_expression
312+
)
313+
arg = dict(log_export=False) if isinstance(inst, SpyglassMixin) else dict()
304314
query_table = query_expression.join(
305-
tbl.proj(nwb2load_filepath=attr_name), log_export=False
315+
tbl.proj(nwb2load_filepath=attr_name), **arg
306316
)
307317
rec_dicts = query_table.fetch(*attrs, **kwargs)
308318
# get filepath for each. Use datajoint for checksum if local

0 commit comments

Comments
 (0)