File size: 1,198 Bytes
1070692
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pathlib
from pathlib import Path
import tempfile
from typing import BinaryIO, Literal
import json
import pandas as pd

import gradio as gr
from huggingface_hub import upload_file, hf_hub_download
from datetime import datetime
import os

from about import PROBLEM_TYPES, TOKEN, CACHE_PATH, API, submissions_repo, results_repo

def make_user_clickable(name):
    link =f'https://huggingface.co/{name}'
    return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{name}</a>'

def make_boundary_clickable(filename):
    link =f'https://huggingface.co/datasets/{results_repo}/blob/main/{filename}'
    return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">link</a>'

def read_result_from_hub(filename):
    local_path = hf_hub_download(
        repo_id=results_repo,
        repo_type="dataset",
        filename=filename,
    )
    return local_path

def get_user(profile: gr.OAuthProfile | None) -> str:
    if profile is None:
        return "Please login to make a submission to the leaderboard."
    return profile.username