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
Dask fails when suppying filesystem or fs to dask.dataframe.read_parquet() #8677
documentationImprove or add to documentationenhancementImprove existing functionality or make things work betterneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.parquet
When reading parquet files from Azure Blob Storage, we are providing an fsspec compatible filesystem to pyarrow (via the adlfs package).
However, in read_parquet() Dask will always determine an alternative filesystems via the path argument (such as s3://).
If one tries to provide a filesystem directly via args/kwargs, we end up with "multiple values for argument" errors.
What you expected to happen:
Either dataset={"filesystem": fs} and/or fs=fs should be valid syntax for read_parquet(), and this setting should overrule the fs determined automatically by Dask from the path.
Minimal Complete Verifiable Example:
## Real life fsspec example:# from adlfs import AzureBlobFileSystem# fs = AzureBlobFileSystem(account_name="myaccount", container_name="mycontainer", ...)# Local fsspec example for debugging:fromfsspec.implementations.localimportLocalFileSystemfs=LocalFileSystem()
importdask.dataframeasdddd.read_parquet(
path='foo.parquet',
engine="pyarrow-dataset",
dataset={"filesystem": fs}
)
# >> TypeError: dataset() got multiple values for keyword argument 'filesystem'dd.read_parquet(
path='foo.parquet',
engine="pyarrow-dataset",
fs=fs
)
# >> TypeError: read_metadata() got multiple values for argument 'fs'
Anything else we need to know?:
Current call to get_fs_token_paths() returning the authoritarian fs:
@th0ger - Can you please try specifying storage_options (as described here). I see that the read_parquet documentation on storage_options is a bit light - Perhaps we should improve the docstring a bit?
It is indeed true that Dask will always consruct its own fsspec-based file-system object (no matter the backend engine).
It is possible to override the file-open function at read time with open_file_options, but Dask will still use the internally-generated filesystem for initial metadata parsing. I'm sure it is possible to allow the backend to completely override file-system generation, but I'm not really convinced that the current behavior is a problem (but will be happy to reconsider if storage_options doesn't resolve your needs here).
OK, some background;
I'm fairly new to working with both Arrow and Dask for interfacing with parquet.
I started with pyarrow, which does not have native support for Azure blob storage (ADLSGen2), but it was very easy to get to work, using their very clear guide on using fsspec-compatible filesystems with Arrow. I also turned to their new Dataset API for better support on parquet partitions/predicate push down/projection.
I needed an engine to perform joins between two parquet datasets (local and/or remote), so I turned to Dask...
Support for arrow-dataset as backend - check! Support for passing kwargs to the backend - check!
I though it would be a walk in the park, but oh my, it's hard to understand how to pass all these wrapped kwargs to different areas of the backend. And when you finally find out how to pass kwargs correctly - dask implements some traps on fsspec that doesn't really allow you to pass kwargs fully anyway... I have read more dask backend code now than I should've.
@jsignell, in short, this is probably not a regression, but a feature request for something one would expect to work. But partly also a request for better documentation of what is (and isn't!) supported.
I did not read the entire Dask documentation, but did read Connect to remote data, which states that both "adl://, abfs:// or az://" protocols are supported, but also states that "fsspec also provides other file systems". Since I was comming from an angle with pyarrow+fsspec working (and not a connection string authentication), I picked the fsspec option. That was clearly a mistake to follow that path.
I tested your recommendations @rjzamora and the following works:
Thanks for writing this up @th0ger! Knowing about your experience is super valuable!
Support for passing kwargs to the backend - check!
Ah yes. This is a mess for a variety of reasons, but there is certainly no excuse for it to be quite as rough as it is. Cleaning this up (and addressing #8491) is on my short list.
I though it would be a walk in the park, but oh my, it's hard to understand how to pass all these wrapped kwargs to different areas of the backend. And when you finally find out how to pass kwargs correctly - dask implements some traps on fsspec that doesn't really allow you to pass kwargs fully anyway... I have read more dask backend code now than I should've.
I completely agree with you. There is no reason someone should need to look at source code to figure out what to do. I do expect that I (and/or others) will be cleaning up kwarg-handling in the near future. It will also be nice when we finally drop pyarrow-legacy (and shed considerable tech debt in the process). However, what we absolutely need the most is clear documentation.
If you don't intend to change the behaviour stated in the issue, maybe:
Clarify in the the docs that fs and dataset={"filesystem": fs} must NOT be supplied in kwargs.
Raise an error that guides the user to the intended usage.
I suspect that it will be challenging to allow the user to pass a filesystem to the backend, but this may be doable. Either way, we should be able to improve user experience with better documentation and warnings. Regarding actual behavior change: I will keep this experience in mind when I take a stab at #8491. Also, suggestions/contributions from other is very welcome. The parquet API has evolved a lot during the last few years to adapt to a variety of upstream changes and down-stream needs. It could be time to introduce breaking changes if we ultimately decide that it’s necessary.
@rjzamora just checking in, what's the status on this issue? From your above comment it seems additional documentation and warnings would be helpful, should we open a separate issue for those changes? Thanks!
just checking in, what's the status on this issue? From your above comment it seems additional documentation and warnings would be helpful, should we open a separate issue for those changes? Thanks!
Thanks for the ping and sorry for missing this @scharlottej13 ! I am hoping that I can clean up #8765 to make it easier to pass custom pyarrow.dataset.Dataset (or fastparquet.ParquetFile) options and improve the errors/warnings when unsupported arguments are passed. However, I do think a dedicated documentation issue makes sense - Hopefully #8772 covers what we want/need.
documentationImprove or add to documentationenhancementImprove existing functionality or make things work betterneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.parquet
Activity
jsignell commentedon Feb 9, 2022
It's not totally clear from your writeup if this is a regression or a request for an enhancement. Can you clarify if this used to work?
Ping @martindurant and @rjzamora for fsspec/parquet expertise.
rjzamora commentedon Feb 9, 2022
@th0ger - Can you please try specifying
storage_options(as described here). I see that theread_parquetdocumentation onstorage_optionsis a bit light - Perhaps we should improve the docstring a bit?It is indeed true that Dask will always consruct its own fsspec-based file-system object (no matter the backend engine).
It is possible to override the file-open function at read time with
open_file_options, but Dask will still use the internally-generated filesystem for initial metadata parsing. I'm sure it is possible to allow the backend to completely override file-system generation, but I'm not really convinced that the current behavior is a problem (but will be happy to reconsider ifstorage_optionsdoesn't resolve your needs here).th0ger commentedon Feb 10, 2022
OK, some background;
I'm fairly new to working with both Arrow and Dask for interfacing with parquet.
I started with pyarrow, which does not have native support for Azure blob storage (ADLSGen2), but it was very easy to get to work, using their very clear guide on using fsspec-compatible filesystems with Arrow. I also turned to their new Dataset API for better support on parquet partitions/predicate push down/projection.
I needed an engine to perform joins between two parquet datasets (local and/or remote), so I turned to Dask...
Support for arrow-dataset as backend - check! Support for passing kwargs to the backend - check!
I though it would be a walk in the park, but oh my, it's hard to understand how to pass all these wrapped kwargs to different areas of the backend. And when you finally find out how to pass kwargs correctly - dask implements some traps on fsspec that doesn't really allow you to pass kwargs fully anyway... I have read more dask backend code now than I should've.
@jsignell, in short, this is probably not a regression, but a feature request for something one would expect to work. But partly also a request for better documentation of what is (and isn't!) supported.
I did not read the entire Dask documentation, but did read Connect to remote data, which states that both "adl://, abfs:// or az://" protocols are supported, but also states that "fsspec also provides other file systems". Since I was comming from an angle with pyarrow+fsspec working (and not a connection string authentication), I picked the fsspec option. That was clearly a mistake to follow that path.
I tested your recommendations @rjzamora and the following works:
(Couldn't get client based auth to work with ADLSGen2 though; adlfs issue 299.)
If you don't intend to change the behaviour stated in the issue, maybe:
fsanddataset={"filesystem": fs}must NOT be supplied in kwargs.rjzamora commentedon Feb 11, 2022
Thanks for writing this up @th0ger! Knowing about your experience is super valuable!
Ah yes. This is a mess for a variety of reasons, but there is certainly no excuse for it to be quite as rough as it is. Cleaning this up (and addressing #8491) is on my short list.
I completely agree with you. There is no reason someone should need to look at source code to figure out what to do. I do expect that I (and/or others) will be cleaning up kwarg-handling in the near future. It will also be nice when we finally drop pyarrow-legacy (and shed considerable tech debt in the process). However, what we absolutely need the most is clear documentation.
I suspect that it will be challenging to allow the user to pass a filesystem to the backend, but this may be doable. Either way, we should be able to improve user experience with better documentation and warnings. Regarding actual behavior change: I will keep this experience in mind when I take a stab at #8491. Also, suggestions/contributions from other is very welcome. The parquet API has evolved a lot during the last few years to adapt to a variety of upstream changes and down-stream needs. It could be time to introduce breaking changes if we ultimately decide that it’s necessary.
scharlottej13 commentedon Feb 23, 2022
@rjzamora just checking in, what's the status on this issue? From your above comment it seems additional documentation and warnings would be helpful, should we open a separate issue for those changes? Thanks!
rjzamora commentedon Mar 2, 2022
Thanks for the ping and sorry for missing this @scharlottej13 ! I am hoping that I can clean up #8765 to make it easier to pass custom
pyarrow.dataset.Dataset(orfastparquet.ParquetFile) options and improve the errors/warnings when unsupported arguments are passed. However, I do think a dedicated documentation issue makes sense - Hopefully #8772 covers what we want/need.nastyakul commentedon Mar 21, 2023
Hi! I'm facing the same issue while using
dd.read_csvwith Azure-Datalake Gen2 Storage. Any tips how to resolve this?martindurant commentedon Mar 21, 2023
Passing a filesystem to read_parquet, the purpose of this issue, has been implemented, so this issue should be closed.
@nastyakul , not sure what problem you are facing or what behaviour you are missing - you might want to start a new issue with more details.