Skip to content

Commit

Permalink
Chec to_dict/load and improve warning msg
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Jan 31, 2024
1 parent d7dedb5 commit 8ef06a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/spikeinterface/extractors/nwbextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ def __init__(

if storage_options is not None and stream_mode == "zarr":
warnings.warn(
"The `storage_options` parameter will not be propagated to the `kwargs` for security reasons. "
"The extractor will not be serializable."
"The `storage_options` parameter will not be propagated to JSON or pickle files for security reasons, "
"so the extractor will not be JSON/pickle serializable. Only in-memory mode will be available."
)
# not serializable if storage_options is provided
self._serializability["json"] = False
Expand All @@ -622,6 +622,7 @@ def __init__(
"samples_for_rate_estimation": samples_for_rate_estimation,
"stream_mode": stream_mode,
"load_channel_properties": load_channel_properties,
"storage_options": storage_options,
"cache": cache,
"stream_cache_path": stream_cache_path,
"file": file,
Expand Down Expand Up @@ -1039,8 +1040,8 @@ def __init__(

if storage_options is not None and stream_mode == "zarr":
warnings.warn(
"The `storage_options` parameter will not be propagated to the `kwargs` for security reasons. "
"The extractor will not be serializable."
"The `storage_options` parameter will not be propagated to JSON or pickle files for security reasons, "
"so the extractor will not be JSON/pickle serializable. Only in-memory mode will be available."
)
# not serializable if storage_options is provided
self._serializability["json"] = False
Expand All @@ -1054,6 +1055,7 @@ def __init__(
"cache": cache,
"stream_mode": stream_mode,
"stream_cache_path": stream_cache_path,
"storage_options": storage_options,
"load_unit_properties": load_unit_properties,
"t_start": self.t_start,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from pathlib import Path
import pickle
from tabnanny import check

import pytest
import numpy as np
import h5py
from spikeinterface.core.testing import check_recordings_equal

from spikeinterface import load_extractor
from spikeinterface.core.testing import check_recordings_equal
from spikeinterface.core.testing import check_recordings_equal, check_sortings_equal
from spikeinterface.extractors import NwbRecordingExtractor, NwbSortingExtractor

Expand Down Expand Up @@ -288,6 +290,10 @@ def test_sorting_s3_nwb_zarr(tmp_path):
assert not sorting.check_serializability("json")
assert not sorting.check_serializability("pickle")

# test to/from dict
sorting_loaded = load_extractor(sorting.to_dict())
check_sortings_equal(sorting, sorting_loaded)


if __name__ == "__main__":
tmp_path = Path("tmp")
Expand Down

0 comments on commit 8ef06a9

Please sign in to comment.