Skip to content

[Bug]: Exporting from Zarr to HDF5 does not preserve chunking #1287

Open
@rly

Description

@rly

What happened?

HDF5IO is not yet set up to read certain IO settings from Zarr.

Steps to Reproduce

from datetime import datetime
from dateutil.tz import tzlocal

import numpy as np
from pynwb import NWBFile, TimeSeries, NWBHDF5IO

from hdmf_zarr import ZarrDataIO
from hdmf_zarr.nwb import NWBZarrIO


# Create the NWBFile
nwbfile = NWBFile(
    session_description="my first synthetic recording",
    identifier="EXAMPLE_ID",
    session_start_time=datetime.now(tzlocal())
)

data_with_data_io = ZarrDataIO(
    data=np.arange(10000),
    chunks=(1000, ),
)

ts = TimeSeries(
    name="test",
    data=data_with_data_io,
    rate=1.0,
    unit="unit",
)

nwbfile.add_acquisition(ts)


zarr_path = "rechunking.nwb.zarr"
with NWBZarrIO(path=zarr_path, mode="w") as io:
    io.write(nwbfile)

hdf5_path = "rechunking.nwb"
with NWBZarrIO(path=zarr_path, mode="r") as read_io:
    read_nwbfile = read_io.read()
    print(read_nwbfile.acquisition["test"].data.chunks)
    
    with NWBHDF5IO(hdf5_path, mode='w') as export_io:
        export_io.export(src_io=read_io, write_args=dict(link_data=False))

with NWBHDF5IO(hdf5_path, mode='r') as hdf5_read_io:
    read_nwbfile = hdf5_read_io.read()
    print(read_nwbfile.acquisition["test"].data.chunks)

Traceback

Output:
(1000, )
None

Operating System

macOS

Python Version

3.13

Package Versions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: bugerrors in the code or code behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions