Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressive handler for fsspec block_size ValueError #142

Merged
merged 17 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/py3.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- codecov
- dask
- distributed
- fsspec>=2021.04.0
- fsspec>=2021.6.0
- h5netcdf
- h5py
- hdf5
Expand Down
2 changes: 1 addition & 1 deletion ci/py3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- codecov
- dask
- distributed
- fsspec>=2021.04.0
- fsspec>=2021.6.0
- h5netcdf
- h5py
- hdf5
Expand Down
2 changes: 1 addition & 1 deletion ci/py3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- codecov
- dask
- distributed
- fsspec>=2021.04.0
- fsspec>=2021.6.0
- h5netcdf
- h5py
- hdf5
Expand Down
9 changes: 8 additions & 1 deletion pangeo_forge_recipes/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Any, Iterator, Optional, Sequence, Union

import fsspec
from fsspec.implementations.http import BlockSizeError

logger = logging.getLogger(__name__)

Expand All @@ -29,7 +30,13 @@ def _copy_btw_filesystems(input_opener, output_opener, BLOCK_SIZE=10_000_000):
with output_opener as target:
while True:
logger.debug("_copy_btw_filesystems reading data")
data = source.read(BLOCK_SIZE)
try:
data = source.read(BLOCK_SIZE)
except BlockSizeError as e:
raise ValueError(
"Server does not permit random access to this file via Range requests. "
'Try re-instantiating recipe with `fsspec_open_kwargs={"block_size": 0}`'
) from e
if not data:
break
logger.debug(f"_copy_btw_filesystems copying block of {len(data)} bytes")
Expand Down