Skip to content

Commit 6583dc8

Browse files
authored
feat: Disable Gradio Analytics (#1165)
* Disable Gradio Analytics Gradio analytics can be disabled by either using the kwargs `enable_analytics` on `gr.Blocks`, or by setting the env variable `GRADIO_ANALYTICS_ENABLED` to something different from `True`. Since that Gradio does not seem to respect their code contract (around `enable_analytics`), and that they are performing other operations only based on the value of `GRADIO_ANALYTICS_ENABLED` (c.f. `gradio.strings` https://github.com/gradio-app/gradio/blob/main/gradio/strings.py#L39), we are disabling gradio analytics by setting the required env variable to `False`. Note: Setting an environment variables using `os.environ['foo'] = 'bar'` on system that are not based on unix might not work. c.f. https://docs.python.org/3/library/os.html#os.environ for details on how `os.environ` works and all its caveats * Update private_gpt/__init__.py
1 parent 0d677e1 commit 6583dc8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: private_gpt/__init__.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""private-gpt."""
22
import logging
3+
import os
34

45
# Set to 'DEBUG' to have extensive logging turned on, even for libraries
56
ROOT_LOG_LEVEL = "INFO"
@@ -9,3 +10,14 @@
910
)
1011
logging.basicConfig(level=ROOT_LOG_LEVEL, format=PRETTY_LOG_FORMAT, datefmt="%H:%M:%S")
1112
logging.captureWarnings(True)
13+
14+
# Disable gradio analytics
15+
# This is done this way because gradio does not solely rely on what values are
16+
# passed to gr.Blocks(enable_analytics=...) but also on the environment
17+
# variable GRADIO_ANALYTICS_ENABLED. `gradio.strings` actually reads this env
18+
# directly, so to fully disable gradio analytics we need to set this env var.
19+
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
20+
21+
# Disable chromaDB telemetry
22+
# It is already disabled, see PR#1144
23+
# os.environ["ANONYMIZED_TELEMETRY"] = "False"

Diff for: private_gpt/ui/ui.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _upload_file(file: TextIO) -> list[list[str]]:
111111
"}"
112112
".logo img { height: 25% }",
113113
) as blocks:
114-
with gr.Blocks(), gr.Row():
114+
with gr.Row():
115115
gr.HTML(f"<div class='logo'/><img src={logo_svg} alt=PrivateGPT></div")
116116

117117
with gr.Row():

0 commit comments

Comments
 (0)