-
Notifications
You must be signed in to change notification settings - Fork 326
/
Copy pathwebsite_regen.py
66 lines (57 loc) · 2.26 KB
/
website_regen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
IMPORTANT NOTE: Should be run only on the CI!!
This script regenerate the benchmark results website, hosted as GH web pages on the
https://github.com/enso-org/engine-benchmark-results repo.
"""
import asyncio
import logging
from argparse import ArgumentParser
from datetime import datetime
from pathlib import Path
from typing import Optional
from bench_tool import Source
from bench_tool.remote_cache import SyncRemoteCache
from bench_tool.website import generate_bench_website
# The inception date of the benchmarks, i.e., the date of the first benchmark run.
ENGINE_SINCE = datetime.fromisoformat("2024-10-01")
STDLIB_SINCE = datetime.fromisoformat("2024-10-01")
_logger = logging.getLogger("website_regen")
async def main():
arg_parser = ArgumentParser(description="Regenerate the benchmark results website")
arg_parser.add_argument("-v", "--verbose", action="store_true")
arg_parser.add_argument("-n", "--dry-run", action="store_true")
arg_parser.add_argument("--local-repo",
type=str,
help="Path to the local clone of the engine-benchmark-results repo")
args = arg_parser.parse_args()
dry_run: bool = args.dry_run
verbose: bool = args.verbose
local_repo: Optional[Path] = Path(args.local_repo) if args.local_repo else None
logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)
_logger.debug(f"Args: dry_run={dry_run}, verbose={verbose}, local_repo={local_repo}")
remote_cache = SyncRemoteCache(local_repo)
_logger.info("Initializing the bench results repo, this might take some time")
await remote_cache.initialize()
_logger.info("Bench results repo initialized")
now = datetime.now()
engine_html_task = generate_bench_website(
Source.ENGINE,
remote_cache,
ENGINE_SINCE,
now,
remote_cache.engine_index_html()
)
stdlib_html_task = generate_bench_website(
Source.STDLIB,
remote_cache,
STDLIB_SINCE,
now,
remote_cache.stdlib_index_html()
)
await asyncio.gather(engine_html_task, stdlib_html_task)
if dry_run:
_logger.info("Dry-run, not syncing the remote cache")
else:
await remote_cache.sync()
if __name__ == "__main__":
asyncio.run(main())