2
0
mirror of https://github.com/gradio-app/gradio.git synced 2025-03-19 12:00:39 +08:00

Analytics Refactor ()

* hub telemetry

* more analytics

* format

* changelog

* Gradio Status Page  ()

* add status page to error message

* changelog

* link to status page on website

* move link to the right

* merge

* merge

* Add option to display gallery in preview mode ()

* Add code + api

* CHANGELOG

* dropdown ()

* fix

* fixes

* format

* changelog

* Update gradio/components.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* fix clear case

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Some improvements to Flag ()

* Fixes to button disable

* button

* formatting

* flagging fix

* fixes

* formatter

* changelog

* ormatting

* tests

* saving

* adding optionality for flagging

* updatest

* error catching

* updates

* changelog

* tests

* typing

* flag button

* formatting

* tests

* tests

* tests

* increased latency

* queue fix

* clear

* formatting

* fix

* fix tests

* Fix flaky external test ()

* Fix flaky external test

* CHANGELOG

* Undo accidental diff

* Fix flaky external test

* CHANGELOG

* Undo accidental diff

* Remove from changelog

* Use bunny file

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* updates

* format

* more updates

* threading

* fixes

* Fix error when using backen_fn and custom js at the same time ()

* Fix error when using backen_fn and custom js at the same time

* generate notebooks

* update changelog

* changes

---------

Co-authored-by: Ali Abid <aabid94@gmail.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>

* Fix File updating ()

* Fix

* Remove line

* Add unit test

* CHANGELOG

* Remove comment

* Updated chat ui ()

* test

* changes

* chagnes

* changes

* changes

* changes

* changes

* Update CHANGELOG.md

* changes

* Update demo/chatbot_multimodal/run.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update demo/chatbot_simple_demo/run.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* fixes

* New Version Docs ()

* [create-pull-request] automated change

* empty commit

* [create-pull-request] automated change

* empty commit

---------

Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* requirements

* test requirements

* Release 3.20.1 ()

* release 3.20.1

* changelog

* merge

* New Version Docs ()

* [create-pull-request] automated change

* trigger ci

---------

Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* merge

* Remove everything related to encryption ()

* remove requirements

* deprecate encrypt

* remove flagging

* deprecate

* formatting

* lint

* Adds a Chinese translation for the `README` ()

* add chinese readme

* add chinese readme

* update changelog

* fix render_readme and english readme

* generate readme

* remove template and quickstart files

* link to chinese from english

* fix assets paths

* link to english from chinese

* change file location

* fix link

* fix link

* fix link

---------

Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* fix bad codeblock ()

* Always set queue=False if every is None for load events ()

* Always set queue=False if every is None

* CHANGELOG + linting

* Move to latest release section

* changelog

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* JS client take 2 ()

* start

* change api

* integrate into gradio

* log

* try this

* format

* changes

* format

* fix css

* fix file

* fix  avoid in-place dict updates ()

* fix  avoid in-place dict updates

* add tests and changelog for PR3405

* Fix markdown embedded component in docs ()

* revert to old md component demo

* changelog

* Added a section on security ()

* security

* added section on security

* security

* changes from review

* Fix local tests ()

* document embed params

* fix tests

* cleanup

* cleanup

* cleanup

* revert

* changelog

* Document web component parameters ()

* document embed params

* changelog

* iframe

* fixed review changes

* requirements

* fixes

* format

* format

* requirements

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Jialei <3217223+jialeicui@users.noreply.github.com>
Co-authored-by: Ali Abid <aabid94@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: Uanu <92366232+uanu2002@users.noreply.github.com>
Co-authored-by: gitgithan <hanqi11991@hotmail.com>
This commit is contained in:
Dawood Khan 2023-03-08 21:28:15 -05:00 committed by GitHub
parent f86b6445f8
commit 12fb005ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 24 deletions

