From 96263e05ffa2e4371b5fee97e0ccfa24867ac7d4 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 31 Jul 2025 09:28:22 -0700 Subject: [PATCH 1/3] Change default codec to JSON --- src/hdmf_zarr/backend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hdmf_zarr/backend.py b/src/hdmf_zarr/backend.py index d5911ac1..db7ac28b 100644 --- a/src/hdmf_zarr/backend.py +++ b/src/hdmf_zarr/backend.py @@ -97,7 +97,7 @@ def can_read(path): "type": None, "doc": ( "Set the numcodec object codec class to be used to encode objects." - "Use numcodecs.pickles.Pickle by default." + "Use numcodecs.json.JSON by default." ), "default": None, }, @@ -150,7 +150,7 @@ def __init__(self, **kwargs): self._written_builders = WriteStatusTracker() # track which builders were written (or read) by this IO object self.__dci_queue = None # Will be initialized on call to io.write # Codec class to be used. Alternates, e.g., =numcodecs.JSON - self.__codec_cls = numcodecs.pickles.Pickle if object_codec_class is None else object_codec_class + self.__codec_cls = numcodecs.json.JSON if object_codec_class is None else object_codec_class source_path = self.__path if isinstance(self.__path, SUPPORTED_ZARR_STORES): source_path = self.__path.path From 412553647dedcf7b6235d8630c49d15036266808 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 31 Jul 2025 09:38:13 -0700 Subject: [PATCH 2/3] Update test to check for new default JSON codec --- tests/unit/base_tests_zarrio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/base_tests_zarrio.py b/tests/unit/base_tests_zarrio.py index d69becce..23c5f934 100644 --- a/tests/unit/base_tests_zarrio.py +++ b/tests/unit/base_tests_zarrio.py @@ -18,7 +18,7 @@ # Try to import numcodecs and disable compression tests if it is not available try: - from numcodecs import Blosc, Delta, JSON + from numcodecs import Blosc, Delta, JSON, Pickle DISABLE_ZARR_COMPRESSION_TESTS = False except ImportError: @@ -517,12 +517,12 @@ def setUp(self): # ZarrDataIO general ############################################# def test_set_object_codec(self): - # Test that the default codec is the Pickle store + # Test that the default codec is the JSON store tempIO = ZarrIO(self.store_path, mode="w") - self.assertEqual(tempIO.object_codec_class.__qualname__, "Pickle") - del tempIO # also calls tempIO.close() - tempIO = ZarrIO(self.store_path, mode="w", object_codec_class=JSON) self.assertEqual(tempIO.object_codec_class.__qualname__, "JSON") + del tempIO # also calls tempIO.close() + tempIO = ZarrIO(self.store_path, mode="w", object_codec_class=Pickle) + self.assertEqual(tempIO.object_codec_class.__qualname__, "Pickle") tempIO.close() def test_synchronizer_constructor_arg_bool(self): From 35f977c3924f3c6a53d1e154cef5e59274a44164 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 31 Jul 2025 09:38:59 -0700 Subject: [PATCH 3/3] Fix ruff --- tests/unit/base_tests_zarrio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/base_tests_zarrio.py b/tests/unit/base_tests_zarrio.py index 23c5f934..2a41dbb7 100644 --- a/tests/unit/base_tests_zarrio.py +++ b/tests/unit/base_tests_zarrio.py @@ -18,7 +18,7 @@ # Try to import numcodecs and disable compression tests if it is not available try: - from numcodecs import Blosc, Delta, JSON, Pickle + from numcodecs import Blosc, Delta, Pickle DISABLE_ZARR_COMPRESSION_TESTS = False except ImportError: