2021-12-17 00:25:09 +08:00
# Contributing to Gradio
2022-01-20 06:02:18 +08:00
Prequisites:
2022-08-30 22:42:44 +08:00
* [Python 3.7+ ](https://www.python.org/downloads/ )
* [pnpm version 7.x ](https://pnpm.io/7.x/installation ) (optional for backend-only changes, but needed for any frontend changes)
2022-01-24 22:33:01 +08:00
2022-08-30 22:42:44 +08:00
More than 80 awesome developers have contributed to the `gradio` library, and we'd be thrilled if you would like be the next `gradio` contributor! Start by cloning this repo and installing Gradio locally:
2021-12-28 02:41:42 +08:00
2022-04-21 17:07:43 +08:00
### Install Gradio locally from the `main` branch
2022-01-24 22:33:01 +08:00
2022-02-08 03:45:07 +08:00
* Clone this repo
2022-01-24 22:33:01 +08:00
* Navigate to the repo folder and run
2022-01-26 22:36:27 +08:00
```bash
bash scripts/install_gradio.sh
```
2022-02-08 03:46:13 +08:00
* Build the front end
2022-01-26 22:36:27 +08:00
2022-01-28 01:01:54 +08:00
```
2022-02-08 03:46:13 +08:00
bash scripts/build_frontend.sh
2022-01-24 22:33:01 +08:00
```
2021-12-28 02:41:42 +08:00
2022-01-28 01:01:54 +08:00
2022-08-30 22:42:44 +08:00
### Install testing requirements
2022-01-26 22:36:27 +08:00
2022-08-30 22:42:44 +08:00
In order to be able to run the Python unit tests, do the following:
* Navigate to the repo folder and install test requirements (note that it is highly recommended to use a virtual environment running **Python 3.9** since the versions are pinned)
2022-01-26 22:36:27 +08:00
2022-01-28 01:01:54 +08:00
```
2022-01-24 22:33:01 +08:00
bash scripts/install_test_requirements.sh
2022-01-26 22:36:27 +08:00
```
2022-08-30 22:42:44 +08:00
* If you have a different Python version and conflicting packages during the installation, please first run:
2022-01-24 22:33:01 +08:00
2022-05-09 13:07:12 +08:00
```
bash scripts/create_test_requirements.sh
```
2022-08-30 22:42:44 +08:00
### Extra tidbits
2022-01-28 01:01:54 +08:00
2022-05-26 01:46:28 +08:00
* You can run gradio scripts in reload mode which will watch for changes in the `gradio` folder and reload the app if changes are made.
2022-05-25 15:12:24 +08:00
```
2022-05-26 01:46:28 +08:00
gradio app.py
2022-05-25 15:12:24 +08:00
```
2022-08-30 22:42:44 +08:00
* You can also start a local frontend development server (on port 3000 by default) that responds to any changes in the frontend.
2022-01-28 01:01:54 +08:00
```
2022-08-30 22:42:44 +08:00
bash scripts/run_frontend.sh
2022-01-28 01:01:54 +08:00
```
2022-08-30 22:42:44 +08:00
* To run all of the tests, do:
2022-01-28 01:01:54 +08:00
```
2022-08-30 22:42:44 +08:00
bash scripts/run_all_tests.sh
2022-01-28 01:01:54 +08:00
```
2021-12-17 00:25:09 +08:00
2022-08-30 22:42:44 +08:00
2021-12-17 00:25:09 +08:00
### Structure of the Repository
It's helpful to know the overall structure of the repository so that you can focus on the part of the source code you'd like to contribute to
2021-12-29 12:56:42 +08:00
* `/gradio` : contains the Python source code for the library
2022-05-09 13:07:12 +08:00
* `/gradio/interface.py` : contains the Python source code for the core `Interface` class
* `/gradio/blocks.py` : contains the Python source code for the core `Blocks` class
* `/gradio/components.py` : contains the Python source code for the `components` , you can add your custom components here.
2022-04-21 17:07:43 +08:00
* `/ui` : contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/ui/README.md))
2021-12-29 12:56:42 +08:00
* `/test` : contains Python unit tests for the library
2022-05-09 13:07:12 +08:00
* `/demo` : contains demos that are used in the documentation, you can find `Gradio` examples over here.
2021-12-17 00:25:09 +08:00
* `/website` : contains the code for the Gradio website (www.gradio.app). See the README in the `/website` folder for more details
2020-06-19 00:59:45 +08:00
### Continuous Integration and Testing
2022-01-24 22:33:01 +08:00
2022-01-26 22:36:27 +08:00
All PRs must pass the continuous integration tests before merging. To test locally, you can run `python -m unittest` from the repo directory.
2020-06-19 00:59:45 +08:00
2021-12-29 13:00:01 +08:00
## Submitting PRs
2020-06-19 00:59:45 +08:00
2022-04-21 17:07:43 +08:00
All PRs should be against `main` . Direct commits to main are blocked, and PRs require an approving review to merge into main. By convention, the Gradio maintainers will review PRs when:
2022-01-24 22:33:01 +08:00
* An initial review has been requested, and
2022-08-30 22:42:44 +08:00
* A maintainer (@abidlabs, @aliabid94 , @aliabd , @AK391 , @dawoodkhan82 , @pngwn , @freddyaboulton ) is tagged in the PR comments and asked to complete a review
2022-01-24 22:33:01 +08:00
We ask that you make sure initial CI checks are passing before requesting a review. One of the Gradio maintainers will merge the PR when all the checks are passing.
2022-02-10 16:25:27 +08:00
Do not forget the format the backend before pushing.
2022-02-10 16:13:49 +08:00
```
2022-02-10 16:25:27 +08:00
bash scripts/format_backend.sh
```
2022-02-17 23:57:55 +08:00
```
bash scripts/format_frontend.sh
```
2022-02-10 16:25:27 +08:00
You can run the circleci checks locally as well.
2022-02-10 16:13:49 +08:00
```
2022-02-10 16:25:27 +08:00
bash scripts/run_circleci.sh
```
2021-12-28 10:23:15 +08:00
*Could these guidelines be clearer? Feel free to open a PR to help us faciltiate open-source contributions!*