Skip to content

Commit 050010e

Browse files
committed
[Chart] Generate chart on website
1 parent 0ac9847 commit 050010e

File tree

7 files changed

+121
-14
lines changed

7 files changed

+121
-14
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test: generation ## Test the code with pytest
1919
@echo "🚀 Testing code: Running pytest"
2020
@poetry run pytest
2121

22-
generation: submission-generation participant-data track-data division-track-data results-generation ## Files generation for the website
22+
generation: submission-generation participant-data track-data division-track-data results-generation charts-generation ## Files generation for the website
2323

2424
.PHONY: build
2525
build: clean-build ## Build wheel file using poetry
@@ -84,6 +84,21 @@ results-generation:
8484
@echo "🚀 Generating results to web/content/results for Parallel"
8585
@poetry run smtcomp export-results-pages data Parallel
8686

87+
charts-generation:
88+
@echo "🚀 Generating results to web/content/results for SingleQuery"
89+
@poetry run smtcomp generate-website-graphics data SingleQuery
90+
@echo "🚀 Generating results to web/content/results for ModelValidation"
91+
@poetry run smtcomp generate-website-graphics data ModelValidation
92+
@echo "🚀 Generating results to web/content/results for UnsatCore"
93+
@poetry run smtcomp generate-website-graphics data UnsatCore
94+
@echo "🚀 Generating results to web/content/results for Incremental"
95+
@poetry run smtcomp generate-website-graphics data Incremental
96+
# @echo "🚀 Generating results to web/content/results for Cloud"
97+
# @poetry run smtcomp generate-website-graphics data Cloud
98+
@echo "🚀 Generating results to web/content/results for Parallel"
99+
@poetry run smtcomp generate-website-graphics data Parallel
100+
101+
87102
cache:
88103
@echo "🚀 Generating cache"
89104
@poetry run smtcomp create-cache data

poetry.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies = [
2121
"polars",
2222
"PyGithub",
2323
"altair",
24+
"python-frontmatter",
2425
]
2526
#pystemd is not set as dependency because it is not in the CI
2627

@@ -70,11 +71,10 @@ module = [
7071
"benchexec","benchexec.util",
7172
"benchexec.result","benchexec.tools.template",
7273
"benchexec.runexecutor",
73-
"bs4","wget"
74+
"bs4","wget","frontmatter"
7475
]
7576
ignore_missing_imports = true
7677

77-
7878
[tool.ruff]
7979
target-version = "py37"
8080
line-length = 120

smtcomp/generate_graphics.py

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
from typing import Set, Dict, Optional, cast, List, DefaultDict, Tuple
55
from pathlib import Path, PurePath
66
from smtcomp import defs
7+
from rich.progress import track as rich_track
78

89
import polars as pl
910
import altair as alt
10-
import smtcomp.scoring
11+
import altair.utils.html
12+
import altair.vegalite.display
1113
from smtcomp.utils import *
12-
import smtcomp.results
14+
import smtcomp.generate_website_page
15+
import frontmatter
1316

1417
c_file = pl.col("file")
1518
c_logic = pl.col("logic")
@@ -28,10 +31,9 @@
2831
def create_output(
2932
config: defs.Config,
3033
results: pl.LazyFrame,
31-
output: Path,
3234
logics: list[defs.Logic] = [],
3335
divisions: list[defs.Division] = [],
34-
) -> None:
36+
) -> alt.api.ChartType:
3537

