EunsuKim commited on
Commit
c91d84c
·
verified ·
1 Parent(s): ce31d8d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -41,13 +41,12 @@ def get_tasks_by_type(task_type):
41
  try:
42
  with open(os.path.join(DATA_DIR, file), "r") as f:
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
50
- print(f"Skipped invalid file: {file}")
51
  return tasks
52
 
53
  # Function to dynamically add a new task type
@@ -92,7 +91,7 @@ with gr.Blocks() as app:
92
  yaml_input = gr.Textbox(
93
  label="YAML/Text Input",
94
  placeholder="Paste your YAML or text configuration here.",
95
- lines=10
96
  )
97
  submit_button = gr.Button("Submit Task")
98
  go_to_view_tab = gr.Button("Go to View Tasks")
@@ -129,15 +128,18 @@ with gr.Blocks() as app:
129
  interactive=True
130
  )
131
  view_button = gr.Button("View Tasks")
132
- task_table = gr.Dataframe(headers=["Task Type", "Description", "YAML/Text"], interactive=False)
133
  go_to_submit_tab = gr.Button("Go to Submit Task")
134
 
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
143
  view_button.click(
@@ -153,4 +155,4 @@ with gr.Blocks() as app:
153
  outputs=[tabs]
154
  )
155
 
156
- app.launch()
 
41
  try:
42
  with open(os.path.join(DATA_DIR, file), "r") as f:
43
  data = json.load(f)
44
+ print(f"File: {file}, Content: {data}") # Debug line
45
  # Filter by task type
46
  if data.get("task_type") == task_type:
 
47
  tasks.append(data)
48
+ except (json.JSONDecodeError, KeyError) as e:
49
+ print(f"Error reading file {file}: {e}") # Debug line
 
50
  return tasks
51
 
52
  # Function to dynamically add a new task type
 
91
  yaml_input = gr.Textbox(
92
  label="YAML/Text Input",
93
  placeholder="Paste your YAML or text configuration here.",
94
+ lines=20
95
  )
96
  submit_button = gr.Button("Submit Task")
97
  go_to_view_tab = gr.Button("Go to View Tasks")
 
128
  interactive=True
129
  )
130
  view_button = gr.Button("View Tasks")
131
+ task_table = gr.HTML(label="Submitted Tasks")
132
  go_to_submit_tab = gr.Button("Go to Submit Task")
133
 
134
  # Function to filter tasks by type
135
  def filter_tasks(task_type):
136
  tasks = get_tasks_by_type(task_type)
137
+ task_html = "<h3>Submitted Tasks:</h3>"
138
+ for task in tasks:
139
+ task_html += f"<b>Task Type:</b> {task['task_type']}<br>"
140
+ task_html += f"<b>Description:</b> {task['description']}<br>"
141
+ task_html += f"<b>YAML/Text:</b><pre>{task['yaml']}</pre><hr>"
142
+ return task_html
143
 
144
  # Handle task filtering
145
  view_button.click(
 
155
  outputs=[tabs]
156
  )
157
 
158
+ app.launch()