Skip to content

Commit f3bedd4

Browse files
not-laingradio-pr-botabidlabs
authored
add gr.Success and update windows contributing (#10262)
* include windows contributions * add gr.Success * add changeset * contributing * changes * clean docstring * format * fix typo --------- Co-authored-by: gradio-pr-bot <[email protected]> Co-authored-by: Abubakar Abid <[email protected]>
1 parent aa2eec2 commit f3bedd4

25 files changed

+608
-19
lines changed

.changeset/old-maps-enter.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@gradio/client": minor
3+
"@gradio/icons": minor
4+
"@gradio/statustracker": minor
5+
"gradio": minor
6+
---
7+
8+
feat:add gr.Success and update windows contributing

CONTRIBUTING.md

+192-2
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,97 @@ There are a few ways to install and run Gradio.
3636

3737
- Clone this repo
3838
- Navigate to the repo directory and run:
39+
<table>
40+
<tr>
41+
<th>MacOS / Linux</th>
42+
<th>Windows</th>
43+
</tr>
44+
<tr>
45+
<td>
3946

4047
```bash
4148
bash scripts/install_gradio.sh
4249
```
50+
</td>
51+
<td>
52+
53+
```bash
54+
scripts\install_gradio.bat
55+
```
56+
</td>
57+
</tr>
58+
</table>
4359

4460
- Run the frontend (only required if you are making changes to the frontend and would like to preview them)
61+
<table>
62+
<tr>
63+
<th>MacOS / Linux</th>
64+
<th>Windows</th>
65+
</tr>
66+
<tr>
67+
<td>
4568

4669
```bash
4770
bash scripts/run_frontend.sh
4871
```
72+
</td>
73+
<td>
74+
75+
```bash
76+
scripts\run_frontend.bat
77+
```
78+
</td>
79+
</tr>
80+
</table>
4981

5082
- Install test requirements (only required if you want to run tests locally)
5183

5284
(Note that it is highly recommended to use a virtual environment running **Python 3.10** since the versions of Gradio's dependencies are pinned)
5385

86+
<table>
87+
<tr>
88+
<th>MacOS / Linux</th>
89+
<th>Windows</th>
90+
</tr>
91+
<tr>
92+
<td>
93+
5494
```bash
5595
bash scripts/install_test_requirements.sh
5696
```
97+
</td>
98+
<td>
99+
100+
```bash
101+
scripts\install_test_requirements.bat
102+
```
103+
</td>
104+
</tr>
105+
</table>
57106

58107
If you have a different Python version and conflicting packages during the installation, please first run:
59108

109+
<table>
110+
<tr>
111+
<th>MacOS / Linux</th>
112+
<th>Windows</th>
113+
</tr>
114+
<tr>
115+
<td>
116+
60117
```bash
61118
bash scripts/create_test_requirements.sh
62119
```
120+
</td>
121+
<td>
122+
123+
```bash
124+
scripts\create_test_requirements.bat
125+
```
126+
</td>
127+
</tr>
128+
</table>
129+
63130

64131
### 📦 Using dev containers
65132

@@ -99,7 +166,7 @@ If you're a newcomer to Gradio, we recommend getting familiar with the overall s
99166

100167
You can get started by creating an `app.py` file in the root:
101168

102-
```
169+
```py
103170
import gradio as gr
104171

105172
with gr.Blocks() as demo:
@@ -123,9 +190,27 @@ Note: if you have `gradio` installed elsewhere in your system, you may need to u
123190

124191
If you're making frontend changes, start the frontend server:
125192

193+
194+
<table>
195+
<tr>
196+
<th>MacOS / Linux</th>
197+
<th>Windows</th>
198+
</tr>
199+
<tr>
200+
<td>
201+
126202
```bash
127203
bash scripts/run_frontend.sh
128204
```
205+
</td>
206+
<td>
207+
208+
```bash
209+
scripts\run_frontend.bat
210+
```
211+
</td>
212+
</tr>
213+
</table>
129214

130215
This will open a separate browser tab. By default, Gradio will launch this on port 9876. Any changes to the frontend will also reload automatically in the browser. For more information about developing in the frontend, you can refer to [js/README.md](js/README.md).
131216

@@ -142,9 +227,26 @@ We use Pytest, Playwright and Vitest to test our code.
142227

143228
- The Python tests are located in `/test`. To run these tests:
144229

230+
<table>
231+
<tr>
232+
<th>MacOS / Linux</th>
233+
<th>Windows</th>
234+
</tr>
235+
<tr>
236+
<td>
237+
145238
```
146239
bash scripts/run_backend_tests.sh
147240
```
241+
</td>
242+
<td>
243+
244+
```bash
245+
scripts\run_backend_tests.bat
246+
```
247+
</td>
248+
</tr>
249+
</table>
148250

149251
- The frontend unit tests are any defined with the filename `*.test.ts`. To run them:
150252

@@ -259,7 +361,7 @@ and then from the website directory:
259361
pnpm dev
260362
```
261363

262-
#### Main vs Released
364+
#### Main vs. Released
263365

264366
The website supports documentation for both the latest released version on pypi as well as the main build on github. You can switch between them on the website by using the toggle on any page or by prefixing '/main' before the route in the url. For example: https://www.gradio.app/main/guides/quickstart
265367

@@ -270,19 +372,53 @@ If you're making changes to documentation and are wondering why they're not show
270372
Gradio-Lite is a Pyodide-based library that lets you run Gradio serverless (in other words, directly in your browser).
271373

272374
You can start the development server by running:
375+
<table>
376+
<tr>
377+
<th>MacOS / Linux</th>
378+
<th>Windows</th>
379+
</tr>
380+
<tr>
381+
<td>
382+
273383
```
274384
bash scripts/run_lite.sh
275385
```
386+
</td>
387+
<td>
388+
389+
```bash
390+
scripts\run_lite.bat
391+
```
392+
</td>
393+
</tr>
394+
</table>
276395

277396
If you make changes to the Python code during development, you will need to rebuild the Python packages loaded to Graio-Lite. To do this, run:
278397
```
279398
pnpm --filter @gradio/lite pybuild
280399
```
281400

282401
To generate the release build, run:
402+
<table>
403+
<tr>
404+
<th>MacOS / Linux</th>
405+
<th>Windows</th>
406+
</tr>
407+
<tr>
408+
<td>
409+
283410
```
284411
bash scripts/build_lite.sh
285412
```
413+
</td>
414+
<td>
415+
416+
```bash
417+
scripts\build_lite.bat
418+
```
419+
</td>
420+
</tr>
421+
</table>
286422
The release build will be located in the `dist` directory in the `js/lite` project.
287423
To test it, you can run a local server in the `js/lite` directory:
288424
```
@@ -302,15 +438,50 @@ All PRs should be submitted against `main`, and ideally should address an open i
302438

303439
Don't forget to format your code before pushing:
304440

441+
<table>
442+
<tr>
443+
<th>MacOS / Linux</th>
444+
<th>Windows</th>
445+
</tr>
446+
<tr>
447+
<td>
448+
305449
```
306450
bash scripts/format_backend.sh
307451
```
452+
</td>
453+
<td>
454+
455+
```bash
456+
scripts\format_backend.bat
457+
```
458+
</td>
459+
</tr>
460+
</table>
308461

309462
And if you made changes to the frontend:
310463

464+
465+
<table>
466+
<tr>
467+
<th>MacOS / Linux</th>
468+
<th>Windows</th>
469+
</tr>
470+
<tr>
471+
<td>
472+
311473
```
312474
bash scripts/format_frontend.sh
313475
```
476+
</td>
477+
<td>
478+
479+
```bash
480+
scripts\format_frontend.bat
481+
```
482+
</td>
483+
</tr>
484+
</table>
314485

315486
Thank you for taking the time to contribute to Gradio!
316487

@@ -339,10 +510,29 @@ rm pnpm-lock.yaml
339510

340511
and run the install scripts:
341512

513+
514+
<table>
515+
<tr>
516+
<th>MacOS / Linux</th>
517+
<th>Windows</th>
518+
</tr>
519+
<tr>
520+
<td>
521+
342522
```
343523
bash scripts/install_gradio.sh
344524
bash scripts/build_frontend.sh
345525
```
526+
</td>
527+
<td>
528+
529+
```bash
530+
scripts\install_gradio.bat
531+
scripts\build_frontend.bat
532+
```
533+
</td>
534+
</tr>
535+
</table>
346536
---
347537

348538
```FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory``` when running `scripts/build_frontend.sh`.

client/js/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export type GradioEvent = {
331331
export interface Log {
332332
log: string;
333333
title: string;
334-
level: "warning" | "info";
334+
level: "warning" | "info" | "success";
335335
}
336336
export interface Render {
337337
data: {

gradio/__init__.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,7 @@
8484
FlaggingCallback,
8585
SimpleCSVLogger,
8686
)
87-
from gradio.helpers import (
88-
Info,
89-
Progress,
90-
Warning,
91-
skip,
92-
update,
93-
)
87+
from gradio.helpers import Info, Progress, Success, Warning, skip, update
9488
from gradio.helpers import create_examples as Examples # noqa: N812
9589
from gradio.interface import Interface, TabbedInterface, close_all
9690
from gradio.layouts import Accordion, Column, Group, Row, Tab, TabItem, Tabs
@@ -173,6 +167,7 @@
173167
"ImageEditor",
174168
"ImageMask",
175169
"Info",
170+
"Success",
176171
"Interface",
177172
"JSON",
178173
"Json",

0 commit comments

Comments
 (0)