Abhishek Thakur
commited on
Commit
·
1fffe05
1
Parent(s):
2ca97e8
custom snapshot download
Browse files- competitions/__init__.py +1 -1
- competitions/competitions.py +1 -1
- competitions/download.py +206 -0
- competitions/leaderboard.py +9 -1
- examples/generate_fake_submissions.py +67 -0
- requirements.txt +1 -0
competitions/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@ import os
|
|
| 3 |
from .info import CompetitionInfo
|
| 4 |
|
| 5 |
|
| 6 |
-
__version__ = "0.0
|
| 7 |
|
| 8 |
MOONLANDING_URL = os.getenv("MOONLANDING_URL")
|
| 9 |
COMPETITION_ID = os.getenv("COMPETITION_ID")
|
|
|
|
| 3 |
from .info import CompetitionInfo
|
| 4 |
|
| 5 |
|
| 6 |
+
__version__ = "0.1.0"
|
| 7 |
|
| 8 |
MOONLANDING_URL = os.getenv("MOONLANDING_URL")
|
| 9 |
COMPETITION_ID = os.getenv("COMPETITION_ID")
|
competitions/competitions.py
CHANGED
|
@@ -89,7 +89,7 @@ with gr.Blocks() as demo:
|
|
| 89 |
gr.Markdown("## Dataset")
|
| 90 |
gr.Markdown(f"{competition_info.dataset_description}")
|
| 91 |
with gr.TabItem("Public Leaderboard", id="public_leaderboard") as public_leaderboard:
|
| 92 |
-
output_df_public = gr.DataFrame()
|
| 93 |
with gr.TabItem("Private Leaderboard", id="private_leaderboard") as private_leaderboard:
|
| 94 |
current_date_time = datetime.now()
|
| 95 |
if current_date_time > competition_info.end_date:
|
|
|
|
| 89 |
gr.Markdown("## Dataset")
|
| 90 |
gr.Markdown(f"{competition_info.dataset_description}")
|
| 91 |
with gr.TabItem("Public Leaderboard", id="public_leaderboard") as public_leaderboard:
|
| 92 |
+
output_df_public = gr.DataFrame(row_count=(50, "fixed"), overflow_row_behaviour="paginate")
|
| 93 |
with gr.TabItem("Private Leaderboard", id="private_leaderboard") as private_leaderboard:
|
| 94 |
current_date_time = datetime.now()
|
| 95 |
if current_date_time > competition_info.end_date:
|
competitions/download.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import Dict, List, Optional, Union
|
| 4 |
+
|
| 5 |
+
from huggingface_hub import HfApi
|
| 6 |
+
from huggingface_hub.constants import DEFAULT_REVISION, HUGGINGFACE_HUB_CACHE, REPO_TYPES
|
| 7 |
+
from huggingface_hub.file_download import REGEX_COMMIT_HASH, hf_hub_download, repo_folder_name
|
| 8 |
+
from huggingface_hub.utils import filter_repo_objects, validate_hf_hub_args
|
| 9 |
+
from joblib import Parallel, delayed
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@validate_hf_hub_args
|
| 13 |
+
def snapshot_download(
|
| 14 |
+
repo_id: str,
|
| 15 |
+
*,
|
| 16 |
+
revision: Optional[str] = None,
|
| 17 |
+
repo_type: Optional[str] = None,
|
| 18 |
+
cache_dir: Union[str, Path, None] = None,
|
| 19 |
+
library_name: Optional[str] = None,
|
| 20 |
+
library_version: Optional[str] = None,
|
| 21 |
+
user_agent: Optional[Union[Dict, str]] = None,
|
| 22 |
+
proxies: Optional[Dict] = None,
|
| 23 |
+
etag_timeout: Optional[float] = 10,
|
| 24 |
+
resume_download: Optional[bool] = False,
|
| 25 |
+
use_auth_token: Optional[Union[bool, str]] = None,
|
| 26 |
+
local_files_only: Optional[bool] = False,
|
| 27 |
+
allow_regex: Optional[Union[List[str], str]] = None,
|
| 28 |
+
ignore_regex: Optional[Union[List[str], str]] = None,
|
| 29 |
+
allow_patterns: Optional[Union[List[str], str]] = None,
|
| 30 |
+
ignore_patterns: Optional[Union[List[str], str]] = None,
|
| 31 |
+
) -> str:
|
| 32 |
+
"""Download all files of a repo.
|
| 33 |
+
|
| 34 |
+
Downloads a whole snapshot of a repo's files at the specified revision. This
|
| 35 |
+
is useful when you want all files from a repo, because you don't know which
|
| 36 |
+
ones you will need a priori. All files are nested inside a folder in order
|
| 37 |
+
to keep their actual filename relative to that folder.
|
| 38 |
+
|
| 39 |
+
An alternative would be to just clone a repo but this would require that the
|
| 40 |
+
user always has git and git-lfs installed, and properly configured.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
repo_id (`str`):
|
| 44 |
+
A user or an organization name and a repo name separated by a `/`.
|
| 45 |
+
revision (`str`, *optional*):
|
| 46 |
+
An optional Git revision id which can be a branch name, a tag, or a
|
| 47 |
+
commit hash.
|
| 48 |
+
repo_type (`str`, *optional*):
|
| 49 |
+
Set to `"dataset"` or `"space"` if uploading to a dataset or space,
|
| 50 |
+
`None` or `"model"` if uploading to a model. Default is `None`.
|
| 51 |
+
cache_dir (`str`, `Path`, *optional*):
|
| 52 |
+
Path to the folder where cached files are stored.
|
| 53 |
+
library_name (`str`, *optional*):
|
| 54 |
+
The name of the library to which the object corresponds.
|
| 55 |
+
library_version (`str`, *optional*):
|
| 56 |
+
The version of the library.
|
| 57 |
+
user_agent (`str`, `dict`, *optional*):
|
| 58 |
+
The user-agent info in the form of a dictionary or a string.
|
| 59 |
+
proxies (`dict`, *optional*):
|
| 60 |
+
Dictionary mapping protocol to the URL of the proxy passed to
|
| 61 |
+
`requests.request`.
|
| 62 |
+
etag_timeout (`float`, *optional*, defaults to `10`):
|
| 63 |
+
When fetching ETag, how many seconds to wait for the server to send
|
| 64 |
+
data before giving up which is passed to `requests.request`.
|
| 65 |
+
resume_download (`bool`, *optional*, defaults to `False):
|
| 66 |
+
If `True`, resume a previously interrupted download.
|
| 67 |
+
use_auth_token (`str`, `bool`, *optional*):
|
| 68 |
+
A token to be used for the download.
|
| 69 |
+
- If `True`, the token is read from the HuggingFace config
|
| 70 |
+
folder.
|
| 71 |
+
- If a string, it's used as the authentication token.
|
| 72 |
+
local_files_only (`bool`, *optional*, defaults to `False`):
|
| 73 |
+
If `True`, avoid downloading the file and return the path to the
|
| 74 |
+
local cached file if it exists.
|
| 75 |
+
allow_patterns (`List[str]` or `str`, *optional*):
|
| 76 |
+
If provided, only files matching at least one pattern are downloaded.
|
| 77 |
+
ignore_patterns (`List[str]` or `str`, *optional*):
|
| 78 |
+
If provided, files matching any of the patterns are not downloaded.
|
| 79 |
+
|
| 80 |
+
Returns:
|
| 81 |
+
Local folder path (string) of repo snapshot
|
| 82 |
+
|
| 83 |
+
<Tip>
|
| 84 |
+
|
| 85 |
+
Raises the following errors:
|
| 86 |
+
|
| 87 |
+
- [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
|
| 88 |
+
if `use_auth_token=True` and the token cannot be found.
|
| 89 |
+
- [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError) if
|
| 90 |
+
ETag cannot be determined.
|
| 91 |
+
- [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
| 92 |
+
if some parameter value is invalid
|
| 93 |
+
|
| 94 |
+
</Tip>
|
| 95 |
+
"""
|
| 96 |
+
if cache_dir is None:
|
| 97 |
+
cache_dir = HUGGINGFACE_HUB_CACHE
|
| 98 |
+
if revision is None:
|
| 99 |
+
revision = DEFAULT_REVISION
|
| 100 |
+
if isinstance(cache_dir, Path):
|
| 101 |
+
cache_dir = str(cache_dir)
|
| 102 |
+
|
| 103 |
+
if repo_type is None:
|
| 104 |
+
repo_type = "model"
|
| 105 |
+
if repo_type not in REPO_TYPES:
|
| 106 |
+
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are:" f" {str(REPO_TYPES)}")
|
| 107 |
+
|
| 108 |
+
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
|
| 109 |
+
|
| 110 |
+
# TODO: remove these 4 lines in version 0.12
|
| 111 |
+
# Deprecated code to ensure backward compatibility.
|
| 112 |
+
if allow_regex is not None:
|
| 113 |
+
allow_patterns = allow_regex
|
| 114 |
+
if ignore_regex is not None:
|
| 115 |
+
ignore_patterns = ignore_regex
|
| 116 |
+
|
| 117 |
+
# if we have no internet connection we will look for an
|
| 118 |
+
# appropriate folder in the cache
|
| 119 |
+
# If the specified revision is a commit hash, look inside "snapshots".
|
| 120 |
+
# If the specified revision is a branch or tag, look inside "refs".
|
| 121 |
+
if local_files_only:
|
| 122 |
+
if REGEX_COMMIT_HASH.match(revision):
|
| 123 |
+
commit_hash = revision
|
| 124 |
+
else:
|
| 125 |
+
# retrieve commit_hash from file
|
| 126 |
+
ref_path = os.path.join(storage_folder, "refs", revision)
|
| 127 |
+
with open(ref_path) as f:
|
| 128 |
+
commit_hash = f.read()
|
| 129 |
+
|
| 130 |
+
snapshot_folder = os.path.join(storage_folder, "snapshots", commit_hash)
|
| 131 |
+
|
| 132 |
+
if os.path.exists(snapshot_folder):
|
| 133 |
+
return snapshot_folder
|
| 134 |
+
|
| 135 |
+
raise ValueError(
|
| 136 |
+
"Cannot find an appropriate cached snapshot folder for the specified"
|
| 137 |
+
" revision on the local disk and outgoing traffic has been disabled. To"
|
| 138 |
+
" enable repo look-ups and downloads online, set 'local_files_only' to"
|
| 139 |
+
" False."
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# if we have internet connection we retrieve the correct folder name from the huggingface api
|
| 143 |
+
_api = HfApi()
|
| 144 |
+
repo_info = _api.repo_info(
|
| 145 |
+
repo_id=repo_id,
|
| 146 |
+
repo_type=repo_type,
|
| 147 |
+
revision=revision,
|
| 148 |
+
use_auth_token=use_auth_token,
|
| 149 |
+
)
|
| 150 |
+
filtered_repo_files = list(
|
| 151 |
+
filter_repo_objects(
|
| 152 |
+
items=[f.rfilename for f in repo_info.siblings],
|
| 153 |
+
allow_patterns=allow_patterns,
|
| 154 |
+
ignore_patterns=ignore_patterns,
|
| 155 |
+
)
|
| 156 |
+
)
|
| 157 |
+
commit_hash = repo_info.sha
|
| 158 |
+
snapshot_folder = os.path.join(storage_folder, "snapshots", commit_hash)
|
| 159 |
+
# if passed revision is not identical to commit_hash
|
| 160 |
+
# then revision has to be a branch name or tag name.
|
| 161 |
+
# In that case store a ref.
|
| 162 |
+
if revision != commit_hash:
|
| 163 |
+
ref_path = os.path.join(storage_folder, "refs", revision)
|
| 164 |
+
os.makedirs(os.path.dirname(ref_path), exist_ok=True)
|
| 165 |
+
with open(ref_path, "w") as f:
|
| 166 |
+
f.write(commit_hash)
|
| 167 |
+
|
| 168 |
+
# we pass the commit_hash to hf_hub_download
|
| 169 |
+
# so no network call happens if we already
|
| 170 |
+
# have the file locally.
|
| 171 |
+
|
| 172 |
+
# for repo_file in tqdm(filtered_repo_files, f"Fetching {len(filtered_repo_files)} files"):
|
| 173 |
+
# _ = hf_hub_download(
|
| 174 |
+
# repo_id,
|
| 175 |
+
# filename=repo_file,
|
| 176 |
+
# repo_type=repo_type,
|
| 177 |
+
# revision=commit_hash,
|
| 178 |
+
# cache_dir=cache_dir,
|
| 179 |
+
# library_name=library_name,
|
| 180 |
+
# library_version=library_version,
|
| 181 |
+
# user_agent=user_agent,
|
| 182 |
+
# proxies=proxies,
|
| 183 |
+
# etag_timeout=etag_timeout,
|
| 184 |
+
# resume_download=resume_download,
|
| 185 |
+
# use_auth_token=use_auth_token,
|
| 186 |
+
# )
|
| 187 |
+
|
| 188 |
+
Parallel(n_jobs=10, backend="threading")(
|
| 189 |
+
delayed(hf_hub_download)(
|
| 190 |
+
repo_id,
|
| 191 |
+
filename=repo_file,
|
| 192 |
+
repo_type=repo_type,
|
| 193 |
+
revision=commit_hash,
|
| 194 |
+
cache_dir=cache_dir,
|
| 195 |
+
library_name=library_name,
|
| 196 |
+
library_version=library_version,
|
| 197 |
+
user_agent=user_agent,
|
| 198 |
+
proxies=proxies,
|
| 199 |
+
etag_timeout=etag_timeout,
|
| 200 |
+
resume_download=resume_download,
|
| 201 |
+
use_auth_token=use_auth_token,
|
| 202 |
+
)
|
| 203 |
+
for repo_file in filtered_repo_files
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
return snapshot_folder
|
competitions/leaderboard.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
| 1 |
import glob
|
| 2 |
import json
|
| 3 |
import os
|
|
|
|
| 4 |
from dataclasses import dataclass
|
| 5 |
from datetime import datetime
|
| 6 |
|
| 7 |
import pandas as pd
|
| 8 |
-
from
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
@dataclass
|
|
@@ -31,12 +35,15 @@ class Leaderboard:
|
|
| 31 |
]
|
| 32 |
|
| 33 |
def _process_public_lb(self):
|
|
|
|
| 34 |
submissions_folder = snapshot_download(
|
| 35 |
repo_id=self.competition_id,
|
| 36 |
allow_patterns="*.json",
|
| 37 |
use_auth_token=self.autotrain_token,
|
| 38 |
repo_type="dataset",
|
| 39 |
)
|
|
|
|
|
|
|
| 40 |
submissions = []
|
| 41 |
for submission in glob.glob(os.path.join(submissions_folder, "*.json")):
|
| 42 |
with open(submission, "r") as f:
|
|
@@ -60,6 +67,7 @@ class Leaderboard:
|
|
| 60 |
"submission_time": submission_info["submissions"]["time"],
|
| 61 |
}
|
| 62 |
submissions.append(temp_info)
|
|
|
|
| 63 |
return submissions
|
| 64 |
|
| 65 |
def _process_private_lb(self):
|
|
|
|
| 1 |
import glob
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
+
import time
|
| 5 |
from dataclasses import dataclass
|
| 6 |
from datetime import datetime
|
| 7 |
|
| 8 |
import pandas as pd
|
| 9 |
+
from loguru import logger
|
| 10 |
+
|
| 11 |
+
# from huggingface_hub import snapshot_download
|
| 12 |
+
from .download import snapshot_download
|
| 13 |
|
| 14 |
|
| 15 |
@dataclass
|
|
|
|
| 35 |
]
|
| 36 |
|
| 37 |
def _process_public_lb(self):
|
| 38 |
+
start_time = time.time()
|
| 39 |
submissions_folder = snapshot_download(
|
| 40 |
repo_id=self.competition_id,
|
| 41 |
allow_patterns="*.json",
|
| 42 |
use_auth_token=self.autotrain_token,
|
| 43 |
repo_type="dataset",
|
| 44 |
)
|
| 45 |
+
logger.info(f"Downloaded submissions in {time.time() - start_time} seconds")
|
| 46 |
+
start_time = time.time()
|
| 47 |
submissions = []
|
| 48 |
for submission in glob.glob(os.path.join(submissions_folder, "*.json")):
|
| 49 |
with open(submission, "r") as f:
|
|
|
|
| 67 |
"submission_time": submission_info["submissions"]["time"],
|
| 68 |
}
|
| 69 |
submissions.append(temp_info)
|
| 70 |
+
logger.info(f"Processed submissions in {time.time() - start_time} seconds")
|
| 71 |
return submissions
|
| 72 |
|
| 73 |
def _process_private_lb(self):
|
examples/generate_fake_submissions.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import io
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import random
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
from huggingface_hub import HfApi
|
| 8 |
+
from tqdm import tqdm
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
NUM_USERS = 1000
|
| 12 |
+
NUM_SUBMISSIONS = 10
|
| 13 |
+
MIN_SCORE = 0.0
|
| 14 |
+
MAX_SCORE = 1.0
|
| 15 |
+
START_DATE = datetime(2022, 1, 1, 0, 0, 0)
|
| 16 |
+
END_DATE = datetime(2022, 11, 23, 0, 0, 0)
|
| 17 |
+
COMPETITION_ID = os.environ.get("COMPETITION_ID")
|
| 18 |
+
AUTOTRAIN_TOKEN = os.environ.get("AUTOTRAIN_TOKEN")
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
# example submission:
|
| 22 |
+
# {"name": "abhishek", "id": "5fa19f4ba13e063b8b2b5e11", "submissions": [{"date": "2022-11-09", "time": "12:54:55", "submission_id": "c0eed646-838f-482f-bf4d-2c651f8de43b", "submission_comment": "", "status": "pending", "selected": true, "public_score": -1, "private_score": -1}, {"date": "2022-11-09", "time": "14:02:21", "submission_id": "bc6b08c2-c684-4ee1-9be2-35cf717ce618", "submission_comment": "", "status": "done", "selected": true, "public_score": 0.3333333333333333, "private_score": 0.3333333333333333}, {"date": "2022-11-17", "time": "21:31:04", "submission_id": "4a2984b1-de10-411d-be0f-9aa7be16245f", "submission_comment": "", "status": "done", "selected": false, "public_score": 0.3333333333333333, "private_score": 0.3333333333333333}]}
|
| 23 |
+
|
| 24 |
+
for i in tqdm(range(NUM_USERS)):
|
| 25 |
+
name = f"test_{i}"
|
| 26 |
+
# generate random id
|
| 27 |
+
id = "".join(random.choices("0123456789abcdef", k=24))
|
| 28 |
+
submissions = []
|
| 29 |
+
for j in range(NUM_SUBMISSIONS):
|
| 30 |
+
date = START_DATE + (END_DATE - START_DATE) * random.random()
|
| 31 |
+
time = date.strftime("%H:%M:%S")
|
| 32 |
+
date = date.strftime("%Y-%m-%d")
|
| 33 |
+
submission_id = "".join(random.choices("0123456789abcdef", k=36))
|
| 34 |
+
submission_comment = ""
|
| 35 |
+
status = "done"
|
| 36 |
+
selected = False
|
| 37 |
+
public_score = MIN_SCORE + (MAX_SCORE - MIN_SCORE) * random.random()
|
| 38 |
+
private_score = MIN_SCORE + (MAX_SCORE - MIN_SCORE) * random.random()
|
| 39 |
+
submission = {
|
| 40 |
+
"date": date,
|
| 41 |
+
"time": time,
|
| 42 |
+
"submission_id": submission_id,
|
| 43 |
+
"submission_comment": submission_comment,
|
| 44 |
+
"status": status,
|
| 45 |
+
"selected": selected,
|
| 46 |
+
"public_score": public_score,
|
| 47 |
+
"private_score": private_score,
|
| 48 |
+
}
|
| 49 |
+
submissions.append(submission)
|
| 50 |
+
|
| 51 |
+
submission = {
|
| 52 |
+
"name": name,
|
| 53 |
+
"id": id,
|
| 54 |
+
"submissions": submissions,
|
| 55 |
+
}
|
| 56 |
+
fname = f"{id}.json"
|
| 57 |
+
user_submission_info_json = json.dumps(submission)
|
| 58 |
+
user_submission_info_json_bytes = user_submission_info_json.encode("utf-8")
|
| 59 |
+
user_submission_info_json_buffer = io.BytesIO(user_submission_info_json_bytes)
|
| 60 |
+
api = HfApi()
|
| 61 |
+
api.upload_file(
|
| 62 |
+
path_or_fileobj=user_submission_info_json_buffer,
|
| 63 |
+
path_in_repo=fname,
|
| 64 |
+
repo_id=COMPETITION_ID,
|
| 65 |
+
repo_type="dataset",
|
| 66 |
+
token=AUTOTRAIN_TOKEN,
|
| 67 |
+
)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio==3.10.1
|
|
|
|
| 2 |
loguru==0.6.0
|
| 3 |
pandas==1.5.0
|
| 4 |
huggingface_hub==0.10.1
|
|
|
|
| 1 |
gradio==3.10.1
|
| 2 |
+
joblib==1.2.0
|
| 3 |
loguru==0.6.0
|
| 4 |
pandas==1.5.0
|
| 5 |
huggingface_hub==0.10.1
|