Skip to content

Commit

Permalink
fetch_nwb non-mixin compatability (#1201)
Browse files Browse the repository at this point in the history
* check if mixin clas in fetch_nwb

* update changelog
  • Loading branch information
samuelbray32 authored Dec 19, 2024
1 parent 11f7cfc commit 36bd132
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
12 changes: 11 additions & 1 deletion src/spyglass/utils/dj_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 36bd132

Please sign in to comment.