making anonymous flag
Browse files
README.md
CHANGED
@@ -3,7 +3,7 @@ title: Ginkgo AbDev benchmark
|
|
3 |
emoji: 🔋
|
4 |
colorFrom: purple
|
5 |
colorTo: green
|
6 |
-
sdk:
|
7 |
pinned: false
|
8 |
hf_oauth: true
|
9 |
hf_oauth_expiration_minutes: 480
|
|
|
3 |
emoji: 🔋
|
4 |
colorFrom: purple
|
5 |
colorTo: green
|
6 |
+
sdk: gradio
|
7 |
pinned: false
|
8 |
hf_oauth: true
|
9 |
hf_oauth_expiration_minutes: 480
|
app.py
CHANGED
@@ -97,8 +97,9 @@ with gr.Blocks() as demo:
|
|
97 |
filename = gr.State(value=None)
|
98 |
eval_state = gr.State(value=None)
|
99 |
user_state = gr.State(value=None)
|
|
|
100 |
|
101 |
-
|
102 |
|
103 |
with gr.Row():
|
104 |
with gr.Column():
|
@@ -107,6 +108,8 @@ with gr.Blocks() as demo:
|
|
107 |
placeholder="Enter your Hugging Face username",
|
108 |
info="This will be displayed on the leaderboard."
|
109 |
)
|
|
|
|
|
110 |
with gr.Column():
|
111 |
boundary_file = gr.File(label="Submission CSV")
|
112 |
|
@@ -123,7 +126,7 @@ with gr.Blocks() as demo:
|
|
123 |
|
124 |
submit_btn.click(
|
125 |
make_submission,
|
126 |
-
inputs=[boundary_file, user_state],
|
127 |
outputs=[message],
|
128 |
).then(
|
129 |
fn=show_output_box,
|
|
|
97 |
filename = gr.State(value=None)
|
98 |
eval_state = gr.State(value=None)
|
99 |
user_state = gr.State(value=None)
|
100 |
+
anonymous_state = gr.State(value=False)
|
101 |
|
102 |
+
gr.LoginButton()
|
103 |
|
104 |
with gr.Row():
|
105 |
with gr.Column():
|
|
|
108 |
placeholder="Enter your Hugging Face username",
|
109 |
info="This will be displayed on the leaderboard."
|
110 |
)
|
111 |
+
|
112 |
+
anonymous_checkbox = gr.Checkbox(label="Would you like to keep your submission anonymous?")
|
113 |
with gr.Column():
|
114 |
boundary_file = gr.File(label="Submission CSV")
|
115 |
|
|
|
126 |
|
127 |
submit_btn.click(
|
128 |
make_submission,
|
129 |
+
inputs=[boundary_file, user_state, anonymous_state],
|
130 |
outputs=[message],
|
131 |
).then(
|
132 |
fn=show_output_box,
|
submit.py
CHANGED
@@ -5,12 +5,14 @@ import json
|
|
5 |
|
6 |
import gradio as gr
|
7 |
from datetime import datetime
|
|
|
8 |
|
9 |
from about import API, submissions_repo
|
10 |
|
11 |
def make_submission(
|
12 |
submitted_file: BinaryIO,
|
13 |
-
user_state
|
|
|
14 |
|
15 |
if user_state is None:
|
16 |
raise gr.Error("You must submit your username to submit a file.")
|
@@ -22,18 +24,21 @@ def make_submission(
|
|
22 |
|
23 |
path_obj = Path(file_path)
|
24 |
timestamp = datetime.utcnow().isoformat()
|
|
|
25 |
|
26 |
with (path_obj.open("rb") as f_in):
|
27 |
file_content = f_in.read().decode("utf-8")
|
28 |
|
29 |
# write to dataset
|
30 |
-
filename = f"{
|
31 |
record = {
|
|
|
32 |
"submission_filename": filename,
|
33 |
"submission_time": timestamp,
|
34 |
"csv_content": file_content,
|
35 |
"evaluated": False,
|
36 |
"user": user_state,
|
|
|
37 |
}
|
38 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
39 |
json.dump(record, tmp, indent=2)
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
from datetime import datetime
|
8 |
+
import uuid
|
9 |
|
10 |
from about import API, submissions_repo
|
11 |
|
12 |
def make_submission(
|
13 |
submitted_file: BinaryIO,
|
14 |
+
user_state,
|
15 |
+
anonymous_state):
|
16 |
|
17 |
if user_state is None:
|
18 |
raise gr.Error("You must submit your username to submit a file.")
|
|
|
24 |
|
25 |
path_obj = Path(file_path)
|
26 |
timestamp = datetime.utcnow().isoformat()
|
27 |
+
submission_id = uuid.uuid4()
|
28 |
|
29 |
with (path_obj.open("rb") as f_in):
|
30 |
file_content = f_in.read().decode("utf-8")
|
31 |
|
32 |
# write to dataset
|
33 |
+
filename = f"{submission_id}.json"
|
34 |
record = {
|
35 |
+
"submission_id": submission_id,
|
36 |
"submission_filename": filename,
|
37 |
"submission_time": timestamp,
|
38 |
"csv_content": file_content,
|
39 |
"evaluated": False,
|
40 |
"user": user_state,
|
41 |
+
"anonymous": anonymous_state
|
42 |
}
|
43 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
44 |
json.dump(record, tmp, indent=2)
|