From 77cea32e7130045bf4995274ff1846314de14b43 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 9 Apr 2026 17:03:34 -0600 Subject: [PATCH 1/3] Fix windows path issue --- dandi/organize.py | 3 ++- dandi/tests/test_organize.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dandi/organize.py b/dandi/organize.py index 4f67ac20b..70771d6cb 100644 --- a/dandi/organize.py +++ b/dandi/organize.py @@ -18,6 +18,7 @@ from enum import Enum import os import os.path as op +import posixpath from pathlib import Path, PurePosixPath import re import traceback @@ -275,7 +276,7 @@ def _create_external_file_names(metadata: list[dict]) -> list[dict]: renamed_path_list = [] uuid_str = ext_file_dict.get("id", str(uuid.uuid4())) for no, ext_file in enumerate(ext_file_dict["external_files"]): - renamed = op.join( + renamed = posixpath.join( nwb_folder_name, f"{uuid_str}_external_file_{no}{ext_file.suffix}" ) renamed_path_list.append(renamed) diff --git a/dandi/tests/test_organize.py b/dandi/tests/test_organize.py index 6015ad57d..c75d54ff1 100644 --- a/dandi/tests/test_organize.py +++ b/dandi/tests/test_organize.py @@ -353,6 +353,10 @@ def test_video_organize( for ext_file_ob in ext_file_objects: for no, name in enumerate(ext_file_ob["external_files"]): video_files_organized.append(name) + # Regression: external_file paths are DANDI/S3 keys, + # must use forward slashes even on Windows. + # See https://github.com/catalystneuro/nwb-video-widgets/issues/33 + assert "\\" not in str(name) # check if external_file arguments are correctly named according to convention: filename = Path( f"{vid_folder.name}/{ext_file_ob['id']}_external_file_{no}" From 4cc311b2d7a1916a9e4642e73c83218815ecc4bc Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 9 Apr 2026 17:22:27 -0600 Subject: [PATCH 2/3] fix tests --- dandi/pynwb_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dandi/pynwb_utils.py b/dandi/pynwb_utils.py index c496d2a55..dc21a1109 100644 --- a/dandi/pynwb_utils.py +++ b/dandi/pynwb_utils.py @@ -17,7 +17,7 @@ import inspect import os import os.path as op -from pathlib import Path +from pathlib import Path, PurePosixPath import re from typing import IO, Any, TypeVar, cast import warnings @@ -408,8 +408,8 @@ def _get_image_series(nwb: pynwb.NWBFile) -> list[dict]: if isinstance(ob, pynwb.image.ImageSeries) and ob.external_file is not None: out_dict = dict(id=ob.object_id, name=ob.name, external_files=[]) for ext_file in ob.external_file: - if Path(ext_file).suffix in VIDEO_FILE_EXTENSIONS: - out_dict["external_files"].append(Path(ext_file)) + if PurePosixPath(ext_file).suffix in VIDEO_FILE_EXTENSIONS: + out_dict["external_files"].append(PurePosixPath(ext_file)) else: lgr.warning( "external file %s should be one of: %s", From b885ad6479f696ebbb50c710d06380ee9a66c131 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 9 Apr 2026 23:44:51 -0600 Subject: [PATCH 3/3] use walrus operation --- dandi/pynwb_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dandi/pynwb_utils.py b/dandi/pynwb_utils.py index dc21a1109..2b21335ea 100644 --- a/dandi/pynwb_utils.py +++ b/dandi/pynwb_utils.py @@ -408,8 +408,8 @@ def _get_image_series(nwb: pynwb.NWBFile) -> list[dict]: if isinstance(ob, pynwb.image.ImageSeries) and ob.external_file is not None: out_dict = dict(id=ob.object_id, name=ob.name, external_files=[]) for ext_file in ob.external_file: - if PurePosixPath(ext_file).suffix in VIDEO_FILE_EXTENSIONS: - out_dict["external_files"].append(PurePosixPath(ext_file)) + if (path := PurePosixPath(ext_file)).suffix in VIDEO_FILE_EXTENSIONS: + out_dict["external_files"].append(path) else: lgr.warning( "external file %s should be one of: %s",