From 9351f438ac61ae72098de1d36161de557702d602 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 8 Nov 2023 14:13:59 -0800 Subject: [PATCH] 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: 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 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. --- benchmark/benchmark.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 28910f5c9..020026f17 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -121,8 +121,9 @@ def show_stats(dirnames): df.sort_values(by=["model", "edit_format"], inplace=True) # dump(df) - 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) def plot_timing(df): @@ -309,6 +310,7 @@ def resolve_dirname(dirname, use_single_prior, make_new): @app.command() def main( 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"), edit_format: str = typer.Option(None, "--edit-format", "-e", help="Edit format"), keywords: str = typer.Option(