still trying to make the leaderboard
Browse files- app.py +2 -3
- evaluation.py +4 -0
- submit.py +0 -1
- utils.py +7 -3
- visualize.py +4 -3
app.py
CHANGED
@@ -25,8 +25,7 @@ def evaluate_boundary(filename):
|
|
25 |
raw = f.read()
|
26 |
data_dict = json.loads(raw)
|
27 |
result = evaluate_problem(data_dict['problem_type'], local_path)
|
28 |
-
|
29 |
-
# data_dict['vis'] = vis
|
30 |
write_results(data_dict, result)
|
31 |
return
|
32 |
|
@@ -96,7 +95,7 @@ def gradio_interface() -> gr.Blocks:
|
|
96 |
boundary_file = gr.File(label="Boundary JSON File (.json)")
|
97 |
|
98 |
boundary_file
|
99 |
-
message = gr.Textbox(
|
100 |
submit_btn = gr.Button("Evaluate")
|
101 |
submit_btn.click(
|
102 |
submit_boundary,
|
|
|
25 |
raw = f.read()
|
26 |
data_dict = json.loads(raw)
|
27 |
result = evaluate_problem(data_dict['problem_type'], local_path)
|
28 |
+
|
|
|
29 |
write_results(data_dict, result)
|
30 |
return
|
31 |
|
|
|
95 |
boundary_file = gr.File(label="Boundary JSON File (.json)")
|
96 |
|
97 |
boundary_file
|
98 |
+
message = gr.Textbox(lines=1, visible=False)
|
99 |
submit_btn = gr.Button("Evaluate")
|
100 |
submit_btn.click(
|
101 |
submit_boundary,
|
evaluation.py
CHANGED
@@ -23,6 +23,8 @@ def evaluate_problem(
|
|
23 |
data_dict = json.loads(raw)
|
24 |
data = data_dict['boundary_json']
|
25 |
|
|
|
|
|
26 |
match problem_type:
|
27 |
case "geometrical":
|
28 |
boundary = load_boundary(data)
|
@@ -35,4 +37,6 @@ def evaluate_problem(
|
|
35 |
result = problems.MHDStableQIStellarator().evaluate(boundaries)
|
36 |
case _:
|
37 |
raise ValueError(f"Unknown problem type: {problem_type}")
|
|
|
|
|
38 |
return result
|
|
|
23 |
data_dict = json.loads(raw)
|
24 |
data = data_dict['boundary_json']
|
25 |
|
26 |
+
print("Starting evaluation.")
|
27 |
+
|
28 |
match problem_type:
|
29 |
case "geometrical":
|
30 |
boundary = load_boundary(data)
|
|
|
37 |
result = problems.MHDStableQIStellarator().evaluate(boundaries)
|
38 |
case _:
|
39 |
raise ValueError(f"Unknown problem type: {problem_type}")
|
40 |
+
|
41 |
+
print("Finished evaluation.")
|
42 |
return result
|
submit.py
CHANGED
@@ -51,7 +51,6 @@ def submit_boundary(
|
|
51 |
"boundary_json": file_content.decode("utf-8"),
|
52 |
"evaluated": False,
|
53 |
"user": user_state,
|
54 |
-
# "vis": "None"
|
55 |
}
|
56 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
57 |
json.dump(record, tmp, indent=2)
|
|
|
51 |
"boundary_json": file_content.decode("utf-8"),
|
52 |
"evaluated": False,
|
53 |
"user": user_state,
|
|
|
54 |
}
|
55 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
56 |
json.dump(record, tmp, indent=2)
|
utils.py
CHANGED
@@ -28,10 +28,14 @@ def write_results(record, result):
|
|
28 |
record['result_filename'] = record['submission_filename'].rstrip('.json') + '_results.json'
|
29 |
print(record['result_filename'])
|
30 |
record['evaluated'] = True
|
31 |
-
if 'objectives' in record.keys():
|
32 |
-
record['objective'] = record.pop('objectives')
|
33 |
-
record['minimize_objective'] = True
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
37 |
json.dump(record, tmp, indent=2)
|
|
|
28 |
record['result_filename'] = record['submission_filename'].rstrip('.json') + '_results.json'
|
29 |
print(record['result_filename'])
|
30 |
record['evaluated'] = True
|
|
|
|
|
|
|
31 |
|
32 |
+
record["objectives"] = json.dumps(record.get("objectives", []))
|
33 |
+
record["feasibilities"] = json.dumps(record.get("feasibility", []))
|
34 |
+
|
35 |
+
if 'objective' not in record.keys():
|
36 |
+
record['objective'] = 0.0
|
37 |
+
record['minimize_objective'] = True
|
38 |
+
record['feasibility'] = sum(record['feasibilities'])/len(record['feasibilities'])
|
39 |
|
40 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
41 |
json.dump(record, tmp, indent=2)
|
visualize.py
CHANGED
@@ -3,9 +3,10 @@ from constellaration.utils import (
|
|
3 |
visualization,
|
4 |
visualization_utils,
|
5 |
)
|
6 |
-
import
|
|
|
7 |
|
8 |
def make_visual(boundary):
|
9 |
vis = visualization.plot_surface(boundary)
|
10 |
-
div = vis.to_html(full_html=False)
|
11 |
-
return
|
|
|
3 |
visualization,
|
4 |
visualization_utils,
|
5 |
)
|
6 |
+
import gradio as gr
|
7 |
+
import plotly.graph_objects as go
|
8 |
|
9 |
def make_visual(boundary):
|
10 |
vis = visualization.plot_surface(boundary)
|
11 |
+
# div = vis.to_html(full_html=False)
|
12 |
+
return vis
|