Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: queue_full_e2e_test"]}, {"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", "import time\n", "import random\n", "\n", "n_calls = 0\n", "\n", "def get_random_number():\n", " global n_calls\n", " if n_calls == 1:\n", " n_calls += 1\n", " raise gr.Error(\"This is a gradio error\")\n", " n_calls += 1\n", " time.sleep(5)\n", " return random.randrange(1, 10)\n", "\n", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: queue_full_e2e_test"]}, {"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", "import time\n", "import random\n", "\n", "n_calls = 0\n", "\n", "def get_random_number():\n", " global n_calls\n", " if n_calls == 1:\n", " n_calls += 1\n", " raise gr.Error(\"This is a gradio error\")\n", " n_calls += 1\n", " time.sleep(5)\n", " return random.randrange(1, 10)\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " with gr.Column():\n", " first = gr.Button(\"First Call\")\n", " second = gr.Button(\"Second Call\")\n", " third = gr.Button(\"Third Call\")\n", " fourth = gr.Button(\"Fourth Call\")\n", " with gr.Column():\n", " first_o = gr.Number(label=\"First Result\")\n", " second_o = gr.Number(label=\"Second Result\")\n", " third_o = gr.Number(label=\"Third Result\")\n", " fourth_o = gr.Number(label=\"Fourth Result\")\n", "\n", " first.click(get_random_number, None, first_o, concurrency_id=\"f\")\n", " second.click(get_random_number, None, second_o, concurrency_id=\"f\")\n", " third.click(get_random_number, None, third_o, concurrency_id=\"f\")\n", " fourth.click(get_random_number, None, fourth_o, concurrency_id=\"f\")\n", "\n", "demo.queue(max_size=2)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -13,7 +13,6 @@ def get_random_number():
|
|
| 13 |
time.sleep(5)
|
| 14 |
return random.randrange(1, 10)
|
| 15 |
|
| 16 |
-
|
| 17 |
with gr.Blocks() as demo:
|
| 18 |
with gr.Row():
|
| 19 |
with gr.Column():
|
|
@@ -26,7 +25,7 @@ with gr.Blocks() as demo:
|
|
| 26 |
second_o = gr.Number(label="Second Result")
|
| 27 |
third_o = gr.Number(label="Third Result")
|
| 28 |
fourth_o = gr.Number(label="Fourth Result")
|
| 29 |
-
|
| 30 |
first.click(get_random_number, None, first_o, concurrency_id="f")
|
| 31 |
second.click(get_random_number, None, second_o, concurrency_id="f")
|
| 32 |
third.click(get_random_number, None, third_o, concurrency_id="f")
|
|
|
|
| 13 |
time.sleep(5)
|
| 14 |
return random.randrange(1, 10)
|
| 15 |
|
|
|
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
with gr.Row():
|
| 18 |
with gr.Column():
|
|
|
|
| 25 |
second_o = gr.Number(label="Second Result")
|
| 26 |
third_o = gr.Number(label="Third Result")
|
| 27 |
fourth_o = gr.Number(label="Fourth Result")
|
| 28 |
+
|
| 29 |
first.click(get_random_number, None, first_o, concurrency_id="f")
|
| 30 |
second.click(get_random_number, None, second_o, concurrency_id="f")
|
| 31 |
third.click(get_random_number, None, third_o, concurrency_id="f")
|