Spaces:
Running
Running
shaipeerms
commited on
Commit
•
cc1bfb0
1
Parent(s):
725ce65
Disable Submit button
Browse files
app.py
CHANGED
@@ -17,6 +17,8 @@ lb_server = LeaderboardServer()
|
|
17 |
|
18 |
LEADERBOARD_TYPES = ['NOTSOFAR-MC', 'NOTSOFAR-SC', 'DASR-Constrained-LM', 'DASR-Unconstrained-LM']
|
19 |
MAX_SUBMISSIONS_PER_24H = os.environ['MAX_SUBMISSIONS_PER_24H']
|
|
|
|
|
20 |
|
21 |
|
22 |
with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility: hidden}") as main):
|
@@ -27,28 +29,54 @@ with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility
|
|
27 |
gr.Markdown(HEADER_MARKDOWN)
|
28 |
|
29 |
with gr.Row():
|
|
|
30 |
# Leaderboards Tab #
|
31 |
####################
|
32 |
-
def populate_leaderboard(leaderboard_type):
|
33 |
-
leaderboard_df = lb_server.get_leaderboard(
|
|
|
34 |
if leaderboard_df.empty:
|
35 |
return pd.DataFrame(columns=['No submissions yet'])
|
36 |
return leaderboard_df
|
37 |
|
38 |
-
def create_leaderboard_tab(tab_name):
|
39 |
-
with gr.Tab(tab_name) as leaderboard_tab:
|
40 |
-
leaderboard_table = gr.DataFrame(populate_leaderboard(tab_name)) if idx == 0 \
|
41 |
else gr.DataFrame(pd.DataFrame(columns=['No submissions yet']))
|
42 |
-
leaderboard_tab.select(fn=populate_leaderboard,
|
|
|
43 |
outputs=[leaderboard_table])
|
44 |
-
leaderboard_table.change(fn=populate_leaderboard,
|
|
|
45 |
outputs=[leaderboard_table])
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
with gr.Tab('Leaderboards') as leaderboards_tab:
|
48 |
-
gr.Markdown(LEADERBOARD_TAB_TITLE_MARKDOWN)
|
49 |
with gr.Row():
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# Submission Tab #
|
54 |
##################
|
@@ -78,7 +106,8 @@ with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility
|
|
78 |
gr.Warning(str(err))
|
79 |
return
|
80 |
|
81 |
-
metadata = {'challenge_name':
|
|
|
82 |
'team_name': team_name,
|
83 |
'submission_type': submission_type,
|
84 |
'description': description,
|
|
|
17 |
|
18 |
LEADERBOARD_TYPES = ['NOTSOFAR-MC', 'NOTSOFAR-SC', 'DASR-Constrained-LM', 'DASR-Unconstrained-LM']
|
19 |
MAX_SUBMISSIONS_PER_24H = os.environ['MAX_SUBMISSIONS_PER_24H']
|
20 |
+
DATASET_VERSIONS = ['Devset1', 'Devset2']
|
21 |
+
CHALLENGE_NAME = 'NOTSOFAR1'
|
22 |
|
23 |
|
24 |
with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility: hidden}") as main):
|
|
|
29 |
gr.Markdown(HEADER_MARKDOWN)
|
30 |
|
31 |
with gr.Row():
|
32 |
+
|
33 |
# Leaderboards Tab #
|
34 |
####################
|
35 |
+
def populate_leaderboard(leaderboard_type, dataset_version):
|
36 |
+
leaderboard_df = lb_server.get_leaderboard(
|
37 |
+
submission_type=leaderboard_type, dataset_version=dataset_version)
|
38 |
if leaderboard_df.empty:
|
39 |
return pd.DataFrame(columns=['No submissions yet'])
|
40 |
return leaderboard_df
|
41 |
|
42 |
+
def create_leaderboard_tab(tab_name, idx, dataset_version):
|
43 |
+
with gr.Tab(id=tab_name, label=tab_name) as leaderboard_tab:
|
44 |
+
leaderboard_table = gr.DataFrame(populate_leaderboard(tab_name, dataset_version)) if idx == 0 \
|
45 |
else gr.DataFrame(pd.DataFrame(columns=['No submissions yet']))
|
46 |
+
leaderboard_tab.select(fn=populate_leaderboard,
|
47 |
+
inputs=[gr.Text(tab_name, visible=False), dataset_version],
|
48 |
outputs=[leaderboard_table])
|
49 |
+
leaderboard_table.change(fn=populate_leaderboard,
|
50 |
+
inputs=[gr.Text(tab_name, visible=False), dataset_version],
|
51 |
outputs=[leaderboard_table])
|
52 |
+
return leaderboard_table
|
53 |
+
|
54 |
+
def on_dropdown_change(dataset_version):
|
55 |
+
first_tab_name = LEADERBOARD_TYPES[0]
|
56 |
+
print(f'Dataset version changed to {dataset_version}, updating leaderboard tab {first_tab_name}...')
|
57 |
+
return gr.Tabs(selected=first_tab_name), populate_leaderboard(first_tab_name, dataset_version_drop)
|
58 |
|
59 |
with gr.Tab('Leaderboards') as leaderboards_tab:
|
|
|
60 |
with gr.Row():
|
61 |
+
gr.Markdown(LEADERBOARD_TAB_TITLE_MARKDOWN)
|
62 |
+
with gr.Row():
|
63 |
+
with gr.Column():
|
64 |
+
dataset_version_drop = gr.Dropdown(choices=DATASET_VERSIONS, multiselect=False,
|
65 |
+
value=DATASET_VERSIONS[-1], label="Dataset", interactive=True)
|
66 |
+
with gr.Column():
|
67 |
+
gr.Markdown('') # Empty column for spacing
|
68 |
+
with gr.Column():
|
69 |
+
gr.Markdown('') # Empty column for spacing
|
70 |
+
with gr.Column():
|
71 |
+
gr.Markdown('') # Empty column for spacing
|
72 |
+
with gr.Row():
|
73 |
+
with gr.Tabs() as leaderboards_tabs:
|
74 |
+
leaderboard_tables_list = []
|
75 |
+
for leaderboard_idx, leaderboard_type in enumerate(LEADERBOARD_TYPES):
|
76 |
+
l_tab = create_leaderboard_tab(leaderboard_type, leaderboard_idx, dataset_version_drop)
|
77 |
+
leaderboard_tables_list.append(l_tab)
|
78 |
+
|
79 |
+
dataset_version_drop.select(fn=on_dropdown_change, inputs=[dataset_version_drop], outputs=[leaderboards_tabs, leaderboard_tables_list[0]])
|
80 |
|
81 |
# Submission Tab #
|
82 |
##################
|
|
|
106 |
gr.Warning(str(err))
|
107 |
return
|
108 |
|
109 |
+
metadata = {'challenge_name': CHALLENGE_NAME,
|
110 |
+
"dataset_version": DATASET_VERSIONS[-1],
|
111 |
'team_name': team_name,
|
112 |
'submission_type': submission_type,
|
113 |
'description': description,
|
server.py
CHANGED
@@ -11,17 +11,19 @@ class LeaderboardServer:
|
|
11 |
self._LOG = logging.getLogger('leaderboard_server')
|
12 |
self._server_address = os.environ['LEADERBOARD_SERVER_ADDRESS']
|
13 |
|
14 |
-
def get_leaderboard(self, submission_type: str) -> pd.DataFrame:
|
15 |
"""
|
16 |
Gets the leaderboard of the given submission type
|
17 |
Args:
|
18 |
submission_type: the type of the submission to get the leaderboard of:
|
19 |
'SC' / 'MC-specific' / 'MC-agnostic' / 'MC-agnostic-all'
|
|
|
20 |
"""
|
21 |
self._LOG.info(f'Getting leaderboard for submission type: {submission_type}')
|
22 |
endpoint = f'{self._server_address}/leaderboard'
|
23 |
submission_type = submission_type.lower().replace('-', '_')
|
24 |
-
response = requests.get(endpoint, params={'submission_type': submission_type
|
|
|
25 |
if response.status_code != 200:
|
26 |
self._LOG.error(f'Error while fetching leaderboard, status code: {response.status_code}, '
|
27 |
f'response: {response.text}, endpoint: {endpoint}')
|
|
|
11 |
self._LOG = logging.getLogger('leaderboard_server')
|
12 |
self._server_address = os.environ['LEADERBOARD_SERVER_ADDRESS']
|
13 |
|
14 |
+
def get_leaderboard(self, submission_type: str, dataset_version: str) -> pd.DataFrame:
|
15 |
"""
|
16 |
Gets the leaderboard of the given submission type
|
17 |
Args:
|
18 |
submission_type: the type of the submission to get the leaderboard of:
|
19 |
'SC' / 'MC-specific' / 'MC-agnostic' / 'MC-agnostic-all'
|
20 |
+
dataset_version: the version of the dataset to get the leaderboard of ('Devset1' / 'Devset2' / ...)
|
21 |
"""
|
22 |
self._LOG.info(f'Getting leaderboard for submission type: {submission_type}')
|
23 |
endpoint = f'{self._server_address}/leaderboard'
|
24 |
submission_type = submission_type.lower().replace('-', '_')
|
25 |
+
response = requests.get(endpoint, params={'submission_type': submission_type,
|
26 |
+
'dataset_version': dataset_version})
|
27 |
if response.status_code != 200:
|
28 |
self._LOG.error(f'Error while fetching leaderboard, status code: {response.status_code}, '
|
29 |
f'response: {response.text}, endpoint: {endpoint}')
|