Skip to content

ArraySpec.from_array returning incorrect results for v3 #92

Description

@ivirshup

Hey! Very excited to use this.

I am getting some incorrect seeming results back from from_array for zarr v3 arrays using the latest (0.8.1) release. I had expected that this was supported now after seeing #53.

Here is an example of what I'm seeing:

from pydantic_zarr.v3 import ArraySpec, GroupSpec
import zarr

z = zarr.open_array(TST_URI)
z
# <Array <FsspecStore(S3FileSystem, ivirshup-sci-data-dev-tmp/scratch/take12/scale0.zarr)> shape=(96, 128, 512, 3328, 2) dtype=uint16>

spec = ArraySpec.from_array(z)
# ArraySpec(zarr_format=3, node_type='array', attributes={}, shape=(96, 128, 512, 3328, 2), data_type='uint16', chunk_grid={'name': 'regular', 'configuration': {'chunk_shape': (96, 128, 512, 3328, 2)}}, chunk_key_encoding={'name': 'default', 'configuration': {'separator': '/'}}, fill_value=0.0, codecs=(), storage_transformers=(), dimension_names=None)

z.chunks, z.shards
# ((1, 32, 32, 32, 1), (1, 128, 128, 128, 1))
spec.chunk_grid
# {'name': 'regular', 'configuration': {'chunk_shape': (96, 128, 512, 3328, 2)}}

z.compressors
# (ZstdCodec(level=3, checksum=False),)
spec.codecs
# ()

It looks like from_array is just failing to read most of the relevant structure metadata. Here is the zarr.json for this array:

zarr.json
{
    "chunk_grid": {
        "configuration": {
            "chunk_shape": [
                1,
                128,
                128,
                128,
                1
            ]
        },
        "name": "regular"
    },
    "chunk_key_encoding": {
        "name": "default"
    },
    "codecs": [
        {
            "configuration": {
                "chunk_shape": [
                    1,
                    32,
                    32,
                    32,
                    1
                ],
                "codecs": [
                    {
                        "configuration": {
                            "endian": "little"
                        },
                        "name": "bytes"
                    },
                    {
                        "configuration": {
                            "checksum": false,
                            "level": 3
                        },
                        "name": "zstd"
                    }
                ],
                "index_codecs": [
                    {
                        "configuration": {
                            "endian": "little"
                        },
                        "name": "bytes"
                    },
                    {
                        "name": "crc32c"
                    }
                ]
            },
            "name": "sharding_indexed"
        }
    ],
    "data_type": "uint16",
    "fill_value": 0,
    "node_type": "array",
    "shape": [
        96,
        128,
        512,
        3328,
        2
    ],
    "zarr_format": 3
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions