Skip to content

Commit f5637d5

Browse files
sispefiop
authored andcommittedDec 5, 2023
refactor: use explicit client keyword arguments
1 parent 9b70522 commit f5637d5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed
 

‎dvc_http/__init__.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ class HTTPFileSystem(FileSystem):
4343
SESSION_BACKOFF_FACTOR = 0.1
4444
REQUEST_TIMEOUT = 60
4545

46-
def __init__(self, fs=None, timeout=REQUEST_TIMEOUT, **kwargs):
46+
def __init__(
47+
self,
48+
fs=None,
49+
ssl_verify=None,
50+
read_timeout=REQUEST_TIMEOUT,
51+
connect_timeout=REQUEST_TIMEOUT,
52+
**kwargs,
53+
):
4754
super().__init__(fs, **kwargs)
4855

4956
self.fs_args["upload_method"] = kwargs.get("method", "POST")
5057
client_kwargs = self.fs_args.setdefault("client_kwargs", {})
5158
client_kwargs.update(
5259
{
53-
"ssl_verify": kwargs.get("ssl_verify"),
54-
"read_timeout": kwargs.get("read_timeout", timeout),
55-
"connect_timeout": kwargs.get("connect_timeout", timeout),
60+
"ssl_verify": ssl_verify,
61+
"read_timeout": read_timeout,
62+
"connect_timeout": connect_timeout,
5663
"trust_env": True, # Allow reading proxy configs from the env
5764
}
5865
)
@@ -92,7 +99,9 @@ def _prepare_credentials(self, **config):
9299
)
93100
return {"client_kwargs": client_kwargs}
94101

95-
async def get_client(self, **kwargs):
102+
async def get_client(
103+
self, ssl_verify, read_timeout, connect_timeout, **kwargs
104+
):
96105
import aiohttp
97106
from aiohttp_retry import ExponentialRetry
98107

@@ -110,19 +119,18 @@ async def get_client(self, **kwargs):
110119
# data blobs. We remove the total timeout, and only limit the time
111120
# that is spent when connecting to the remote server and waiting
112121
# for new data portions.
113-
connect_timeout = kwargs.pop("connect_timeout")
114122
kwargs["timeout"] = aiohttp.ClientTimeout(
115123
total=None,
116124
connect=connect_timeout,
117125
sock_connect=connect_timeout,
118-
sock_read=kwargs.pop("read_timeout"),
126+
sock_read=read_timeout,
119127
)
120128

121129
kwargs["connector"] = aiohttp.TCPConnector(
122130
# Force cleanup of closed SSL transports.
123131
# See https://github.com/iterative/dvc/issues/7414
124132
enable_cleanup_closed=True,
125-
ssl=make_context(kwargs.pop("ssl_verify", None)),
133+
ssl=make_context(ssl_verify),
126134
)
127135

128136
return ReadOnlyRetryClient(**kwargs)

0 commit comments

Comments
 (0)
Please sign in to comment.