Skip to content

Commit

Permalink
Make seekable True by default for arrow (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant authored Feb 13, 2023
1 parent 6b2039c commit 35da646
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fsspec/implementations/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def rm(self, path, recursive=False, maxdepth=None):
self.fs.delete_file(path)

@wrap_exceptions
def _open(self, path, mode="rb", block_size=None, seekable=False, **kwargs):
def _open(self, path, mode="rb", block_size=None, seekable=True, **kwargs):
if mode == "rb":
if seekable:
method = self.fs.open_input_file
Expand Down Expand Up @@ -202,6 +202,14 @@ def modified(self, path):
path = self._strip_protocol(path)
return self.fs.get_file_info(path).mtime

def cat_file(self, path, start=None, end=None, **kwargs):
kwargs["seekable"] = start not in [None, 0]
return super().cat_file(path, start=None, end=None, **kwargs)

def get_file(self, rpath, lpath, **kwargs):
kwargs["seekable"] = False
super().get_file(rpath, lpath, **kwargs)


@mirror_from(
"stream",
Expand Down
5 changes: 5 additions & 0 deletions fsspec/implementations/tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,8 @@ def test_seekable(fs, remote_dir):
for seekable in [True, False]:
with fs.open(remote_dir + "/a.txt", "rb", seekable=seekable) as file:
assert file.seekable() == seekable
assert file.read() == data

with fs.open(remote_dir + "/a.txt", "rb", seekable=False) as file:
with pytest.raises(IOError):
file.seek(5)

0 comments on commit 35da646

Please sign in to comment.