fixing login button
Browse files
app.py
CHANGED
@@ -14,12 +14,13 @@ import os
|
|
14 |
|
15 |
from submit import submit_boundary
|
16 |
from about import PROBLEM_TYPES, TOKEN, CACHE_PATH, API, submissions_repo, results_repo
|
17 |
-
from utils import
|
18 |
from visualize import make_visual
|
|
|
19 |
|
20 |
def evaluate_boundary(filename):
|
21 |
print(filename)
|
22 |
-
local_path =
|
23 |
with Path(local_path).open("r") as f:
|
24 |
raw = f.read()
|
25 |
data_dict = json.loads(raw)
|
@@ -38,7 +39,8 @@ def get_leaderboard():
|
|
38 |
full_df['full results'] = full_df['result_filename'].apply(lambda x: make_boundary_clickable(x)).astype(str)
|
39 |
|
40 |
full_df.rename(columns={'submission_time': 'submission time', 'problem_type': 'problem type'}, inplace=True)
|
41 |
-
to_show = full_df
|
|
|
42 |
to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
|
43 |
|
44 |
return to_show
|
@@ -100,6 +102,36 @@ def gradio_interface() -> gr.Blocks:
|
|
100 |
# dropdown = gr.Dropdown(choices=filenames, label="Choose a file")
|
101 |
# plot_output = gr.Plot()
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
with gr.TabItem("✉️ Submit", elem_id="boundary-benchmark-tab-table"):
|
104 |
gr.Markdown(
|
105 |
"""
|
@@ -111,9 +143,8 @@ def gradio_interface() -> gr.Blocks:
|
|
111 |
filename = gr.State(value=None)
|
112 |
eval_state = gr.State(value=None)
|
113 |
|
114 |
-
gr.LoginButton()
|
115 |
-
|
116 |
-
demo.load(get_user, inputs=None, outputs=user_state)
|
117 |
|
118 |
with gr.Row():
|
119 |
problem_type = gr.Dropdown(PROBLEM_TYPES, label="Problem Type")
|
|
|
14 |
|
15 |
from submit import submit_boundary
|
16 |
from about import PROBLEM_TYPES, TOKEN, CACHE_PATH, API, submissions_repo, results_repo
|
17 |
+
from utils import read_file_from_hub, write_results, get_user, make_user_clickable, make_boundary_clickable
|
18 |
from visualize import make_visual
|
19 |
+
from evaluation import load_boundary, load_boundaries
|
20 |
|
21 |
def evaluate_boundary(filename):
|
22 |
print(filename)
|
23 |
+
local_path = read_file_from_hub(filename)
|
24 |
with Path(local_path).open("r") as f:
|
25 |
raw = f.read()
|
26 |
data_dict = json.loads(raw)
|
|
|
39 |
full_df['full results'] = full_df['result_filename'].apply(lambda x: make_boundary_clickable(x)).astype(str)
|
40 |
|
41 |
full_df.rename(columns={'submission_time': 'submission time', 'problem_type': 'problem type'}, inplace=True)
|
42 |
+
to_show = full_df.copy(deep=True)
|
43 |
+
to_show = to_show[['submission time', 'problem type', 'user', 'score', 'full results']]
|
44 |
to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
|
45 |
|
46 |
return to_show
|
|
|
102 |
# dropdown = gr.Dropdown(choices=filenames, label="Choose a file")
|
103 |
# plot_output = gr.Plot()
|
104 |
|
105 |
+
'''with gr.TabItem("🔍 Visualize", elem_id="boundary-benchmark-tab-table"):
|
106 |
+
ds = load_dataset(results_repo, split='train')
|
107 |
+
full_df = pd.DataFrame(ds)
|
108 |
+
filenames = full_df['results_files'].to_list()
|
109 |
+
dropdown = gr.Dropdown(choices=filenames, label="Choose a file", value=filenames[0])
|
110 |
+
plot = gr.Plot()
|
111 |
+
|
112 |
+
def update_plot(selected_file):
|
113 |
+
local_path = read_file_from_hub(selected_file)
|
114 |
+
with Path(local_path).open("r") as f:
|
115 |
+
raw = f.read()
|
116 |
+
data_dict = json.loads(raw)
|
117 |
+
boundary_json = data_dict['boundary_json']
|
118 |
+
|
119 |
+
if data_dict['problem_type'] == 'mhd_stable':
|
120 |
+
raise gr.Error("Sorry this isn't implemented for mhd_stable submissions yet!")
|
121 |
+
else:
|
122 |
+
boundary = load_boundary(boundary_json)
|
123 |
+
|
124 |
+
vis = make_visual(boundary)
|
125 |
+
return vis
|
126 |
+
|
127 |
+
dropdown.change(fn=update_plot, inputs=dropdown, outputs=plot)
|
128 |
+
gr.on(
|
129 |
+
triggers="load", # when app loads
|
130 |
+
fn=update_plot,
|
131 |
+
inputs=[dropdown],
|
132 |
+
outputs=[plot]
|
133 |
+
)'''
|
134 |
+
|
135 |
with gr.TabItem("✉️ Submit", elem_id="boundary-benchmark-tab-table"):
|
136 |
gr.Markdown(
|
137 |
"""
|
|
|
143 |
filename = gr.State(value=None)
|
144 |
eval_state = gr.State(value=None)
|
145 |
|
146 |
+
login_button = gr.LoginButton()
|
147 |
+
login_button.load(get_user, inputs=None, outputs=user_state)
|
|
|
148 |
|
149 |
with gr.Row():
|
150 |
problem_type = gr.Dropdown(PROBLEM_TYPES, label="Problem Type")
|
utils.py
CHANGED
@@ -21,7 +21,7 @@ def make_boundary_clickable(filename):
|
|
21 |
link =f'https://huggingface.co/datasets/proxima-fusion/constellaration-bench-results/blob/main/{filename}'
|
22 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">link</a>'
|
23 |
|
24 |
-
def
|
25 |
local_path = hf_hub_download(
|
26 |
repo_id=submissions_repo,
|
27 |
repo_type="dataset",
|
|
|
21 |
link =f'https://huggingface.co/datasets/proxima-fusion/constellaration-bench-results/blob/main/{filename}'
|
22 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">link</a>'
|
23 |
|
24 |
+
def read_file_from_hub(filename):
|
25 |
local_path = hf_hub_download(
|
26 |
repo_id=submissions_repo,
|
27 |
repo_type="dataset",
|