diff --git a/src/transformers/file_utils.py b/src/transformers/file_utils.py index d710296fc0f559..0dfcefd9c49cfa 100644 --- a/src/transformers/file_utils.py +++ b/src/transformers/file_utils.py @@ -18,6 +18,7 @@ """ from huggingface_hub import get_full_repo_name # for backward compatibility +from huggingface_hub.constants import HF_HUB_DISABLE_TELEMETRY as DISABLE_TELEMETRY # for backward compatibility from . import __version__ @@ -25,7 +26,6 @@ from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, - DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, diff --git a/src/transformers/utils/__init__.py b/src/transformers/utils/__init__.py index e9e2f9e0403987..02959b329fd016 100644 --- a/src/transformers/utils/__init__.py +++ b/src/transformers/utils/__init__.py @@ -16,6 +16,7 @@ # limitations under the License. from huggingface_hub import get_full_repo_name # for backward compatibility +from huggingface_hub.constants import HF_HUB_DISABLE_TELEMETRY as DISABLE_TELEMETRY # for backward compatibility from packaging import version from .. import __version__ @@ -60,7 +61,6 @@ ) from .hub import ( CLOUDFRONT_DISTRIB_PREFIX, - DISABLE_TELEMETRY, HF_MODULES_CACHE, HUGGINGFACE_CO_PREFIX, HUGGINGFACE_CO_RESOLVE_ENDPOINT, diff --git a/src/transformers/utils/hub.py b/src/transformers/utils/hub.py index 6ab1670ea37cf3..83ef69b5f37213 100644 --- a/src/transformers/utils/hub.py +++ b/src/transformers/utils/hub.py @@ -115,7 +115,6 @@ def is_offline_mode(): HF_MODULES_CACHE = os.getenv("HF_MODULES_CACHE", os.path.join(constants.HF_HOME, "modules")) TRANSFORMERS_DYNAMIC_MODULE_NAME = "transformers_modules" SESSION_ID = uuid4().hex -DISABLE_TELEMETRY = os.getenv("DISABLE_TELEMETRY", constants.HF_HUB_DISABLE_TELEMETRY) in ENV_VARS_TRUE_VALUES # Add deprecation warning for old environment variables. for key in ("PYTORCH_PRETRAINED_BERT_CACHE", "PYTORCH_TRANSFORMERS_CACHE", "TRANSFORMERS_CACHE"): @@ -124,11 +123,6 @@ def is_offline_mode(): f"Using `{key}` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.", FutureWarning, ) -if os.getenv("DISABLE_TELEMETRY") is not None: - warnings.warn( - "Using `DISABLE_TELEMETRY` is deprecated and will be removed in v5 of Transformers. Use `HF_HUB_DISABLE_TELEMETRY` instead.", - FutureWarning, - ) S3_BUCKET_PREFIX = "https://s3.amazonaws.com/models.huggingface.co/bert" @@ -229,7 +223,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str: ua += f"; torch/{_torch_version}" if is_tf_available(): ua += f"; tensorflow/{_tf_version}" - if DISABLE_TELEMETRY: + if constants.HF_HUB_DISABLE_TELEMETRY: return ua + "; telemetry/off" if is_training_run_on_sagemaker(): ua += "; " + "; ".join(f"{k}/{v}" for k, v in define_sagemaker_information().items())