Spaces:
Runtime error
Runtime error
Improved exception error logging
Browse files348 unmodified lines349350351352353354355356357358359360361362363136 unmodified lines5005015025035045051 unmodified line507508509510511512348 unmodified linesif not result:result.append("Result evaluates to False (empty?)")return dict(task_id=task_id,passed=result[0] == "passed",result=result[0],completion_id=completion_id,)class AllowListImporter:def __init__(self, allowed_imports: List[str]):136 unmodified lineswith time_limit(timeout):byte_code = compile_restricted(check_program, filename="<model output>", mode="exec", policy=policy_class)exec(byte_code, exec_globals, additional_locals)result.append("passed")except EOFError:result.append("EOF error")1 unmodified lineresult.append("timed out")except BaseException as e:result.append(f"failed ({type(e)}): {str(e)}")# Needed for cleaning up.shutil.rmtree = rmtree348 unmodified lines349350351352353354355356357358359360361362363364365366367368369370136 unmodified lines5075085095105115125131 unmodified line515516517518519520521348 unmodified linesif not result:result.append("Result evaluates to False (probably timed out)")out_dict = dict(task_id=task_id,passed=result[0] == "passed",result=result[0],completion_id=completion_id,)if 'failed' in result[0] and len(result) > 1:exc = result[1]out_dict["exception_type"] = type(exc).__name__out_dict["exception_description"] = str(exc)return out_dictclass AllowListImporter:def __init__(self, allowed_imports: List[str]):136 unmodified lineswith time_limit(timeout):byte_code = compile_restricted(check_program, filename="<model output>", mode="exec", policy=policy_class)exec(byte_code, exec_globals, additional_locals)result.append("passed")except EOFError:result.append("EOF error")1 unmodified lineresult.append("timed out")except BaseException as e:result.append(f"failed ({type(e)}): {str(e)}")result.append(e)# Needed for cleaning up.shutil.rmtree = rmtree
restrictedpython_code_eval.py+11-2