Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Implement Group.tree #2406

Open
Tracked by #2412
jhamman opened this issue Oct 18, 2024 · 2 comments · May be fixed by #2433
Open
Tracked by #2412

[v3] Implement Group.tree #2406

jhamman opened this issue Oct 18, 2024 · 2 comments · May be fixed by #2433
Labels
bug Potential issues with the zarr-python library V3 Affects the v3 branch
Milestone

Comments

@jhamman
Copy link
Member

jhamman commented Oct 18, 2024

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

@jhamman jhamman added the bug Potential issues with the zarr-python library label Oct 18, 2024
@jhamman jhamman added this to the 3.0.0 milestone Oct 18, 2024
@jhamman jhamman added the V3 Affects the v3 branch label Oct 18, 2024
@TomAugspurger
Copy link
Contributor

Zarr v2 relied on asciitree for this, I think as a required dependency.

What do folks think of using rich instead, and possibly as an optional dependency?

@d-v-b
Copy link
Contributor

d-v-b commented Oct 22, 2024

optional rich seems fine to me!

@TomAugspurger TomAugspurger linked a pull request Oct 23, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library V3 Affects the v3 branch
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants