diff --git a/src/spikeinterface/core/core_tools.py b/src/spikeinterface/core/core_tools.py index b5ee518208..db4e94b70c 100644 --- a/src/spikeinterface/core/core_tools.py +++ b/src/spikeinterface/core/core_tools.py @@ -777,7 +777,8 @@ def is_path_remote(path: str | Path) -> bool: is_remote: bool Whether the path is a remote path. """ - return "s3://" in str(path) or "gcs://" in str(path) + remote_schemes = ("s3://", "gcs://", "http://", "https://") + return any(scheme in str(path) for scheme in remote_schemes) def ms_to_samples(ms: float, sampling_frequency: float) -> int: diff --git a/src/spikeinterface/sorters/container_tools.py b/src/spikeinterface/sorters/container_tools.py index b08cd8d60e..a75ca57be7 100644 --- a/src/spikeinterface/sorters/container_tools.py +++ b/src/spikeinterface/sorters/container_tools.py @@ -8,14 +8,19 @@ # TODO move this inside functions -from spikeinterface.core.core_tools import recursive_path_modifier, _get_paths_list +from spikeinterface.core.core_tools import recursive_path_modifier, _get_paths_list, is_path_remote def find_recording_folders(d): """Finds all recording folders 'paths' in a dict""" path_list = _get_paths_list(d=d) - folders_to_mount = [Path(p).resolve().parent for p in path_list] + # Remote paths (URLs) are read over the network from inside the container, so there is nothing + # to mount for them. + local_path_list = [p for p in path_list if not is_path_remote(p)] + folders_to_mount = [Path(p).resolve().parent for p in local_path_list] + if len(folders_to_mount) == 0: + return [] try: # this will fail if on different drives (Windows) base_folders_to_mount = [Path(os.path.commonpath(folders_to_mount))] diff --git a/src/spikeinterface/sorters/tests/test_container_tools.py b/src/spikeinterface/sorters/tests/test_container_tools.py index 606fe9940e..2f3b176cc5 100644 --- a/src/spikeinterface/sorters/tests/test_container_tools.py +++ b/src/spikeinterface/sorters/tests/test_container_tools.py @@ -64,6 +64,12 @@ def test_find_recording_folders(setup_module): assert len(f3) == 3 +def test_find_recording_folders_skips_remote_paths(tmp_path): + """A remote path is read from inside the container, so it is not mounted (GH-2370).""" + recording_dict = {"kwargs": {"file_paths": [str(tmp_path / "recording.bin"), "s3://bucket/recording.zarr"]}} + assert find_recording_folders(recording_dict) == [tmp_path.resolve()] + + @pytest.mark.skipif(ON_GITHUB, reason="Docker tests don't run on github: test locally") def test_ContainerClient(): mode = "docker"