-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Model3D download button and other issues (#6414)
* Add code * add changeset * add changeset * add changeset * Don't bind * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
- Loading branch information
1 parent
e76a9e8
commit da1e318
Showing
9 changed files
with
2,538 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@gradio/model3d": patch | ||
"gradio": patch | ||
--- | ||
|
||
fix:Fix Model3D download button and other issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: model3d_component_events"]}, {"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", " with gr.Row():\n", " with gr.Column():\n", " input_3d = gr.Model3D(label=\"Input Model3D\")\n", " with gr.Column():\n", " output_3d = gr.Model3D(label=\"Output Model3D\")\n", " with gr.Column():\n", " num_change = gr.Number(label=\"# Change Events\", value=0)\n", " num_load = gr.Number(label=\"# Upload Events\", value=0)\n", " num_clear = gr.Number(label=\"# Clear Events\", value=0)\n", " clear_value = gr.Textbox(label=\"Clear Value\", value=\"\")\n", " input_3d.upload(lambda s, n: (s, n + 1), [input_3d, num_load], [output_3d, num_load])\n", " input_3d.change(lambda n: n + 1, num_change, num_change)\n", " input_3d.clear(lambda s, n: (s, n + 1), [input_3d, num_clear], [clear_value, num_clear])\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
with gr.Row(): | ||
with gr.Column(): | ||
input_3d = gr.Model3D(label="Input Model3D") | ||
with gr.Column(): | ||
output_3d = gr.Model3D(label="Output Model3D") | ||
with gr.Column(): | ||
num_change = gr.Number(label="# Change Events", value=0) | ||
num_load = gr.Number(label="# Upload Events", value=0) | ||
num_clear = gr.Number(label="# Clear Events", value=0) | ||
clear_value = gr.Textbox(label="Clear Value", value="") | ||
input_3d.upload(lambda s, n: (s, n + 1), [input_3d, num_load], [output_3d, num_load]) | ||
input_3d.change(lambda n: n + 1, num_change, num_change) | ||
input_3d.clear(lambda s, n: (s, n + 1), [input_3d, num_clear], [clear_value, num_clear]) | ||
|
||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { test, expect } from "@gradio/tootils"; | ||
|
||
test("Model3D click-to-upload uploads file successfuly. Upload and clear events work correctly. Downloading works.", async ({ | ||
page | ||
}) => { | ||
await page | ||
.getByRole("button", { name: "Drop File Here - or - Click to Upload" }) | ||
.click(); | ||
const uploader = await page.locator("input[type=file]"); | ||
await Promise.all([ | ||
uploader.setInputFiles(["./test/files/face.obj"]), | ||
page.waitForResponse("**/upload?*?*") | ||
]); | ||
|
||
await expect(page.getByLabel("# Change Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("1"); | ||
|
||
await page.getByLabel("Clear").nth(0).click(); | ||
await expect(page.getByLabel("# Change Events")).toHaveValue("2"); | ||
await expect(page.getByLabel("# Clear Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("Clear Value")).toHaveValue(""); | ||
|
||
const downloadPromise = page.waitForEvent("download"); | ||
await page.getByLabel("Download").click(); | ||
const download = await downloadPromise; | ||
await expect(download.suggestedFilename()).toBe("face.obj"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters