From c778bcd1031458b44cf9280dd9cc6c9735457156 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sat, 10 Jan 2026 17:39:09 +0000 Subject: [PATCH 1/4] Remove checkpoint Signed-off-by: kerthcet --- src/hive_cli/libs/main.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/hive_cli/libs/main.py b/src/hive_cli/libs/main.py index c622c0e..100a136 100644 --- a/src/hive_cli/libs/main.py +++ b/src/hive_cli/libs/main.py @@ -1,5 +1,6 @@ """A simple Python sandbox server that executes Python functions.""" +import json import logging import os import subprocess @@ -58,7 +59,6 @@ def execute_python_function( with open(os.path.join(REPO_DIR, rel_path), "w", encoding="utf-8") as f: f.write(range_and_content) - # Run the Python program try: output = common_tools.run_command( ["python", evaluation_script] + args, REPO_DIR, timeout @@ -66,20 +66,9 @@ def execute_python_function( return output except common_tools.FunctionExecutionError as e: logger.info( - "Run command failed: %s. Attempting to read checkpoint data.", e + "Run command failed: %s.", e ) - try: - # If the script leaves checkpointed json data, find and return it - output = common_tools.run_command(["cat", "checkpoint.json"], REPO_DIR) - return f'{{"output": {output}, "metainfo": "Checkpoint"}}' - except common_tools.FunctionExecutionError as ee: - logger.info( - "Failed to read checkpoint data: %s. Returning original error.", ee - ) - raise common_tools.FunctionExecutionError( - f"Execution failed: {e}" - ) - + return json.dumps({"output": None, "metainfo": str(e)}) @app.route("/health", methods=["GET"]) def health_check(): From 30023f669105e1dceeba95b1a576674d88ed2b20 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sat, 10 Jan 2026 17:39:25 +0000 Subject: [PATCH 2/4] Always use the last line of output as the metric Signed-off-by: kerthcet --- src/hive_cli/libs/common_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hive_cli/libs/common_tools.py b/src/hive_cli/libs/common_tools.py index 9628f69..78bbea9 100644 --- a/src/hive_cli/libs/common_tools.py +++ b/src/hive_cli/libs/common_tools.py @@ -55,7 +55,7 @@ def run_command( raise FunctionExecutionError(error_code_to_string(-process.returncode)) if process.returncode != 0: raise FunctionExecutionError(f"Error: {stderr}") - return stdout + return stdout.strip().splitlines()[-1] # Return only the last line of output except subprocess.TimeoutExpired as exc: process.kill() raise FunctionExecutionError("Timeout") from exc From 2166acc679bea6aac1b8c9d71f88d5150d0e35cb Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sun, 11 Jan 2026 14:24:09 +0000 Subject: [PATCH 3/4] remove unused libraries Signed-off-by: kerthcet --- src/hive_cli/libs/common_tools.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hive_cli/libs/common_tools.py b/src/hive_cli/libs/common_tools.py index 78bbea9..b404ad1 100644 --- a/src/hive_cli/libs/common_tools.py +++ b/src/hive_cli/libs/common_tools.py @@ -3,10 +3,8 @@ import io import signal import subprocess -import threading import time -import psutil import requests GCR_SANDBOX_BUCKET = "hi-sandbox" From b51c43c30fea16a7a41bacb7b4a8d9a7a4601782 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Fri, 16 Jan 2026 18:45:26 +0000 Subject: [PATCH 4/4] Revert "Remove checkpoint" This reverts commit c778bcd1031458b44cf9280dd9cc6c9735457156. --- src/hive_cli/libs/main.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/hive_cli/libs/main.py b/src/hive_cli/libs/main.py index 100a136..c622c0e 100644 --- a/src/hive_cli/libs/main.py +++ b/src/hive_cli/libs/main.py @@ -1,6 +1,5 @@ """A simple Python sandbox server that executes Python functions.""" -import json import logging import os import subprocess @@ -59,6 +58,7 @@ def execute_python_function( with open(os.path.join(REPO_DIR, rel_path), "w", encoding="utf-8") as f: f.write(range_and_content) + # Run the Python program try: output = common_tools.run_command( ["python", evaluation_script] + args, REPO_DIR, timeout @@ -66,9 +66,20 @@ def execute_python_function( return output except common_tools.FunctionExecutionError as e: logger.info( - "Run command failed: %s.", e + "Run command failed: %s. Attempting to read checkpoint data.", e ) - return json.dumps({"output": None, "metainfo": str(e)}) + try: + # If the script leaves checkpointed json data, find and return it + output = common_tools.run_command(["cat", "checkpoint.json"], REPO_DIR) + return f'{{"output": {output}, "metainfo": "Checkpoint"}}' + except common_tools.FunctionExecutionError as ee: + logger.info( + "Failed to read checkpoint data: %s. Returning original error.", ee + ) + raise common_tools.FunctionExecutionError( + f"Execution failed: {e}" + ) + @app.route("/health", methods=["GET"]) def health_check():