aider: Add a cmd line switch --graphs and only draw them if it's provided.

# Aider chat conversation:

USER: add a cmd line switch --graphs and only draw them if its provided

ASSISTANT: To add a command-line switch `--graphs` and conditionally generate graphs based on its presence, we need to modify the `benchmark.py` file. Specifically, we will add a new option to the `main` function to accept the `--graphs` switch and then use this option to control the calls to `plot_timing` and `plot_outcomes` functions.

Here are the steps we will follow:

1. Add the `--graphs` option to the `typer` command-line interface in the `main` function.
2. Use the value of this option to conditionally call the `plot_timing` and `plot_outcomes` functions.

Let's make these changes:

<source>python
benchmark/benchmark.py
<<<<<<< SEARCH
@app.command()
def main(
    dirnames: List[str] = typer.Argument(..., help="Directory names"),
=======
@app.command()
def main(
    dirnames: List[str] = typer.Argument(..., help="Directory names"),
    graphs: bool = typer.Option(False, "--graphs", help="Generate graphs"),
>>>>>>> REPLACE

...

<<<<<<< SEARCH
    plot_timing(df)
    plot_outcomes(df, repeats, repeat_hi, repeat_lo, repeat_avg)
=======
    if graphs:
        plot_timing(df)
        plot_outcomes(df, repeats, repeat_hi, repeat_lo, repeat_avg)
>>>>>>> REPLACE
</source>

With these changes, the `--graphs` switch will be available when running the `benchmark.py` script, and the graph generation will only occur if this switch is provided.
This commit is contained in:
Paul Gauthier 2023-11-08 14:13:59 -08:00
parent 8f06658436
commit 9351f438ac

View file

@ -121,8 +121,9 @@ def show_stats(dirnames):
df.sort_values(by=["model", "edit_format"], inplace=True) df.sort_values(by=["model", "edit_format"], inplace=True)
# dump(df) # dump(df)
plot_timing(df) if graphs:
plot_outcomes(df, repeats, repeat_hi, repeat_lo, repeat_avg) plot_timing(df)
plot_outcomes(df, repeats, repeat_hi, repeat_lo, repeat_avg)
def plot_timing(df): def plot_timing(df):
@ -309,6 +310,7 @@ def resolve_dirname(dirname, use_single_prior, make_new):
@app.command() @app.command()
def main( def main(
dirnames: List[str] = typer.Argument(..., help="Directory names"), dirnames: List[str] = typer.Argument(..., help="Directory names"),
graphs: bool = typer.Option(False, "--graphs", help="Generate graphs"),
model: str = typer.Option("gpt-3.5-turbo", "--model", "-m", help="Model name"), model: str = typer.Option("gpt-3.5-turbo", "--model", "-m", help="Model name"),
edit_format: str = typer.Option(None, "--edit-format", "-e", help="Edit format"), edit_format: str = typer.Option(None, "--edit-format", "-e", help="Edit format"),
keywords: str = typer.Option( keywords: str = typer.Option(