Commit
·
c6b2561
1
Parent(s):
00aad64
Uncomment submission deletion logic in refresh_submissions function and update time handling for submission timestamps
Browse files- gradio_interface.py +5 -4
gradio_interface.py
CHANGED
@@ -16,9 +16,9 @@ submissions = None # [{"user": u, "task": t, "submitted_time": ts}]
|
|
16 |
|
17 |
def refresh_submissions():
|
18 |
global hub_path, submissions
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
hub_path = snapshot_download(repo_type="dataset",
|
24 |
repo_id=SUBMISSION_REPO, allow_patterns=['*.json'])
|
@@ -45,7 +45,8 @@ hub_dir = hub_path.split("snapshot")[0] + "snapshot"
|
|
45 |
|
46 |
|
47 |
def time_ago(submitted_time):
|
48 |
-
delta = datetime.now(timezone.utc) -
|
|
|
49 |
if delta.days > 0:
|
50 |
return f"{delta.days} days ago"
|
51 |
elif delta.seconds // 3600 > 0:
|
|
|
16 |
|
17 |
def refresh_submissions():
|
18 |
global hub_path, submissions
|
19 |
+
if hub_path and Path(hub_path).exists():
|
20 |
+
shutil.rmtree(hub_path, ignore_errors=True)
|
21 |
+
print("Deleted existing submissions")
|
22 |
|
23 |
hub_path = snapshot_download(repo_type="dataset",
|
24 |
repo_id=SUBMISSION_REPO, allow_patterns=['*.json'])
|
|
|
45 |
|
46 |
|
47 |
def time_ago(submitted_time):
|
48 |
+
delta = datetime.now(timezone.utc) - datetime.fromtimestamp(
|
49 |
+
int(submitted_time) / 1000, tz=timezone.utc)
|
50 |
if delta.days > 0:
|
51 |
return f"{delta.days} days ago"
|
52 |
elif delta.seconds // 3600 > 0:
|