Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import json
|
|
|
|
| 4 |
|
| 5 |
# Directory to store submissions
|
| 6 |
DATA_DIR = "submissions"
|
|
@@ -9,6 +10,9 @@ os.makedirs(DATA_DIR, exist_ok=True)
|
|
| 9 |
# Predefined task types
|
| 10 |
TASK_TYPES = ["Classification", "Regression", "Translation"]
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
# Function to handle task submission
|
| 13 |
def submit_task(task_type, description, yaml_text):
|
| 14 |
if not yaml_text.strip():
|
|
@@ -128,24 +132,34 @@ with gr.Blocks() as app:
|
|
| 128 |
interactive=True
|
| 129 |
)
|
| 130 |
view_button = gr.Button("View Tasks")
|
| 131 |
-
|
| 132 |
go_to_submit_tab = gr.Button("Go to Submit Task")
|
| 133 |
|
| 134 |
-
# Function to
|
| 135 |
-
def
|
| 136 |
tasks = get_tasks_by_type(task_type)
|
| 137 |
-
|
| 138 |
-
for task in tasks:
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
view_button.click(
|
| 146 |
-
|
| 147 |
inputs=[task_type_filter],
|
| 148 |
-
outputs=[
|
| 149 |
)
|
| 150 |
|
| 151 |
# Button to switch to "Submit Task" tab
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
+
import random
|
| 5 |
|
| 6 |
# Directory to store submissions
|
| 7 |
DATA_DIR = "submissions"
|
|
|
|
| 10 |
# Predefined task types
|
| 11 |
TASK_TYPES = ["Classification", "Regression", "Translation"]
|
| 12 |
|
| 13 |
+
# Colors for task cards
|
| 14 |
+
CARD_COLORS = ["#FFDDC1", "#FFABAB", "#FFC3A0", "#D5AAFF", "#85E3FF", "#B9FBC0"]
|
| 15 |
+
|
| 16 |
# Function to handle task submission
|
| 17 |
def submit_task(task_type, description, yaml_text):
|
| 18 |
if not yaml_text.strip():
|
|
|
|
| 132 |
interactive=True
|
| 133 |
)
|
| 134 |
view_button = gr.Button("View Tasks")
|
| 135 |
+
task_display = gr.HTML(label="Submitted Tasks")
|
| 136 |
go_to_submit_tab = gr.Button("Go to Submit Task")
|
| 137 |
|
| 138 |
+
# Function to display tasks as clickable cards
|
| 139 |
+
def display_tasks(task_type):
|
| 140 |
tasks = get_tasks_by_type(task_type)
|
| 141 |
+
html_content = "<div style='display: flex; flex-wrap: wrap; gap: 10px;'>"
|
| 142 |
+
for idx, task in enumerate(tasks):
|
| 143 |
+
color = random.choice(CARD_COLORS)
|
| 144 |
+
html_content += f"""
|
| 145 |
+
<div style='background-color: {color}; padding: 10px; border-radius: 5px; cursor: pointer;' onclick="document.getElementById('task-details-{idx}').style.display='block';">
|
| 146 |
+
<b>{task['description']}</b>
|
| 147 |
+
</div>
|
| 148 |
+
<div id='task-details-{idx}' style='display: none; margin-top: 10px;'>
|
| 149 |
+
<b>Task Type:</b> {task['task_type']}<br>
|
| 150 |
+
<b>Description:</b> {task['description']}<br>
|
| 151 |
+
<b>YAML/Text:</b><pre>{task['yaml']}</pre>
|
| 152 |
+
<hr>
|
| 153 |
+
</div>
|
| 154 |
+
"""
|
| 155 |
+
html_content += "</div>"
|
| 156 |
+
return html_content
|
| 157 |
+
|
| 158 |
+
# Handle task display
|
| 159 |
view_button.click(
|
| 160 |
+
display_tasks,
|
| 161 |
inputs=[task_type_filter],
|
| 162 |
+
outputs=[task_display]
|
| 163 |
)
|
| 164 |
|
| 165 |
# Button to switch to "Submit Task" tab
|