locodellm.bench.run_code#

Compile and run generated Python functions with undefined arguments.

class locodellm.bench.run_code.RunStatus(compiled: bool = False, compile_error: BaseException | None = None, ran: bool = False, run_error: BaseException | None = None, result: Any = None, _function: Any = None)#

Result of compiling and running a Python function string.

compiled#

Whether the code compiled successfully.

Type:

bool

compile_error#

The exception raised during compilation, if any.

Type:

BaseException | None

ran#

Whether the function executed without error.

Type:

bool

run_error#

The exception raised during execution, if any.

Type:

BaseException | None

result#

The return value of the function, or None if it did not run or raised.

Type:

Any

__repr__()#

Return repr(self).

property success: bool#

Returns True if the code both compiled and ran without error.

locodellm.bench.run_code.run_function(source: str) RunStatus#

Compiles and executes a Python function defined in source.

The function is called with UNDEFINED for each of its positional parameters and as the default for keyword arguments.

Parameters:

source – Python source code defining exactly one function.

Returns:

A RunStatus describing the outcome.