Hao Xu
commited on
Commit
·
5588471
1
Parent(s):
5e9e543
require hf login
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import pandas as pd
|
|
| 5 |
from huggingface_hub import HfApi, hf_hub_download
|
| 6 |
from datasets import load_dataset
|
| 7 |
import requests
|
|
|
|
| 8 |
|
| 9 |
TOKEN = os.environ.get("HF_TOKEN")
|
| 10 |
OWNER = os.environ.get("OWNER")
|
|
@@ -160,7 +161,12 @@ def build_table(source, refresh=False):
|
|
| 160 |
return html
|
| 161 |
|
| 162 |
|
| 163 |
-
def record_submission(benchmark_name, contributor, jsonl_file, hf_path, hf_split, field_name, hf_config):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
if not benchmark_name or not benchmark_name.strip():
|
| 165 |
return "❌ Please provide a benchmark name."
|
| 166 |
|
|
@@ -331,13 +337,15 @@ with gr.Blocks() as interface:
|
|
| 331 |
hf_config_input = gr.Textbox(label="Dataset Config (optional)", placeholder="name of dataset config")
|
| 332 |
field_name_input = gr.Textbox(label="Context or Question Field Name", placeholder="e.g., context, question, ...")
|
| 333 |
|
| 334 |
-
|
|
|
|
|
|
|
| 335 |
result_output = gr.Textbox(label="Submission Status", interactive=False)
|
| 336 |
|
| 337 |
submit_button.click(
|
| 338 |
fn=record_submission,
|
| 339 |
inputs=[benchmark_name_input, contributor_input, jsonl_input, hf_path_input, hf_split_input, field_name_input, hf_config_input],
|
| 340 |
-
outputs=result_output
|
| 341 |
)
|
| 342 |
|
| 343 |
interface.launch()
|
|
|
|
| 5 |
from huggingface_hub import HfApi, hf_hub_download
|
| 6 |
from datasets import load_dataset
|
| 7 |
import requests
|
| 8 |
+
import datetime
|
| 9 |
|
| 10 |
TOKEN = os.environ.get("HF_TOKEN")
|
| 11 |
OWNER = os.environ.get("OWNER")
|
|
|
|
| 161 |
return html
|
| 162 |
|
| 163 |
|
| 164 |
+
def record_submission(benchmark_name, contributor, jsonl_file, hf_path, hf_split, field_name, hf_config, profile: gr.OAuthProfile):
|
| 165 |
+
user_data = requests.get(f"https://huggingface.co/api/users/{profile.username}/overview")
|
| 166 |
+
creation_date = json.loads(user_data.content)["createdAt"]
|
| 167 |
+
if datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ') < datetime.timedelta(days=10):
|
| 168 |
+
return format_error("This account is not authorized to submit.")
|
| 169 |
+
|
| 170 |
if not benchmark_name or not benchmark_name.strip():
|
| 171 |
return "❌ Please provide a benchmark name."
|
| 172 |
|
|
|
|
| 337 |
hf_config_input = gr.Textbox(label="Dataset Config (optional)", placeholder="name of dataset config")
|
| 338 |
field_name_input = gr.Textbox(label="Context or Question Field Name", placeholder="e.g., context, question, ...")
|
| 339 |
|
| 340 |
+
with gr.Row():
|
| 341 |
+
gr.LoginButton()
|
| 342 |
+
submit_button = gr.Button("Submit for Contamination Check")
|
| 343 |
result_output = gr.Textbox(label="Submission Status", interactive=False)
|
| 344 |
|
| 345 |
submit_button.click(
|
| 346 |
fn=record_submission,
|
| 347 |
inputs=[benchmark_name_input, contributor_input, jsonl_input, hf_path_input, hf_split_input, field_name_input, hf_config_input],
|
| 348 |
+
outputs=result_output,
|
| 349 |
)
|
| 350 |
|
| 351 |
interface.launch()
|