Repository navigation
Closed
Description
When iterating on workflows, I find it useful to specify overwrite=True when writing out parquet datasets. Previously I had always been writing to an S3 bucket which already existed and everything worked as expected. Today I tried writing to a bucket which did not exist and hoped that to_parquet would create the bucket for me, however when I run this snippet:
import dask
df = dask.datasets.timeseries()
storage_options={
"config_kwargs": {"region_name": "us-east-1"},
}
df.to_parquet(
"s3://james-foo/timeseries.parquet",
# "james-foo/timeseries.parquet", # When using a local path, the necessary directories are created
engine="pyarrow-dataset",
storage_options=storage_options,
overwrite=True,
)I get the following FileNotFoundError: The specified bucket does not exist exception:
Traceback (most recent call last):
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/s3fs/core.py", line 574, in _lsdir
async for i in it:
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/aiobotocore/paginate.py", line 32, in __anext__
response = await self._make_request(current_kwargs)
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/aiobotocore/client.py", line 155, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchBucket: An error occurred (NoSuchBucket) when calling the ListObjectsV2 operation: The specified bucket does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/james/projects/dask/dask/test.py", line 10, in <module>
df.to_parquet(
File "/Users/james/projects/dask/dask/dask/dataframe/core.py", line 4440, in to_parquet
return to_parquet(self, path, *args, **kwargs)
File "/Users/james/projects/dask/dask/dask/dataframe/io/parquet/core.py", line 572, in to_parquet
if fs.isdir(path):
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/fsspec/asyn.py", line 88, in wrapper
return sync(self.loop, func, *args, **kwargs)
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/fsspec/asyn.py", line 69, in sync
raise result[0]
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/fsspec/asyn.py", line 25, in _runner
result[0] = await coro
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/s3fs/core.py", line 1161, in _isdir
return bool(await self._lsdir(path))
File "/Users/james/mambaforge/envs/dask/lib/python3.9/site-packages/s3fs/core.py", line 597, in _lsdir
raise translate_boto_error(e)
FileNotFoundError: The specified bucket does not exist
A couple of relevant things to note:
- If I set
overwrite=False, then the bucket is created and the above snippet runs successfully - If I use a local path, instead of on S3, then the appropriate local directories are also created
This makes me think there's a mismatch between how fsspec filesystems behave. cc @martindurant
Activity
martindurant commentedon Aug 19, 2021
Coming back to this, I wonder if it's possible to write a test with s3fs methods alone, which produces contradictory outputs for
isdirandexists? I have not been able to do it yet.jrbourbeau commentedon Aug 20, 2021
That's a fair point, here's what I've been able to come up with
when I run this locally I get the following
Note that
fs.exists(bad_path)returnsFalse, whilefs.isdir(bad_path)raises aFileNotFoundError: The specified bucket does not existerror. This is the type of discrepancy I was running into earlier withto_parquet+overwrite=Trueand what motivated me proposing thefs.existscheck in #8057.martindurant commentedon Aug 24, 2021
Close this?
jrbourbeau commentedon Aug 24, 2021
Yep, let's close via #8057 and continue to track over in fsspec/s3fs#519