You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider supporting pathlib.Path within Dask Arrays .to_zarr(...) method #8006
Not sure if this should be raised in maybe the zarr repo, and I've looked through previous issues and couldn't find anything regarding this - it's feels like the Dask Array .to_zarr(...) method could support pathlib.Path (directly, i.e. without having to turn it into a str):
Thanks for raising an issue @asmith26! The error you're running into looks similar to zarr-developers/zarr-python#601. It looks like zarr itself doesn't have full support for pathlib.Path objects yet, but that it is currently in the works (xref zarr-developers/zarr-python#768). I agree it would be reasonable for Dask to support them
fsspec handles Path objects in a few places (e.g., fsspec.open), but not generally, because there is no consensus on how to represent non-local paths. I think zarr will defer to fsspec only if the path is URL-like (containing "://" or "::" - but probably not knowing to convert to string first), and fsspec.get_mapper does not support Path.
I encourage you to comment at drivendataorg/cloudpathlib#96 to push support for pathlib with fsspec. That would solve this kind of issue, without dask's explicit involvement, for local and remote paths both.
It looks like zarr itself doesn't have full support for pathlib.Path objects yet, but that it is currently in the works (xref zarr-developers/zarr-python#768)
That PR is now merged; zarr will accept pathlib.Path in its convenience methods and store constructors (although it does so by normalising to str) from the next release.
I could create a new issue it's so close to this one: while to_zarr works as expected, from_zarr still raises the error mentioned in the original post. It'd be great if it worked both ways!
Activity
jrbourbeau commentedon Aug 10, 2021
Thanks for raising an issue @asmith26! The error you're running into looks similar to zarr-developers/zarr-python#601. It looks like
zarritself doesn't have full support forpathlib.Pathobjects yet, but that it is currently in the works (xref zarr-developers/zarr-python#768). I agree it would be reasonable for Dask to support themcc @martindurant
martindurant commentedon Aug 10, 2021
fsspec handles Path objects in a few places (e.g.,
fsspec.open), but not generally, because there is no consensus on how to represent non-local paths. I think zarr will defer to fsspec only if the path is URL-like (containing "://" or "::" - but probably not knowing to convert to string first), andfsspec.get_mapperdoes not support Path.Do you think a
Pathis implicitly local?asmith26 commentedon Aug 11, 2021
Thanks for all the answers.
That's a good question - I had a little Google and would consider
pathlib.Pathto be intended only for local paths. In particular:pathlib.Pathsupports a.home()method, whilst for example s3 does not have the concept of "home"(as far as I'm aware?)pathlib.Pathwith s3 has been created: https://github.com/liormizr/s3pathThat said, I'm certainly no expert on
pathlib.Path, so all thoughts/corrections very welcome.martindurant commentedon Aug 11, 2021
I encourage you to comment at drivendataorg/cloudpathlib#96 to push support for pathlib with fsspec. That would solve this kind of issue, without dask's explicit involvement, for local and remote paths both.
clbarnes commentedon Aug 17, 2021
That PR is now merged; zarr will accept
pathlib.Pathin its convenience methods and store constructors (although it does so by normalising tostr) from the next release.clbarnes commentedon Sep 1, 2021
Zarr's convenience methods accept Path objects as of 2.9.0: https://zarr.readthedocs.io/en/stable/release.html#enhancements
jsignell commentedon Sep 1, 2021
I just reran the original reproducer with zarr=2.9.0 and it worked as expected, so I think we can safely close this.
jamestwebber commentedon Sep 21, 2021
I could create a new issue it's so close to this one: while
to_zarrworks as expected,from_zarrstill raises the error mentioned in the original post. It'd be great if it worked both ways!Just tested with
zarr=2.10anddask=2021.09.0jrbourbeau commentedon Sep 21, 2021
A new issue, or a PR, for
from_zarrwould be very welcome : )