@ -5,7 +5,8 @@
No changes to highlight.
## Bug Fixes:
- Ensure load events created by components (randomize for slider, callable values) are never queued unless every is passed by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3391](https://github.com/gradio-app/gradio/pull/3391)
- Use `huggingface_hub` to send telemetry on `interface` and `blocks`; eventaully to replace segment by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3342](https://github.com/gradio-app/gradio/pull/3342)
- Ensure load events created by components (randomize for slider, callable values) are never queued unless every is passed by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3391](https://github.com/gradio-app/gradio/pull/3391)
- Prevent in-place updates of `generic_update` by shallow copying by [@gitgithan](https://github.com/gitgithan) in [PR 3405](https://github.com/gradio-app/gradio/pull/3405) to fix [#3282](https://github.com/gradio-app/gradio/issues/3282)
## Documentation Changes:

@ -4,7 +4,6 @@ import copy
import inspect
import json
import os
import pkgutil
import random
import secrets
import sys
@ -30,6 +29,7 @@ from gradio.themes import Default as DefaultTheme
from gradio.themes import ThemeClass as Theme
from gradio.tunneling import CURRENT_TUNNELS
from gradio.utils import (
GRADIO_VERSION,
TupleNoPrint,
check_function_inputs_match,
component_or_layout_class,
@ -40,7 +40,6 @@ from gradio.utils import (
set_documentation_group("blocks")
if TYPE_CHECKING: # Only import for type checking (is False at runtime).
import comet_ml
from fastapi.applications import FastAPI
@ -485,7 +484,8 @@ class Blocks(BlockContext):
if analytics_enabled is not None
else os.getenv("GRADIO_ANALYTICS_ENABLED", "True") == "True"
)
if not self.analytics_enabled:
os.environ["HF_HUB_DISABLE_TELEMETRY"] = "True"
super().__init__(render=False, **kwargs)
self.blocks: Dict[int, Block] = {}
self.fns: List[BlockFunction] = []
@ -522,9 +522,8 @@ class Blocks(BlockContext):
data = {
"mode": self.mode,
"custom_css": self.css is not None,
"version": (pkgutil.get_data(__name__, "version.txt") or b"")
.decode("ascii")
.strip(),
"theme": self.theme,
"version": GRADIO_VERSION,
}
utils.initiated_analytics(data)
@ -1579,6 +1578,7 @@ class Blocks(BlockContext):
"mode": self.mode,
}
utils.launch_analytics(data)
utils.launched_telemetry(self, data)
utils.show_tip(self)

@ -8,7 +8,6 @@ from __future__ import annotations
import inspect
import json
import os
import pkgutil
import re
import warnings
import weakref
@ -31,6 +30,7 @@ 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")
@ -316,13 +316,8 @@ class Interface(Blocks):
self.simple_server = None
# For analytics_enabled and allow_flagging: (1) first check for
# parameter, (2) check for env variable, (3) default to True/"manual"
self.analytics_enabled = (
analytics_enabled
if analytics_enabled is not None
else os.getenv("GRADIO_ANALYTICS_ENABLED", "True") == "True"
)
# For allow_flagging: (1) first check for parameter,
# (2) check for env variable, (3) default to True/"manual"
if allow_flagging is None:
allow_flagging = os.getenv("GRADIO_ALLOW_FLAGGING", "manual")
if allow_flagging is True:
@ -388,9 +383,8 @@ class Interface(Blocks):
"interpretation": interpretation,
"allow_flagging": allow_flagging,
"custom_css": self.css is not None,
"version": (pkgutil.get_data(__name__, "version.txt") or b"")
.decode("ascii")
.strip(),
"theme": self.theme,
"version": GRADIO_VERSION,
}
utils.initiated_analytics(data)

@ -41,6 +41,7 @@ import fsspec.asyn
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
@ -57,6 +58,9 @@ if TYPE_CHECKING: # Only import for type checking (is False at runtime).
analytics_url = "https://api.gradio.app/"
PKG_VERSION_URL = "https://api.gradio.app/pkg-version"
JSON_PATH = os.path.join(os.path.dirname(gradio.__file__), "launches.json")
GRADIO_VERSION = (
(pkgutil.get_data(__name__, "version.txt") or b"").decode("ascii").strip()
)
T = TypeVar("T")
@ -113,7 +117,19 @@ 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:
@ -130,6 +146,65 @@ def launch_analytics(data: Dict[str, Any]) -> None:
threading.Thread(target=launch_analytics_thread, args=(data,)).start()
def launched_telemetry(blocks: gradio.Blocks, data: Dict[str, Any]) -> None:
blocks_telemetry, inputs_telemetry, outputs_telemetry, targets_telemetry = (
[],
[],
[],
[],
)
for x in list(blocks.blocks.values()):
blocks_telemetry.append(x.get_block_name()) if isinstance(
x, BlockContext
) else blocks_telemetry.append(str(x))
for x in blocks.dependencies:
targets_telemetry = targets_telemetry + [
str(blocks.blocks[y]) for y in x["targets"]
]
inputs_telemetry = inputs_telemetry + [
str(blocks.blocks[y]) for y in x["inputs"]
]
outputs_telemetry = outputs_telemetry + [
str(blocks.blocks[y]) for y in x["outputs"]
]
additional_data = {
"is_kaggle": blocks.is_kaggle,
"is_sagemaker": blocks.is_sagemaker,
"using_auth": blocks.auth is not 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"
else inputs_telemetry,
"outputs": blocks.output_components
if blocks.mode == "interface"
else outputs_telemetry,
"targets": targets_telemetry,
"blocks": blocks_telemetry,
"events": [str(x["trigger"]) for x in blocks.dependencies],
}
data.update(additional_data)
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,
)
except Exception as e:
print("Error while sending telemetry: {}".format(e))
threading.Thread(target=launched_telemtry_thread, args=(data,)).start()
def integration_analytics(data: Dict[str, Any]) -> None:
data.update({"ip_address": get_local_ip_address()})
@ -141,7 +216,19 @@ 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:
@ -160,7 +247,19 @@ 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:

