Spaces:
Running
Running
Commit
·
441f3cf
1
Parent(s):
cef7c8f
Add hf_hub_download for submission repository and fix timestamp conversion in add_submission function
Browse files- gradio_interface.py +4 -1
gradio_interface.py
CHANGED
|
@@ -2,10 +2,13 @@ import gradio as gr
|
|
| 2 |
import json
|
| 3 |
from datetime import datetime, timezone, timedelta
|
| 4 |
from huggingface_hub import upload_file
|
|
|
|
| 5 |
SUBMISSION_REPO = "SushantGautam/medvqa-submissions"
|
| 6 |
|
| 7 |
|
| 8 |
# Sample data structure to hold submission information
|
|
|
|
|
|
|
| 9 |
submissions = [
|
| 10 |
{"user": "User1", "task": "task1", "submitted_time": datetime.now() -
|
| 11 |
timedelta(hours=1)},
|
|
@@ -115,7 +118,7 @@ def add_submission(file):
|
|
| 115 |
username, sub_timestamp, task = file.replace(
|
| 116 |
".json", "").split("-_-_-")
|
| 117 |
submission_time = datetime.fromtimestamp(
|
| 118 |
-
sub_timestamp / 1000, tz=timezone.utc)
|
| 119 |
assert task in ["task1", "task2"], "Invalid task type"
|
| 120 |
assert len(username) > 0, "Invalid username"
|
| 121 |
assert submission_time < datetime.now(), "Invalid submission time"
|
|
|
|
| 2 |
import json
|
| 3 |
from datetime import datetime, timezone, timedelta
|
| 4 |
from huggingface_hub import upload_file
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
SUBMISSION_REPO = "SushantGautam/medvqa-submissions"
|
| 7 |
|
| 8 |
|
| 9 |
# Sample data structure to hold submission information
|
| 10 |
+
hf_hub_download(repo_id="SUBMISSION_REPO")
|
| 11 |
+
|
| 12 |
submissions = [
|
| 13 |
{"user": "User1", "task": "task1", "submitted_time": datetime.now() -
|
| 14 |
timedelta(hours=1)},
|
|
|
|
| 118 |
username, sub_timestamp, task = file.replace(
|
| 119 |
".json", "").split("-_-_-")
|
| 120 |
submission_time = datetime.fromtimestamp(
|
| 121 |
+
int(sub_timestamp) / 1000, tz=timezone.utc)
|
| 122 |
assert task in ["task1", "task2"], "Invalid task type"
|
| 123 |
assert len(username) > 0, "Invalid username"
|
| 124 |
assert submission_time < datetime.now(), "Invalid submission time"
|