From a44a8bace9e68fecc9cb2fafe4c41c197206917c Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 18 Jan 2026 02:04:06 +0000 Subject: [PATCH] Fix: Don't crash when no entries are converted in swebenchmultimodal When convert_to_swebench_format converts 0 entries, it should not raise an exception. Instead, let the harness be responsible for handling the empty results. Fixes #338 --- benchmarks/swebenchmultimodal/eval_infer.py | 3 --- tests/test_swebenchmultimodal.py | 30 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/test_swebenchmultimodal.py diff --git a/benchmarks/swebenchmultimodal/eval_infer.py b/benchmarks/swebenchmultimodal/eval_infer.py index f8404f64..06106fd7 100644 --- a/benchmarks/swebenchmultimodal/eval_infer.py +++ b/benchmarks/swebenchmultimodal/eval_infer.py @@ -106,9 +106,6 @@ def convert_to_swebench_format( f"{error_count} errors" ) - if converted_count == 0: - raise ValueError("No valid entries were converted") - def run_swebench_multimodal_evaluation( predictions_file: str, diff --git a/tests/test_swebenchmultimodal.py b/tests/test_swebenchmultimodal.py new file mode 100644 index 00000000..3238ee90 --- /dev/null +++ b/tests/test_swebenchmultimodal.py @@ -0,0 +1,30 @@ +"""Tests for SWE-Bench Multimodal eval_infer functionality.""" + +import tempfile + +from benchmarks.swebenchmultimodal.eval_infer import convert_to_swebench_format + + +class TestConvertToSwebenchFormat: + """Tests for convert_to_swebench_format function.""" + + def test_empty_input_file_does_not_raise(self): + """Test that an empty input file does not raise an exception.""" + with tempfile.NamedTemporaryFile( + mode="w", suffix=".jsonl", delete=False + ) as infile: + infile.write("") # Empty file + input_path = infile.name + + with tempfile.NamedTemporaryFile( + mode="w", suffix=".swebench.jsonl", delete=False + ) as outfile: + output_path = outfile.name + + # Should not raise - let the harness handle empty results + convert_to_swebench_format(input_path, output_path) + + # Verify output file is empty + with open(output_path, "r") as f: + lines = f.readlines() + assert len(lines) == 0