Skip to content

B5: Element fidelity, legacy stores and HDF5 safety #95

Closed

Description

@Claptar

Part of #87.

wave 2 · 0.17.5 · size L · starts after: B1 (#89) (both edit storage/__init__.py)

Goal. Every element anndata or scanpy writes survives every copy path (HDF5 to HDF5, HDF5 to Zarr, Zarr to HDF5), and crafted files are refused.

Owns: storage/__init__.py (copy paths and open_store), elements/*, conversion/anndata_copy.py, formats/pandas_frame.py, tests/reference_stores.py, docs/reference/spec-*.md

Approach:

  • A hardening fix for crafted HDF5 inputs (F041, security; details after the fix is released).
  • Copy scanpy rec-arrays (rank_genes_groups) field by field across backends rather than through H5Ocopy or the text path (F017, F021).
  • Copies of anndata 0.7 data:
    • remap nested object references (F006);
    • keep ordered on categoricals (F072);
    • warn once, not on every read (F164).
  • Attributes and dtypes:
    • copy_attrs handles h5py.Empty, byte arrays and references (F130);
    • vlen numeric data is not treated as text (F126);
    • float32 renders at its own precision (F125);
    • the fill value is converted with the dtype (F071).
  • Zarr v2:
    • compressor choice: no Blosc on an uncompressed array (F135);
    • use the current codec API instead of the deprecated one (F134);
    • an untagged empty dataspace is not tagged null (F136);
    • None in text columns (F133).
  • Fixtures:
    • real files written by anndata 0.7, 0.8 and 0.10 (F087);
    • plain-string fixtures under pandas 3 (F090);
    • pinned integration oracles.
  • Docs: spec-zarr, testing.md and the 0.8–0.13 promise (F154, F156, F086). Remove the dead code in strings.py (F163).

Findings

Ref Sev Finding Where
F006 H HDF5-to-HDF5 copies null the object references of anndata 0.7 dataframes nested below the top level (raw/var, obsm, uns), so the output … src/adata/conversion/anndata_copy.py:84
F017 H rec-array elements (scanpy rank_genes_groups) cannot cross backends: h5ad->zarr and zarr->h5ad convert/subset/concat abort src/adata/elements/strings.py:64
F021 H Copying a scanpy rec-array (uns/rank_genes_groups/*) HDF5-to-HDF5 through copy_dataset segfaults the process, leaving a staged leftover … src/adata/storage/__init__.py:278
F041 H Crafted HDF5 inputs need a hardening check (security; details after the fix is released)
F071 M recast to bool fails on every HDF5 float source: the forwarded float fillvalue cannot be converted to h5py's bool type src/adata/storage/__init__.py:278
F072 M Ordered categoricals from anndata 0.7 files silently become unordered in every copy (convert, subset, split, mudata) src/adata/storage/__init__.py:806
F086 M The docs promise that every anndata release from 0.8 to 0.13 reads what adata writes, but only subset outputs are ever read back by an old … docs/index.md:69
F087 M anndata 0.7 support is claimed but tested only on hand-built h5py fixtures; integration oracles are unpinned tests/reference_stores.py:46
F090 M With locked pandas 3 + anndata 0.13, fixtures write every text column as nullable-string-array, so concat's plain-string and mixed-encoding … tests/test_invariants.py:32
F125 L Read-side string rendering widens float32/float16 to Python float, so exports print 0.10000000149011612 for 0.1 src/adata/elements/read.py:229
F126 L Every object dtype is treated as text: HDF5 vlen numeric sequences (and reference datasets) are silently stringified on copy to Zarr src/adata/elements/strings.py:38
F130 L copy_attrs to Zarr crashes with a JSON error on h5py.Empty, nested byte arrays and object references src/adata/storage/__init__.py:212
F133 L pycisTopic conversion writes a model table's text column that holds a None as nullable-string-array, so anndata 0.8 to 0.10 cannot open the … src/adata/formats/pandas_frame.py:150
F134 L v2-to-v2 codec carry-over relies on zarr's deprecated Array.compressor behind except Exception; when that attribute fails, outputs … src/adata/storage/__init__.py:315
F135 L Zarr v2 -> v2 copies turn an uncompressed array into a Blosc-compressed one src/adata/storage/__init__.py:318
F136 L Converting HDF5 to Zarr tags an untagged empty-dataspace dataset as encoding-type: null, turning a store that 0.8 to 0.11 read into one … src/adata/storage/__init__.py:560
F154 L Spec docs contradict the code and anndata: Zarr string scalars, legacy Zarr categories path, 'dict' called legacy, rec-array missing docs/reference/spec-zarr.md:204
F156 L testing.md and reference_stores.py say anndata 0.11 made the index a nullable-string-array group; it did not docs/reference/testing.md:392
F163 L Dead code and spec constants duplicated outside spec.py src/adata/elements/strings.py:79
F164 L Every read of a genuine anndata 0.7 store prints a UserWarning that its root attrs are 'missing or invalid' src/adata/storage/__init__.py:195

Done when one PR on fix/b5 closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions