Skip to content

Commit

Permalink
Merge branch 'main' into 7020-update-interactive-with-every
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyaboulton committed Jan 22, 2024
2 parents 30dbca6 + c17533c commit dd84f57
Show file tree
Hide file tree
Showing 100 changed files with 2,560 additions and 369 deletions.
5 changes: 0 additions & 5 deletions .changeset/huge-dogs-suffer.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/large-olives-unite.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/little-knives-switch.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/lucky-meals-sin.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/major-owls-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"website": minor
---

feat:Style changes to custom components gallery
6 changes: 0 additions & 6 deletions .changeset/orange-cameras-tell.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/sad-horses-find.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/silent-lions-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/model3d": minor
"gradio": minor
---

feat:add STL 3D model support
8 changes: 0 additions & 8 deletions .changeset/slow-ends-double.md

This file was deleted.

12 changes: 12 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# https://github.com/gradio-app/gradio/pull/4487 - refactor components.py to separate files
69f36f98535c904e7cac2b4942cecc747ed7443c
# Format the codebase
cc0cff893f9d7d472788adc2510c123967b384fe
# Switch from black to ruff
8a70e83db9c7751b46058cdd2514e6bddeef6210
# format (#4810)
7fa5e766ce0f89f1fb84c329e62c9df9c332120a
# lint website
4bf301324b3b180fa32166ff1774312b01334c88
# format frontend with prettier
980b9f60eb49ed81e4957debe7b23a559a4d4b51
# Refactor component directories (#5074)
1419538ea795caa391e3de809379f10639e9e764
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# gradio

## 4.15.0

### Highlights

#### Custom component documentation generator ([#7030](https://github.com/gradio-app/gradio/pull/7030) [`3a944ed`](https://github.com/gradio-app/gradio/commit/3a944ed9f162a224d26959a9c556346a9d205311))

If your custom component has type hints and docstrings for both parameters and return values, you can now automatically generate a documentation page and README.md with no additional effort. Simply run the following command:

```sh
gradio cc docs
```

This will generate a Gradio app that you can upload to spaces providing rich documentation for potential users. The documentation page includes:

- Installation instructions.
- A live embedded demo and working code snippet, pulled from your demo app.
- An API reference for initialising the component, with types, default values and descriptions.
- An explanation of how the component affects the user's predict function inputs and outputs.
- Any additional interfaces or classes that are necessary to understand the API reference.
- Optional links to GitHub, PyPi, and Hugging Face Spaces.

A README will also be generated detailing the same information but in a format that is optimised for viewing on GitHub or PyPi!

