8000 Reading a dataset fails with zarr 3 (z.data, .zattrs) · Issue #167 · ecmwf/anemoi-registry · GitHub
[go: up one dir, main page]

Skip to content

Reading a dataset fails with zarr 3 (z.data, .zattrs) #167

Open

Description

@Zappandy

I'm testing the anemoi packages with zarr 3 and with datasets in zarr format 3, as part of the zarr 3 work in anemoi-datasets (ecmwf/anemoi-datasets#786, and the tracking issue #792). Two places in anemoi-registry only work with zarr 2.

  1. DatasetCatalogueEntry.load_from_path raises AttributeError: 'Group' object has no attribute 'data' with zarr 3, for datasets in format 2 and in format 3. It reads the shape with z.data.shape (entry/dataset.py). Item access, z["data"], works with zarr 2 and 3.
  2. update --catalogue-from-recipe-file reads {tmp}/.zattrs after running init (commands/update.py). A format 3 dataset has zarr.json and no .zattrs, so the read fails. zarr.open(tmp, mode="r").attrs.asdict() works for both formats.

I have a fix in #166. I could not run update against a real catalogue. I ran its code path with the catalogue stubbed and the real init task, and the fix reads variables_metadata on both formats.

Versions. anemoi-registry 0.3.4 (main 888ac9e), zarr 3.4.1 with numcodecs 0.17.0 (and zarr 2.18.7 with numcodecs 0.15.2 for comparison), anemoi-datasets from main, Python 3.12, Linux.

How to reproduce

Create a small dataset in each format with anemoi-datasets (output: {format: zarr3} for format 3, from ecmwf/anemoi-datasets#786).

1.

from anemoi.registry.entry.dataset import DatasetCatalogueEntry

DatasetCatalogueEntry.load_from_path("dataset.zarr")

Before the fix, zarr 3.4.1 raises the AttributeError above for both formats. On zarr 2.18.7 it works for format 2.

2.

import zarr
from anemoi.datasets.create.tasks import run_task

run_task("init", recipe="recipe.yaml", path="tmp.zarr", overwrite=True)  # recipe with output: {format: zarr3}
open("tmp.zarr/.zattrs")

Before the fix, update reads tmp.zarr/.zattrs, which does not exist for a format 3 dataset (FileNotFoundError). zarr.open("tmp.zarr", mode="r").attrs.asdict() returns the attributes for both formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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

    0