2020from typing import Dict , Optional , Union
2121from uuid import uuid4
2222
23- import requests
2423from huggingface_hub import HfFolder , whoami
2524
2625from . import __version__
@@ -56,7 +55,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
5655 Formats a user-agent string with basic info about a request.
5756 """
5857 ua = f"diffusers/{ __version__ } ; python/{ sys .version .split ()[0 ]} ; session_id/{ SESSION_ID } "
59- if DISABLE_TELEMETRY :
58+ if DISABLE_TELEMETRY or HF_HUB_OFFLINE :
6059 return ua + "; telemetry/off"
6160 if is_torch_available ():
6261 ua += f"; torch/{ _torch_version } "
@@ -75,27 +74,6 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
7574 return ua
7675
7776
78- def send_telemetry (data : Dict , name : str ):
79- """
80- Sends logs to the Hub telemetry endpoint.
81-
82- Args:
83- data: the fields to track, e.g. {"example_name": "dreambooth"}
84- name: a unique name to differentiate the telemetry logs, e.g. "diffusers_examples" or "diffusers_notebooks"
85- """
86- if DISABLE_TELEMETRY or HF_HUB_OFFLINE :
87- return
88-
89- headers = {"user-agent" : http_user_agent (data )}
90- endpoint = HUGGINGFACE_CO_TELEMETRY + name
91- try :
92- r = requests .head (endpoint , headers = headers )
93- r .raise_for_status ()
94- except Exception :
95- # We don't want to error in case of connection errors of any kind.
96- pass
97-
98-
9977def get_full_repo_name (model_id : str , organization : Optional [str ] = None , token : Optional [str ] = None ):
10078 if token is None :
10179 token = HfFolder .get_token ()
0 commit comments