Skip to content
Open
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
5 changes: 4 additions & 1 deletion fsspec/implementations/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def get_file(self, rpath, lpath, **kwargs):
"readable",
"writable",
"close",
"size",
"seekable",
],
)
Expand All @@ -241,6 +240,10 @@ def __init__(self, fs, stream, path, mode, block_size=None, **kwargs):
def __enter__(self):
return self

@property
def size(self):
return self.stream.size()

def __exit__(self, *args):
return self.close()

Expand Down
18 changes: 8 additions & 10 deletions fsspec/implementations/tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ def test_get_file_seekable_default(fs, remote_dir, tmp_path):

# Test default behavior (seekable=False)
local_file = tmp_path / "test_default.txt"
fs.get_file(remote_dir + "/test_file.txt", str(local_file))
with open(local_file, "rb") as f:
assert f.read() == data
with pytest.raises(OSError, match="only valid on seekable files"):
fs.get_file(remote_dir + "/test_file.txt", str(local_file))

# Test with explicit seekable=True
local_file_seekable = tmp_path / "test_seekable.txt"
Expand All @@ -292,11 +291,10 @@ def test_get_file_seekable_default(fs, remote_dir, tmp_path):

# Test with explicit seekable=False
local_file_not_seekable = tmp_path / "test_not_seekable.txt"
fs.get_file(
remote_dir + "/test_file.txt", str(local_file_not_seekable), seekable=False
)
with open(local_file_not_seekable, "rb") as f:
assert f.read() == data
with pytest.raises(OSError, match="only valid on seekable files"):
fs.get_file(
remote_dir + "/test_file.txt", str(local_file_not_seekable), seekable=False
)


def test_cat_file_seekable_override(fs, remote_dir):
Expand Down Expand Up @@ -333,7 +331,7 @@ def test_seekable_true_allows_size_method(fs, remote_dir):
with fs.open(test_file, "rb", seekable=True) as f:
assert f.seekable() is True
# Verify size() method works and returns correct size
file_size = f.size()
file_size = f.size
assert file_size == len(data)
# Also verify we can read the data
assert f.read() == data
Expand All @@ -353,6 +351,6 @@ def test_seekable_false_prevents_size_method(fs, remote_dir):
assert f.seekable() is False
# Verify size() raises OSError
with pytest.raises(OSError, match="only valid on seekable files"):
f.size()
_ = f.size
# Verify we can still read the data
assert f.read() == data
Loading