From a6e72f78149b2c879f6023494ac3445509033e4d Mon Sep 17 00:00:00 2001 From: Freddy Boulton Date: Wed, 2 Nov 2022 17:47:53 -0400 Subject: [PATCH] Fix some spaces that were not building (#2596) * Add requirements * Delete unused demo * Remove some spaces from download * explain reasoning --- .../requirements.txt | 2 + demo/components_demos/requirements.txt | 2 - demo/components_demos/run.py | 100 ------------------ demo/hello_login/run.py | 2 +- demo/map_airbnb/requirements.txt | 1 + website/homepage/upload_demos.py | 11 +- 6 files changed, 14 insertions(+), 104 deletions(-) create mode 100644 demo/blocks_multiple_event_triggers/requirements.txt delete mode 100644 demo/components_demos/requirements.txt delete mode 100644 demo/components_demos/run.py create mode 100644 demo/map_airbnb/requirements.txt diff --git a/demo/blocks_multiple_event_triggers/requirements.txt b/demo/blocks_multiple_event_triggers/requirements.txt new file mode 100644 index 0000000000..5cb63bcc8c --- /dev/null +++ b/demo/blocks_multiple_event_triggers/requirements.txt @@ -0,0 +1,2 @@ +plotly +pypistats \ No newline at end of file diff --git a/demo/components_demos/requirements.txt b/demo/components_demos/requirements.txt deleted file mode 100644 index 8248f97be9..0000000000 --- a/demo/components_demos/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -matplotlib -numpy \ No newline at end of file diff --git a/demo/components_demos/run.py b/demo/components_demos/run.py deleted file mode 100644 index 65a65a23dc..0000000000 --- a/demo/components_demos/run.py +++ /dev/null @@ -1,100 +0,0 @@ -# This file is used to embed components in gradio.app/docs - -import gradio as gr - - -with gr.Blocks() as Textbox_demo: - gr.Textbox() - -with gr.Blocks() as Number_demo: - gr.Number() - -with gr.Blocks() as Slider_demo: - gr.Slider() - -with gr.Blocks() as Checkbox_demo: - gr.Checkbox() - -with gr.Blocks() as CheckboxGroup_demo: - gr.CheckboxGroup(choices=["First Choice", "Second Choice", "Third Choice"]) - -with gr.Blocks() as Radio_demo: - gr.Radio(choices=["First Choice", "Second Choice", "Third Choice"]) - -with gr.Blocks() as Dropdown_demo: - gr.Dropdown(choices=["First Choice", "Second Choice", "Third Choice"]) - -with gr.Blocks() as Image_demo: - gr.Image() - -with gr.Blocks() as Video_demo: - gr.Video() - -with gr.Blocks() as Audio_demo: - gr.Audio() - -with gr.Blocks() as File_demo: - gr.File() - -with gr.Blocks() as Dataframe_demo: - gr.Dataframe(interactive=True) - -with gr.Blocks() as Timeseries_demo: - gr.Timeseries() - -with gr.Blocks() as State_demo: - gr.State() - -with gr.Blocks() as Button_demo: - gr.Button() - -with gr.Blocks() as ColorPicker_demo: - gr.ColorPicker() - -with gr.Blocks() as Label_demo: - gr.Label(value={"First Label": 0.7, "Second Label": 0.2, "Third Label": 0.1}) - -with gr.Blocks() as HighlightedText_demo: - gr.HighlightedText(value=[("Text","Label 1"),("to be","Label 2"),("highlighted","Label 3")]) - -with gr.Blocks() as JSON_demo: - gr.JSON(value={"Key 1": "Value 1", "Key 2": {"Key 3": "Value 2", "Key 4": "Value 3"}, "Key 5": ["Item 1", "Item 2", "Item 3"]}) - -with gr.Blocks() as HTML_demo: - gr.HTML(value="

Gradio Docs Readers: visitor badge

") - -with gr.Blocks() as Gallery_demo: - cheetahs = [ - "https://upload.wikimedia.org/wikipedia/commons/0/09/TheCheethcat.jpg", - "https://nationalzoo.si.edu/sites/default/files/animals/cheetah-003.jpg", - "https://img.etimg.com/thumb/msid-50159822,width-650,imgsize-129520,,resizemode-4,quality-100/.jpg", - "https://nationalzoo.si.edu/sites/default/files/animals/cheetah-002.jpg", - "https://images.theconversation.com/files/375893/original/file-20201218-13-a8h8uq.jpg?ixlib=rb-1.1.0&rect=16%2C407%2C5515%2C2924&q=45&auto=format&w=496&fit=clip", - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQeSdQE5kHykTdB970YGSW3AsF6MHHZzY4QiQ&usqp=CAU", - "https://www.lifegate.com/app/uploads/ghepardo-primo-piano.jpg", - "https://i.natgeofe.com/n/60004bcc-cd85-4401-8bfa-6f96551557db/cheetah-extinction-3_3x4.jpg", - "https://qph.cf2.quoracdn.net/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq" - ] - gr.Gallery(value=cheetahs) - -with gr.Blocks() as Chatbot_demo: - gr.Chatbot(value=[["Hello World","Hey Gradio!"],["❤️","😍"],["🔥","🤗"]]) - -with gr.Blocks() as Model3D_demo: - gr.Model3D() - -import matplotlib.pyplot as plt -import numpy as np - -Fs = 8000 -f = 5 -sample = 8000 -x = np.arange(sample) -y = np.sin(2 * np.pi * f * x / Fs) -plt.plot(x, y) - -with gr.Blocks() as Plot_demo: - gr.Plot(value=plt) - -with gr.Blocks() as Markdown_demo: - gr.Markdown(value="This _example_ was **written** in [Markdown](https://en.wikipedia.org/wiki/Markdown)\n") \ No newline at end of file diff --git a/demo/hello_login/run.py b/demo/hello_login/run.py index 2483f95e31..c3e4d2ecd7 100644 --- a/demo/hello_login/run.py +++ b/demo/hello_login/run.py @@ -9,6 +9,6 @@ def greet(name): demo = gr.Interface(fn=greet, inputs="text", outputs="text") if __name__ == "__main__": - demo.launch( + demo.launch(enable_queue=False, auth=lambda u, p: user_db.get(u) == p, auth_message="This is a welcome message") diff --git a/demo/map_airbnb/requirements.txt b/demo/map_airbnb/requirements.txt new file mode 100644 index 0000000000..d42d0ad03b --- /dev/null +++ b/demo/map_airbnb/requirements.txt @@ -0,0 +1 @@ +plotly \ No newline at end of file diff --git a/website/homepage/upload_demos.py b/website/homepage/upload_demos.py index ba26cd7ce3..eb81d2f298 100644 --- a/website/homepage/upload_demos.py +++ b/website/homepage/upload_demos.py @@ -15,6 +15,14 @@ with open(VERSION_TXT) as f: gradio_version=f.read() gradio_version = gradio_version.strip() +# Reasoning: +# 1. all_demos includes all demos and is for testing PRs +# 2. reset_components includes media files that are only present in all_demos (only for PRs) +# 3. custom_path doesn't have .launch since the point is to show how to launch with uvicorn +# 4. The same reason as 2 for kitchen_sink_random +DEMOS_TO_SKIP = {"all_demos", "reset_components", "custom_path", "kitchen_sink_random"} + + def upload_demo_to_space( demo_name: str, space_id: str, hf_token: str, gradio_version: Optional[str] ): @@ -62,7 +70,8 @@ def upload_demo_to_space( return f"https://huggingface.co/spaces/{space_id}" demos = os.listdir(GRADIO_DEMO_DIR) -demos = [demo for demo in demos if demo != "all_demos" and os.path.isdir(os.path.join(GRADIO_DEMO_DIR, demo)) and os.path.exists(os.path.join(GRADIO_DEMO_DIR, demo, "run.py"))] + +demos = [demo for demo in demos if demo not in DEMOS_TO_SKIP and os.path.isdir(os.path.join(GRADIO_DEMO_DIR, demo)) and os.path.exists(os.path.join(GRADIO_DEMO_DIR, demo, "run.py"))] if __name__ == "__main__": if AUTH_TOKEN is not None: