Skip to content

Commit

Permalink
bump to gradio 6.0, make trackio compatible, and fix related issues…
Browse files Browse the repository at this point in the history
… (#305)

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
2 people authored and GitHub committed Nov 24, 2025
1 parent 96e8acc commit e64883a
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-ways-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trackio": minor
---

feat:bump to gradio 6.0, make `trackio` compatible, and fix related issues
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
- name: Install Python dependencies
run: |
uv pip install --system -e .[dev,tensorboard]
uv pip install --system pytest
uv pip install --system -e .[dev,tensorboard] --prerelease=allow
uv pip install --system pytest --prerelease=allow
- name: Install Playwright
run: |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Supported query parameters:
- `project`: (string) Filter the dashboard to show only a specific project
- `metrics`: (comma-separated list) Filter the dashboard to show only specific metrics, e.g. `train_loss,train_accuracy`
- `sidebar`: (string: one of "hidden" or "collapsed"). If "hidden", then the sidebar will not be visible. If "collapsed", the sidebar will be in a collapsed state initially but the user will be able to open it. Otherwise, by default, the sidebar is shown in an open and visible state.
- `footer`: (string: "false"). When set to "false", hides the Gradio footer. By default, the footer is visible.
- `xmin`: (number) Set the initial minimum value for the x-axis limits across all metric plots.
- `xmax`: (number) Set the initial maximum value for the x-axis limits across all metric plots.
- `smoothing`: (number) Set the initial value of the smoothing slider (0-20, where 0 = no smoothing).
Expand Down
1 change: 1 addition & 0 deletions docs/source/deploy_embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ You can also filter the dashboard to display only specific projects or metrics u

* `"hidden"` hides the sidebar completely.
* `"collapsed"` keeps the sidebar initially collapsed, but the user can expand it. By default, the sidebar is visible and open.
* `footer` (string, `"false"`): When set to `"false"`, hides the Gradio footer. By default, the footer is visible.
* `xmin` (number): Set the initial minimum value for the x-axis limits across all metrics plots.
* `xmax` (number): Set the initial maximum value for the x-axis limits across all metrics plots.
* `smoothing` (number): Set the initial value of the smoothing slider (0-20, where 0 = no smoothing).
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"pandas<3.0.0",
"huggingface-hub<1.0.0",
"gradio[oauth]>=5.48.0,<6.0.0",
"huggingface-hub<2.0.0",
"gradio[oauth]>=6.0.0,<7.0.0",
"numpy<3.0.0",
"pillow<12.0.0",
"orjson>=3.0,<4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/test_ui_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def test_that_runs_are_displayed(temp_dir):
# The project name and run name should be displayed
locator = page.get_by_label("Project")
expect(locator).to_be_visible()
locator = page.get_by_text("test_run")
locator = page.get_by_test_id("checkbox-group").get_by_label("test_run")
expect(locator).to_be_visible()

# Initially, two line plots should be displayed
locator = page.locator(".vega-embed")
expect(locator).to_have_count(2)

# But if we uncheck the run, the line plots should be hidden
page.get_by_label("test_run").uncheck()
page.get_by_test_id("checkbox-group").get_by_label("test_run").uncheck()
locator = page.locator(".vega-embed")
expect(locator).to_have_count(0)

Expand Down
47 changes: 15 additions & 32 deletions trackio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import hashlib
import json
import logging
import os
Expand All @@ -7,8 +6,6 @@
from pathlib import Path
from typing import Any

from gradio.blocks import BUILT_IN_THEMES
from gradio.themes import Default as DefaultTheme
from gradio.themes import ThemeClass
from gradio.utils import TupleNoPrint
from gradio_client import Client
Expand All @@ -22,7 +19,7 @@
from trackio.run import Run
from trackio.sqlite_storage import SQLiteStorage
from trackio.table import Table
from trackio.ui.main import demo
from trackio.ui.main import CSS, HEAD, demo
from trackio.utils import TRACKIO_DIR, TRACKIO_LOGO_DIR

logging.getLogger("httpx").setLevel(logging.WARNING)
Expand Down Expand Up @@ -144,7 +141,9 @@ def init(
if url is None:
if space_id is None:
_, url, share_url = demo.launch(
show_api=False,
css=CSS,
head=HEAD,
footer_links=["gradio", "settings"],
inline=False,
quiet=True,
prevent_thread_lock=True,
Expand Down Expand Up @@ -173,7 +172,7 @@ def init(
if utils.is_in_notebook() and embed:
base_url = share_url + "/" if share_url else url
full_url = utils.get_full_url(
base_url, project=project, write_token=demo.write_token
base_url, project=project, write_token=demo.write_token, footer=True
)
utils.embed_url_in_notebook(full_url)
else:
Expand Down Expand Up @@ -311,10 +310,11 @@ def delete_project(project: str, force: bool = False) -> bool:

def show(
project: str | None = None,
*,
theme: str | ThemeClass | None = None,
mcp_server: bool | None = None,
footer: bool = True,
color_palette: list[str] | None = None,
*,
open_browser: bool = True,
block_thread: bool | None = None,
):
Expand All @@ -336,6 +336,9 @@ def show(
functions will be added as MCP tools. If `None` (default behavior), then the
`GRADIO_MCP_SERVER` environment variable will be used to determine if the
MCP server should be enabled (which is `"True"` on Hugging Face Spaces).
footer (`bool`, *optional*, defaults to `True`):
Whether to show the Gradio footer. When `False`, the footer will be hidden.
This can also be controlled via the `footer` query parameter in the URL.
color_palette (`list[str]`, *optional*):
A list of hex color codes to use for plot lines. If not provided, the
`TRACKIO_COLOR_PALETTE` environment variable will be used (comma-separated
Expand All @@ -360,48 +363,28 @@ def show(

theme = theme or os.environ.get("TRACKIO_THEME", DEFAULT_THEME)

if theme != DEFAULT_THEME:
# TODO: It's a little hacky to reproduce this theme-setting logic from Gradio Blocks,
# but in Gradio 6.0, the theme will be set in `launch()` instead, which means that we
# will be able to remove this code.
if isinstance(theme, str):
if theme.lower() in BUILT_IN_THEMES:
theme = BUILT_IN_THEMES[theme.lower()]
else:
try:
theme = ThemeClass.from_hub(theme)
except Exception as e:
warnings.warn(f"Cannot load {theme}. Caught Exception: {str(e)}")
theme = DefaultTheme()
if not isinstance(theme, ThemeClass):
warnings.warn("Theme should be a class loaded from gradio.themes")
theme = DefaultTheme()
demo.theme: ThemeClass = theme
demo.theme_css = theme._get_theme_css()
demo.stylesheets = theme._stylesheets
theme_hasher = hashlib.sha256()
theme_hasher.update(demo.theme_css.encode("utf-8"))
demo.theme_hash = theme_hasher.hexdigest()

_mcp_server = (
mcp_server
if mcp_server is not None
else os.environ.get("GRADIO_MCP_SERVER", "False") == "True"
)

app, url, share_url = demo.launch(
show_api=_mcp_server,
css=CSS,
head=HEAD,
footer_links=["gradio", "settings"] + (["api"] if _mcp_server else []),
quiet=True,
inline=False,
prevent_thread_lock=True,
favicon_path=TRACKIO_LOGO_DIR / "trackio_logo_light.png",
allowed_paths=[TRACKIO_LOGO_DIR, TRACKIO_DIR],
mcp_server=_mcp_server,
theme=theme,
)

base_url = share_url + "/" if share_url else url
full_url = utils.get_full_url(
base_url, project=project, write_token=demo.write_token
base_url, project=project, write_token=demo.write_token, footer=footer
)

if not utils.is_in_notebook():
Expand Down
20 changes: 19 additions & 1 deletion trackio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ def main():
action="store_true",
help="Enable MCP server functionality. The Trackio dashboard will be set up as an MCP server and certain functions will be exposed as MCP tools.",
)
ui_parser.add_argument(
"--footer",
action="store_true",
default=True,
help="Show the Gradio footer. Use --no-footer to hide it.",
)
ui_parser.add_argument(
"--no-footer",
dest="footer",
action="store_false",
help="Hide the Gradio footer.",
)
ui_parser.add_argument(
"--color-palette",
required=False,
Expand Down Expand Up @@ -59,7 +71,13 @@ def main():
color_palette = None
if args.color_palette:
color_palette = [color.strip() for color in args.color_palette.split(",")]
show(args.project, args.theme, args.mcp_server, color_palette)
show(
project=args.project,
theme=args.theme,
mcp_server=args.mcp_server,
footer=args.footer,
color_palette=color_palette,
)
elif args.command == "sync":
sync(
project=args.project,
Expand Down
Loading

0 comments on commit e64883a

Please sign in to comment.