-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
fix/normalize storage paths #2384
Conversation
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.
Good stuff @d-v-b - I'm glad we're moving path
into make_store_path
.
Co-authored-by: Joe Hamman <[email protected]>
…x/normalize-storage-paths
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, a couple questions about the implementation.
One meta-comment I've been thinking about, probably for a future PR: we could define PathLike
as a NewType. The user-facing API could accept str | PathLike
, and internally we could use just PathLike
. Then we can verify with mypy that we've normalized all paths provided by the user.
This PR adds some of the path normalization logic from zarr v2 into v3. I largely copied this function as-is with a few tweaks. That function is actually not terribly strict as far as path parsing is concerned, so I'm open to requests that we make it stricter. The main thing to note is that
normalize_path
(the new name for that function) strips leading/
characters from strings, which ensures that paths are relative.I wired this function up to
make_store_path
, which previously didn't takepath
as a parameter (now it does). This led to some nice code deletion opportunities in our various creation routines.Something that always bugged me in zarr v2 was use of
None
as a default value for types where there's already a default value. In the case of strings, the empty string''
is a perfectly good default value, and so allowingNone
is just noise IMO. I was tempted to try and removeNone
as a valid path argument in this PR, but I held back. If people agree thatNone
is a silly default for a stringy value likepath
when we can just use''
instead, then I can make that change as well.Fixes #2357
TODO: