Skip to content

String too large to store inside array when writing Zarr store #85

Description

@WeilerP

Report

Description

When I try saving a TreeData as a zarr ZipStore, writing the obst slot fails. My lineage trees (stage/condition dependent) are stored as networkx DiGraphs. The object I am trying to save has approx 1.8 million cells if that could be an issue.

CCing @ilan-gold since the issue is in the anndata writer, so maybe you have a suggestion.

import warnings
import zarr
import treedata as td

tdata = td.read_h5td("tdata.h5td")

with warnings.catch_warnings():
    warnings.simplefilter("ignore", UserWarning)
    store = zarr.storage.ZipStore("tdata.zarr.zip", mode="w")
    data.write_zarr(store=store)
    store.close()

Traceback:

Traceback (most recent call last):
  File ".env/tdatabug-py312/lib/python3.12/site-packages/treedata/_core/treedata.py", line 531, in write_zarr
    write_zarr(store, self, chunks=chunks)
  File ".env/tdatabug-py312/lib/python3.12/site-packages/treedata/_core/write.py", line 199, in write_zarr
    _write_tdata(f, tdata, filename, chunks, **kwargs)
  File ".env/tdatabug-py312/lib/python3.12/site-packages/treedata/_core/write.py", line 87, in _write_tdata
    _write_elem(f, key, _serialize_axis_trees(getattr(tdata, key)), dataset_kwargs=kwargs)
  File ".env/tdatabug-py312/lib/python3.12/site-packages/treedata/_core/write.py", line 48, in _write_elem
    ad.io.write_elem(f, k, elem, dataset_kwargs=dataset_kwargs)
  File ".env/tdatabug-py312/lib/python3.12/site-packages/anndata/_io/specs/registry.py", line 518, in write_elem
    Writer(_REGISTRY).write_elem(store, k, elem, dataset_kwargs=dataset_kwargs)
  File ".env/tdatabug-py312/lib/python3.12/site-packages/anndata/_io/utils.py", line 272, in func_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File ".env/tdatabug-py312/lib/python3.12/site-packages/anndata/_io/specs/registry.py", line 389, in write_elem
    return write_func(store, k, elem, dataset_kwargs=dataset_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".env/tdatabug-py312/lib/python3.12/site-packages/anndata/_io/specs/registry.py", line 77, in wrapper
    result = func(g, k, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".env/tdatabug-py312/lib/python3.12/site-packages/anndata/_io/specs/methods.py", line 1321, in write_scalar_zarr
    a[...] = np.array(value)
             ^^^^^^^^^^^^^^^
TypeError: string too large to store inside array.
Error raised while writing key 'obst' of <class 'zarr.core.group.Group'> to /

Versions

| Package  | Version |
| -------- | ------- |
| treedata | 0.2.5   |

| Dependency         | Version        |
| ------------------ | -------------- |
| typing_extensions  | 4.15.0         |
| session-info2      | 0.4            |
| google-crc32c      | 1.8.0          |
| scipy              | 1.16.3         |
| charset-normalizer | 3.4.4          |
| fast-array-utils   | 1.3.1          |
| cloudpickle        | 3.1.2          |
| PyYAML             | 6.0.3          |
| packaging          | 26.0           |
| scanpy             | 1.12           |
| donfig             | 0.8.1.post1    |
| setuptools         | 82.0.0         |
| psutil             | 7.2.2          |
| natsort            | 8.4.0          |
| Jinja2             | 3.1.6          |
| pyarrow            | 23.0.0         |
| h5py               | 3.15.1         |
| numcodecs          | 0.16.5         |
| six                | 1.17.0         |
| llvmlite           | 0.46.0         |
| threadpoolctl      | 3.6.0          |
| anndata            | 0.12.10        |
| cuda-pathfinder    | 1.3.4 (12.9.4) |
| xarray             | 2026.1.0       |
| pytz               | 2025.2         |
| MarkupSafe         | 3.0.3          |
| fsspec             | 2026.2.0       |
| sparse             | 0.17.0         |
| zarr               | 3.1.5          |
| pandas             | 2.3.3          |
| python-dateutil    | 2.9.0.post0    |
| networkx           | 3.6.1          |
| numba              | 0.63.1         |
| legacy-api-wrap    | 1.5            |
| dask               | 2026.1.2       |
| numpy              | 2.3.5          |
| toolz              | 1.1.0          |
| cuda-bindings      | 12.9.4         |

| Component | Info                                                     |
| --------- | -------------------------------------------------------- |
| Python    | 3.12.12 (main, Feb  3 2026, 22:51:04) [Clang 21.1.4 ]    |
| OS        | Linux-4.18.0-425.19.2.el8_7.x86_64-x86_64-with-glibc2.28 |
| Updated   | 2026-04-21 15:29                                         |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions