Skip to content

Commit c36066c

Browse files
authored
fix: allow protocol prefixed paths for webhdfs (#1761)
1 parent 5ac1500 commit c36066c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

fsspec/implementations/tests/test_webhdfs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,16 @@ def test_write_read_verify_file_with_equals(hdfs_cluster):
195195
assert len(file_info) == 1
196196
assert file_info[0]["name"] == file_path
197197
assert file_info[0]["size"] == len(content)
198+
199+
200+
def test_protocol_prefixed_path(hdfs_cluster):
201+
fs = WebHDFS(
202+
hdfs_cluster, user="testuser", data_proxy={"worker.example.com": "localhost"}
203+
)
204+
protocol_prefixed_path = "webhdfs://localhost:50070/user/testuser/test_dir"
205+
206+
fs.mkdir(protocol_prefixed_path)
207+
assert fs.exists(protocol_prefixed_path)
208+
209+
file_info = fs.ls(protocol_prefixed_path, detail=True)
210+
assert len(file_info) == 0

fsspec/implementations/webhdfs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def _connect(self):
166166
self.session.auth = HTTPBasicAuth(self.user, self.password)
167167

168168
def _call(self, op, method="get", path=None, data=None, redirect=True, **kwargs):
169-
url = self._apply_proxy(self.url + quote(path or "", safe="/="))
169+
path = self._strip_protocol(path) if path is not None else ""
170+
url = self._apply_proxy(self.url + quote(path, safe="/="))
170171
args = kwargs.copy()
171172
args.update(self.pars)
172173
args["op"] = op.upper()

0 commit comments

Comments
 (0)