Skip to content

Supporting links and references #389

Open

Description

@jakirkham

In HDF5, there are a few different mechanisms used to refer to other data in an HDF5 file from a location other than where they are stored.

For example, HDF5 supports different types of links like hard links, soft links, and external links. These are analogous to links on the filesystem with the exception of external links, which constitute a soft link to a different HDF5 file. These can refer to groups or datasets in HDF5.

Also HDF5 supports a couple kinds of references such as object references and region references. These refer simply to datasets or some subselection of datasets.

It would be useful to support these in Zarr as there appear to be some use cases for them. ( #297 ) ( #298 ) ( https://github.com/zarr-developers/zarr/issues/333 ) Also downstream libraries like pynwb would like to use them. ( NeurodataWithoutBorders/pynwb#230 )

Am raising here to discuss how we might support these features in Zarr across various stores.

Activity

  1. amkigit commented on Oct 1, 2019

    @amkigit

    I like and use the feature of hdf5 to use object references. Instead of using symbolic links would it be possible to create a "virtual" Group, a directory or a data storage, which does contain references (path) to the effective Group members. Instead of using the file system the reference is in a lets say .vgroup file. May be an easy and flexible approach.

  2. NumesSanguis commented on Dec 12, 2019

    @NumesSanguis

    Someone recently made an issue over at ASDF (Advanced Scientific Data Format) to integrate with Zarr: asdf-format/asdf#718
    ASDF supports:

    ASDF currently doesn't support chunking however, which would make Zarr a good addition to ASDF. The original issue points out that integrating with Zarr would benefit parallel computation with ASDF (e.g. with Dask).

  3. alimanfoo commented on Dec 12, 2019

    @alimanfoo
    Member

    Thanks @NumesSanguis for making the connection, very interesting.

  4. perrygreenfield commented on Dec 12, 2019

    @perrygreenfield

    Thanks @NumesSanguis from the ASDF side as well. This is something we want to take a serious look at.

  5. Cadair commented on Dec 12, 2019

    @Cadair

    Thanks for making the link @NumesSanguis once we have wrapped our heads around things a little more I might open some issues here 😀

  6. NumesSanguis commented on May 8, 2020

    @NumesSanguis

    Is there any update on this issue? It would be great to be able to refer to parts of a larger array as a new dataset, without having to copy the data or having to create your own parsing code.

  7. perrygreenfield commented on May 8, 2020

    @perrygreenfield

    From our view we would like to start working on this for ASDF in a couple months (after a new staff member starts). If someone is willing to help, even better.

  8. marcel-goldschen-ohm commented on Jun 29, 2023

    @marcel-goldschen-ohm

    Any news on this? I'm currently trying to plan out how to use zarr for electrophysiology datasets. These data can have repeated stimulus patterns and identical time arrays for which shared arrays (see #690) and/or groups seem like they could be really useful.

  9. added
    enhancement
    on Dec 28, 2024
  10. TomNicholas commented on Feb 18, 2025

    @TomNicholas
    Member

    Note that VirtualiZarr + Icechunk together give something similar to external links (we call them "virtual chunks").

    But they do not provide anything like internal links - I've raised earth-mover/icechunk#747 to discuss the idea of implementing that through icechunk manifests.

  11. TomNicholas commented on Feb 18, 2025

    @TomNicholas
    Member

    Also separately xarray.DataTree has "inherited coordinates", which allows analysis code to have coordinate variables defined once and automatically made available amongst many child datasets.

  12. d-v-b commented on Jul 8, 2026

    @d-v-b
    Contributor

    for me the big question is which level of the stack should support links / references as first-class entities, and what the APIs would look like.

    The key: value store abstraction is a great target for the implementation of links, but in order to prevent pathologies like circular references, we would probably need to impose zarr-format-aware rules at store definition time -- we don't want to a group to contain its own ancestors via links, but for array chunks, there's no possibility of recursion. So the difference between a safe link and an unsafe link requires knowing the elements of the zarr hierarchy that are being linked, which is a higher level of abstraction than the store API.

    Maybe simpler to detect cyclic paths at runtime, and refuse to enter them with an exception. In any case, we don't have a clear policy for handling links in our local file system store, so I opened an issue about that: #4126

  13. marcel-goldschen-ohm commented on Jul 8, 2026

    @marcel-goldschen-ohm

    Whatever the policy, it should definitely allow referencing ancestor arrays (e.g., like xarray.DataTree inherited coordinates). Indeed, I see ancestor array reference as likely the primary use case.

  14. d-v-b commented on Jul 8, 2026

    @d-v-b
    Contributor

    at the moment I don't see a compelling reason why links to arbitrary arrays would be problematic, as long as everything is scoped to the file system. but this might also be something users would want to opt into explicitly. There are also questions about what other zarr implementations support -- if tensorstore and zarrs support following symlinks, then that's a very compelling reason for us to adopt it. if they don't, then we risk generating zarr data on the file system that can't be accessed consistently across implementations, and we want to avoid this.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions