@@ -75,6 +75,31 @@ For more information on groups see the :class:`zarr.Group` API docs.
7575
7676.. _user-guide-diagnostics :
7777
78+ Batch Group Creation
79+ --------------------
80+
81+ You can also create multiple groups concurrently with a single function call. :func: `zarr.create_hierarchy ` takes
82+ a :class: `zarr.storage.Store ` instance and a dict of ``key : metadata `` pairs, parses that dict, and
83+ writes metadata documents to storage:
84+
85+ >>> from zarr import create_hierarchy
86+ >>> from zarr.core.group import GroupMetadata
87+ >>> from zarr.storage import LocalStore
88+ >>> node_spec = {' a/b/c' : GroupMetadata()}
89+ >>> nodes_created = dict (create_hierarchy(store = LocalStore(root = ' data' ), nodes = node_spec))
90+ >>> print (sorted (nodes_created.items(), key = lambda kv : len (kv[0 ])))
91+ [('', <Group file://data>), ('a', <Group file://data/a>), ('a/b', <Group file://data/a/b>), ('a/b/c', <Group file://data/a/b/c>)]
92+
93+ Note that we only specified a single group named ``a/b/c ``, but 4 groups were created. These additional groups
94+ were created to ensure that the desired node ``a/b/c `` is connected to the root group ``'' `` by a sequence
95+ of intermediate groups. :func: `zarr.create_hierarchy ` normalizes the ``nodes `` keyword argument to
96+ ensure that the resulting hierarchy is complete, i.e. all groups or arrays are connected to the root
97+ of the hierarchy via intermediate groups.
98+
99+ Because :func: `zarr.create_hierarchy ` concurrently creates metadata documents, it's more efficient
100+ than repeated calls to :func: `create_group ` or :func: `create_array `, provided you can statically define
101+ the metadata for the groups and arrays you want to create.
102+
78103Array and group diagnostics
79104---------------------------
80105
0 commit comments