[http] Tweak http user-agent (#2353)

This commit is contained in:
Julien Chaumond 2019-12-29 10:06:50 -05:00 committed by GitHub
parent f75bf05ce6
commit 0df4e62da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,7 +98,6 @@ def is_torch_available():
def is_tf_available():
return _tf_available
@ -274,6 +273,10 @@ def s3_get(url, temp_file, proxies=None):
def http_get(url, temp_file, proxies=None, resume_size=0, user_agent=None):
ua = "transformers/{}; python/{}".format(__version__, sys.version.split()[0])
if is_torch_available():
ua += "; torch/{}".format(torch.__version__)
if is_tf_available():
ua += "; tensorflow/{}".format(tf.__version__)
if isinstance(user_agent, dict):
ua += "; " + "; ".join("{}/{}".format(k, v) for k, v in user_agent.items())
elif isinstance(user_agent, str):