Skip to content

Commit

Permalink
fix the incorrect list of ends for _cat_ranges (#1402)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Durant <[email protected]>
  • Loading branch information
AlbertXingZhang and martindurant authored Oct 26, 2023
1 parent e20f626 commit 71262d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion fsspec/asyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ async def _cat_ranges(
on_error="return",
**kwargs,
):
"""Get the contents of byte ranges from one or more files
Parameters
----------
paths: list
A list of of filepaths on this filesystems
starts, ends: int or list
Bytes limits of the read. If using a single int, the same value will be
used to read all the specified files.
"""
# TODO: on_error
if max_gap is not None:
# use utils.merge_offset_ranges
Expand All @@ -476,7 +486,7 @@ async def _cat_ranges(
if not isinstance(starts, Iterable):
starts = [starts] * len(paths)
if not isinstance(ends, Iterable):
ends = [starts] * len(paths)
ends = [ends] * len(paths)
if len(starts) != len(paths) or len(ends) != len(paths):
raise ValueError
coros = [
Expand Down
12 changes: 11 additions & 1 deletion fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,24 @@ def pipe(self, path, value=None, **kwargs):
def cat_ranges(
self, paths, starts, ends, max_gap=None, on_error="return", **kwargs
):
"""Get the contents of byte ranges from one or more files
Parameters
----------
paths: list
A list of of filepaths on this filesystems
starts, ends: int or list
Bytes limits of the read. If using a single int, the same value will be
used to read all the specified files.
"""
if max_gap is not None:
raise NotImplementedError
if not isinstance(paths, list):
raise TypeError
if not isinstance(starts, list):
starts = [starts] * len(paths)
if not isinstance(ends, list):
ends = [starts] * len(paths)
ends = [ends] * len(paths)
if len(starts) != len(paths) or len(ends) != len(paths):
raise ValueError
out = []
Expand Down

0 comments on commit 71262d1

Please sign in to comment.