Thanks [@pngwn](https://github.com/pngwn)!

### Features

- [#7075](https://github.com/gradio-app/gradio/pull/7075) [`1fc8a94`](https://github.com/gradio-app/gradio/commit/1fc8a941384775f587a6ef30365960f43353cb0d) - fix lint. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#7069](https://github.com/gradio-app/gradio/pull/7069) [`07d520c`](https://github.com/gradio-app/gradio/commit/07d520c7a2590eb5544bd0b17f82ea31ecf43e00) - fix versions. Thanks [@pngwn](https://github.com/pngwn)!
- [#7058](https://github.com/gradio-app/gradio/pull/7058) [`3642b7a`](https://github.com/gradio-app/gradio/commit/3642b7ac93128793b75b94f8d785457869a4447e) - publish: simplify twine_files code. Thanks [@akx](https://github.com/akx)!
- [#7054](https://github.com/gradio-app/gradio/pull/7054) [`64c65d8`](https://github.com/gradio-app/gradio/commit/64c65d821983961111297a969946d87e2fc4105d) - Add encoding to open/writing files on the deploy_discord function. Thanks [@WilliamHarer](https://github.com/WilliamHarer)!
- [#7024](https://github.com/gradio-app/gradio/pull/7024) [`f2d69fc`](https://github.com/gradio-app/gradio/commit/f2d69fc7d0c1c3457112e702b53e38a0255fc1b7) - Fix gallery thumbnail design regression. Thanks [@hannahblair](https://github.com/hannahblair)!
- [#7018](https://github.com/gradio-app/gradio/pull/7018) [`ec28b4e`](https://github.com/gradio-app/gradio/commit/ec28b4e7c47a9233d9e3a725cc9fe8f9044dfa94) - Add `visible` and `interactive` params to `gr.Tab()`. Thanks [@hannahblair](https://github.com/hannahblair)!
- [#7060](https://github.com/gradio-app/gradio/pull/7060) [`aaecfe5`](https://github.com/gradio-app/gradio/commit/aaecfe54d913c1c4713e23233f32ae1e4239730e) - Themes: fix bogus header image URL. Thanks [@akx](https://github.com/akx)!

### Fixes

- [#7050](https://github.com/gradio-app/gradio/pull/7050) [`a336508`](https://github.com/gradio-app/gradio/commit/a3365086468568db871940fa2807454ac047cadd) - Fix bug preventing layout components to be used as custom components. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#7055](https://github.com/gradio-app/gradio/pull/7055) [`3c3cf86`](https://github.com/gradio-app/gradio/commit/3c3cf8618a8cad1ef66a7f96664923d2c9f5e0e2) - Fix UI freeze on rapid generators. Thanks [@aliabid94](https://github.com/aliabid94)!
- [#7046](https://github.com/gradio-app/gradio/pull/7046) [`9201f86`](https://github.com/gradio-app/gradio/commit/9201f86450c377f78a77ac003a5d5ff009a8894c) - Raise error in build step if custom component package is not installed. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#6933](https://github.com/gradio-app/gradio/pull/6933) [`9cefd2e`](https://github.com/gradio-app/gradio/commit/9cefd2e90a1d0cc4d3e4e953fc5b9b1a7afb68dd) - Refactor examples so they accept data in the same format as is returned by function, rename `.as_example()` to `.process_example()`. Thanks [@abidlabs](https://github.com/abidlabs)!
- [#6980](https://github.com/gradio-app/gradio/pull/6980) [`523b6bc`](https://github.com/gradio-app/gradio/commit/523b6bc534e221b028a3ea3f274c7466fe242d5a) - `gr.update(value=[])` for `gr.File()` clears it. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
- [#7038](https://github.com/gradio-app/gradio/pull/7038) [`6be3c2c`](https://github.com/gradio-app/gradio/commit/6be3c2c47a616c904c8497d1fbef7a851c54d488) - Fix Chatbot custom component template. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#6982](https://github.com/gradio-app/gradio/pull/6982) [`3f139c7`](https://github.com/gradio-app/gradio/commit/3f139c7c995f749562bb007d2a567bb167669de9) - Fix File drag and drop for specific file_types. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!

## 4.14.0

### Features
Expand Down
6 changes: 6 additions & 0 deletions client/js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @gradio/client

## 0.10.1

### Fixes

- [#7055](https://github.com/gradio-app/gradio/pull/7055) [`3c3cf86`](https://github.com/gradio-app/gradio/commit/3c3cf8618a8cad1ef66a7f96664923d2c9f5e0e2) - Fix UI freeze on rapid generators. Thanks [@aliabid94](https://github.com/aliabid94)!

## 0.10.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion client/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gradio/client",
"version": "0.10.0",
"version": "0.10.1",
"description": "Gradio API client",
"type": "module",
"main": "dist/index.js",
Expand Down
14 changes: 10 additions & 4 deletions client/js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export function api_factory(
let pending_stream_messages: Record<string, any[]> = {}; // Event messages may be received by the SSE stream before the initial data POST request is complete. To resolve this race condition, we store the messages in a dictionary and process them when the POST request is complete.
let event_stream: EventSource | null = null;
const event_callbacks: Record<string, () => Promise<void>> = {};
const unclosed_events: Set<string> = new Set();
let config: Config;
let api_map: Record<string, number> = {};

Expand Down Expand Up @@ -902,9 +903,6 @@ export function api_factory(
) {
if (event_callbacks[event_id]) {
delete event_callbacks[event_id];
if (Object.keys(event_callbacks).length === 0) {
close_stream();
}
}
}
} catch (e) {
Expand All @@ -928,6 +926,7 @@ export function api_factory(
delete pending_stream_messages[event_id];
}
event_callbacks[event_id] = callback;
unclosed_events.add(event_id);
if (!stream_open) {
open_stream();
}
Expand Down Expand Up @@ -1042,7 +1041,14 @@ export function api_factory(
)
);
} else if (event_callbacks[event_id]) {
await event_callbacks[event_id](_data);
if (_data.msg === "process_completed") {
unclosed_events.delete(event_id);
if (unclosed_events.size === 0) {
close_stream();
}
}
let fn = event_callbacks[event_id];
window.setTimeout(fn, 0, _data); // need to do this to put the event on the end of the event loop, so the browser can refresh between callbacks and not freeze in case of quick generations. See https://github.com/gradio-app/gradio/pull/7055
} else {
if (!pending_stream_messages[event_id]) {
pending_stream_messages[event_id] = [];
Expand Down
7 changes: 7 additions & 0 deletions client/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# gradio_client

## 0.8.1

### Features

- [#7075](https://github.com/gradio-app/gradio/pull/7075) [`1fc8a94`](https://github.com/gradio-app/gradio/commit/1fc8a941384775f587a6ef30365960f43353cb0d) - fix lint. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#7054](https://github.com/gradio-app/gradio/pull/7054) [`64c65d8`](https://github.com/gradio-app/gradio/commit/64c65d821983961111297a969946d87e2fc4105d) - Add encoding to open/writing files on the deploy_discord function. Thanks [@WilliamHarer](https://github.com/WilliamHarer)!

## 0.8.0

### Fixes
Expand Down
7 changes: 7 additions & 0 deletions client/python/gradio_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# gradio_client

## 0.8.1

### Features

- [#7075](https://github.com/gradio-app/gradio/pull/7075) [`1fc8a94`](https://github.com/gradio-app/gradio/commit/1fc8a941384775f587a6ef30365960f43353cb0d) - fix lint. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
- [#7054](https://github.com/gradio-app/gradio/pull/7054) [`64c65d8`](https://github.com/gradio-app/gradio/commit/64c65d821983961111297a969946d87e2fc4105d) - Add encoding to open/writing files on the deploy_discord function. Thanks [@WilliamHarer](https://github.com/WilliamHarer)!

## 0.8.0

### Fixes
Expand Down
10 changes: 8 additions & 2 deletions client/python/gradio_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,18 @@ def deploy_discord(
metadata={"tags": ["gradio-discord-bot"]},
)

with open(str(Path(__file__).parent / "templates" / "discord_chat.py")) as f:
with open(
str(Path(__file__).parent / "templates" / "discord_chat.py"),
encoding="utf-8",
) as f:
app = f.read()
app = app.replace("<<app-src>>", self.src)
app = app.replace("<<api-name>>", api_names[0][0])
app = app.replace("<<command-name>>", api_names[0][1])

with tempfile.NamedTemporaryFile(mode="w", delete=False) as app_file:
with tempfile.NamedTemporaryFile(
mode="w", delete=False, encoding="utf-8"
) as app_file:
with tempfile.NamedTemporaryFile(mode="w", delete=False) as requirements:
app_file.write(app)
requirements.write("\n".join(["discord.py==2.3.1"]))
Expand Down Expand Up @@ -1554,6 +1559,7 @@ def __next__(self) -> tuple | Any:
return o
if self.communicator.job.latest_status.code == Status.FINISHED:
raise StopIteration()
time.sleep(0.001)

def result(self, timeout: float | None = None) -> Any:
"""
Expand Down
2 changes: 1 addition & 1 deletion client/python/gradio_client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gradio_client",
"version": "0.8.0",
"version": "0.8.1",
"description": "",
"python": "true",
"main_changeset": true
Expand Down
1 change: 1 addition & 0 deletions demo/imageeditor_component/run.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: imageeditor_component"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.ImageEditor()\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
6 changes: 6 additions & 0 deletions demo/imageeditor_component/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import gradio as gr

with gr.Blocks() as demo:
gr.ImageEditor()

demo.launch()
Binary file added demo/model3D/files/sofia.stl
Binary file not shown.
6 changes: 5 additions & 1 deletion demo/model3D/files/source.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ Duck & Fox:
https://github.com/KhronosGroup/glTF-Sample-Models

Face:
https://github.com/mikedh/trimesh/tree/main/models
https://github.com/mikedh/trimesh/tree/main/models

NASA SOFIA:
https://nasa3d.arc.nasa.gov/detail/sofia
https://github.com/nasa/NASA-3D-Resources/blob/master/3D%20Models/SOFIA/Fuselage_top.stl
2 changes: 1 addition & 1 deletion demo/model3D/run.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: model3D"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('files')\n", "!wget -q -O files/Bunny.obj https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Bunny.obj\n", "!wget -q -O files/Duck.glb https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Duck.glb\n", "!wget -q -O files/Fox.gltf https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Fox.gltf\n", "!wget -q -O files/face.obj https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/face.obj\n", "!wget -q -O files/source.txt https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/source.txt"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "\n", "\n", "def load_mesh(mesh_file_name):\n", " return mesh_file_name\n", "\n", "\n", "demo = gr.Interface(\n", " fn=load_mesh,\n", " inputs=gr.Model3D(),\n", " outputs=gr.Model3D(\n", " clear_color=[0.0, 0.0, 0.0, 0.0], label=\"3D Model\"),\n", " examples=[\n", " [os.path.join(os.path.abspath(''), \"files/Bunny.obj\")],\n", " [os.path.join(os.path.abspath(''), \"files/Duck.glb\")],\n", " [os.path.join(os.path.abspath(''), \"files/Fox.gltf\")],\n", " [os.path.join(os.path.abspath(''), \"files/face.obj\")],\n", " ],\n", " cache_examples=True\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: model3D"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('files')\n", "!wget -q -O files/Bunny.obj https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Bunny.obj\n", "!wget -q -O files/Duck.glb https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Duck.glb\n", "!wget -q -O files/Fox.gltf https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/Fox.gltf\n", "!wget -q -O files/face.obj https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/face.obj\n", "!wget -q -O files/sofia.stl https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/sofia.stl\n", "!wget -q -O files/source.txt https://github.com/gradio-app/gradio/raw/main/demo/model3D/files/source.txt"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "\n", "\n", "def load_mesh(mesh_file_name):\n", " return mesh_file_name\n", "\n", "\n", "demo = gr.Interface(\n", " fn=load_mesh,\n", " inputs=gr.Model3D(),\n", " outputs=gr.Model3D(\n", " clear_color=[0.0, 0.0, 0.0, 0.0], label=\"3D Model\"),\n", " examples=[\n", " [os.path.join(os.path.abspath(''), \"files/Bunny.obj\")],\n", " [os.path.join(os.path.abspath(''), \"files/Duck.glb\")],\n", " [os.path.join(os.path.abspath(''), \"files/Fox.gltf\")],\n", " [os.path.join(os.path.abspath(''), \"files/face.obj\")],\n", " [os.path.join(os.path.abspath(''), \"files/sofia.stl\")],\n", " ],\n", " cache_examples=True\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
1 change: 1 addition & 0 deletions demo/model3D/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def load_mesh(mesh_file_name):
[os.path.join(os.path.dirname(__file__), "files/Duck.glb")],
[os.path.join(os.path.dirname(__file__), "files/Fox.gltf")],
[os.path.join(os.path.dirname(__file__), "files/face.obj")],
[os.path.join(os.path.dirname(__file__), "files/sofia.stl")],
],
cache_examples=True
)
Expand Down

0 comments on commit dd84f57

Please sign in to comment.