Skip to content

Commit

Permalink
Add a proper CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
wpietri committed Dec 15, 2023
1 parent baf9849 commit 09dde2b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
14 changes: 2 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ python = ">=3.10,<3.11"
pyext = {url = "https://files.pythonhosted.org/packages/b0/be/9b6005ac644aaef022527ce49617263379e49dbdbd433d1d3dd66d71f570/pyext-0.7.tar.gz"}
crfm-helm = "0.3"
jq = "^1.6.0"
click = "^8.1.7"

[tool.poetry.group.dev.dependencies]
pytest-datafiles = "^3.0.0"
Expand Down
24 changes: 18 additions & 6 deletions src/coffee/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from enum import Enum
from typing import List

import click
import jq

from coffee.benchmark import Benchmark, RidiculousBenchmark
Expand Down Expand Up @@ -172,18 +173,29 @@ def quantize_stars(raw_score):
return round(2 * raw_score) / 2.0


if __name__ == "__main__":
@click.command()
@click.option(
"--output-dir",
"-o",
default="./web",
type=click.Path(file_okay=False, dir_okay=True, path_type=pathlib.Path),
)
@click.option("--max-instances", "-m", type=int, default=100)
def cli(output_dir: pathlib.Path, max_instances: int):
if not output_dir.exists():
output_dir.mkdir(parents=True)
runner = CliHelmRunner()
suts = [HelmSut.GPT2]
result = runner.run([BbqHelmTest()], suts, max_instances=100)
result = runner.run([BbqHelmTest()], suts, max_instances=max_instances)
scores = result.load_scores()
benchmarks: list[Benchmark] = []
for sut in suts:
benchmark = RidiculousBenchmark(sut, scores.for_sut(sut))
benchmarks.append(benchmark)
print(
f"{benchmark.sut.name} scored {quantize_stars(benchmark.overall_score())} stars"
)

static_site_generator = StaticSiteGenerator()
static_site_generator.generate(benchmarks, pathlib.Path("/tmp/coffee/web"))
static_site_generator.generate(benchmarks, output_dir)


if __name__ == "__main__":
cli()

0 comments on commit 09dde2b

Please sign in to comment.