@ -2,6 +2,7 @@ aiohttp
altair>=4.2.0
fastapi
ffmpy
huggingface_hub>=0.13.0
markdown-it-py[linkify]>=2.0.0
mdit-py-plugins<=0.3.3
markupsafe

@ -11,7 +11,7 @@ scikit-image
shap
pytest
wandb
huggingface_hub
huggingface_hub>=0.13.0
pytest-cov
pytest-asyncio
black

@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements.txt
@ -24,8 +24,12 @@ backcall==0.2.0
# via ipython
black==22.6.0
# via -r requirements.in
boto3==1.26.65
boto3==1.26.65
# via -r requirements.in
botocore==1.29.87
# via
# boto3
# s3transfer
certifi==2022.6.15
# via
# dulwich
@ -98,7 +102,7 @@ httpx==0.23.0
# via
# -r requirements.in
# respx
huggingface-hub==0.8.1
huggingface-hub==0.13.0
# via
# -r requirements.in
# transformers
@ -110,7 +114,9 @@ idna==3.3
imageio==2.19.5
# via scikit-image
importlib-metadata==4.2.0
# via mlflow
# via
# flask
# mlflow
iniconfig==1.1.1
# via pytest
ipython==7.34.0
@ -125,6 +131,10 @@ jinja2==3.1.2
# via
# altair
# flask
jmespath==1.0.1
# via
# boto3
# botocore
joblib==1.1.0
# via scikit-learn
jsonschema==4.7.2
@ -245,7 +255,9 @@ pytest-asyncio==0.19.0
pytest-cov==3.0.0
# via -r requirements.in
python-dateutil==2.8.2
# via pandas
# via
# botocore
# pandas
pytz==2022.1
# via
# mlflow
@ -278,6 +290,8 @@ respx==0.19.2
# via -r requirements.in
rfc3986[idna2008]==1.5.0
# via httpx
s3transfer==0.6.0
# via boto3
scikit-image==0.19.3
# via -r requirements.in
scikit-learn==1.0.2
@ -358,11 +372,14 @@ transformers==4.20.1
# via -r requirements.in
typing-extensions==4.3.0
# via
# black
# huggingface-hub
# pydantic
# starlette
# torch
urllib3==1.26.10
# via
# botocore
# dulwich
# requests
# sentry-sdk