fixing login button
Browse files
app.py
CHANGED
@@ -139,15 +139,10 @@ def gradio_interface() -> gr.Blocks:
|
|
139 |
Upload your plasma boundary JSON and select the problem type to get your score.
|
140 |
"""
|
141 |
)
|
142 |
-
user_state = gr.State(value=None)
|
143 |
filename = gr.State(value=None)
|
144 |
eval_state = gr.State(value=None)
|
145 |
-
print(f"User state: {user_state}")
|
146 |
|
147 |
-
|
148 |
-
login_button.click(get_user, inputs=None, outputs=user_state)
|
149 |
-
|
150 |
-
print(f"User state: {user_state}")
|
151 |
|
152 |
with gr.Row():
|
153 |
problem_type = gr.Dropdown(PROBLEM_TYPES, label="Problem Type")
|
@@ -157,7 +152,7 @@ def gradio_interface() -> gr.Blocks:
|
|
157 |
message = gr.Textbox(label="Status", lines=1, visible=False)
|
158 |
submit_btn.click(
|
159 |
submit_boundary,
|
160 |
-
inputs=[problem_type, boundary_file
|
161 |
outputs=[message, filename],
|
162 |
).then(
|
163 |
fn=show_output_box,
|
|
|
139 |
Upload your plasma boundary JSON and select the problem type to get your score.
|
140 |
"""
|
141 |
)
|
|
|
142 |
filename = gr.State(value=None)
|
143 |
eval_state = gr.State(value=None)
|
|
|
144 |
|
145 |
+
gr.LoginButton()
|
|
|
|
|
|
|
146 |
|
147 |
with gr.Row():
|
148 |
problem_type = gr.Dropdown(PROBLEM_TYPES, label="Problem Type")
|
|
|
152 |
message = gr.Textbox(label="Status", lines=1, visible=False)
|
153 |
submit_btn.click(
|
154 |
submit_boundary,
|
155 |
+
inputs=[problem_type, boundary_file],
|
156 |
outputs=[message, filename],
|
157 |
).then(
|
158 |
fn=show_output_box,
|
submit.py
CHANGED
@@ -19,11 +19,11 @@ from about import PROBLEM_TYPES, TOKEN, CACHE_PATH, API, submissions_repo, resul
|
|
19 |
def submit_boundary(
|
20 |
problem_type: Literal["geometrical", "simple_to_build", "mhd_stable"],
|
21 |
boundary_file: BinaryIO,
|
22 |
-
|
23 |
) -> str:
|
24 |
|
25 |
# error handling
|
26 |
-
if
|
27 |
raise gr.Error("You must be logged in to submit a file.")
|
28 |
|
29 |
file_path = boundary_file.name
|
@@ -50,7 +50,7 @@ def submit_boundary(
|
|
50 |
"problem_type": problem_type,
|
51 |
"boundary_json": file_content.decode("utf-8"),
|
52 |
"evaluated": False,
|
53 |
-
"user":
|
54 |
}
|
55 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
56 |
json.dump(record, tmp, indent=2)
|
|
|
19 |
def submit_boundary(
|
20 |
problem_type: Literal["geometrical", "simple_to_build", "mhd_stable"],
|
21 |
boundary_file: BinaryIO,
|
22 |
+
profile: gr.OAuthProfile | None
|
23 |
) -> str:
|
24 |
|
25 |
# error handling
|
26 |
+
if profile.username is None:
|
27 |
raise gr.Error("You must be logged in to submit a file.")
|
28 |
|
29 |
file_path = boundary_file.name
|
|
|
50 |
"problem_type": problem_type,
|
51 |
"boundary_json": file_content.decode("utf-8"),
|
52 |
"evaluated": False,
|
53 |
+
"user": profile.username,
|
54 |
}
|
55 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
56 |
json.dump(record, tmp, indent=2)
|