From 2b63cb43b169417f9ccf981ed7f9457b2e69584a Mon Sep 17 00:00:00 2001 From: Jake Koenig Date: Tue, 16 Jan 2024 07:11:33 -0800 Subject: [PATCH] try/catch --- benchmarks/benchmark_runner.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/benchmarks/benchmark_runner.py b/benchmarks/benchmark_runner.py index f26cab368..32ce81b4d 100755 --- a/benchmarks/benchmark_runner.py +++ b/benchmarks/benchmark_runner.py @@ -189,21 +189,23 @@ async def evaluate_sample(sample_file, retries=1): diff_merge_base=sample.diff_merge_base, diff_active=sample.diff_active, ) - cwd = Path(repo.working_dir) - - # Run sample in PythonClient - paths = list[Path]() - for a in sample.context: - paths.append(Path(a)) - client = PythonClient(cwd=cwd, paths=paths) - response = await run_client( - client, sample.message_prompt, result, sample.message_history - ) - await grade_and_clean_diff( - repo, response, result, comparison_diff=sample.diff_edit - ) - os.chdir('../..') - results.append(result) + try: + cwd = Path(repo.working_dir) + + # Run sample in PythonClient + paths = list[Path]() + for a in sample.context: + paths.append(Path(a)) + client = PythonClient(cwd=cwd, paths=paths) + response = await run_client( + client, sample.message_prompt, result, sample.message_history + ) + await grade_and_clean_diff( + repo, response, result, comparison_diff=sample.diff_edit + ) + results.append(result) + finally: + os.chdir('../..') return results