(database: Database, directory: Path, addr: str)
| 329 | |
| 330 | |
| 331 | def create_comparer_page(database: Database, directory: Path, addr: str): |
| 332 | def create_href(addr, location, name): |
| 333 | return Div(text=f"""<a href='{addr}/{str(location)}'>{str(name)}</a>""") |
| 334 | |
| 335 | entry_map = pregenerate_entries(database, directory) |
| 336 | df = create_database_df(database) |
| 337 | ensure_directory(directory.joinpath("comparisons")) |
| 338 | |
| 339 | comparisons = {} |
| 340 | for comparison in glob(str(directory.joinpath("comparisons/*"))): |
| 341 | name = os.path.basename(comparison) |
| 342 | comparisons[name] = create_href(addr, Path("comparisons").joinpath(name), os.path.splitext(name)[0]) |
| 343 | |
| 344 | comparisons_col = column(list(comparisons.values())) |
| 345 | |
| 346 | def callback(): |
| 347 | name = "_".join(bench_choice.value) + ".html" |
| 348 | if comparisons.get(name) is None: |
| 349 | entries = [] |
| 350 | for bench in bench_choice.value: |
| 351 | if entry_map.get(bench) is not None: |
| 352 | entries.append(entry_map[bench]) |
| 353 | |
| 354 | page = render_hq_comparison(entries) |
| 355 | location = Path("comparisons").joinpath(name) |
| 356 | save(page, directory.joinpath(location), CDN, "Comparison") |
| 357 | |
| 358 | comparisons[name] = create_href(addr, location, name) |
| 359 | comparisons_col.update(children=list(comparisons.values())) |
| 360 | |
| 361 | bench_opts = df["key"].to_list() |
| 362 | bench_choice = MultiChoice(options=bench_opts) |
| 363 | |
| 364 | btn = Button(label="Compare", button_type="success") |
| 365 | btn.on_click(callback) |
| 366 | return column(row(bench_choice, btn), comparisons_col) |
no test coverage detected