Skip to content

API to open only an Array or only a Group from an exisiting Group #3445

Closed

Description

@dstansby

It would be nice to have some API to open only an {Array or Group} from an open Group, and raise an error if the {Array or Group} isn't present, or is a {Group or Array}. Current options are:

# No way to know if return type is array or group
group['path']

# Creates a array/group if one doesn't exist
group.require_array('path')
group.require_group('path')

So maybe Group.open_array(...) -> Array and Group.open_group(...) methods could be added? These could also have a mode argument, to allow for creating the array if it doesn't exist, similar to zarr.open_array() and zarr.open_group(), which would allow require_array() and require_group() to be deprecated.

Activity

  1. d-v-b commented on Sep 9, 2025

    @d-v-b
    Contributor

    So maybe Group.open_array(...) -> Array and Group.open_group(...) methods could be added?

    this makes sense to me! While the initial design would probably need to use the problematic mode parameter, later on we should distinguish between "mutable access to an array / group" vs "create a new array / group if one does not already exist" (and the latter is refined by whether overwriting an existing node is allowed)

  2. d-v-b commented on Oct 27, 2026

    @d-v-b
    Contributor

    this was added in #4128

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