download a folder using recursive gives FileNotFoundError but works
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1k
- Forks
- 305
- Avg merge
- 22h 37m
- Merged PRs (30d)
- 4
Description
What happened:
I was debugging something over at aldfs (https://github.com/dask/adlfs/issues/120) and wanted to see the behavior of s3fs.
What you expected to happen:
I download a folder to local.
Minimal Complete Verifiable Example:
This downloads the remote folder '00' to a local folder '00
import s3fs
fs = s3fs.S3FileSystem(anon=True)
fs.get("noaa-goes16/ABI-L2-MCMIPC/2020/001/00", "00", recursive=True)
This returns
>>> fs.get("noaa-goes16/ABI-L2-MCMIPC/2020/001/00", "00", recursive=True)
Traceback (most recent call last):
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/s3fs/core.py", line 207, in _call_s3
return await method(**additional_kwargs)
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/aiobotocore/client.py", line 151, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/fsspec/asyn.py", line 278, in get
return sync(self.loop, self._get, rpaths, lpaths)
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/fsspec/asyn.py", line 68, in sync
raise exc.with_traceback(tb)
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/fsspec/asyn.py", line 52, in f
result[0] = await future
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/fsspec/asyn.py", line 263, in _get
return await asyncio.gather(
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/s3fs/core.py", line 694, in _get_file
resp = await self._call_s3(
File "/Users/Ray/miniconda3/envs/main/lib/python3.8/site-packages/s3fs/core.py", line 225, in _call_s3
raise translate_boto_error(err) from err
FileNotFoundError: The specified key does not exist.
However, the process still runs in the background and gives the desired output.

Anything else we need to know?:
Environment:
- Dask version: 2.29.0
- Python version: 3.8.5
- Operating System: Mac
- Install method (conda, pip, source): Conda
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in s3fs/core.py at _get_file and compare it with the fsspec/asyn.py _get path shown in the traceback. Reproduce the recursive fs.get call against the NOAA S3 path, then trace why a FileNotFoundError is raised even though the folder is downloaded. Done means the recursive download completes without the misleading exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100