"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "90cb55bf773d6879441616e6378d16971b557868"
Unverified Commit f2b744f6 authored by Philipp Schmid's avatar Philipp Schmid Committed by GitHub
Browse files

Add transformers id to hub requests (#10811)

* add uuid.hext to user_agent

* add log

* changed order of it

* renamed as session id

* renamed variable

* reverted naming of the const
parent 946400fb
...@@ -37,6 +37,7 @@ from pathlib import Path ...@@ -37,6 +37,7 @@ from pathlib import Path
from types import ModuleType from types import ModuleType
from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union
from urllib.parse import urlparse from urllib.parse import urlparse
from uuid import uuid4
from zipfile import ZipFile, is_zipfile from zipfile import ZipFile, is_zipfile
import numpy as np import numpy as np
...@@ -217,6 +218,7 @@ if ( ...@@ -217,6 +218,7 @@ if (
PYTORCH_PRETRAINED_BERT_CACHE = os.getenv("PYTORCH_PRETRAINED_BERT_CACHE", default_cache_path) PYTORCH_PRETRAINED_BERT_CACHE = os.getenv("PYTORCH_PRETRAINED_BERT_CACHE", default_cache_path)
PYTORCH_TRANSFORMERS_CACHE = os.getenv("PYTORCH_TRANSFORMERS_CACHE", PYTORCH_PRETRAINED_BERT_CACHE) PYTORCH_TRANSFORMERS_CACHE = os.getenv("PYTORCH_TRANSFORMERS_CACHE", PYTORCH_PRETRAINED_BERT_CACHE)
TRANSFORMERS_CACHE = os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE) TRANSFORMERS_CACHE = os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE)
SESSION_ID = uuid4().hex
DISABLE_TELEMETRY = os.getenv("DISABLE_TELEMETRY", False) DISABLE_TELEMETRY = os.getenv("DISABLE_TELEMETRY", False)
WEIGHTS_NAME = "pytorch_model.bin" WEIGHTS_NAME = "pytorch_model.bin"
...@@ -1215,7 +1217,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str: ...@@ -1215,7 +1217,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
""" """
Formats a user-agent string with basic info about a request. Formats a user-agent string with basic info about a request.
""" """
ua = "transformers/{}; python/{}".format(__version__, sys.version.split()[0]) ua = f"transformers/{__version__}; python/{sys.version.split()[0]}; session_id/{SESSION_ID}"
if is_torch_available(): if is_torch_available():
ua += f"; torch/{_torch_version}" ua += f"; torch/{_torch_version}"
if is_tf_available(): if is_tf_available():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment