Skip to content

Commit f4a4fcc

Browse files
committed
webhdfs: move code to _prepare_credentials
Addressing comment of @efiop
1 parent 1506cdc commit f4a4fcc

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

dvc_webhdfs/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,24 @@ def _prepare_credentials(self, **config):
4242
principal = config.pop("kerberos_principal", None)
4343
if principal:
4444
config["kerb_kwargs"] = {"principal": principal}
45+
46+
# If target data_proxy provided construct the source from host/port
47+
data_proxy_target = config.pop("data_proxy_target", None)
48+
if data_proxy_target:
49+
host = config["host"]
50+
port = config["port"]
51+
52+
protocol = "https" if config.get("use_https") else "http"
53+
54+
source_url = f"{protocol}://{host}:{port}/webhdfs/v1"
55+
config["data_proxy"] = {source_url: data_proxy_target}
4556
return config
4657

4758
@wrap_prop(threading.Lock())
4859
@cached_property
4960
def fs(self):
5061
from fsspec.implementations.webhdfs import WebHDFS
5162

52-
# If target data_proxy provided construct the source from host/port
53-
if "data_proxy_target" in self.fs_args:
54-
host = self.fs_args["host"]
55-
port = self.fs_args["port"]
56-
57-
protocol = "https" if self.fs_args.get("use_https") else "http"
58-
59-
source_url = f"{protocol}://{host}:{port}/webhdfs/v1"
60-
self.fs_args["data_proxy"] = {
61-
source_url: self.fs_args["data_proxy_target"]
62-
}
63-
6463
fs = WebHDFS(**self.fs_args)
6564
fs.session.verify = self._ssl_verify
6665
return fs

0 commit comments

Comments
 (0)