Unverified Commit 0695b242 authored by Lucain's avatar Lucain Committed by GitHub
Browse files

Remove warning if `DISABLE_TELEMETRY` is used (#28113)

remove warning if DISABLE_TELEMETRY is used
parent 7c5408da
...@@ -18,6 +18,7 @@ This module should not be update anymore and is only left for backward compatibi ...@@ -18,6 +18,7 @@ This module should not be update anymore and is only left for backward compatibi
""" """
from huggingface_hub import get_full_repo_name # for backward compatibility 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__ from . import __version__
...@@ -25,7 +26,6 @@ from . import __version__ ...@@ -25,7 +26,6 @@ from . import __version__
from .utils import ( from .utils import (
CLOUDFRONT_DISTRIB_PREFIX, CLOUDFRONT_DISTRIB_PREFIX,
CONFIG_NAME, CONFIG_NAME,
DISABLE_TELEMETRY,
DUMMY_INPUTS, DUMMY_INPUTS,
DUMMY_MASK, DUMMY_MASK,
ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_AND_AUTO_VALUES,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# limitations under the License. # limitations under the License.
from huggingface_hub import get_full_repo_name # for backward compatibility 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 packaging import version
from .. import __version__ from .. import __version__
...@@ -60,7 +61,6 @@ from .generic import ( ...@@ -60,7 +61,6 @@ from .generic import (
) )
from .hub import ( from .hub import (
CLOUDFRONT_DISTRIB_PREFIX, CLOUDFRONT_DISTRIB_PREFIX,
DISABLE_TELEMETRY,
HF_MODULES_CACHE, HF_MODULES_CACHE,
HUGGINGFACE_CO_PREFIX, HUGGINGFACE_CO_PREFIX,
HUGGINGFACE_CO_RESOLVE_ENDPOINT, HUGGINGFACE_CO_RESOLVE_ENDPOINT,
......
...@@ -115,7 +115,6 @@ if ( ...@@ -115,7 +115,6 @@ if (
HF_MODULES_CACHE = os.getenv("HF_MODULES_CACHE", os.path.join(constants.HF_HOME, "modules")) HF_MODULES_CACHE = os.getenv("HF_MODULES_CACHE", os.path.join(constants.HF_HOME, "modules"))
TRANSFORMERS_DYNAMIC_MODULE_NAME = "transformers_modules" TRANSFORMERS_DYNAMIC_MODULE_NAME = "transformers_modules"
SESSION_ID = uuid4().hex 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. # Add deprecation warning for old environment variables.
for key in ("PYTORCH_PRETRAINED_BERT_CACHE", "PYTORCH_TRANSFORMERS_CACHE", "TRANSFORMERS_CACHE"): for key in ("PYTORCH_PRETRAINED_BERT_CACHE", "PYTORCH_TRANSFORMERS_CACHE", "TRANSFORMERS_CACHE"):
...@@ -124,11 +123,6 @@ for key in ("PYTORCH_PRETRAINED_BERT_CACHE", "PYTORCH_TRANSFORMERS_CACHE", "TRAN ...@@ -124,11 +123,6 @@ for key in ("PYTORCH_PRETRAINED_BERT_CACHE", "PYTORCH_TRANSFORMERS_CACHE", "TRAN
f"Using `{key}` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.", f"Using `{key}` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.",
FutureWarning, 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" 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: ...@@ -229,7 +223,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
ua += f"; torch/{_torch_version}" ua += f"; torch/{_torch_version}"
if is_tf_available(): if is_tf_available():
ua += f"; tensorflow/{_tf_version}" ua += f"; tensorflow/{_tf_version}"
if DISABLE_TELEMETRY: if constants.HF_HUB_DISABLE_TELEMETRY:
return ua + "; telemetry/off" return ua + "; telemetry/off"
if is_training_run_on_sagemaker(): if is_training_run_on_sagemaker():
ua += "; " + "; ".join(f"{k}/{v}" for k, v in define_sagemaker_information().items()) ua += "; " + "; ".join(f"{k}/{v}" for k, v in define_sagemaker_information().items())
......
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