Skip to content

Possible Regression: 'Float32' object has no attribute 'value' raised when using zarr>3.0.10. #3396

@jbusecke

Description

@jbusecke

Zarr version

main@94983362f06f9bb4be3f04562b179549e36a87c4

Numcodecs version

0.16.2

Python Version

3.12.9

Operating System

Mac

Installation

uv

Description

I was trying to test #3369 for a project using titiler-multidim together with @maxrjones earlier, and ran into this issue.

I wrote out a native zarr v3 dataset (I believe it was using v3.0.8) on the NASA veda hub and downloaded it locally for testing. When I am trying to read that in with the newest version or the main branch I get the following error:

Traceback (most recent call last):
  File "/Users/juliusbusecke/Code/titiler-multidim/temp_dont_commit/mre_object_has_no_attr_value.py", line 19, in <module>
    ds = xr.open_dataset(
         ^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/api.py", line 679, in open_dataset
    backend_ds = backend.open_dataset(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/zarr.py", line 1581, in open_dataset
    ds = store_entrypoint.open_dataset(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/store.py", line 44, in open_dataset
    vars, attrs = filename_or_obj.load()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/common.py", line 312, in load
    (_decode_variable_name(k), v) for k, v in self.get_variables().items()
                                              ^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/zarr.py", line 858, in get_variables
    return FrozenDict((k, self.open_store_variable(k)) for k in self.array_keys())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/core/utils.py", line 415, in FrozenDict
    return Frozen(dict(*args, **kwargs))
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/zarr.py", line 858, in <genexpr>
    return FrozenDict((k, self.open_store_variable(k)) for k in self.array_keys())
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juliusbusecke/.cache/uv/environments-v2/mre-object-has-no-attr-value-cd1317b944d0d9b9/lib/python3.12/site-packages/xarray/backends/zarr.py", line 852, in open_store_variable
    attributes["_FillValue"], original_zarr_dtype.value
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Float32' object has no attribute 'value'

If I downgrade to v3.0.10 the read works fine, so I am wondering if this is a regression. I am a bit confused because Max showed me the regression tests which should cover exactly this case.

I uploaded the dataset to a public bucket, so the script below should be fully repoducible and the dataset inspectable. Thankfull for any pointers.

Steps to reproduce

# /// script
# requires-python = ">=3.10"
# dependencies = [
#   "fsspec==2024.12.0",
#   "s3fs==2024.12.0",
#   "xarray==2025.1.1",
#   "zarr @ git+https://github.com/zarr-developers/zarr-python@94983362f06f9bb4be3f04562b179549e36a87c4"
# ]
# ///

# To reproduce failure use dependencies above. To fix, swap "zarr @ git+https://github.com/zarr-developers/zarr-python@94983362f06f9bb4be3f04562b179549e36a87c4"  for "zarr==3.0.10"

import xarray as xr
import zarr
zarr.print_debug_info()


ds = xr.open_dataset(
    "s3://s3://nasa-eodc-public/jbusecke/reproducers/nldas3_subsampled.zarr",
    engine='zarr',
    storage_options={
        "anon": True
    }
)
print(ds)

Additional output

Required dependencies:
packaging: 25.0
numpy: 2.3.2
numcodecs: 0.16.2
typing_extensions: 4.14.1
donfig: 0.8.1.post1

Optional dependencies:
botocore: 1.39.11
fsspec: 2024.12.0
numcodecs: 0.16.2
s3fs: 2024.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions