diff --git a/verifiers/v1/utils/sandbox_program_utils.py b/verifiers/v1/utils/sandbox_program_utils.py index c0aa8f866..e2b36d0f4 100644 --- a/verifiers/v1/utils/sandbox_program_utils.py +++ b/verifiers/v1/utils/sandbox_program_utils.py @@ -1,3 +1,4 @@ +from pathlib import Path from __future__ import annotations import json @@ -369,7 +370,7 @@ def model_name(state): def load_tool_defs(protocol): - defs = json.loads(open(TOOL_DEFS_BY_PROTOCOL_PATH).read()) + defs = json.loads(Path(TOOL_DEFS_BY_PROTOCOL_PATH).read_text()) return defs.get(protocol) or [] @@ -567,7 +568,7 @@ async def create_model_message(state, messages, client): async def run_base(task, state, client): prompt_messages = [*(state.get("system_prompt") or []), *(state.get("prompt") or [])] messages = list(prompt_messages) - config = json.loads(open(RUNNER_CONFIG_PATH).read()) + config = json.loads(Path(RUNNER_CONFIG_PATH).read_text()) max_turns = int(config["max_turns"]) turn = 0 while max_turns <= 0 or turn < max_turns: @@ -613,8 +614,8 @@ async def run_base(task, state, client): async def main(): mode = sys.argv[1] - task = json.loads(open(TASK_PATH).read()) - state = json.loads(open(STATE_INPUT_PATH).read()) + task = json.loads(Path(TASK_PATH).read_text()) + state = json.loads(Path(STATE_INPUT_PATH).read_text()) original_state = json.loads(json.dumps(state)) client = Client(state) try: