Skip to content

Commit

Permalink
add gr.Success and update windows contributing (#10262)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Dec 30, 2024
1 parent aa2eec2 commit f3bedd4
Show file tree
Hide file tree
Showing 25 changed files with 608 additions and 19 deletions.
8 changes: 8 additions & 0 deletions .changeset/old-maps-enter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@gradio/client": minor
"@gradio/icons": minor
"@gradio/statustracker": minor
"gradio": minor
---

feat:add gr.Success and update windows contributing
194 changes: 192 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,97 @@ There are a few ways to install and run Gradio.

- Clone this repo
- Navigate to the repo directory and run:
<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```bash
bash scripts/install_gradio.sh
```
</td>
<td>

```bash
scripts\install_gradio.bat
```
</td>
</tr>
</table>

- Run the frontend (only required if you are making changes to the frontend and would like to preview them)
<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```bash
bash scripts/run_frontend.sh
```
</td>
<td>

```bash
scripts\run_frontend.bat
```
</td>
</tr>
</table>

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

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

<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```bash
bash scripts/install_test_requirements.sh
```
</td>
<td>

```bash
scripts\install_test_requirements.bat
```
</td>
</tr>
</table>

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

<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```bash
bash scripts/create_test_requirements.sh
```
</td>
<td>

```bash
scripts\create_test_requirements.bat
```
</td>
</tr>
</table>


### 📦 Using dev containers

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

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

```
```py
import gradio as gr

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

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


<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```bash
bash scripts/run_frontend.sh
```
</td>
<td>

```bash
scripts\run_frontend.bat
```
</td>
</tr>
</table>

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).

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

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

<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/run_backend_tests.sh
```
</td>
<td>

```bash
scripts\run_backend_tests.bat
```
</td>
</tr>
</table>

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

Expand Down Expand Up @@ -259,7 +361,7 @@ and then from the website directory:
pnpm dev
```

#### Main vs Released
#### Main vs. Released

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

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

You can start the development server by running:
<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/run_lite.sh
```
</td>
<td>

```bash
scripts\run_lite.bat
```
</td>
</tr>
</table>

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:
```
pnpm --filter @gradio/lite pybuild
```

To generate the release build, run:
<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/build_lite.sh
```
</td>
<td>

```bash
scripts\build_lite.bat
```
</td>
</tr>
</table>
The release build will be located in the `dist` directory in the `js/lite` project.
To test it, you can run a local server in the `js/lite` directory:
```
Expand All @@ -302,15 +438,50 @@ All PRs should be submitted against `main`, and ideally should address an open i

Don't forget to format your code before pushing:

<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/format_backend.sh
```
</td>
<td>

```bash
scripts\format_backend.bat
```
</td>
</tr>
</table>

And if you made changes to the frontend:


<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/format_frontend.sh
```
</td>
<td>

```bash
scripts\format_frontend.bat
```
</td>
</tr>
</table>

Thank you for taking the time to contribute to Gradio!

Expand Down Expand Up @@ -339,10 +510,29 @@ rm pnpm-lock.yaml

and run the install scripts:


<table>
<tr>
<th>MacOS / Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>

```
bash scripts/install_gradio.sh
bash scripts/build_frontend.sh
```
</td>
<td>

```bash
scripts\install_gradio.bat
scripts\build_frontend.bat
```
</td>
</tr>
</table>
---

```FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory``` when running `scripts/build_frontend.sh`.
Expand Down
2 changes: 1 addition & 1 deletion client/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export type GradioEvent = {
export interface Log {
log: string;
title: string;
level: "warning" | "info";
level: "warning" | "info" | "success";
}
export interface Render {
data: {
Expand Down
9 changes: 2 additions & 7 deletions gradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@
FlaggingCallback,
SimpleCSVLogger,
)
from gradio.helpers import (
Info,
Progress,
Warning,
skip,
update,
)
from gradio.helpers import Info, Progress, Success, Warning, skip, update
from gradio.helpers import create_examples as Examples # noqa: N812
from gradio.interface import Interface, TabbedInterface, close_all
from gradio.layouts import Accordion, Column, Group, Row, Tab, TabItem, Tabs
Expand Down Expand Up @@ -173,6 +167,7 @@
"ImageEditor",
"ImageMask",
"Info",
"Success",
"Interface",
"JSON",
"Json",
Expand Down
Loading

0 comments on commit f3bedd4

Please sign in to comment.