eval: improve swebench infer error handling and retry (#4205)

This commit is contained in:
Xingyao Wang
2024-10-04 07:09:56 -05:00
committed by GitHub
parent 0c2a35b256
commit 9cc9b19958
2 changed files with 72 additions and 39 deletions

View File

@@ -86,6 +86,10 @@ class EvalOutput(BaseModel):
return json.dumps(dumped_dict)
class EvalException(Exception):
pass
def codeact_user_response(
state: State,
encapsulate_solution: bool = False,
@@ -252,6 +256,15 @@ def update_progress(
output_fp.flush()
def assert_and_raise(condition: bool, msg: str):
"""Raise an EvalException if the condition is not met.
This will be used in conjunction with _process_instance_wrapper to handle retries. An EvalException should trigger a retry.
"""
if not condition:
raise EvalException(msg)
def _process_instance_wrapper(
process_instance_func: Callable[[pd.Series, EvalMetadata, bool], EvalOutput],
instance: pd.Series,