Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -143,10 +143,11 @@ async def update_validation_space_on_answer(response, type, timestamp):
|
|
143 |
# Store the error in the queue for display
|
144 |
incoming_events.put({"event": "error", "error": str(e)})
|
145 |
|
146 |
-
# Function to read the next event from the queue
|
147 |
def read_next_event():
|
148 |
if not incoming_events.empty():
|
149 |
-
|
|
|
150 |
return {}
|
151 |
|
152 |
# Function to get the current annotation progress data
|
@@ -424,16 +425,16 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="pink", secondary_hue="purple"))
|
|
424 |
return annotation_progress[code]
|
425 |
return {}
|
426 |
|
427 |
-
#
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
)
|
437 |
|
438 |
country_selector.change(
|
439 |
fn=update_country_details,
|
@@ -441,9 +442,11 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="pink", secondary_hue="purple"))
|
|
441 |
outputs=[country_progress]
|
442 |
)
|
443 |
|
444 |
-
#
|
445 |
-
gr.
|
446 |
-
|
|
|
|
|
447 |
outputs=[map_html]
|
448 |
)
|
449 |
|
|
|
143 |
# Store the error in the queue for display
|
144 |
incoming_events.put({"event": "error", "error": str(e)})
|
145 |
|
146 |
+
# Function to read the next event from the queue and update UI elements
|
147 |
def read_next_event():
|
148 |
if not incoming_events.empty():
|
149 |
+
event = incoming_events.get()
|
150 |
+
return event
|
151 |
return {}
|
152 |
|
153 |
# Function to get the current annotation progress data
|
|
|
425 |
return annotation_progress[code]
|
426 |
return {}
|
427 |
|
428 |
+
# Simple event processing functions for better compatibility
|
429 |
+
def update_events():
|
430 |
+
return read_next_event()
|
431 |
+
|
432 |
+
def update_all_stats():
|
433 |
+
return update_stats()
|
434 |
+
|
435 |
+
# Use separate timers for each component for better compatibility
|
436 |
+
gr.Timer(1, active=True).tick(update_events, outputs=events_json)
|
437 |
+
gr.Timer(5, active=True).tick(update_all_stats, outputs=[total_docs, avg_completion, countries_over_50])
|
438 |
|
439 |
country_selector.change(
|
440 |
fn=update_country_details,
|
|
|
442 |
outputs=[country_progress]
|
443 |
)
|
444 |
|
445 |
+
# Use refresh button instead of timer for map updates (more compatible across versions)
|
446 |
+
refresh_btn = gr.Button("Refresh Map")
|
447 |
+
refresh_btn.click(
|
448 |
+
fn=update_map,
|
449 |
+
inputs=None,
|
450 |
outputs=[map_html]
|
451 |
)
|
452 |
|