You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+192-2
Original file line number
Diff line number
Diff line change
@@ -36,30 +36,97 @@ There are a few ways to install and run Gradio.
36
36
37
37
- Clone this repo
38
38
- 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>
39
46
40
47
```bash
41
48
bash scripts/install_gradio.sh
42
49
```
50
+
</td>
51
+
<td>
52
+
53
+
```bash
54
+
scripts\install_gradio.bat
55
+
```
56
+
</td>
57
+
</tr>
58
+
</table>
43
59
44
60
- 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>
45
68
46
69
```bash
47
70
bash scripts/run_frontend.sh
48
71
```
72
+
</td>
73
+
<td>
74
+
75
+
```bash
76
+
scripts\run_frontend.bat
77
+
```
78
+
</td>
79
+
</tr>
80
+
</table>
49
81
50
82
- Install test requirements (only required if you want to run tests locally)
51
83
52
84
(Note that it is highly recommended to use a virtual environment running **Python 3.10** since the versions of Gradio's dependencies are pinned)
53
85
86
+
<table>
87
+
<tr>
88
+
<th>MacOS / Linux</th>
89
+
<th>Windows</th>
90
+
</tr>
91
+
<tr>
92
+
<td>
93
+
54
94
```bash
55
95
bash scripts/install_test_requirements.sh
56
96
```
97
+
</td>
98
+
<td>
99
+
100
+
```bash
101
+
scripts\install_test_requirements.bat
102
+
```
103
+
</td>
104
+
</tr>
105
+
</table>
57
106
58
107
If you have a different Python version and conflicting packages during the installation, please first run:
59
108
109
+
<table>
110
+
<tr>
111
+
<th>MacOS / Linux</th>
112
+
<th>Windows</th>
113
+
</tr>
114
+
<tr>
115
+
<td>
116
+
60
117
```bash
61
118
bash scripts/create_test_requirements.sh
62
119
```
120
+
</td>
121
+
<td>
122
+
123
+
```bash
124
+
scripts\create_test_requirements.bat
125
+
```
126
+
</td>
127
+
</tr>
128
+
</table>
129
+
63
130
64
131
### 📦 Using dev containers
65
132
@@ -99,7 +166,7 @@ If you're a newcomer to Gradio, we recommend getting familiar with the overall s
99
166
100
167
You can get started by creating an `app.py` file in the root:
101
168
102
-
```
169
+
```py
103
170
import gradio as gr
104
171
105
172
with gr.Blocks() as demo:
@@ -123,9 +190,27 @@ Note: if you have `gradio` installed elsewhere in your system, you may need to u
123
190
124
191
If you're making frontend changes, start the frontend server:
125
192
193
+
194
+
<table>
195
+
<tr>
196
+
<th>MacOS / Linux</th>
197
+
<th>Windows</th>
198
+
</tr>
199
+
<tr>
200
+
<td>
201
+
126
202
```bash
127
203
bash scripts/run_frontend.sh
128
204
```
205
+
</td>
206
+
<td>
207
+
208
+
```bash
209
+
scripts\run_frontend.bat
210
+
```
211
+
</td>
212
+
</tr>
213
+
</table>
129
214
130
215
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).
131
216
@@ -142,9 +227,26 @@ We use Pytest, Playwright and Vitest to test our code.
142
227
143
228
- The Python tests are located in `/test`. To run these tests:
144
229
230
+
<table>
231
+
<tr>
232
+
<th>MacOS / Linux</th>
233
+
<th>Windows</th>
234
+
</tr>
235
+
<tr>
236
+
<td>
237
+
145
238
```
146
239
bash scripts/run_backend_tests.sh
147
240
```
241
+
</td>
242
+
<td>
243
+
244
+
```bash
245
+
scripts\run_backend_tests.bat
246
+
```
247
+
</td>
248
+
</tr>
249
+
</table>
148
250
149
251
- The frontend unit tests are any defined with the filename `*.test.ts`. To run them:
150
252
@@ -259,7 +361,7 @@ and then from the website directory:
259
361
pnpm dev
260
362
```
261
363
262
-
#### Main vs Released
364
+
#### Main vs. Released
263
365
264
366
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
265
367
@@ -270,19 +372,53 @@ If you're making changes to documentation and are wondering why they're not show
270
372
Gradio-Lite is a Pyodide-based library that lets you run Gradio serverless (in other words, directly in your browser).
271
373
272
374
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
+
273
383
```
274
384
bash scripts/run_lite.sh
275
385
```
386
+
</td>
387
+
<td>
388
+
389
+
```bash
390
+
scripts\run_lite.bat
391
+
```
392
+
</td>
393
+
</tr>
394
+
</table>
276
395
277
396
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:
278
397
```
279
398
pnpm --filter @gradio/lite pybuild
280
399
```
281
400
282
401
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
+
283
410
```
284
411
bash scripts/build_lite.sh
285
412
```
413
+
</td>
414
+
<td>
415
+
416
+
```bash
417
+
scripts\build_lite.bat
418
+
```
419
+
</td>
420
+
</tr>
421
+
</table>
286
422
The release build will be located in the `dist` directory in the `js/lite` project.
287
423
To test it, you can run a local server in the `js/lite` directory:
288
424
```
@@ -302,15 +438,50 @@ All PRs should be submitted against `main`, and ideally should address an open i
302
438
303
439
Don't forget to format your code before pushing:
304
440
441
+
<table>
442
+
<tr>
443
+
<th>MacOS / Linux</th>
444
+
<th>Windows</th>
445
+
</tr>
446
+
<tr>
447
+
<td>
448
+
305
449
```
306
450
bash scripts/format_backend.sh
307
451
```
452
+
</td>
453
+
<td>
454
+
455
+
```bash
456
+
scripts\format_backend.bat
457
+
```
458
+
</td>
459
+
</tr>
460
+
</table>
308
461
309
462
And if you made changes to the frontend:
310
463
464
+
465
+
<table>
466
+
<tr>
467
+
<th>MacOS / Linux</th>
468
+
<th>Windows</th>
469
+
</tr>
470
+
<tr>
471
+
<td>
472
+
311
473
```
312
474
bash scripts/format_frontend.sh
313
475
```
476
+
</td>
477
+
<td>
478
+
479
+
```bash
480
+
scripts\format_frontend.bat
481
+
```
482
+
</td>
483
+
</tr>
484
+
</table>
314
485
315
486
Thank you for taking the time to contribute to Gradio!
316
487
@@ -339,10 +510,29 @@ rm pnpm-lock.yaml
339
510
340
511
and run the install scripts:
341
512
513
+
514
+
<table>
515
+
<tr>
516
+
<th>MacOS / Linux</th>
517
+
<th>Windows</th>
518
+
</tr>
519
+
<tr>
520
+
<td>
521
+
342
522
```
343
523
bash scripts/install_gradio.sh
344
524
bash scripts/build_frontend.sh
345
525
```
526
+
</td>
527
+
<td>
528
+
529
+
```bash
530
+
scripts\install_gradio.bat
531
+
scripts\build_frontend.bat
532
+
```
533
+
</td>
534
+
</tr>
535
+
</table>
346
536
---
347
537
348
538
```FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory``` when running `scripts/build_frontend.sh`.
0 commit comments