aliabd commited on
Commit
8389f20
·
verified ·
1 Parent(s): c4a4845

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +6 -6
  2. run.ipynb +1 -0
  3. run.py +38 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Queue Full E2e Test
3
- emoji: 🐠
4
- colorFrom: purple
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.17.0
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: queue_full_e2e_test
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 4.17.0
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
run.ipynb ADDED
@@ -0,0 +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", "\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 ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ import random
4
+
5
+ n_calls = 0
6
+
7
+ def get_random_number():
8
+ global n_calls
9
+ if n_calls == 1:
10
+ n_calls += 1
11
+ raise gr.Error("This is a gradio error")
12
+ n_calls += 1
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():
20
+ first = gr.Button("First Call")
21
+ second = gr.Button("Second Call")
22
+ third = gr.Button("Third Call")
23
+ fourth = gr.Button("Fourth Call")
24
+ with gr.Column():
25
+ first_o = gr.Number(label="First Result")
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")
33
+ fourth.click(get_random_number, None, fourth_o, concurrency_id="f")
34
+
35
+ demo.queue(max_size=2)
36
+
37
+ if __name__ == "__main__":
38
+ demo.launch()