Repository navigation
Closed
Labels
dataframeioneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.parquet
Description
I attempted to load a large Parquet dataset on S3 with
import dask.dataframe as dd
df = dd.read_parquet("s3://oss-shared-scratch/timeseries.parquet", storage_options=storage_options)but encountered the following error from pyarrow (full traceback down below):
OSError: Passed non-file path: oss-shared-scratch/timeseries.parquetI'm not sure if the underlying issue is with pyarrow or dask or fsspec. I'll attempt to create a minimal reproducer, but thought the traceback might be useful by itself.
cc @jorisvandenbossche @rjzamora
Full traceback:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<timed exec> in <module>
~/projects/dask/dask/dask/dataframe/io/parquet/core.py in read_parquet(path, columns, filters, categories, index, storage_options, engine, gather_statistics, split_row_groups, read_from_paths, chunksize, aggregate_files, **kwargs)
314 gather_statistics = True
315
--> 316 read_metadata_result = engine.read_metadata(
317 fs,
318 paths,
~/projects/dask/dask/dask/dataframe/io/parquet/arrow.py in read_metadata(cls, fs, paths, categories, index, gather_statistics, filters, split_row_groups, read_from_paths, chunksize, aggregate_files, **kwargs)
540 split_row_groups,
541 gather_statistics,
--> 542 ) = cls._gather_metadata(
543 paths,
544 fs,
~/projects/dask/dask/dask/dataframe/io/parquet/arrow.py in _gather_metadata(cls, paths, fs, split_row_groups, gather_statistics, filters, index, dataset_kwargs)
1786
1787 # Step 1: Create a ParquetDataset object
-> 1788 dataset, base, fns = _get_dataset_object(paths, fs, filters, dataset_kwargs)
1789 if fns == [None]:
1790 # This is a single file. No danger in gathering statistics
~/projects/dask/dask/dask/dataframe/io/parquet/arrow.py in _get_dataset_object(paths, fs, filters, dataset_kwargs)
1754 base = paths[0]
1755 fns = [None]
-> 1756 dataset = pq.ParquetDataset(paths[0], filesystem=fs, **kwargs)
1757
1758 return dataset, base, fns
~/mambaforge/envs/coiled/lib/python3.9/site-packages/pyarrow/parquet.py in __init__(self, path_or_paths, filesystem, schema, metadata, split_row_groups, validate_schema, filters, metadata_nthreads, read_dictionary, memory_map, buffer_size, partitioning, use_legacy_dataset, pre_buffer, coerce_int96_timestamp_unit)
1330 self._partitions,
1331 self.common_metadata_path,
-> 1332 self.metadata_path) = _make_manifest(
1333 path_or_paths, self._fs, metadata_nthreads=metadata_nthreads,
1334 open_file_func=partial(_open_dataset_file, self._metadata)
~/mambaforge/envs/coiled/lib/python3.9/site-packages/pyarrow/parquet.py in _make_manifest(path_or_paths, fs, pathsep, metadata_nthreads, open_file_func)
1577 for path in path_or_paths:
1578 if not fs.isfile(path):
-> 1579 raise OSError('Passed non-file path: {}'
1580 .format(path))
1581 piece = ParquetDatasetPiece._create(
OSError: Passed non-file path: oss-shared-scratch/timeseries.parquetMetadata
Metadata
Assignees
Labels
dataframeioneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.parquet
Activity
jorisvandenbossche commentedon Aug 13, 2021
From the traceback, it seems this is a problem with
fs(an fsspec / s3fs filesystem) not recognizing it correctly as a file or directory (not sure which of the two would be correct?)Is the file publicly accessible? (or do you see something similar with a publicly accessible bucket?)
jorisvandenbossche commentedon Aug 13, 2021
Also, which version of dask are you using? If not latest main branch, can you check with
engine=pyarrow-dataset? (the traceback seems to indicate that you are using the legacy engine)mrocklin commentedon Aug 17, 2021
Ping @jrbourbeau to put this on his inbox in the morning.
jrbourbeau commentedon Aug 25, 2021
Sorry for the delayed response. Here's a minimal reproducer
I've run this locally using
mainbranch ofdaskanddistributedpyarrow=5.0.0fastparquet=0.7.1s3fs=2021.7.0which produces an error with both the
pyarrow-datasetandfastparquetengines (errors included below).pyarrow-dataset traceback:
fastparquet traceback:
Interestingly, I also found that:
s3fscache betweento_parquetandread_parquetcalls, then everything runs as expectedread_parquetcall, without theto_parquetcall, then everything runs as expected.All this makes me think that perhaps the underlying issue has to do with
s3fs, and not Dask itself. I'm not sure though, this is just a hunch. cc @martindurantmartindurant commentedon Aug 26, 2021
Oh no, it passes for me! :) 50MB isn't that small on my home internet.
So probably what is happening, is that files are being written to paths within the bucket by the workers, and the s3fs instance in the client doesn't know about any change to the bucket status. So any cached file listings will become out of date, leading to the FileNotFound.
This all suggests that any dask write operation should aggressively call
.invalidate_cacheon any filesystem it uses. All fsspec filesystems have this method, even if they don't maintain a listings cache. In fact, the workers should do this too, because it may happen that some worker didn't happen to write a file in some particular workload, but already had an instance with now outdated listings.So, we face a conflict between the potentially large savings of reusing s3 instances and caching file listings (in the client and workers) versus having to orchestrate filesystem instances across the cluster. We've thought a bit about the latter more in the context of atomicity, only finalise all the files when every task has finished; but this idea has not yet been fleshed out.
Of course, it's possible to turn off file listings caching while still reusing instances (
use_listings_cache=False). That might be an OK general recommendation for cases like this.jrbourbeau commentedon Aug 26, 2021
Thanks for the additional details @martindurant, that's quite useful to know. Passing
use_listings_cache=Falsethroughstorage_optionsindeed resolves theFileNotFoundErrorfailure in the above snippet.Do you have thoughts on how we should improve the current situation? We could
use_listings_cacheto beFalseby default infsspec(this may be an overreaction)use_listings_cache=Falsein Dask'sstorage_options(if not already specified by the user)invalidate_cachecalls when performing write operations in Dask (I'd prefer thestorage_optionsapproach)FWIW when running parquet + S3 workloads, I came across a variety of seemingly strange errors related to caching in
s3fs. I was able to look around and found some issues which said to uses3fs.S3FileSystem.clear_instance_cache(). This worked in most (maybe all?) cases, but I wouldn't expect most Dask users to hunts3fs.S3FileSystem.clear_instance_cache()down.martindurant commentedon Aug 27, 2021
Let me dump a little information here, and then we can figure out where it should be stored...
There are FOUR kinds of cache in fsspec:
Noneto clear all paths. You can set how the cache behaves with instance arguments use_listings_cache, listings_expiry_time, max_pathscache_typesome with various options. These live with the file instance while it is open.I would argue, to your question, that clear_instance_cache is a bad idea, since you incur the cost of new connections and auth in every dask task. Either use_listings_cache=False or appropriate calls to invalidate_cache() are the reasonable choices here. Or, we could somehow make the listings cache itself smarter. Currently it only has a simple TTL, which might actually already be enough for the situation at hand.
jcrist commentedon Apr 13, 2022
Summarizing the state of this issue, it looks like there are 2 suggested solutions:
fs.invalidate_cache()in non-read operations. (wouldn't this still not work if files were written by an external process before aread_parquetcall?)AFAICT the former should always work but may lead to performance issues, while the latter may work but would fail if something was modified external to the process doing the listing. Is that accurate?
A third option would be to:
read_parquet) call on the client. This ensures all files are always found when setting up a graph for a read.I think this would be sufficient - the generated graph would always contain all files, and it would let caching on the workers still work during reads for any performance benefits that may have (are there any for read calls?).
If this more complicated third option doesn't get us anything, I'd opt for the first option, as it's simple to implement. @martindurant can you add some color into the performance impacts we might see from disabling caching using the strategies above? Should we worry about such a change?
jcrist commentedon Apr 27, 2022
@martindurant , if you have a moment I'd appreciate some fsspec advice here ^^
martindurant commentedon Apr 27, 2022
Listing files on s3 can be slow, because a limited number of files are returned in each call (with a surprising amount of bytes, due to XML encoding and lots of details), and you need to paginate through serially. Since we are explicitly moving towards a no _metadata and many datafiles in many directories model, this cost will be bigger in the future. You would notice not caching particularly if you had reason to
dd.read_parquetmultiple times on the same dataset, perhaps because you want to try different options.(If there were a _metadata, there would be no need to list at all. Of course, my intuition might be out of date by now...)
Correct, you can always have stale info when files are modified in another process. If all you want to do is open a file with known path, that's probably always fine, so this only matters on the client. Which argues that it doesn't matter much whether you have it on the workers.
One note: sharing FS instances is good for cutting the cost of establishing connections/credentials; if the uses has one they are using to list files and find their data, with the default listings cache, and we choose to make a another one without, then it will be a separate instance and session. This point argues (weakly) towards invalidating the cache rather than disabling it.
jcrist commentedon Apr 27, 2022
Based on your comment above, I think the 2nd option (call
fs.invalidate_cache()in non-read operations) might make the most sense then? We'd haveto_parquetinvalidate the local (client side) cache before returning. This gets a bit weird ifcompute=False, but I think it's still what we want to do. This would solve the specific issue here, and shouldn't be too costly in the normal case. I also think we wouldn't need to callinvalidate_cacheever on the workers, since the real issue here is with listings and those never happen on the workers?martindurant commentedon Apr 27, 2022
The workers should invalidate their cache for the specific directory they are writing into anyway. So yes, agreed.
jcrist commentedon Apr 28, 2022
#8994.