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.
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_groups
for zarr backends #9469open_groups
for zarr backends #9469Changes from 3 commits
7e9d5b0
746977a
7a6fd8c
dac8c32
633a1f5
25f171e
f2c169b
1f17d95
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to add type hints (though I don't know what the type of
root
is)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what the appropriate TypeHint would be here that wouldn't break
mypy
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a play with this. I traced
root
back and found it is indeed azarr.Group
, so I think the type hint above works (along with addingfrom zarr import Group as ZarrGroup
in theif TYPE_CHECKING
block at the top of the file).The bit that was causing an issue the assignment of a
NodePath
object toparent
, which is astr
from the function signature. (Apologies if I'm just playing catch up here from what you guys have been saying all along)I could make
mypy
happy if I did the following in the function:Maybe that's an option? (Unless I'm missing a trick with this breaking the recursion?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
(No need for from
xarray.core.treenode import NodePath
to live inside the function though)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Owen! That did the trick!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely use
to match a much more specific error. We are expecting this test to fail because of an alignment error, not any other type of
ValueError
.(Maybe we should create a new exception
AlignmentError(ValueError)
, given that we do already haveMergeError(ValueError)
? @shoyer)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this but in the
treenode.py
module?If we do this I think we might have to change
datatree.py
to raiseAlignmentError
in`_check_alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment is a core xarray concept separate of datatree. My suggestion was to change the
ValueErrors
raised inalignment.py
to becomeAlignmentErrors
, thendatatree.py
would automatically throwAlignmentError
when_check_alignment
is called (because it callsxr.align
internally).This suggestion is outside the scope of this PR though - you should go ahead with just using
match
to match a specificValueError
and then we can maybe doAlignmentError
in a separate PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in the last commit 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the order of merging to expect, but if @flamingbear merges #9033 first, then we can clean up the imports and use
xr.open_datatree
. If it's the other way around, then it'll probably be best for one of us to take a quick skim over the tests and tidy them up in a separate PR.My guess is that this PR will merge before #9033, so we'll likely end up with a separate tiny PR for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tidying up these imports isn't a big deal, and can be left for another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.identical
is going to be different to check if the coordinates are defined on disk.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically see #9473.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so from looking at this and testing this locally I don't think this will affect these tests.