-
-
Notifications
You must be signed in to change notification settings - Fork 329
Normalize paths when creating StorePath #2850
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
Conversation
The spec controls the characters that can be used, and the "separator" is configurable, so I'm finding it hard to see what other axis of flexbility exists. zarr-python/src/zarr/testing/strategies.py Lines 79 to 89 in e8bfb64
|
different key-value storage backends can set different rules about what keys are allowed. e.g., s3 and OSX might have different rules about file name length. It's not terrible if we end up parsing paths twice, but if there's a bug in one parsing path or the other, it would be annoying to look in two different classes to find that bug. I guess my broader complaint is that |
I believe so |
…into fix/node-name-resolution
@@ -277,6 +278,8 @@ def arrays( | |||
if a.metadata.zarr_format == 3: | |||
assert a.fill_value is not None | |||
assert a.name is not None | |||
assert a.path == normalize_path(array_path) |
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.
shall we delete line 287 then.
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.
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.
Can we merge this? I think it's blocking DataTree compatibility.
@dcherian could you review 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.
LGTM. Is this fixing a bug? (from the description it seems so?). If so, it should get a changelog entry explaining to users what's fixed. Also I left one minor test suggestion inline.
""" | ||
Test basic properties of groups |
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 do think the old test here is useful (in addition to the updated test), because it shows explicitly what the values of all the properties are, making it much easier to see what's changed if they change (which they might have done with this PR). So I'd be pro just copy/pasting the old test back here along with the new test?
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.
the new test is the same as the old test, but parametrized instead of 2 cases copy + pasted
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.
as a rule we should avoid tests that follow the "copy + pasted code blocks with minor modifications" pattern. these are huge source of friction when fixing bugs. that friction should be reduced by using parametrization where we can, as I did here.
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.
Agree that we shouldn't copy/paste with minor modifications, but I think one test that hard codes the results instead of using other properties is worthwhile to have.
…on into fix/node-name-resolution
In main we don't normalize paths when constructing an instance of
StorePath
, which means it's possible to create groups with names likea//b
. This PR fixes this behavior by ensuring that thepath
attribute ofStorePath
is normalized withnormalize_path
inStorePath.__init__
.There is potentially a problem here if different store classes have different rules about path names. This argues against the existence of a separate
StorePath
class, and in favor of allowingStore
instances to manage their current path.