3638
# We are computing the buckets offline because we have too much data
3739
results = results.filter(
@@ -82,7 +84,7 @@ def create_output(
8284

8385
bucket_domain: list[float] = list(df_buckets["bucket"])
8486

85-
row1 = df_corr.row(1, named=True)
87+
row1 = df_corr.row(min(1, len(df_corr) - 1), named=True)
8688

8789
# Create heatmap with selection
8890
select_x = alt.selection_point(fields=["solver"], name="solver1", value=row1["solver"], toggle=False)
@@ -170,10 +172,58 @@ def create_output(
170172
.add_params(division)
171173
)
172174

173-
graph = (g_select_provers | g_results_rect + g_results_text).resolve_scale(color="independent")
175+
graph: alt.api.ChartType = (g_select_provers | g_results_rect + g_results_text).resolve_scale(color="independent")
174176

175177
graph = alt.vconcat(graph, legend_answer_x | legend_answer_y | legend_logic | legend_division)
176178

177179
graph = graph.resolve_scale(color="independent")
178180

179-
graph.save(output)
181+
return graph
182+
183+
184+
def save_output(
185+
config: defs.Config,
186+
results: pl.LazyFrame,
187+
output: Path,
188+
logics: list[defs.Logic] = [],
189+
divisions: list[defs.Division] = [],
190+
) -> None:
191+
192+
create_output(config, results, logics, divisions).save(output)
193+
194+
195+
def save_hugo_output(chart: alt.api.ChartType, output: Path, title: str) -> None:
196+
197+
with alt.data_transformers.disable_max_rows():
198+
content = chart.to_html(
199+
fullhtml=False,
200+
)
201+
post = frontmatter.Post(content=content, title=title, layout="chart")
202+
output.write_text(frontmatter.dumps(post))
203+
204+
205+
def generate_pages(config: defs.Config, results: pl.LazyFrame, track: defs.Track) -> None:
206+
page_suffix = smtcomp.generate_website_page.page_track_suffix(track)
207+
dst = config.web_results
208+
dst.mkdir(parents=True, exist_ok=True)
209+
210+
df_results = results.filter(c_run == True).collect()
211+
results = df_results.lazy()
212+
213+
divisions = list(df_results["division"].unique())
214+
for div in rich_track(list(map(defs.Division.of_int, divisions)), description="Generating chart for divisions"):
215+
chart = create_output(config, results, divisions=[div])
216+
save_hugo_output(
217+
chart,
218+
output=dst / f"{div.name.lower()}-{page_suffix}-chart.html",
219+
title=f"Chart for division {div.name}",
220+
)
221+
222+
logics = list(df_results["logic"].unique())
223+
for logic in rich_track(list(map(defs.Logic.of_int, logics)), description="Generating chart for logics"):
224+
chart = create_output(config, results, logics=[logic])
225+
save_hugo_output(
226+
chart,
227+
output=dst / f"{logic.name.lower()}-{page_suffix}-chart.html",
228+
title=f"Chart for logic {logic.name}",
229+
)

smtcomp/main.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,4 +1149,25 @@ def generate_graphics(
11491149

11501150
results = smtcomp.scoring.add_disagreements_info(results, track).filter(disagreements=False).drop("disagreements")
11511151

1152-
smtcomp_generate_graphics.create_output(config, results, output, logic, division)
1152+
smtcomp_generate_graphics.save_output(config, results, output, logic, division)
1153+
1154+
1155+
@app.command()
1156+
def generate_website_graphics(
1157+
data: Path,
1158+
track: defs.Track,
1159+
src: List[Path] = typer.Argument(None),
1160+
) -> None:
1161+
"""
1162+
Generate graphics for hugo website
1163+
1164+
If src is empty use results in data
1165+
"""
1166+
config = defs.Config(data)
1167+
results = smtcomp.results.helper_get_results(config, src, track)
1168+
1169+
smtcomp.scoring.sanity_check(config, results)
1170+
1171+
results = smtcomp.scoring.add_disagreements_info(results, track).filter(disagreements=False).drop("disagreements")
1172+
1173+
smtcomp_generate_graphics.generate_pages(config, results, track)

smtcomp/results.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,7 @@ def helper_get_results(config: defs.Config, results: List[Path], track: defs.Tra
525525
defaults=defaults,
526526
)
527527

528+
if track == defs.Track.Parallel:
529+
selected = selected.with_columns(run=True)
530+
528531
return selected

web/themes/smtcomp/layouts/_default/result.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ <h1>{{ .Params.division }} ({{ $prettyTrack }})</h1>
1515
<p>
1616
Competition results for the {{ .Params.division }}
1717
{{ if $trueDivision }} division {{ else }} logic {{ end }}
18-
in the {{ $prettyTrack }}.
18+
in the {{ $prettyTrack }}. <a href="{{math.Add (path.Dir .RelPermalink) "-chart"}}"><b>Chart</b></a> </p>
1919
<p>Results were generated on {{ .Params.resultdate }}</p>
20-
</p>
2120
<p>
2221
<b>Benchmarks</b>: {{ .Params.n_benchmarks }}<br/>
2322
<b>Time Limit:</b> {{ .Params.time_limit }} seconds<br/>

0 commit comments

Comments
 (0)