Abhishek Thakur
commited on
Commit
·
3ea1b9b
1
Parent(s):
02532c0
fixes
Browse files- competitions/__init__.py +1 -1
- competitions/competitions.py +7 -9
- competitions/info.py +21 -6
- competitions/text.py +1 -1
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.0.5"
|
| 7 |
|
| 8 |
MOONLANDING_URL = os.getenv("MOONLANDING_URL")
|
| 9 |
COMPETITION_ID = os.getenv("COMPETITION_ID")
|
competitions/competitions.py
CHANGED
|
@@ -6,7 +6,7 @@ import gradio as gr
|
|
| 6 |
from . import AUTOTRAIN_BACKEND_API, AUTOTRAIN_TOKEN, AUTOTRAIN_USERNAME, COMPETITION_ID, competition_info
|
| 7 |
from .leaderboard import Leaderboard
|
| 8 |
from .submissions import Submissions
|
| 9 |
-
from .text import NO_SUBMISSIONS,
|
| 10 |
|
| 11 |
|
| 12 |
leaderboard = Leaderboard(
|
|
@@ -41,18 +41,15 @@ with gr.Blocks() as demo:
|
|
| 41 |
gr.Markdown("## Dataset")
|
| 42 |
gr.Markdown(f"{competition_info.dataset_description}")
|
| 43 |
with gr.TabItem("Public Leaderboard", id="public_leaderboard") as public_leaderboard:
|
| 44 |
-
# fetch_lb = gr.Button("Fetch Leaderboard")
|
| 45 |
output_df_public = gr.DataFrame()
|
| 46 |
-
# fetch_lb_partial = partial(leaderboard.fetch, private=False)
|
| 47 |
-
# fetch_lb.click(fn=fetch_lb_partial, outputs=[output_df])
|
| 48 |
with gr.TabItem("Private Leaderboard", id="private_leaderboard") as private_leaderboard:
|
| 49 |
current_date_time = datetime.now()
|
| 50 |
-
if current_date_time
|
| 51 |
output_df_private = gr.DataFrame()
|
| 52 |
else:
|
| 53 |
gr.Markdown("Private Leaderboard will be available after the competition ends")
|
| 54 |
with gr.TabItem("New Submission", id="new_submission"):
|
| 55 |
-
gr.Markdown(SUBMISSION_TEXT)
|
| 56 |
user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
|
| 57 |
uploaded_file = gr.File()
|
| 58 |
output_text = gr.Markdown(visible=True, show_label=False)
|
|
@@ -63,7 +60,7 @@ with gr.Blocks() as demo:
|
|
| 63 |
outputs=[output_text],
|
| 64 |
)
|
| 65 |
with gr.TabItem("My Submissions", id="my_submissions"):
|
| 66 |
-
gr.Markdown(
|
| 67 |
user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
|
| 68 |
output_text = gr.Markdown(visible=True, show_label=False)
|
| 69 |
output_df = gr.DataFrame(visible=False)
|
|
@@ -76,5 +73,6 @@ with gr.Blocks() as demo:
|
|
| 76 |
|
| 77 |
fetch_lb_partial = partial(leaderboard.fetch, private=False)
|
| 78 |
public_leaderboard.select(fetch_lb_partial, inputs=[], outputs=[output_df_public])
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
| 6 |
from . import AUTOTRAIN_BACKEND_API, AUTOTRAIN_TOKEN, AUTOTRAIN_USERNAME, COMPETITION_ID, competition_info
|
| 7 |
from .leaderboard import Leaderboard
|
| 8 |
from .submissions import Submissions
|
| 9 |
+
from .text import NO_SUBMISSIONS, SUBMISSION_SELECTION_TEXT, SUBMISSION_TEXT
|
| 10 |
|
| 11 |
|
| 12 |
leaderboard = Leaderboard(
|
|
|
|
| 41 |
gr.Markdown("## Dataset")
|
| 42 |
gr.Markdown(f"{competition_info.dataset_description}")
|
| 43 |
with gr.TabItem("Public Leaderboard", id="public_leaderboard") as public_leaderboard:
|
|
|
|
| 44 |
output_df_public = gr.DataFrame()
|
|
|
|
|
|
|
| 45 |
with gr.TabItem("Private Leaderboard", id="private_leaderboard") as private_leaderboard:
|
| 46 |
current_date_time = datetime.now()
|
| 47 |
+
if current_date_time > competition_info.end_date:
|
| 48 |
output_df_private = gr.DataFrame()
|
| 49 |
else:
|
| 50 |
gr.Markdown("Private Leaderboard will be available after the competition ends")
|
| 51 |
with gr.TabItem("New Submission", id="new_submission"):
|
| 52 |
+
gr.Markdown(SUBMISSION_TEXT.format(competition_info.submission_limit))
|
| 53 |
user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
|
| 54 |
uploaded_file = gr.File()
|
| 55 |
output_text = gr.Markdown(visible=True, show_label=False)
|
|
|
|
| 60 |
outputs=[output_text],
|
| 61 |
)
|
| 62 |
with gr.TabItem("My Submissions", id="my_submissions"):
|
| 63 |
+
gr.Markdown(SUBMISSION_SELECTION_TEXT.format(competition_info.selection_limit))
|
| 64 |
user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
|
| 65 |
output_text = gr.Markdown(visible=True, show_label=False)
|
| 66 |
output_df = gr.DataFrame(visible=False)
|
|
|
|
| 73 |
|
| 74 |
fetch_lb_partial = partial(leaderboard.fetch, private=False)
|
| 75 |
public_leaderboard.select(fetch_lb_partial, inputs=[], outputs=[output_df_public])
|
| 76 |
+
if current_date_time > competition_info.end_date:
|
| 77 |
+
fetch_lb_partial_private = partial(leaderboard.fetch, private=True)
|
| 78 |
+
private_leaderboard.select(fetch_lb_partial_private, inputs=[], outputs=[output_df_private])
|
competitions/info.py
CHANGED
|
@@ -20,6 +20,18 @@ class CompetitionInfo:
|
|
| 20 |
use_auth_token=self.autotrain_token,
|
| 21 |
repo_type="dataset",
|
| 22 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
except EntryNotFoundError:
|
| 24 |
raise Exception("Competition config not found. Please check the competition id.")
|
| 25 |
except Exception as e:
|
|
@@ -27,6 +39,13 @@ class CompetitionInfo:
|
|
| 27 |
raise Exception("Hugging Face Hub is unreachable, please try again later.")
|
| 28 |
|
| 29 |
self.config = self.load_config(config_fname)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def load_config(self, config_path):
|
| 32 |
with open(config_path) as f:
|
|
@@ -51,13 +70,9 @@ class CompetitionInfo:
|
|
| 51 |
hb = self.config["EVAL_HIGHER_IS_BETTER"]
|
| 52 |
return True if int(hb) == 1 else False
|
| 53 |
|
| 54 |
-
@property
|
| 55 |
-
def competition_dataset(self):
|
| 56 |
-
return self.config["DATASET"]
|
| 57 |
-
|
| 58 |
@property
|
| 59 |
def competition_description(self):
|
| 60 |
-
return self.
|
| 61 |
|
| 62 |
@property
|
| 63 |
def competition_name(self):
|
|
@@ -69,4 +84,4 @@ class CompetitionInfo:
|
|
| 69 |
|
| 70 |
@property
|
| 71 |
def dataset_description(self):
|
| 72 |
-
return self.
|
|
|
|
| 20 |
use_auth_token=self.autotrain_token,
|
| 21 |
repo_type="dataset",
|
| 22 |
)
|
| 23 |
+
competition_desc = hf_hub_download(
|
| 24 |
+
repo_id=self.competition_id,
|
| 25 |
+
filename="COMPETITION_DESC.md",
|
| 26 |
+
use_auth_token=self.autotrain_token,
|
| 27 |
+
repo_type="dataset",
|
| 28 |
+
)
|
| 29 |
+
dataset_desc = hf_hub_download(
|
| 30 |
+
repo_id=self.competition_id,
|
| 31 |
+
filename="DATASET_DESC.md",
|
| 32 |
+
use_auth_token=self.autotrain_token,
|
| 33 |
+
repo_type="dataset",
|
| 34 |
+
)
|
| 35 |
except EntryNotFoundError:
|
| 36 |
raise Exception("Competition config not found. Please check the competition id.")
|
| 37 |
except Exception as e:
|
|
|
|
| 39 |
raise Exception("Hugging Face Hub is unreachable, please try again later.")
|
| 40 |
|
| 41 |
self.config = self.load_config(config_fname)
|
| 42 |
+
self.competition_desc = self.load_md(competition_desc)
|
| 43 |
+
self.dataset_desc = self.load_md(dataset_desc)
|
| 44 |
+
|
| 45 |
+
def load_md(self, md_path):
|
| 46 |
+
with open(md_path) as f:
|
| 47 |
+
md = f.read()
|
| 48 |
+
return md
|
| 49 |
|
| 50 |
def load_config(self, config_path):
|
| 51 |
with open(config_path) as f:
|
|
|
|
| 70 |
hb = self.config["EVAL_HIGHER_IS_BETTER"]
|
| 71 |
return True if int(hb) == 1 else False
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
@property
|
| 74 |
def competition_description(self):
|
| 75 |
+
return self.competition_desc
|
| 76 |
|
| 77 |
@property
|
| 78 |
def competition_name(self):
|
|
|
|
| 84 |
|
| 85 |
@property
|
| 86 |
def dataset_description(self):
|
| 87 |
+
return self.dataset_desc
|
competitions/text.py
CHANGED
|
@@ -8,6 +8,6 @@ The final rankings will be based on the private split performance.
|
|
| 8 |
SUBMISSION_ERROR = """Submission is not in a proper format.
|
| 9 |
Please check evaluation instructions for more details."""
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
NO_SUBMISSIONS = """You have not made any submissions yet."""
|
|
|
|
| 8 |
SUBMISSION_ERROR = """Submission is not in a proper format.
|
| 9 |
Please check evaluation instructions for more details."""
|
| 10 |
|
| 11 |
+
SUBMISSION_SELECTION_TEXT = """You can select upto {} submissions for private leaderboard."""
|
| 12 |
|
| 13 |
NO_SUBMISSIONS = """You have not made any submissions yet."""
|