Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'zarr.storage' has no attribute 'DirectoryStore' #8298

Open
KumoLiu opened this issue Jan 14, 2025 · 5 comments · Fixed by #8299 or #8313 · May be fixed by #8319
Open

AttributeError: module 'zarr.storage' has no attribute 'DirectoryStore' #8298

KumoLiu opened this issue Jan 14, 2025 · 5 comments · Fixed by #8299 or #8313 · May be fixed by #8319
Labels
bug Something isn't working

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Jan 14, 2025

Traceback (most recent call last):
  File "/home/runner/work/MONAI/MONAI/tests/runner.py", line 135, in <module>
    tests = unittest.TestLoader().loadTestsFromNames(cases)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/unittest/loader.py", line 232, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/unittest/loader.py", line 232, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/unittest/loader.py", line 162, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 157, in <module>
    dict(merged_shape=TENSOR_4x4.shape, store=zarr.storage.DirectoryStore("test.zarr")),
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'DirectoryStore'
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Jan 14, 2025

May related to the new release: https://pypi.org/project/zarr/3.0.0/

zarr-developers/zarr-python#2699

@KumoLiu KumoLiu added the bug Something isn't working label Jan 14, 2025
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Jan 14, 2025
Signed-off-by: YunLiu <[email protected]>
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Jan 14, 2025
Signed-off-by: YunLiu <[email protected]>
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Jan 20, 2025

More deprecated usage found here: https://github.com/Project-MONAI/MONAI/actions/runs/12862267071/job/35856920175

Error Logs

======================================================================
ERROR: test_zarr_avg_merger_finalized_error (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_finalized_error)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 314, in test_zarr_avg_merger_finalized_error
    merger = ZarrAvgMerger(merged_shape=(1, 3, 2, 3))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_00 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_00)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_01 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_01)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_02 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_02)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_03 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_03)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_04 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_04)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_05 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_05)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_06 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_06)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_07 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_07)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_08 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_08)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_09 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_09)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_10 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_10)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_11 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_11)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 255, in __init__
    self.output = zarr.empty(
                  ^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/synchronous.py", line 918, in empty
    return Array(sync(async_api.empty(shape, **kwargs)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/sync.py", line 142, in sync
    raise return_result
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/sync.py", line 98, in _runner
    return await coro
           ^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/asynchronous.py", line 1084, in empty
    return await create(shape=shape, fill_value=None, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/asynchronous.py", line 1044, in create
    return await AsyncArray._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/array.py", line 603, in _create
    raise ValueError(
ValueError: compressor cannot be used for arrays with zarr_format 3. Use bytes-to-bytes codecs instead.

======================================================================
ERROR: test_zarr_avg_merger_patches_12 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_12)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_13 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_13)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 292, in test_zarr_avg_merger_patches
    arguments["compressor"] = zarr.codec_registry[arguments["compressor"].lower()]()
                              ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr' has no attribute 'codec_registry'

======================================================================
ERROR: test_zarr_avg_merger_patches_14 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_14)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 292, in test_zarr_avg_merger_patches
    arguments["compressor"] = zarr.codec_registry[arguments["compressor"].lower()]()
                              ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr' has no attribute 'codec_registry'

======================================================================
ERROR: test_zarr_avg_merger_patches_15 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_15)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 292, in test_zarr_avg_merger_patches
    arguments["compressor"] = zarr.codec_registry[arguments["compressor"].lower()]()
                              ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr' has no attribute 'codec_registry'

======================================================================
ERROR: test_zarr_avg_merger_patches_16 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_16)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

======================================================================
ERROR: test_zarr_avg_merger_patches_17 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_17)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 299, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 249, in __init__
    self.value_store = zarr.storage.TempStore() if value_store is None else value_store
                       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'TempStore'

----------------------------------------------------------------------

@KumoLiu KumoLiu reopened this Jan 20, 2025
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Jan 24, 2025
Signed-off-by: YunLiu <[email protected]>
garciadias pushed a commit to garciadias/MONAI that referenced this issue Jan 27, 2025
Fixes Project-MONAI#8298

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>
@KumoLiu KumoLiu reopened this Jan 27, 2025
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Jan 27, 2025

Hi @ericspod and @virginiafdez, please help take a look at this issue.

There are still several places have deprecated usage. For details, please see: https://github.com/Project-MONAI/MONAI/actions/runs/12952100697/job/36128672442

Thanks!

@ericspod
Copy link
Member

There are 3 errors all saying the same thing:

======================================================================
ERROR: test_zarr_avg_merger_patches_13 (tests.test_zarr_avg_merger.ZarrAvgMergerTests.test_zarr_avg_merger_patches_13)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/test_zarr_avg_merger.py", line 300, in test_zarr_avg_merger_patches
    merger = ZarrAvgMerger(**arguments)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/utils/module.py", line 477, in _wrapper
    return call_obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/inferers/merger.py", line 270, in __init__
    self.output = zarr.empty(
                  ^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/synchronous.py", line 918, in empty
    return Array(sync(async_api.empty(shape, **kwargs)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/sync.py", line 142, in sync
    raise return_result
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/sync.py", line 98, in _runner
    return await coro
           ^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/asynchronous.py", line 1084, in empty
    return await create(shape=shape, fill_value=None, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/api/asynchronous.py", line 1044, in create
    return await AsyncArray._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/zarr/core/array.py", line 603, in _create
    raise ValueError(
ValueError: compressor cannot be used for arrays with zarr_format 3. Use bytes-to-bytes codecs instead.

@ericspod
Copy link
Member

The underlying cause is that the compressor argument doesn't work for Zarr version 3 and instead codecs should be used. If we wanted to use codecs we'd have to work out what would be worth testing. Honestly, since these arguments are just being passed to zarr calls, I don't think we really need to test them. I can do a quick PR to remove these tests or only run them if zarr<3 is used.

@ericspod ericspod linked a pull request Jan 29, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants