Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Protocol Prefixed Paths for WebHDFS #1761

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
13 changes: 13 additions & 0 deletions fsspec/implementations/tests/test_webhdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,16 @@ def test_write_read_verify_file_with_equals(hdfs_cluster):
assert len(file_info) == 1
assert file_info[0]["name"] == file_path
assert file_info[0]["size"] == len(content)


def test_protocol_prefixed_path(hdfs_cluster):
fs = WebHDFS(
hdfs_cluster, user="testuser", data_proxy={"worker.example.com": "localhost"}
)
protocol_prefixed_path = "webhdfs://localhost:50070/user/testuser/test_dir"

fs.mkdir(protocol_prefixed_path)
assert fs.exists(protocol_prefixed_path)

file_info = fs.ls(protocol_prefixed_path, detail=True)
assert len(file_info) == 0
3 changes: 2 additions & 1 deletion fsspec/implementations/webhdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def _connect(self):
self.session.auth = HTTPBasicAuth(self.user, self.password)

def _call(self, op, method="get", path=None, data=None, redirect=True, **kwargs):
url = self._apply_proxy(self.url + quote(path or "", safe="/="))
path = self._strip_protocol(path) if path is not None else ""
url = self._apply_proxy(self.url + quote(path, safe="/="))
args = kwargs.copy()
args.update(self.pars)
args["op"] = op.upper()
Expand Down
Loading