Add .to_icechunk() method to ManifestGroup#591
Draft
TomNicholas wants to merge 3 commits intozarr-developers:mainfrom
Draft
Add .to_icechunk() method to ManifestGroup#591TomNicholas wants to merge 3 commits intozarr-developers:mainfrom
.to_icechunk() method to ManifestGroup#591TomNicholas wants to merge 3 commits intozarr-developers:mainfrom
Conversation
TomNicholas
commented
May 11, 2025
|
|
||
| return cls(arrays=manifestarrays, attributes=attributes) | ||
|
|
||
| def to_icechunk( |
Member
Author
There was a problem hiding this comment.
The point of adding this on ManifestGroup instead of ManifestStore initially is to make it easier to compose to deal with virtual datatrees later.
maxrjones
reviewed
Sep 5, 2025
Comment on lines
+139
to
+169
| @classmethod | ||
| def from_virtual_dataset( | ||
| cls, | ||
| vds: xr.Dataset, | ||
| ) -> "ManifestGroup": | ||
| """ | ||
| Create a new ManifestGroup from a virtual dataset object. | ||
|
|
||
| The virtual dataset should contain only virtual variables, i.e. those backed by ManifestArrays. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| vds: xr.Dataset | ||
| Virtual dataset, containing only virtual variables. | ||
| """ | ||
|
|
||
| for name, var in vds.variables.items(): | ||
| if not isinstance(var.data, ManifestArray): | ||
| raise TypeError( | ||
| f"Cannot convert a dataset containing a loadable variable directly to a ManifestGroup, but found variable {name} has type {type(var.data)}" | ||
| ) | ||
|
|
||
| manifestarrays = {name: var.data for name, var in vds.variables.items()} | ||
|
|
||
| attributes = vds.attrs | ||
| # TODO test this is correct | ||
| attributes["dimension_names"] = " ".join(list(vds.dims)) | ||
| # TODO test this constructor round-trips coordinates | ||
| attributes["coordinates"] = " ".join(list(vds.coords)) | ||
|
|
||
| return cls(arrays=manifestarrays, attributes=attributes) |
Member
There was a problem hiding this comment.
Could this functionality be moved to a different PR to constrain the scope of the ManifestGroup.to_icechunk feature?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This (WIP) PR adds a
to_icechunk()method directly onManifestGroup, and refactors the.to_icechunk()virtual dataset accessor method to go via the newManifestGroupmethod.The point is
ManifestStoreto virtual dataset, by adding the ability to go back from a virtual dataset to a ManifestStore,After this PR we should do the same for
.to_kerchunk()- at that point we could actually make xarray an optional dependency if we want to.docs/releases.rstapi.rst