Skip to content

Saving DataTree to zarr changes the order of the groups #10204

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

Open
bweeding opened this issue Apr 7, 2025 · 2 comments
Open

Saving DataTree to zarr changes the order of the groups #10204

bweeding opened this issue Apr 7, 2025 · 2 comments
Labels
plan to close May be closeable, needs more eyeballs topic-DataTree Related to the implementation of a DataTree class topic-zarr Related to zarr storage library upstream issue

Comments

@bweeding
Copy link

bweeding commented Apr 7, 2025

What is your issue?

When I generate a DataTree and save it to a zarr file, the order of the groups is not preserved.

This is irritating as I had ordered the DataTree in a particular way for automated plotting.

Image

@bweeding bweeding added the needs triage Issue that has not been reviewed by xarray team member label Apr 7, 2025
@TomNicholas TomNicholas added bug topic-zarr Related to zarr storage library topic-DataTree Related to the implementation of a DataTree class and removed needs triage Issue that has not been reviewed by xarray team member labels Apr 7, 2025
@TomNicholas
Copy link
Member

I don't think zarr is guaranteed to preserve order. Zarr's list operation is the result of an async list, which can return results in any order (needed for scalability). The best zarr could do would be to always sort that list before returning it, but that still wouldn't allow you to create an arbitrary order (i.e. insertion order) and round-trip it like you are trying to here.

ordered the DataTree in a particular way for automated plotting.

I'm curious why the ordering of groups would matter for plotting? Ordering of groups doesn't really mean anything in DataTree...

@TomNicholas TomNicholas added upstream issue plan to close May be closeable, needs more eyeballs and removed bug labels Apr 7, 2025
@bweeding
Copy link
Author

bweeding commented Apr 8, 2025

Ok, no worries.

It came up as a had a plotting routine comparing climate model outputs and I was iterating through the groups using indices rather than keys, but I've fixed that now so it's no longer a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to close May be closeable, needs more eyeballs topic-DataTree Related to the implementation of a DataTree class topic-zarr Related to zarr storage library upstream issue
Projects
None yet
Development

No branches or pull requests

2 participants