Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a proper CLI. #23

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
dhosterman marked this conversation as resolved.
Show resolved Hide resolved
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()