mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
Use gradio-api-server for telemetry (#3488)
* analytics * changelog * remove interface analytics * ip * remove import * format * theme name * theme analytics * format * changelog * fixes * format * remove unused param --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
7a4e22b61a
commit
811d26aab4
@ -10,6 +10,7 @@
|
||||
|
||||
- Fixed bug where text for altair plots was not legible in dark mode by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3555](https://github.com/gradio-app/gradio/pull/3555)
|
||||
- Fixes `Chatbot` and `Image` components so that files passed during processing are added to a directory where they can be served from, by [@abidlabs](https://github.com/abidlabs) in [PR 3523](https://github.com/gradio-app/gradio/pull/3523)
|
||||
- Use Gradio API server to send telemetry using `huggingface_hub` [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3488](https://github.com/gradio-app/gradio/pull/3488)
|
||||
- Fixes an an issue where if the Blocks scope was not exited, then State could be shared across sessions, by [@abidlabs](https://github.com/abidlabs) in [PR 3600](https://github.com/gradio-app/gradio/pull/3600)
|
||||
- Fixed bug where "or" was not being localized in file upload text by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3599](https://github.com/gradio-app/gradio/pull/3599)
|
||||
|
||||
|
@ -20,7 +20,16 @@ from anyio import CapacityLimiter
|
||||
from gradio_client import utils as client_utils
|
||||
from typing_extensions import Literal
|
||||
|
||||
from gradio import components, external, networking, queueing, routes, strings, utils
|
||||
from gradio import (
|
||||
components,
|
||||
external,
|
||||
networking,
|
||||
queueing,
|
||||
routes,
|
||||
strings,
|
||||
themes,
|
||||
utils,
|
||||
)
|
||||
from gradio.context import Context
|
||||
from gradio.deprecation import check_deprecated_parameters
|
||||
from gradio.documentation import document, set_documentation_group
|
||||
@ -562,10 +571,22 @@ class Blocks(BlockContext):
|
||||
self.file_directories = []
|
||||
|
||||
if self.analytics_enabled:
|
||||
built_in_themes = [
|
||||
themes.Base(),
|
||||
themes.Default(),
|
||||
themes.Monochrome(),
|
||||
themes.Soft(),
|
||||
themes.Glass(),
|
||||
]
|
||||
is_custom_theme = not any(
|
||||
self.theme.to_dict() == built_in_theme.to_dict()
|
||||
for built_in_theme in built_in_themes
|
||||
)
|
||||
data = {
|
||||
"mode": self.mode,
|
||||
"custom_css": self.css is not None,
|
||||
"theme": self.theme,
|
||||
"theme": self.theme.name,
|
||||
"is_custom_theme": is_custom_theme,
|
||||
"version": GRADIO_VERSION,
|
||||
}
|
||||
utils.initiated_analytics(data)
|
||||
|
@ -30,7 +30,6 @@ from gradio.flagging import CSVLogger, FlaggingCallback, FlagMethod
|
||||
from gradio.layouts import Column, Row, Tab, Tabs
|
||||
from gradio.pipelines import load_from_pipeline
|
||||
from gradio.themes import ThemeClass as Theme
|
||||
from gradio.utils import GRADIO_VERSION
|
||||
|
||||
set_documentation_group("interface")
|
||||
|
||||
@ -369,22 +368,6 @@ class Interface(Blocks):
|
||||
self.local_url = None
|
||||
|
||||
self.favicon_path = None
|
||||
|
||||
if self.analytics_enabled:
|
||||
data = {
|
||||
"mode": self.mode,
|
||||
"fn": fn,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"live": live,
|
||||
"interpretation": interpretation,
|
||||
"allow_flagging": allow_flagging,
|
||||
"custom_css": self.css is not None,
|
||||
"theme": self.theme,
|
||||
"version": GRADIO_VERSION,
|
||||
}
|
||||
utils.initiated_analytics(data)
|
||||
|
||||
utils.version_check()
|
||||
Interface.instances.add(self)
|
||||
|
||||
|
@ -40,7 +40,6 @@ import aiohttp
|
||||
import httpx
|
||||
import matplotlib.pyplot as plt
|
||||
import requests
|
||||
from huggingface_hub.utils import send_telemetry
|
||||
from markdown_it import MarkdownIt
|
||||
from mdit_py_plugins.dollarmath.index import dollarmath_plugin
|
||||
from mdit_py_plugins.footnote.index import footnote_plugin
|
||||
@ -116,19 +115,7 @@ def initiated_analytics(data: Dict[str, Any]) -> None:
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
def initiated_telemetry_thread(data: Dict[str, Any]) -> None:
|
||||
try:
|
||||
send_telemetry(
|
||||
topic="gradio/initiated",
|
||||
library_name="gradio",
|
||||
library_version=GRADIO_VERSION,
|
||||
user_agent=data,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
threading.Thread(target=initiated_analytics_thread, args=(data,)).start()
|
||||
threading.Thread(target=initiated_telemetry_thread, args=(data,)).start()
|
||||
|
||||
|
||||
def launch_analytics(data: Dict[str, Any]) -> None:
|
||||
@ -177,7 +164,6 @@ def launched_telemetry(blocks: gradio.Blocks, data: Dict[str, Any]) -> None:
|
||||
"dev_mode": blocks.dev_mode,
|
||||
"show_api": blocks.show_api,
|
||||
"show_error": blocks.show_error,
|
||||
"theme": blocks.theme,
|
||||
"title": blocks.title,
|
||||
"inputs": blocks.input_components
|
||||
if blocks.mode == "interface"
|
||||
@ -191,14 +177,12 @@ def launched_telemetry(blocks: gradio.Blocks, data: Dict[str, Any]) -> None:
|
||||
}
|
||||
|
||||
data.update(additional_data)
|
||||
data.update({"ip_address": get_local_ip_address()})
|
||||
|
||||
def launched_telemtry_thread(data: Dict[str, Any]) -> None:
|
||||
try:
|
||||
send_telemetry(
|
||||
topic="gradio/launched",
|
||||
library_name="gradio",
|
||||
library_version=GRADIO_VERSION,
|
||||
user_agent=data,
|
||||
requests.post(
|
||||
analytics_url + "gradio-launched-telemetry/", data=data, timeout=3
|
||||
)
|
||||
except Exception as e:
|
||||
print("Error while sending telemetry: {}".format(e))
|
||||
@ -217,19 +201,7 @@ def integration_analytics(data: Dict[str, Any]) -> None:
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
def integration_telemetry_thread(data: Dict[str, Any]) -> None:
|
||||
try:
|
||||
send_telemetry(
|
||||
topic="gradio/integration",
|
||||
library_name="gradio",
|
||||
library_version=GRADIO_VERSION,
|
||||
user_agent=data,
|
||||
)
|
||||
except Exception as e:
|
||||
print("Error while sending telemetry: {}".format(e))
|
||||
|
||||
threading.Thread(target=integration_analytics_thread, args=(data,)).start()
|
||||
threading.Thread(target=integration_telemetry_thread, args=(data,)).start()
|
||||
|
||||
|
||||
def error_analytics(message: str) -> None:
|
||||
@ -248,19 +220,7 @@ def error_analytics(message: str) -> None:
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
def error_telemetry_thread(data: Dict[str, Any]) -> None:
|
||||
try:
|
||||
send_telemetry(
|
||||
topic="gradio/error",
|
||||
library_name="gradio",
|
||||
library_version=GRADIO_VERSION,
|
||||
user_agent=message,
|
||||
)
|
||||
except Exception as e:
|
||||
print("Error while sending telemetry: {}".format(e))
|
||||
|
||||
threading.Thread(target=error_analytics_thread, args=(data,)).start()
|
||||
threading.Thread(target=error_telemetry_thread, args=(data,)).start()
|
||||
|
||||
|
||||
async def log_feature_analytics(feature: str) -> None:
|
||||
|
@ -11,7 +11,7 @@ scikit-image
|
||||
shap
|
||||
pytest
|
||||
wandb
|
||||
huggingface_hub>=0.13.0
|
||||
huggingface_hub
|
||||
pytest-cov
|
||||
pytest-asyncio
|
||||
black
|
||||
|
Loading…
Reference in New Issue
Block a user