Amber Tanaka commited on
Commit
11de2f8
·
unverified ·
1 Parent(s): cd5338b

Nav bar updates (#18)

Browse files
Files changed (11) hide show
  1. about.py +1 -1
  2. app.py +74 -30
  3. c_and_e.py +1 -2
  4. category_page_builder.py +64 -63
  5. content.py +19 -6
  6. data_analysis.py +1 -2
  7. e2e.py +1 -2
  8. literature_understanding.py +1 -3
  9. main_page.py +1 -1
  10. submission.py +1 -1
  11. ui_components.py +1 -0
about.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
 
3
 
4
- with gr.Blocks() as demo:
5
  gr.Markdown(
6
  """
7
  ## About AstaBench
 
1
  import gradio as gr
2
 
3
 
4
+ def build_page():
5
  gr.Markdown(
6
  """
7
  ## About AstaBench
app.py CHANGED
@@ -1,12 +1,19 @@
1
  # app.py
2
  import gradio as gr
3
  import os
 
4
 
5
  from apscheduler.schedulers.background import BackgroundScheduler
6
  from huggingface_hub import HfApi
7
- import literature_understanding, main_page, c_and_e, data_analysis, e2e, submission, about
8
 
9
  from content import css
 
 
 
 
 
 
 
10
 
11
  # --- Constants and Configuration ---
12
  LOCAL_DEBUG = not (os.environ.get("system") == "spaces")
@@ -43,6 +50,8 @@ theme = gr.themes.Base(
43
  font_mono=[gr.themes.GoogleFont('Roboto Mono'), 'ui-monospace', 'monospace', 'monospace'],
44
  ).set(
45
  body_text_color='*neutral_950',
 
 
46
  body_text_color_dark='*neutral_50',
47
  background_fill_primary='*neutral_50',
48
  background_fill_primary_dark='*neutral_900',
@@ -79,40 +88,75 @@ theme = gr.themes.Base(
79
  block_background_fill_dark="#032629",
80
  block_background_fill="#FAF2E9",
81
  )
82
- def render_logo():
83
- return gr.Image(
84
- value=LOGO_PATH,
85
- show_label=False,
86
- interactive=False,
87
- container=False,
88
- show_download_button=False,
89
- show_fullscreen_button=False,
90
- elem_id="logo-image"
91
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # --- Gradio App Definition ---
93
- demo = gr.Blocks(theme=theme, css=css, head=scroll_script)
94
- with demo:
95
- render_logo()
96
- main_page.demo.render()
97
  with demo.route("Literature Understanding", "/literature-understanding"):
98
- render_logo()
99
- literature_understanding.demo.render()
100
  with demo.route("Code & Execution", "/code-execution"):
101
- render_logo()
102
- c_and_e.demo.render()
103
  with demo.route("Data Analysis", "/data-analysis"):
104
- render_logo()
105
- data_analysis.demo.render()
106
  with demo.route("Discovery", "/discovery"):
107
- render_logo()
108
- e2e.demo.render()
109
  with demo.route("About", "/about"):
110
- render_logo()
111
- about.demo.render()
112
- with demo.route(" 🚀 Submit an Agent"):
113
- render_logo()
114
- submission.demo.render()
115
 
 
 
116
  # --- Scheduler and Launch
117
  def restart_space_job():
118
  print("Scheduler: Attempting to restart space.")
@@ -131,10 +175,10 @@ if __name__ == "__main__":
131
  if LOCAL_DEBUG:
132
  print("Launching in LOCAL_DEBUG mode.")
133
  def get_initial_global_tag_choices(): return ["Overall", "TagA"]
134
- demo.launch(debug=True)
135
  else:
136
  print("Launching in Space mode.")
137
  # For Spaces, share=False is typical unless specific tunneling is needed.
138
  # debug=True can be set to False for a "production" Space.
139
- demo.launch(server_name="0.0.0.0", server_port=7860, debug=True, share=False)
140
 
 
1
  # app.py
2
  import gradio as gr
3
  import os
4
+ import urllib.parse
5
 
6
  from apscheduler.schedulers.background import BackgroundScheduler
7
  from huggingface_hub import HfApi
 
8
 
9
  from content import css
10
+ from main_page import build_page as build_main_page
11
+ from literature_understanding import build_page as build_lit_page
12
+ from c_and_e import build_page as build_c_and_e_page
13
+ from data_analysis import build_page as build_data_analysis_page
14
+ from e2e import build_page as build_e2e_page
15
+ from submission import build_page as build_submission_page
16
+ from about import build_page as build_about_page
17
 
18
  # --- Constants and Configuration ---
19
  LOCAL_DEBUG = not (os.environ.get("system") == "spaces")
 
50
  font_mono=[gr.themes.GoogleFont('Roboto Mono'), 'ui-monospace', 'monospace', 'monospace'],
51
  ).set(
52
  body_text_color='*neutral_950',
53
+ body_text_color_subdued='*neutral_950',
54
+ body_text_color_subdued_dark='*neutral_50',
55
  body_text_color_dark='*neutral_50',
56
  background_fill_primary='*neutral_50',
57
  background_fill_primary_dark='*neutral_900',
 
88
  block_background_fill_dark="#032629",
89
  block_background_fill="#FAF2E9",
90
  )
91
+ try:
92
+ with open(LOGO_PATH, "r") as f:
93
+ svg_content = f.read()
94
+ encoded_svg = urllib.parse.quote(svg_content)
95
+ home_icon_data_uri = f"data:image/svg+xml,{encoded_svg}"
96
+ except FileNotFoundError:
97
+ print(f"Warning: Home icon file not found at {LOGO_PATH}.")
98
+ home_icon_data_uri = "none"
99
+
100
+ # --- This part creates the JavaScript redirect. It is correct. ---
101
+ redirect_script = """
102
+ <script>
103
+ if (window.location.pathname === '/') { window.location.replace('/home'); }
104
+ </script>
105
+ """
106
+
107
+ # --- This is the final CSS ---
108
+ final_css = css + f"""
109
+ /* --- Find the "Home" button and replace its text with an icon --- */
110
+ .nav-holder nav a[href$="/"] {{
111
+ display: none !important;
112
+ }}
113
+ .nav-holder nav a[href*="/home"] {{
114
+ grid-row: 1 !important;
115
+ grid-column: 1 !important;
116
+ justify-self: start !important;
117
+ display: flex !important;
118
+ align-items: center !important;
119
+ justify-content: center !important;
120
+
121
+ /* 2. Hide the original "Home" text */
122
+ font-size: 0 !important;
123
+ text-indent: -9999px;
124
+
125
+ /* 3. Apply the icon as the background */
126
+ background-image: url("{home_icon_data_uri}") !important;
127
+ background-size: contain !important;
128
+ background-repeat: no-repeat !important;
129
+ background-position: center !important;
130
+
131
+ width: 240px !important;
132
+ height: 50px !important;
133
+ padding: 0 !important;
134
+ border: none !important;
135
+ outline: none !important;
136
+ }}
137
+ """
138
  # --- Gradio App Definition ---
139
+ demo = gr.Blocks(theme=theme, css=final_css, head=scroll_script + redirect_script)
140
+ with demo.route("Home", "/home"):
141
+ build_main_page()
142
+
143
  with demo.route("Literature Understanding", "/literature-understanding"):
144
+ build_lit_page()
145
+
146
  with demo.route("Code & Execution", "/code-execution"):
147
+ build_c_and_e_page()
148
+
149
  with demo.route("Data Analysis", "/data-analysis"):
150
+ build_data_analysis_page()
151
+
152
  with demo.route("Discovery", "/discovery"):
153
+ build_e2e_page()
154
+
155
  with demo.route("About", "/about"):
156
+ build_about_page()
 
 
 
 
157
 
158
+ with demo.route("🚀 Submit an Agent", "/submit"):
159
+ build_submission_page()
160
  # --- Scheduler and Launch
161
  def restart_space_job():
162
  print("Scheduler: Attempting to restart space.")
 
175
  if LOCAL_DEBUG:
176
  print("Launching in LOCAL_DEBUG mode.")
177
  def get_initial_global_tag_choices(): return ["Overall", "TagA"]
178
+ demo.launch(debug=True, allowed_paths=["assets"])
179
  else:
180
  print("Launching in Space mode.")
181
  # For Spaces, share=False is typical unless specific tunneling is needed.
182
  # debug=True can be set to False for a "production" Space.
183
+ demo.launch(server_name="0.0.0.0", server_port=7860, debug=True, share=False, allowed_paths=["assets"])
184
 
c_and_e.py CHANGED
@@ -5,6 +5,5 @@ from category_page_builder import build_category_page
5
  # Define the category for this page
6
  CATEGORY_NAME = "Code Execution"
7
 
8
- with gr.Blocks() as demo:
9
- gr.Markdown(f"## Astabench {CATEGORY_NAME} Leaderboard")
10
  build_category_page(CATEGORY_NAME, CODE_EXECUTION_DESCRIPTION)
 
5
  # Define the category for this page
6
  CATEGORY_NAME = "Code Execution"
7
 
8
+ def build_page():
 
9
  build_category_page(CATEGORY_NAME, CODE_EXECUTION_DESCRIPTION)
category_page_builder.py CHANGED
@@ -5,76 +5,77 @@ import pandas as pd
5
  from ui_components import create_leaderboard_display, create_benchmark_details_display, get_full_leaderboard_data, create_sub_navigation_bar
6
 
7
  def build_category_page(CATEGORY_NAME, PAGE_DESCRIPTION):
8
- validation_df, validation_tag_map = get_full_leaderboard_data("validation")
9
- test_df, test_tag_map = get_full_leaderboard_data("test")
10
- gr.Markdown(PAGE_DESCRIPTION, elem_id="category-intro")
11
- with gr.Column(elem_id="validation_nav_container", visible=False) as validation_nav_container:
12
- create_sub_navigation_bar(validation_tag_map, CATEGORY_NAME)
13
 
14
- with gr.Column(elem_id="test_nav_container", visible=True) as test_nav_container:
15
- create_sub_navigation_bar(test_tag_map, CATEGORY_NAME)
 
 
 
 
 
 
 
16
 
17
- # --- This page now has two main sections: Validation and Test ---
18
- with gr.Tabs():
19
- with gr.Tab("Results: Test Set") as test_tab:
20
- # Repeat the process for the "test" split
21
- test_df, test_tag_map = get_full_leaderboard_data("test")
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- if not test_df.empty:
24
- create_leaderboard_display(
25
- full_df=test_df,
26
- tag_map=test_tag_map,
27
- category_name=CATEGORY_NAME,
28
- split_name="test"
29
- )
30
- create_benchmark_details_display(
31
- full_df=test_df,
32
- tag_map=test_tag_map,
33
- category_name=CATEGORY_NAME
34
- )
35
- else:
36
- gr.Markdown("No data available for test split.")
37
- with gr.Tab("Results: Validation Set") as validation_tab:
38
- # 1. Load all necessary data for the "validation" split ONCE.
39
- validation_df, validation_tag_map = get_full_leaderboard_data("validation")
40
 
41
- if not validation_df.empty:
42
- # 2. Render the main category display using the loaded data.
43
- create_leaderboard_display(
44
- full_df=validation_df,
45
- tag_map=validation_tag_map,
46
- category_name=CATEGORY_NAME,
47
- split_name="validation"
48
- )
49
 
50
- # 3. Render the detailed breakdown for each benchmark in the category.
51
- create_benchmark_details_display(
52
- full_df=validation_df,
53
- tag_map=validation_tag_map,
54
- category_name=CATEGORY_NAME
55
- )
56
- else:
57
- gr.Markdown("No data available for validation split.")
58
 
 
 
 
 
 
 
 
59
 
60
- show_validation_js = """
61
- () => {
62
- document.getElementById('validation_nav_container').style.display = 'block';
63
- document.getElementById('test_nav_container').style.display = 'none';
64
- setTimeout(() => { window.dispatchEvent(new Event('resize')) }, 0);
65
- }
66
- """
67
 
68
- # JavaScript to show the TEST nav, hide the VALIDATION nav, AND fix the plots.
69
- show_test_js = """
70
- () => {
71
- document.getElementById('validation_nav_container').style.display = 'none';
72
- document.getElementById('test_nav_container').style.display = 'block';
73
- }
74
- """
75
-
76
- # Assign the pure JS functions to the select events. No Python `fn` is needed.
77
- validation_tab.select(fn=None, inputs=None, outputs=None, js=show_validation_js)
78
- test_tab.select(fn=None, inputs=None, outputs=None, js=show_test_js)
79
 
80
  return validation_nav_container, test_nav_container
 
5
  from ui_components import create_leaderboard_display, create_benchmark_details_display, get_full_leaderboard_data, create_sub_navigation_bar
6
 
7
  def build_category_page(CATEGORY_NAME, PAGE_DESCRIPTION):
8
+ with gr.Column(elem_id="page-content-wrapper"):
9
+ validation_df, validation_tag_map = get_full_leaderboard_data("validation")
10
+ test_df, test_tag_map = get_full_leaderboard_data("test")
11
+ with gr.Column(elem_id="validation_nav_container", visible=False) as validation_nav_container:
12
+ create_sub_navigation_bar(validation_tag_map, CATEGORY_NAME)
13
 
14
+ with gr.Column(elem_id="test_nav_container", visible=True) as test_nav_container:
15
+ create_sub_navigation_bar(test_tag_map, CATEGORY_NAME)
16
+ gr.Markdown(f"## Astabench{CATEGORY_NAME} Leaderboard")
17
+ gr.Markdown(PAGE_DESCRIPTION, elem_id="category-intro")
18
+ # --- This page now has two main sections: Validation and Test ---
19
+ with gr.Tabs():
20
+ with gr.Tab("Results: Test Set") as test_tab:
21
+ # Repeat the process for the "test" split
22
+ test_df, test_tag_map = get_full_leaderboard_data("test")
23
 
24
+ if not test_df.empty:
25
+ create_leaderboard_display(
26
+ full_df=test_df,
27
+ tag_map=test_tag_map,
28
+ category_name=CATEGORY_NAME,
29
+ split_name="test"
30
+ )
31
+ create_benchmark_details_display(
32
+ full_df=test_df,
33
+ tag_map=test_tag_map,
34
+ category_name=CATEGORY_NAME
35
+ )
36
+ else:
37
+ gr.Markdown("No data available for test split.")
38
+ with gr.Tab("Results: Validation Set") as validation_tab:
39
+ # 1. Load all necessary data for the "validation" split ONCE.
40
+ validation_df, validation_tag_map = get_full_leaderboard_data("validation")
41
 
42
+ if not validation_df.empty:
43
+ # 2. Render the main category display using the loaded data.
44
+ create_leaderboard_display(
45
+ full_df=validation_df,
46
+ tag_map=validation_tag_map,
47
+ category_name=CATEGORY_NAME,
48
+ split_name="validation"
49
+ )
 
 
 
 
 
 
 
 
 
50
 
51
+ # 3. Render the detailed breakdown for each benchmark in the category.
52
+ create_benchmark_details_display(
53
+ full_df=validation_df,
54
+ tag_map=validation_tag_map,
55
+ category_name=CATEGORY_NAME
56
+ )
57
+ else:
58
+ gr.Markdown("No data available for validation split.")
59
 
 
 
 
 
 
 
 
 
60
 
61
+ show_validation_js = """
62
+ () => {
63
+ document.getElementById('validation_nav_container').style.display = 'block';
64
+ document.getElementById('test_nav_container').style.display = 'none';
65
+ setTimeout(() => { window.dispatchEvent(new Event('resize')) }, 0);
66
+ }
67
+ """
68
 
69
+ # JavaScript to show the TEST nav, hide the VALIDATION nav, AND fix the plots.
70
+ show_test_js = """
71
+ () => {
72
+ document.getElementById('validation_nav_container').style.display = 'none';
73
+ document.getElementById('test_nav_container').style.display = 'block';
74
+ }
75
+ """
76
 
77
+ # Assign the pure JS functions to the select events. No Python `fn` is needed.
78
+ validation_tab.select(fn=None, inputs=None, outputs=None, js=show_validation_js)
79
+ test_tab.select(fn=None, inputs=None, outputs=None, js=show_test_js)
 
 
 
 
 
 
 
 
80
 
81
  return validation_nav_container, test_nav_container
content.py CHANGED
@@ -144,10 +144,12 @@ css = """
144
  #intro-paragraph {
145
  font-size: 18px;
146
  max-width: 60%;
 
147
  }
148
  #about-content {
149
  font-size: 18px;
150
  max-width: 60%;
 
151
  }
152
  #category-intro {
153
  font-size: 18px;
@@ -160,6 +162,9 @@ css = """
160
  max-width: 250px;
161
  height: auto;
162
  }
 
 
 
163
  .table-component{
164
  height: auto !important;
165
  max-height: none !important;
@@ -243,6 +248,12 @@ nav.svelte-ti537g.svelte-ti537g {
243
  .sub-nav-link-button:hover {
244
  text-decoration: underline;
245
  }
 
 
 
 
 
 
246
  .wrap-header-df th span{
247
  white-space: normal !important;
248
  word-break: normal !important;
@@ -335,12 +346,6 @@ html:not(.dark) #legend-markdown .light-mode-icon,
335
  gap: 10px 20px !important; /* Vertical and horizontal spacing */
336
  width: 100% !important;
337
  }
338
- .nav-holder nav a[href*="/"] {
339
- grid-row: 1 !important;
340
- grid-column: 1 !important;
341
- justify-self: start !important;
342
- width: fit-content !important;
343
- }
344
  .nav-holder nav a[href*="about"] {
345
  grid-row: 1 !important;
346
  grid-column: 6 !important;
@@ -352,18 +357,26 @@ html:not(.dark) #legend-markdown .light-mode-icon,
352
  .nav-holder nav a[href*="literature-understanding"] {
353
  grid-row: 3 !important;
354
  grid-column: 1 !important;
 
 
355
  }
356
  .nav-holder nav a[href*="code-execution"] {
357
  grid-row: 3 !important;
358
  grid-column: 2 !important;
 
 
359
  }
360
  .nav-holder nav a[href*="data-analysis"] {
361
  grid-row: 3 !important;
362
  grid-column: 3 !important;
 
 
363
  }
364
  .nav-holder nav a[href*="discovery"] {
365
  grid-row: 3 !important;
366
  grid-column: 4 !important;
 
 
367
  }
368
  .nav-holder nav::after {
369
  content: ''; /* Required for pseudo-elements to appear */
 
144
  #intro-paragraph {
145
  font-size: 18px;
146
  max-width: 60%;
147
+ padding-left: 25px;
148
  }
149
  #about-content {
150
  font-size: 18px;
151
  max-width: 60%;
152
+ padding-left: 25px;
153
  }
154
  #category-intro {
155
  font-size: 18px;
 
162
  max-width: 250px;
163
  height: auto;
164
  }
165
+ #page-content-wrapper{
166
+ padding-left: 25px;
167
+ }
168
  .table-component{
169
  height: auto !important;
170
  max-height: none !important;
 
248
  .sub-nav-link-button:hover {
249
  text-decoration: underline;
250
  }
251
+ .sub-nav-label {
252
+ font-weight: bold;
253
+ font-size: 16px;
254
+ display: flex;
255
+ align-items: center;
256
+ }
257
  .wrap-header-df th span{
258
  white-space: normal !important;
259
  word-break: normal !important;
 
346
  gap: 10px 20px !important; /* Vertical and horizontal spacing */
347
  width: 100% !important;
348
  }
 
 
 
 
 
 
349
  .nav-holder nav a[href*="about"] {
350
  grid-row: 1 !important;
351
  grid-column: 6 !important;
 
357
  .nav-holder nav a[href*="literature-understanding"] {
358
  grid-row: 3 !important;
359
  grid-column: 1 !important;
360
+ width: fit-content !important;
361
+ justify-self: center !important;
362
  }
363
  .nav-holder nav a[href*="code-execution"] {
364
  grid-row: 3 !important;
365
  grid-column: 2 !important;
366
+ padding-right: 20px !important;
367
+ justify-self: center !important;
368
  }
369
  .nav-holder nav a[href*="data-analysis"] {
370
  grid-row: 3 !important;
371
  grid-column: 3 !important;
372
+ padding-right: 20px !important;
373
+ justify-self: center !important;
374
  }
375
  .nav-holder nav a[href*="discovery"] {
376
  grid-row: 3 !important;
377
  grid-column: 4 !important;
378
+ padding-right: 20px !important;
379
+ justify-self: center !important;
380
  }
381
  .nav-holder nav::after {
382
  content: ''; /* Required for pseudo-elements to appear */
data_analysis.py CHANGED
@@ -4,6 +4,5 @@ from category_page_builder import build_category_page
4
  # Define the category for this page
5
  CATEGORY_NAME = "Data Analysis"
6
 
7
- with gr.Blocks() as demo:
8
- gr.Markdown(f"## Astabench{CATEGORY_NAME} Leaderboard")
9
  build_category_page(CATEGORY_NAME, DATA_ANALYSIS_DESCRIPTION)
 
4
  # Define the category for this page
5
  CATEGORY_NAME = "Data Analysis"
6
 
7
+ def build_page():
 
8
  build_category_page(CATEGORY_NAME, DATA_ANALYSIS_DESCRIPTION)
e2e.py CHANGED
@@ -4,6 +4,5 @@ from category_page_builder import build_category_page
4
  # Define the category for this page
5
  CATEGORY_NAME = "Discovery"
6
 
7
- with gr.Blocks() as demo:
8
- gr.Markdown(f"## Astabench{CATEGORY_NAME} Leaderboard")
9
  build_category_page(CATEGORY_NAME, DISCOVERY_DESCRIPTION)
 
4
  # Define the category for this page
5
  CATEGORY_NAME = "Discovery"
6
 
7
+ def build_page():
 
8
  build_category_page(CATEGORY_NAME, DISCOVERY_DESCRIPTION)
literature_understanding.py CHANGED
@@ -1,10 +1,8 @@
1
- import gradio as gr
2
  from content import LIT_DESCRIPTION
3
  from category_page_builder import build_category_page
4
 
5
  # Define the category for this page
6
  CATEGORY_NAME = "Literature Understanding"
7
 
8
- with gr.Blocks() as demo:
9
- gr.Markdown(f"## Astabench{CATEGORY_NAME} Leaderboard")
10
  build_category_page(CATEGORY_NAME, LIT_DESCRIPTION)
 
 
1
  from content import LIT_DESCRIPTION
2
  from category_page_builder import build_category_page
3
 
4
  # Define the category for this page
5
  CATEGORY_NAME = "Literature Understanding"
6
 
7
+ def build_page():
 
8
  build_category_page(CATEGORY_NAME, LIT_DESCRIPTION)
main_page.py CHANGED
@@ -15,7 +15,7 @@ from content import (
15
  CACHED_VIEWERS = {}
16
  CACHED_TAG_MAPS = {}
17
 
18
- with gr.Blocks(fill_width=True) as demo:
19
  gr.Markdown(INTRO_PARAGRAPH, elem_id="intro-paragraph")
20
  # --- Leaderboard Display Section ---
21
  gr.Markdown("---")
 
15
  CACHED_VIEWERS = {}
16
  CACHED_TAG_MAPS = {}
17
 
18
+ def build_page():
19
  gr.Markdown(INTRO_PARAGRAPH, elem_id="intro-paragraph")
20
  # --- Leaderboard Display Section ---
21
  gr.Markdown("---")
submission.py CHANGED
@@ -283,7 +283,7 @@ def add_new_eval(
283
 
284
 
285
  # --- Submission Accordion ---
286
- with gr.Blocks() as demo:
287
  gr.Markdown(f"## 🚀 Submit a new agent for evaluation", elem_id="markdown-text")
288
  with gr.Row():
289
  with gr.Column():
 
283
 
284
 
285
  # --- Submission Accordion ---
286
+ def build_page():
287
  gr.Markdown(f"## 🚀 Submit a new agent for evaluation", elem_id="markdown-text")
288
  with gr.Row():
289
  with gr.Column():
ui_components.py CHANGED
@@ -566,6 +566,7 @@ def create_sub_navigation_bar(tag_map: dict, category_name: str):
566
  # This container will be our flexbox row.
567
  full_html = f"""
568
  <div class="sub-nav-bar-container">
 
569
  {''.join(html_buttons)}
570
  </div>
571
  """
 
566
  # This container will be our flexbox row.
567
  full_html = f"""
568
  <div class="sub-nav-bar-container">
569
+ <span class="sub-nav-label">Benchmarks:</span>
570
  {''.join(html_buttons)}
571
  </div>
572
  """