Skip to content

[V3] v2 -> v3 data migration #1798

Closed

Description

@d-v-b

We should invest in tools to make the v2 -> v3 conversion simple for people who are motivated to convert their data. A few high-level ideas:

  • A simple CLI that converts an array, or a group (recursive or not) from v2 to v3, in a new location.
    • Someone should investigate how complicated in-place conversions would be. On a local filesystem where mv is cheap, this could be attractive.. V3 is designed to make array conversions easy, requiring only the creation of new metadata.
    • The CLI should use functions that are accessible from scripts that don't use the CLI. We can look at work @normanrz did in Zarrita.
  • Documentation of the key differences between zarr-python v2 and v3, and a migration guide. This should have its own page in the docs.
    • We should consider options for people who don't want to re-save their data. I'm not presently a kerchunk user, but I presume that kerchunk could map v2 to v3, for people who don't want to convert their data? cc @martindurant.

Activity

  1. jeromekelleher commented on Apr 17, 2024

    @jeromekelleher
    Member

    Big +1 on this. I'm working on a conversion tool for large-scale genomics data (100s TB scale) which is usually held in file systems (for the moment, it will probably migrate to object stores later on). A CLI tool that does an in-place migration from v2 to v3 would be a big help. I'm hoping to move to v3 early on, before too many datasets are converted into v2 format and so most users won't ever know about v2.

    My assumptions was that the migration was largely a case of writing a new JSON metadata file per-array, and should be possible to do both cheaply and safely?

  2. d-v-b commented on Apr 17, 2024

    @d-v-b
    ContributorAuthor

    My assumptions was that the migration was largely a case of writing a new JSON metadata file per-array, and should be possible to do both cheaply and safely?

    Yes, I think this is right. Besides the metadata, which will live in a completely new JSON document (zarr.json), V3 supports a backwards-compatible layout for the chunks

  3. jeromekelleher commented on Apr 17, 2024

    @jeromekelleher
    Member

    Thanks yes, I've been aiming for v3 forwards compatibility by using "/" as the default dimension separator. Then, iterating over the chunks in the first dimension and renaming to have a "c" prefix should be relatively cheap (I forgot about this difference).

    Is there some developer documentation with recommendations for forwards/backwards compatibility?

  4. normanrz commented on Apr 17, 2024

    @normanrz
    Member
    • Someone should investigate how complicated in-place conversions would be. On a local filesystem where mv is cheap, this could be attractive.

    For most cases, the migration only requires adding zarr.json files throughout the hierarchy. There should be no need to even touch the chunk files. zarr.json and .zarray files can also live side-by-side. So, why would a mv be needed?
    Only, when using a non-supported codec or filter, chunks need to be rewritten.

  5. d-v-b commented on Apr 17, 2024

    @d-v-b
    ContributorAuthor

    So, why would a mv be needed?
    Only, when using a non-supported codec or filter, chunks need to be rewritten.

    This is correct. When I wrote up this issue, I forgot about the v2 chunk key encoding supported by v3 🤦

  6. d-v-b commented on Apr 17, 2024

    @d-v-b
    ContributorAuthor

    i updated the issue to be more accurate :)

  7. normanrz commented on Apr 17, 2024

    @normanrz
    Member

    I agree that a CLI tool that can convert an entire hierarchy would be great!

  8. added this to the After 3.0.0 milestone on Apr 19, 2024
  9. jhamman commented on Apr 19, 2024

    @jhamman
    Member

    Today I learned that there is a v1 to v2 migrator in the zarr-python codebase:

    zarr-python/zarr/storage.py

    Lines 1941 to 1956 in 6105ef2

    def migrate_1to2(store):
    """Migrate array metadata in `store` from Zarr format version 1 to
    version 2.
    Parameters
    ----------
    store : Store
    Store to be migrated.
    Notes
    -----
    Version 1 did not support hierarchies, so this migration function will
    look for a single array in `store` and migrate the array metadata to
    version 2.
    """

  10. modified the milestones: After 3.0.0, 3.0.0 on Apr 22, 2024
  11. 6 remaining items

  12. modified the milestones: 3.0.0, After 3.0.0 on Jan 3, 2025
  13. moved this from In Progress to Done in Zarr-Python - 3.0on Jan 3, 2025
  14. reopened this on Jan 3, 2025
  15. jhamman commented on Jan 3, 2025

    @jhamman
    Member

    #2596 was mislabeled as closing this. A migration tool would still be great!

  16. meteoDaniel commented on Feb 6, 2025

    @meteoDaniel

    I am intersted, too.

    Without the opportunity to migrate Data from v2 to v3, it would be a nightmare to deprecate zarr v2 support.
    M

  17. eschechter commented on Mar 14, 2025

    @eschechter

    This gist is a first-pass effort at a migration script. My team has begun to use it to explore converting our existing zarr datasets, but it is currently limited in scope to zarrs stored on s3. I'd welcome any feedback or discussion about how this could be useful to other devs.

  18. meteoDaniel commented on Mar 14, 2025

    @meteoDaniel

    @eschechter thanks for sharing!

    So it is enough to adapt the metadata without touching the data itself?

  19. eschechter commented on Mar 17, 2025

    @eschechter

    That's correct @meteoDaniel - the zarr v3 conversion can be done with just the creation of zarr.json metadata files. No need to touch the data.

  20. removed this from the After 3.0.0 milestone on May 14, 2025
  21. K-Meech commented on Jun 25, 2025

    @K-Meech
    Contributor

    Hi all, I'd be happy to put together a draft PR of a v2 > v3 conversion CLI (expanding / extending @eschechter 's gist - which is a great start 😄). Do let me know if anyone is already working on this (happy to collaborate!) + if there are any preferences for structure / location of the CLI in the existing codebase.

  22. normanrz commented on Jun 30, 2025

    @normanrz
    Member

    That's great! I don't think there are any CLI tools in this codebase already. So, I guess we're open for suggestions on the structure.
    I think it would be great, if the conversion functions could also be called from Python directly. A CLI would then be using these functions.
    I had good experiences with building CLIs with typer. That should probably go in a new dependency group, e.g. pip install zarr[cli].
    I think the CLI should only attempt to do metadata-only conversions. If that is not possible (e.g. due to missing codecs in v3) it should fail.

  23. d-v-b commented on Apr 23, 2026

    @d-v-b
    ContributorAuthor

    with the CLI added and improved documentation, I think this can be closed as completed.

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

    enhancementNew features or improvements

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions