Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ def submit_task(task_type, description, yaml_text):
|
|
25 |
try:
|
26 |
with open(file_path, "w") as f:
|
27 |
json.dump(data, f)
|
|
|
28 |
return f"Task submitted successfully under type '{task_type}'!"
|
29 |
except Exception as e:
|
30 |
return f"Error saving task: {e}"
|
@@ -42,6 +43,7 @@ def get_tasks_by_type(task_type):
|
|
42 |
data = json.load(f)
|
43 |
# Filter by task type
|
44 |
if data.get("task_type") == task_type:
|
|
|
45 |
tasks.append(data)
|
46 |
except (json.JSONDecodeError, KeyError):
|
47 |
# Skip invalid or corrupted files
|
@@ -55,6 +57,10 @@ def add_new_task_type(new_type):
|
|
55 |
return gr.update(choices=TASK_TYPES), f"Task type '{new_type}' added successfully!"
|
56 |
return gr.update(choices=TASK_TYPES), "Task type already exists or invalid input."
|
57 |
|
|
|
|
|
|
|
|
|
58 |
# Gradio App
|
59 |
with gr.Blocks() as app:
|
60 |
gr.Markdown("# Task Configuration Sharing Space")
|
@@ -129,6 +135,8 @@ with gr.Blocks() as app:
|
|
129 |
# Function to filter tasks by type
|
130 |
def filter_tasks(task_type):
|
131 |
tasks = get_tasks_by_type(task_type)
|
|
|
|
|
132 |
return [{"Task Type": t["task_type"], "Description": t["description"], "YAML/Text": t["yaml"]} for t in tasks]
|
133 |
|
134 |
# Handle task filtering
|
@@ -145,4 +153,4 @@ with gr.Blocks() as app:
|
|
145 |
outputs=[tabs]
|
146 |
)
|
147 |
|
148 |
-
app.launch()
|
|
|
25 |
try:
|
26 |
with open(file_path, "w") as f:
|
27 |
json.dump(data, f)
|
28 |
+
print(f"Saved file: {file_path}, Contents: {data}") # Debug line
|
29 |
return f"Task submitted successfully under type '{task_type}'!"
|
30 |
except Exception as e:
|
31 |
return f"Error saving task: {e}"
|
|
|
43 |
data = json.load(f)
|
44 |
# Filter by task type
|
45 |
if data.get("task_type") == task_type:
|
46 |
+
print(f"Retrieved task: {data}") # Debug line
|
47 |
tasks.append(data)
|
48 |
except (json.JSONDecodeError, KeyError):
|
49 |
# Skip invalid or corrupted files
|
|
|
57 |
return gr.update(choices=TASK_TYPES), f"Task type '{new_type}' added successfully!"
|
58 |
return gr.update(choices=TASK_TYPES), "Task type already exists or invalid input."
|
59 |
|
60 |
+
# Function to switch tabs
|
61 |
+
def switch_tab(tab_name):
|
62 |
+
return gr.Tabs.update(visible_tab=tab_name)
|
63 |
+
|
64 |
# Gradio App
|
65 |
with gr.Blocks() as app:
|
66 |
gr.Markdown("# Task Configuration Sharing Space")
|
|
|
135 |
# Function to filter tasks by type
|
136 |
def filter_tasks(task_type):
|
137 |
tasks = get_tasks_by_type(task_type)
|
138 |
+
for task in tasks: # Debug line
|
139 |
+
print(f"Task to display: {task}") # Debug line
|
140 |
return [{"Task Type": t["task_type"], "Description": t["description"], "YAML/Text": t["yaml"]} for t in tasks]
|
141 |
|
142 |
# Handle task filtering
|
|
|
153 |
outputs=[tabs]
|
154 |
)
|
155 |
|
156 |
+
app.launch()
|