Skip to content

[v3] Implement Group.tree #2406

Closed
Closed
@jhamman

Description

@jhamman

Zarr version

3.0.0.beta

Numcodecs version

0.13

Python Version

3.11

Operating System

Mac

Installation

pip

Description

We are missing the Group.tree method from 2.x. We should add it for backward compatibility.

Steps to reproduce

In [18]: root = zarr.group()

In [19]: root.tree()
--------------------------------------------------------------------------
NotImplementedError                      Traceback (most recent call last)
Cell In[19], line 1
----> 1 root.tree()

File ~/miniforge3/envs/icechunk-demo/lib/python3.12/site-packages/zarr/core/group.py:1474, in Group.tree(self, expand, level)
   1473 def tree(self, expand: bool = False, level: int | None = None) -> Any:
-> 1474     return self._sync(self._async_group.tree(expand=expand, level=level))

File ~/miniforge3/envs/icechunk-demo/lib/python3.12/site-packages/zarr/core/sync.py:185, in SyncMixin._sync(self, coroutine)
    182 def _sync(self, coroutine: Coroutine[Any, Any, T]) -> T:
    183     # TODO: refactor this to to take *args and **kwargs and pass those to the method
    184     # this should allow us to better type the sync wrapper
--> 185     return sync(
    186         coroutine,
    187         timeout=config.get("async.timeout"),
    188     )

File ~/miniforge3/envs/icechunk-demo/lib/python3.12/site-packages/zarr/core/sync.py:141, in sync(coro, loop, timeout)
    138 return_result = next(iter(finished)).result()
    140 if isinstance(return_result, BaseException):
--> 141     raise return_result
    142 else:
    143     return return_result

File ~/miniforge3/envs/icechunk-demo/lib/python3.12/site-packages/zarr/core/sync.py:100, in _runner(coro)
     95 """
     96 Await a coroutine and return the result of running it. If awaiting the coroutine raises an
     97 exception, the exception will be returned.
     98 """
     99 try:
--> 100     return await coro
    101 except Exception as ex:
    102     return ex

File ~/miniforge3/envs/icechunk-demo/lib/python3.12/site-packages/zarr/core/group.py:1244, in AsyncGroup.tree(self, expand, level)
   1243 async def tree(self, expand: bool = False, level: int | None = None) -> Any:
-> 1244     raise NotImplementedError

NotImplementedError:

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions