Skip to content

Commit 0042c63

Browse files
authored
Strip protocol in arrowfs.ls and add tests for calling arrowfs with protocol (#1099)
1 parent b9a508f commit 0042c63

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

fsspec/implementations/arrow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def _strip_protocol(cls, path):
5959
return path
6060

6161
def ls(self, path, detail=False, **kwargs):
62+
path = self._strip_protocol(path)
6263
from pyarrow.fs import FileSelector
6364

6465
entries = [

fsspec/implementations/tests/test_arrow.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def fs():
1414
return ArrowFSWrapper(fs)
1515

1616

17-
@pytest.fixture(scope="function")
18-
def remote_dir(fs):
17+
@pytest.fixture(scope="function", params=[False, True])
18+
def remote_dir(fs, request):
1919
directory = secrets.token_hex(16)
2020
fs.makedirs(directory)
21-
yield directory
21+
yield ("hdfs://" if request.param else "") + directory
2222
fs.rm(directory, recursive=True)
2323

2424

@@ -30,18 +30,19 @@ def strip_keys(original_entry):
3030

3131
def test_info(fs, remote_dir):
3232
fs.touch(remote_dir + "/a.txt")
33+
remote_dir_strip_protocol = fs._strip_protocol(remote_dir)
3334
details = fs.info(remote_dir + "/a.txt")
3435
assert details["type"] == "file"
35-
assert details["name"] == remote_dir + "/a.txt"
36+
assert details["name"] == remote_dir_strip_protocol + "/a.txt"
3637
assert details["size"] == 0
3738

3839
fs.mkdir(remote_dir + "/dir")
3940
details = fs.info(remote_dir + "/dir")
4041
assert details["type"] == "directory"
41-
assert details["name"] == remote_dir + "/dir"
42+
assert details["name"] == remote_dir_strip_protocol + "/dir"
4243

4344
details = fs.info(remote_dir + "/dir/")
44-
assert details["name"] == remote_dir + "/dir/"
45+
assert details["name"] == remote_dir_strip_protocol + "/dir/"
4546

4647

4748
def test_move(fs, remote_dir):
@@ -114,12 +115,14 @@ def test_rm(fs, remote_dir):
114115

115116

116117
def test_ls(fs, remote_dir):
118+
remote_dir_strip_protocol = fs._strip_protocol(remote_dir)
117119
fs.mkdir(remote_dir + "dir/")
118120
files = set()
119121
for no in range(8):
120122
file = remote_dir + f"dir/test_{no}"
123+
# we also want to make sure `fs.touch` works with protocol
121124
fs.touch(file)
122-
files.add(file)
125+
files.add(remote_dir_strip_protocol + f"dir/test_{no}")
123126

124127
assert set(fs.ls(remote_dir + "dir/")) == files
125128

0 commit comments

Comments
 (0)