Skip to content

Nested storage detection in Zarr V2 #707

Closed

Description

@joshmoore

see: ome/ngff#29 and bcdev/jzarr#17

In order to better handle Zarr arrays created with NestedDirectoryStorage or FSStore(key_separator="/"), SabineEmbacher and I have been working on a "protocol heuristic" that can be used by V2 implementations to detect nested chunking rather than requiring the user to specify it correctly.

tl;dr: This proposes a new key for .zarray which it would be good to have feedback on.


Proposal

When creating a zarr array:

  • add to .zarray json: {"dimension_separator": "/"}
  • always write a 0-position chunk

When opening an array:

  • try to read the separator character from the .zarray json
  • if not available, try to find a 0-position chunk
  • if not available, at every read action try to find chunks with both standard variants until the situation is clarified. (Standard separator list ["/", "."])

Points for discussion:

  • The name dimension_separator differs from the code implementation key_separator to reduce confusion about whether every separator in the key name is effected.
  • There has been some discussion (community call, gitter) about whether or not "/" could become the default.
  • Is an addition to the .zarray metadata sufficiently low impact to be rolled into v2?

Activity

  1. SabineEmbacher commented on Mar 7, 2021

    @SabineEmbacher

    Thoughts on the name of the separator:
    What the separator separates is the respective chunk index per dimension.
    See bcdev/jzarr#19 and bcdev/jzarr#17 (comment) and

    Therefore the following suggestions:

    • chunk_index_separator
    • chunk_index_sep
    • chunk_idx_separator
    • chunk_idx_sep
  2. jbms commented on Mar 15, 2021

    @jbms

    One issue with the detection protocol is that it does not work when writing. While auto-detection is nice it might be better to just assume "." unless the metadata key is present --- any existing arrays could be fixed up, and hopefully all future arrays would have the metadata key. That avoids the added complexity (and inefficiency) of auto-detection.

  3. joshmoore commented on Mar 16, 2021

    @joshmoore
    MemberAuthor

    Hi @jbms. You mean a mode="a"-style writing? If so, I see the problem. I had initially intended the auto-detection only as a means of not needing to "standardize" a new key. Then I got greedy and went for both. Anyone else have thoughts?

    In the case of a mode="w" situation I would assume the writer simply asserts where it will write.

    any existing arrays could be fixed up, and hopefully all future arrays would have the metadata key.

    Guess there are some edge cases I worry about here. Maybe there are a number of strategies that can be enabled:

    • auto-detect
    • fail if missing metadata
    • set if missing metadata
    • ...

    The real question is likely to be what should be the default.

  4. joshmoore commented on Mar 26, 2021

    @joshmoore
    MemberAuthor

    #707 (comment) What the separator separates is the respective chunk index per dimension.

    @SabineEmbacher, @axtimwalde suggests "dimension separator".

  5. SabineEmbacher commented on Apr 6, 2021

    @SabineEmbacher

    I did not make my suggestions regarding the name in order to enforce them.
    They were simply suggestions.
    I agree with any decision. Even if a decision does not correspond to my personal preferences.
    That is perfectly fine with me.

    Please make a decision and I will put it in asap according to the specification.

  6. joshmoore commented on Apr 8, 2021

    @joshmoore
    MemberAuthor

    I did not make my suggestions regarding the name in order to enforce them.

    No worries, @SabineEmbacher. The suggestions were definitely useful. It's more just a matter of https://martinfowler.com/bliki/TwoHardThings.html ...

    Since key_separator leads to confusion and dimensionSeparator/dimension_separator is at least used in some other implementation, I've updated the description with dimension_separator.

    On the community call last night, there were no objections to moving forward with the .zarray addition, so I'll open a v2 spec PR now.

    I'm a bit more hesitant about defining the heuristic as part of the specification (cf. @jbms comment) I'll leave this open for a discussion of where first-chunk writing falls on the MAY/SHOULD/MUST spectrum.

  7. joshmoore commented on Sep 22, 2021

    @joshmoore
    MemberAuthor

    I consider the dimension_separator saga complete! whew

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions