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
This commit is contained in:
parent
946400fb68
commit
f2b744f690
|
@ -37,6 +37,7 @@ from pathlib import Path
|
|||
from types import ModuleType
|
||||
from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union
|
||||
from urllib.parse import urlparse
|
||||
from uuid import uuid4
|
||||
from zipfile import ZipFile, is_zipfile
|
||||
|
||||
import numpy as np
|
||||
|
@ -217,6 +218,7 @@ if (
|
|||
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)
|
||||
TRANSFORMERS_CACHE = os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE)
|
||||
SESSION_ID = uuid4().hex
|
||||
DISABLE_TELEMETRY = os.getenv("DISABLE_TELEMETRY", False)
|
||||
|
||||
WEIGHTS_NAME = "pytorch_model.bin"
|
||||
|
@ -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.
|
||||
"""
|
||||
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():
|
||||
ua += f"; torch/{_torch_version}"
|
||||
if is_tf_available():
|
||||
|
|
Loading…
Reference in New Issue