From 349911232fef4cbdeeeb2cb79f6f155cebb5e33c Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Thu, 20 Nov 2025 11:22:21 -0800 Subject: [PATCH 1/3] always return path as str --- src/spyglass/utils/mixins/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spyglass/utils/mixins/analysis.py b/src/spyglass/utils/mixins/analysis.py index 427652e86..0ad42e5cb 100644 --- a/src/spyglass/utils/mixins/analysis.py +++ b/src/spyglass/utils/mixins/analysis.py @@ -489,7 +489,7 @@ def get_abs_path( cls()._ext_tbl & f"filepath LIKE '%{analysis_nwb_file_name}'" ) if len(query) == 1: # Else try the standard way - return Path(cls()._analysis_dir) / query.fetch1("filepath") + return str(Path(cls()._analysis_dir) / query.fetch1("filepath")) cls()._logger.warning( f"Found {len(query)} files for: {analysis_nwb_file_name}" ) From a38fd3b86ba62e9d243bc4b9421f80b2f2a854a2 Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Thu, 20 Nov 2025 11:24:07 -0800 Subject: [PATCH 2/3] skip redundant fetch of nwb2load_filepath --- src/spyglass/utils/dj_helper_fn.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/spyglass/utils/dj_helper_fn.py b/src/spyglass/utils/dj_helper_fn.py index 5c86fac7d..d0e9e528f 100644 --- a/src/spyglass/utils/dj_helper_fn.py +++ b/src/spyglass/utils/dj_helper_fn.py @@ -360,10 +360,6 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs): tbl.proj(nwb2load_filepath=attr_name), **arg ) - # Fix for custom analysis tables #1435 - if attrs and "nwb2load_filepath" not in attrs: - attrs = list(attrs) + ["nwb2load_filepath"] - rec_dicts = query_table.fetch(*attrs, **kwargs) # get filepath for each. Use datajoint for checksum if local for rec_dict in rec_dicts: From bef39fded43ab271eb2237d381a9cd0de1c49e93 Mon Sep 17 00:00:00 2001 From: samuelbray32 Date: Thu, 20 Nov 2025 11:28:06 -0800 Subject: [PATCH 3/3] fix raw dandi file fetch --- src/spyglass/utils/nwb_helper_fn.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/spyglass/utils/nwb_helper_fn.py b/src/spyglass/utils/nwb_helper_fn.py index 93dc7375b..6f9cc49bd 100644 --- a/src/spyglass/utils/nwb_helper_fn.py +++ b/src/spyglass/utils/nwb_helper_fn.py @@ -30,8 +30,16 @@ def _open_nwb_file(nwb_file_path, source="local"): elif source == "dandi": from ..common.common_dandi import DandiPath + if DandiPath().has_file_path(nwb_file_path): + path_to_load = nwb_file_path + elif DandiPath().has_raw_path(nwb_file_path): + path_to_load = DandiPath().raw_from_path(nwb_file_path)["filename"] + else: + raise ValueError( + f"File not found in Dandi: {Path(nwb_file_path).name}" + ) io, nwbfile = DandiPath().fetch_file_from_dandi( - nwb_file_path=nwb_file_path + nwb_file_path=path_to_load ) else: raise ValueError(f"Invalid open_nwb source: {source}") @@ -99,13 +107,11 @@ def get_nwb_file(nwb_file_path, query_expression=None): # Dandi fallback SB 2024-04-03 from ..common.common_dandi import DandiPath - if DandiPath().has_file_path(file_path=nwb_file_path): + if DandiPath().has_file_path( + file_path=nwb_file_path + ) or DandiPath().has_raw_path(file_path=nwb_file_path): return _open_nwb_file(nwb_file_path, source="dandi") - if DandiPath().has_raw_path(file_path=nwb_file_path): - raw = DandiPath().raw_from_path(file_path=nwb_file_path)["filename"] - return _open_nwb_file(raw, source="dandi") - if hasattr(query_expression, "_make_file"): # if the query_expression has a _make_file method, call it to # recompute the file