Skip to content

Commit 835e4bd

Browse files
dawoodkhan82gradio-pr-botfreddyaboulton
authored
Reduce load times of all components (#13041)
* lazy load info * add changeset * add changeset * fix cache * test fix * check file exists * inline markdown utility * format * fixes * fix profiling * add changeset * add changeset * median time --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freddy Boulton <41651716+freddyaboulton@users.noreply.github.com>
1 parent dbbff5f commit 835e4bd

12 files changed

Lines changed: 448 additions & 57 deletions

File tree

.changeset/some-zebras-behave.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/atoms": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Reduce load times of all components

.github/actions/install-all-deps/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ runs:
101101
if: inputs.skip_gradio_install != 'true' && inputs.os == 'ubuntu-latest'
102102
run: |
103103
. ${{ env.VENV_ACTIVATE }}
104-
python scripts/generate_css_vars_docs.py
104+
[ -f scripts/generate_css_vars_docs.py ] && python scripts/generate_css_vars_docs.py || true
105105
- name: generate json
106106
shell: bash
107107
if: inputs.skip_gradio_install != 'true' && inputs.os == 'ubuntu-latest'

.github/workflows/frontend_profiling.yml

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,57 @@ jobs:
3333
id: latest_tag
3434
run: echo "tag=$(git tag --list 'gradio@*' --sort=-v:refname | head -n 1)" >> "$GITHUB_OUTPUT"
3535

36-
- name: Restore base benchmark cache
36+
- name: Setup Python
3737
if: steps.changes.outputs.should_run == 'true'
38-
id: base_cache
39-
uses: actions/cache@v4
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: "3.10"
41+
42+
- name: Install uv
43+
if: steps.changes.outputs.should_run == 'true'
44+
run: curl -LsSf https://astral.sh/uv/0.9.2/install.sh | sh
45+
46+
- name: Install pnpm
47+
if: steps.changes.outputs.should_run == 'true'
48+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # @v4
4049
with:
41-
path: /tmp/bench_base.json
42-
key: frontend-bench-base-${{ steps.latest_tag.outputs.tag }}
50+
version: 10.17.0
51+
52+
- name: Setup Node.js
53+
if: steps.changes.outputs.should_run == 'true'
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: 24
57+
cache: pnpm
58+
cache-dependency-path: pnpm-lock.yaml
4359

4460
- name: Checkout latest release
45-
if: steps.changes.outputs.should_run == 'true' && steps.base_cache.outputs.cache-hit != 'true'
61+
if: steps.changes.outputs.should_run == 'true'
4662
run: git checkout ${{ steps.latest_tag.outputs.tag }}
4763

48-
- name: Install dependencies
49-
if: steps.changes.outputs.should_run == 'true' && steps.base_cache.outputs.cache-hit != 'true'
50-
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
51-
with:
52-
python_version: "3.10"
53-
os: "ubuntu-latest"
64+
- name: Create venv and install Python deps (base)
65+
if: steps.changes.outputs.should_run == 'true'
66+
run: |
67+
export PATH="$HOME/.cargo/bin:$PATH"
68+
uv venv venv --python=3.10
69+
. venv/bin/activate
70+
uv pip install -e client/python
71+
uv pip install -e ".[oauth,mcp]"
72+
73+
- name: Install frontend deps and build (base)
74+
if: steps.changes.outputs.should_run == 'true'
75+
run: pnpm i --frozen-lockfile --ignore-scripts && pnpm css && pnpm build
5476

5577
- name: Install Playwright (base)
56-
if: steps.changes.outputs.should_run == 'true' && steps.base_cache.outputs.cache-hit != 'true'
78+
if: steps.changes.outputs.should_run == 'true'
5779
run: pnpm exec playwright install chromium
5880

5981
- name: Checkout benchmark spec and demo from PR
60-
if: steps.changes.outputs.should_run == 'true' && steps.base_cache.outputs.cache-hit != 'true'
82+
if: steps.changes.outputs.should_run == 'true'
6183
run: git checkout ${{ github.event.pull_request.head.sha }} -- js/spa/test/big_complex_demo.spec.ts demo/big_complex_demo
6284

6385
- name: Run benchmark (base)
64-
if: steps.changes.outputs.should_run == 'true' && steps.base_cache.outputs.cache-hit != 'true'
86+
if: steps.changes.outputs.should_run == 'true'
6587
run: |
6688
. venv/bin/activate
6789
PERF_RESULTS_FILE=/tmp/bench_base.json pnpm exec playwright test \
@@ -74,36 +96,16 @@ jobs:
7496
git clean -fd
7597
git checkout -f ${{ github.event.pull_request.head.sha }}
7698
77-
- name: Setup Python (PR)
78-
if: steps.changes.outputs.should_run == 'true'
79-
uses: actions/setup-python@v5
80-
with:
81-
python-version: "3.10"
82-
83-
- name: Install pnpm (PR)
84-
if: steps.changes.outputs.should_run == 'true'
85-
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # @v4
86-
with:
87-
version: 10.17.0
88-
89-
- name: Setup Node.js (PR)
90-
if: steps.changes.outputs.should_run == 'true'
91-
uses: actions/setup-node@v4
92-
with:
93-
node-version: 24
94-
cache: pnpm
95-
cache-dependency-path: pnpm-lock.yaml
96-
9799
- name: Install and build PR
98100
if: steps.changes.outputs.should_run == 'true'
99101
run: |
100-
command -v uv >/dev/null 2>&1 || { curl -LsSf https://astral.sh/uv/0.9.2/install.sh | sh && export PATH="$HOME/.cargo/bin:$PATH"; }
102+
export PATH="$HOME/.cargo/bin:$PATH"
101103
uv venv venv --python=3.10
102104
. venv/bin/activate
103105
uv pip install -e client/python
104106
uv pip install -e ".[oauth,mcp]"
105107
pnpm install --no-frozen-lockfile
106-
pnpm build
108+
pnpm css && pnpm build
107109
108110
- name: Install Playwright (PR)
109111
if: steps.changes.outputs.should_run == 'true'

js/atoms/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"license": "ISC",
99
"dependencies": {
1010
"@gradio/icons": "workspace:^",
11-
"@gradio/markdown-code": "workspace:^",
1211
"@gradio/utils": "workspace:^"
1312
},
1413
"peerDependencies": {

js/atoms/src/BlockTitle.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
2-
import { default as Info } from "./Info.svelte";
2+
import Info from "./Info.svelte";
3+
34
export let show_label = true;
45
export let info: string | undefined = undefined;
56
export let rtl = false;

js/atoms/src/Info.svelte

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<script lang="ts">
2-
import { MarkdownCode as Markdown } from "@gradio/markdown-code";
2+
import { render_inline_markdown } from "./inline-markdown";
33
export let info: string;
44
</script>
55

6-
<div>
7-
<Markdown message={info} sanitize_html={true} />
6+
<div class="info-text">
7+
{@html render_inline_markdown(info)}
88
</div>
99

1010
<style>
11-
div > :global(.md.prose) {
11+
.info-text {
1212
font-weight: var(--block-info-text-weight);
1313
font-size: var(--block-info-text-size);
1414
line-height: var(--line-sm);
15-
}
16-
div > :global(.md.prose *) {
1715
color: var(--block-info-text-color);
18-
}
19-
div {
2016
margin-bottom: var(--spacing-md);
2117
}
18+
.info-text :global(a) {
19+
color: var(--link-text-color);
20+
text-decoration: underline;
21+
}
22+
.info-text :global(code) {
23+
background: var(--code-background-fill);
24+
padding: 0.1em 0.3em;
25+
border-radius: 3px;
26+
font-size: 0.9em;
27+
}
2228
</style>

0 commit comments

Comments
 (0)