Commit
·
160dbfd
1
Parent(s):
22c03cf
Add last submission update time tracking to refresh submissions
Browse files- gradio_interface.py +5 -2
gradio_interface.py
CHANGED
@@ -13,10 +13,11 @@ SUBMISSION_REPO = "SushantGautam/medvqa-submissions"
|
|
13 |
hub_path = None
|
14 |
|
15 |
submissions = None # [{"user": u, "task": t, "submitted_time": ts}]
|
|
|
16 |
|
17 |
|
18 |
def refresh_submissions():
|
19 |
-
global hub_path, submissions
|
20 |
if hub_path and Path(hub_path).exists():
|
21 |
shutil.rmtree(hub_path, ignore_errors=True)
|
22 |
print("Deleted existing submissions")
|
@@ -35,6 +36,8 @@ def refresh_submissions():
|
|
35 |
".json", "").split("-_-_-")
|
36 |
submissions.append({"user": username, "task": task,
|
37 |
"submitted_time": sub_timestamp})
|
|
|
|
|
38 |
return hub_path
|
39 |
|
40 |
|
@@ -60,7 +63,7 @@ def filter_submissions(task_type, search_query):
|
|
60 |
|
61 |
|
62 |
def display_submissions(task_type="all", search_query=""):
|
63 |
-
if submissions is None:
|
64 |
refresh_submissions()
|
65 |
filtered_submissions = filter_submissions(task_type, search_query)
|
66 |
return [[s["user"], s["task"], s["submitted_time"]] for s in filtered_submissions]
|
|
|
13 |
hub_path = None
|
14 |
|
15 |
submissions = None # [{"user": u, "task": t, "submitted_time": ts}]
|
16 |
+
last_submission_update_time = datetime.now(timezone.utc)
|
17 |
|
18 |
|
19 |
def refresh_submissions():
|
20 |
+
global hub_path, submissions, last_submission_update_time
|
21 |
if hub_path and Path(hub_path).exists():
|
22 |
shutil.rmtree(hub_path, ignore_errors=True)
|
23 |
print("Deleted existing submissions")
|
|
|
36 |
".json", "").split("-_-_-")
|
37 |
submissions.append({"user": username, "task": task,
|
38 |
"submitted_time": sub_timestamp})
|
39 |
+
last_submission_update_time = datetime.now(timezone.utc)
|
40 |
+
|
41 |
return hub_path
|
42 |
|
43 |
|
|
|
63 |
|
64 |
|
65 |
def display_submissions(task_type="all", search_query=""):
|
66 |
+
if submissions is None or ((datetime.now(timezone.utc) - last_submission_update_time).seconds > 3600):
|
67 |
refresh_submissions()
|
68 |
filtered_submissions = filter_submissions(task_type, search_query)
|
69 |
return [[s["user"], s["task"], s["submitted_time"]] for s in filtered_submissions]
|