Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .gitattributes +1 -0
- contributing.md +239 -0
- fex demo.mp4 +3 -0
- lorem.txt +9 -0
- zipped_files.zip +3 -0
.gitattributes
CHANGED
@@ -37,3 +37,4 @@ sdxl/image[[:space:]](1).png filter=lfs diff=lfs merge=lfs -text
|
|
37 |
sdxl/image[[:space:]](2).png filter=lfs diff=lfs merge=lfs -text
|
38 |
sdxl/image[[:space:]](3).png filter=lfs diff=lfs merge=lfs -text
|
39 |
sdxl/image.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
37 |
sdxl/image[[:space:]](2).png filter=lfs diff=lfs merge=lfs -text
|
38 |
sdxl/image[[:space:]](3).png filter=lfs diff=lfs merge=lfs -text
|
39 |
sdxl/image.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
fex[[:space:]]demo.mp4 filter=lfs diff=lfs merge=lfs -text
|
contributing.md
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to Gradio
|
2 |
+
|
3 |
+

|
4 |
+
|
5 |
+
|
6 |
+
More than 200 awesome developers have contributed to the `gradio` library, and we'd be thrilled if you would like to be the next contributor!
|
7 |
+
|
8 |
+
Prerequisites:
|
9 |
+
|
10 |
+
- [Python 3.8+](https://www.python.org/downloads/)
|
11 |
+
- [Node.js v16.14+](https://nodejs.dev/en/download/package-manager/) (only needed if you are making changes to the frontend)
|
12 |
+
- [pnpm 8.1+](https://pnpm.io/8.x/installation) (only needed if you are making changes to the frontend)
|
13 |
+
|
14 |
+
## ๐ก Setup for local development
|
15 |
+
|
16 |
+
There are a few ways to install and run Gradio.
|
17 |
+
|
18 |
+
### ๐ ๏ธ Install Gradio locally from `main`
|
19 |
+
|
20 |
+
- Clone this repo
|
21 |
+
- Navigate to the repo directory and (from the root directory) run
|
22 |
+
|
23 |
+
```bash
|
24 |
+
bash scripts/install_gradio.sh
|
25 |
+
```
|
26 |
+
|
27 |
+
- Build the front end
|
28 |
+
|
29 |
+
```
|
30 |
+
bash scripts/build_frontend.sh
|
31 |
+
```
|
32 |
+
|
33 |
+
- Install development requirements
|
34 |
+
|
35 |
+
(Note that it is highly recommended to use a virtual environment running **Python 3.9** since the versions of Gradio's dependencies are pinned)
|
36 |
+
|
37 |
+
```
|
38 |
+
bash scripts/install_test_requirements.sh
|
39 |
+
```
|
40 |
+
|
41 |
+
If you have a different Python version and conflicting packages during the installation, please first run:
|
42 |
+
|
43 |
+
```
|
44 |
+
bash scripts/create_test_requirements.sh
|
45 |
+
```
|
46 |
+
|
47 |
+
### ๐ฆ Using dev containers
|
48 |
+
|
49 |
+
You can alternatively use dev containers. This is supported on all platforms (macOS/Windows/Linux), as well as on GitHub Codespaces.
|
50 |
+
|
51 |
+
Prerequisites:
|
52 |
+
|
53 |
+
- An editor which supports dev containers, like VS Code
|
54 |
+
- Docker support on the host computer:
|
55 |
+
- macOS: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
|
56 |
+
- Windows: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
|
57 |
+
- Linux: [Docker CE/EE 18.06+](https://docs.docker.com/get-docker/) and [Docker Compose 1.21+](https://docs.docker.com/compose/install/)
|
58 |
+
- If using VS Code, the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
|
59 |
+
|
60 |
+
Steps:
|
61 |
+
|
62 |
+
- Clone repository
|
63 |
+
- Open it in your editor
|
64 |
+
- For VS Code, execute `Dev Containers: Reopen in container` command
|
65 |
+
|
66 |
+
For detailed instructions, please see the [Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial).
|
67 |
+
|
68 |
+
## ๐งฑ Structure of the Repository
|
69 |
+
|
70 |
+
If you're a newcomer to Gradio, we recommend getting familiar with the overall structure of the repository so that you can focus on the part of the source code you'd like to contribute to.
|
71 |
+
|
72 |
+
- `/gradio`: contains the Python source code for the library
|
73 |
+
- `/gradio/interface.py`: contains the Python source code for the core `Interface` class
|
74 |
+
- `/gradio/blocks.py`: contains the Python source code for the core `Blocks` class
|
75 |
+
- `/gradio/components/`: the directory that contains the Python source code for all of the Gradio components.
|
76 |
+
- `/js`: contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/js/README.md))
|
77 |
+
- `/js/_website`: contains the code for the Gradio website (www.gradio.app). See the README in the `/js/_website` folder for more details
|
78 |
+
- `/test`: contains Python unit tests for the library
|
79 |
+
- `/demo`: contains demos that are used in the documentation, you can find `Gradio` examples over here.
|
80 |
+
|
81 |
+
|
82 |
+
## ๐ Run a Gradio app
|
83 |
+
|
84 |
+
You can get started by creating an `app.py` file in the root:
|
85 |
+
|
86 |
+
```
|
87 |
+
import gradio as gr
|
88 |
+
|
89 |
+
with gr.Blocks() as demo:
|
90 |
+
gr.Button()
|
91 |
+
|
92 |
+
if __name__ == "__main__":
|
93 |
+
demo.launch()
|
94 |
+
```
|
95 |
+
|
96 |
+
then run:
|
97 |
+
|
98 |
+
```
|
99 |
+
gradio app.py
|
100 |
+
```
|
101 |
+
|
102 |
+
This will start the backend server in reload mode, which will watch for changes in the `gradio` folder and reload the app if changes are made. By default, Gradio will launch on port 7860. You can also just use `python app.py`, but this won't automatically trigger updates.
|
103 |
+
|
104 |
+
|
105 |
+
If you're making frontend changes, start the frontend server:
|
106 |
+
|
107 |
+
```
|
108 |
+
pnpm dev
|
109 |
+
```
|
110 |
+
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).
|
111 |
+
|
112 |
+
We also have demos of all our components in the `/gradio/demo` directory. To get our simple gradio Chatbot running locally:
|
113 |
+
|
114 |
+
```
|
115 |
+
gradio demo/chatbot_simple/run.py
|
116 |
+
```
|
117 |
+
|
118 |
+
|
119 |
+
## ๐งช Testing
|
120 |
+
|
121 |
+
We use Pytest, Playwright and Vitest to test our code.
|
122 |
+
|
123 |
+
- The Python tests are located in `/test`. To run these tests:
|
124 |
+
|
125 |
+
```
|
126 |
+
bash scripts/run_all_tests.sh
|
127 |
+
```
|
128 |
+
|
129 |
+
- The frontend unit tests are any defined with the filename `*.test.ts`. To run them:
|
130 |
+
|
131 |
+
```
|
132 |
+
pnpm test
|
133 |
+
```
|
134 |
+
|
135 |
+
- Browser tests are located in `js/app/test` and are defined as `*spec.ts` files. To run browser tests:
|
136 |
+
|
137 |
+
```
|
138 |
+
pnpm test:browser
|
139 |
+
```
|
140 |
+
|
141 |
+
To build the frontend code before running browser tests:
|
142 |
+
|
143 |
+
```
|
144 |
+
pnpm test:browser:full
|
145 |
+
```
|
146 |
+
|
147 |
+
You can also run browser tests in the UI mode by adding the `--ui` flag:
|
148 |
+
|
149 |
+
```
|
150 |
+
pnpm test:browser --ui
|
151 |
+
```
|
152 |
+
|
153 |
+
If you have made any significant visual changes to a component, we encourage you to add a new Storybook story or amend an existing one to reflect them. You can create a new story with a `*.stories.svelte` file.
|
154 |
+
|
155 |
+
## ๐ธ๏ธ Gradio Website
|
156 |
+
|
157 |
+
We also welcome any contributions to our [website](https://www.gradio.app).
|
158 |
+
|
159 |
+
First, build the website:
|
160 |
+
|
161 |
+
```
|
162 |
+
pnpm build:cdn-local
|
163 |
+
```
|
164 |
+
then serve the website build:
|
165 |
+
```
|
166 |
+
pnpm preview:cdn-local
|
167 |
+
```
|
168 |
+
|
169 |
+
This will serve a build of `gradio.js` on port `4321`. You can then navigate to `js/_website/src/routes/+layout.svelte` and replace the source of the website build from:
|
170 |
+
```
|
171 |
+
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/{version}/gradio.js"></script>
|
172 |
+
```
|
173 |
+
to
|
174 |
+
```
|
175 |
+
<script type="module" src="http://localhost:4321/gradio.js"></script>
|
176 |
+
```
|
177 |
+
|
178 |
+
You should now be able to view a local version of the website at `http://localhost:4321`.
|
179 |
+
## ๐ Component Storybook
|
180 |
+
|
181 |
+
If you would like to fix an issue or contribute to our Storybook, you can get it running locally with:
|
182 |
+
|
183 |
+
```
|
184 |
+
pnpm storybook
|
185 |
+
```
|
186 |
+
|
187 |
+
|
188 |
+
## ๐ฎ Submitting PRs
|
189 |
+
|
190 |
+
All PRs should be against `main`, and ideally should address an open issue, unless the change is small. 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:
|
191 |
+
|
192 |
+
- An initial review has been requested
|
193 |
+
- A clear, descriptive title has been assigned to the PR
|
194 |
+
- A maintainer (@abidlabs, @aliabid94, @aliabd, @AK391, @dawoodkhan82, @pngwn, @freddyaboulton, @hannahblair) is tagged in the PR comments and asked to complete a review
|
195 |
+
|
196 |
+
๐งน 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. You can safely ignore the Vercel and Spaces checks, which only run under maintainers' pull requests.
|
197 |
+
|
198 |
+
Don't forget the format your code before pushing:
|
199 |
+
|
200 |
+
```
|
201 |
+
bash scripts/format_backend.sh
|
202 |
+
```
|
203 |
+
|
204 |
+
```
|
205 |
+
bash scripts/format_frontend.sh
|
206 |
+
```
|
207 |
+
|
208 |
+
Thank you for taking the time to contribute to our project!
|
209 |
+
## โ Need help getting started?
|
210 |
+
|
211 |
+
- Browse [issues](https://github.com/gradio-app/gradio/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) with the "good first issue" label. These are issues we think are good for newcomers.
|
212 |
+
- Ask the Gradio community in our [Discord](https://discord.com/invite/feTf9x3ZSB)
|
213 |
+
- Raise an issue for a feature or a bug you want to tackle
|
214 |
+
|
215 |
+
## ๐ง Troubleshooting
|
216 |
+
`ERROR: Error loading ASGI app. Could not import module "<filename>"`
|
217 |
+
|
218 |
+
Verify that you've used the correct filename of your gradio app, and that you're in the directory of the file.
|
219 |
+
|
220 |
+
---
|
221 |
+
|
222 |
+
```ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @gradio/[email protected] build:local: vite build --mode production:local --emptyOutDir "--emptyOutDir"```
|
223 |
+
|
224 |
+
Delete `/node_modules` and `pnpm-lock.yaml`:
|
225 |
+
|
226 |
+
```
|
227 |
+
rm -rf node_modules/
|
228 |
+
rm pnpm-lock.yaml
|
229 |
+
```
|
230 |
+
|
231 |
+
and run the install scripts:
|
232 |
+
|
233 |
+
```
|
234 |
+
bash scripts/install_gradio.sh
|
235 |
+
bash scripts/build_frontend.sh
|
236 |
+
```
|
237 |
+
---
|
238 |
+
|
239 |
+
_Could these guidelines be clearer? Feel free to open a PR to help us faciltiate open-source contributions!_
|
fex demo.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a1eb9d8ae1665867e0565ce7d14c157bbabe25b07ae9d442ea23367742d7c96c
|
3 |
+
size 1927911
|
lorem.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a dui ac purus cursus dignissim nec in purus. Donec iaculis turpis ac eros gravida, ac iaculis odio faucibus. Curabitur condimentum venenatis mi, et bibendum est accumsan sed. Quisque volutpat nec nulla quis congue. Etiam hendrerit neque massa, eu mollis orci molestie sed. Nam in dui eget neque ultrices imperdiet id vitae lacus. Maecenas vel odio aliquet, maximus lectus in, porttitor quam.
|
2 |
+
|
3 |
+
Nunc interdum dictum purus sit amet maximus. Aliquam ac bibendum justo. Mauris tempor tortor id purus iaculis scelerisque id a massa. Vivamus ante metus, dapibus sed risus sed, accumsan efficitur dolor. Suspendisse turpis elit, feugiat posuere lobortis nec, bibendum vel ipsum. Nulla consectetur maximus sem in feugiat. Suspendisse congue congue erat vitae fermentum.
|
4 |
+
|
5 |
+
Curabitur erat nunc, dignissim ut justo a, pulvinar consequat mauris. Nulla consequat ex erat, nec blandit lorem interdum vitae. Maecenas eleifend ex vel quam sollicitudin malesuada. Donec sodales facilisis lacus, sit amet pretium odio semper vel. Cras eleifend vehicula eros a bibendum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec ipsum augue, vulputate ut laoreet a, ultrices id velit. Phasellus mollis consectetur turpis sit amet volutpat. Sed dapibus pretium orci at aliquam.
|
6 |
+
|
7 |
+
Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla facilisi. Proin ut sapien maximus, vehicula odio eu, commodo elit. Nullam ut cursus ante. Praesent sit amet tortor lacinia, rutrum erat ut, porta elit. Aenean ultricies libero sit amet felis commodo convallis ac in arcu. Fusce tempor, urna vitae volutpat egestas, quam ipsum varius diam, id ultricies nibh orci non nibh.
|
8 |
+
|
9 |
+
Suspendisse varius tristique mauris at gravida. Vestibulum ipsum nibh, consectetur sed eros in, tempus tristique neque. Phasellus vel rhoncus magna. Ut id tristique ligula. Duis id consectetur ipsum, eget ornare mi. Fusce viverra lectus eu risus tincidunt, nec semper felis congue. Duis in imperdiet diam. In pretium risus et ultrices iaculis. Proin eget quam ac dolor tristique commodo. Curabitur elit elit, aliquam vel est id, interdum bibendum est.
|
zipped_files.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f51e65d5b63ce4f255a6b30f31cfec48cc7367e6a5d8550302f489fe45a55a3
|
3 |
+
size 366
|