From ec707e021acc50ba9dcbd6939a3a111629b7c43b Mon Sep 17 00:00:00 2001 From: Fahad Date: Sat, 14 Jun 2025 16:00:54 +0400 Subject: [PATCH] Fix for path translation within docker --- tools/testgen.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testgen.py b/tools/testgen.py index 8746b0a..3e5e5ef 100644 --- a/tools/testgen.py +++ b/tools/testgen.py @@ -22,6 +22,7 @@ from pydantic import Field from config import TEMPERATURE_ANALYTICAL from systemprompts import TESTGEN_PROMPT +from utils.file_utils import translate_file_paths from .base import BaseTool, ToolRequest from .models import ToolOutput @@ -182,6 +183,10 @@ class TestGenTool(BaseTool): logger.info(f"[TESTGEN] All {len(test_examples)} test examples already in conversation history") return "", "" + # Translate file paths for Docker environment before accessing files + translated_examples = translate_file_paths(examples_to_process) + logger.debug(f"[TESTGEN] Translated {len(examples_to_process)} file paths for container access") + # Calculate token budget for test examples (25% of available tokens, or fallback) if available_tokens: test_examples_budget = int(available_tokens * 0.25) # 25% for test examples @@ -198,11 +203,13 @@ class TestGenTool(BaseTool): ) # Sort by file size (smallest first) for pattern-focused selection + # Use translated paths for file system operations, but keep original paths for processing file_sizes = [] - for file_path in examples_to_process: + for i, file_path in enumerate(examples_to_process): + translated_path = translated_examples[i] try: - size = os.path.getsize(file_path) - file_sizes.append((file_path, size)) + size = os.path.getsize(translated_path) + file_sizes.append((file_path, size)) # Keep original path for consistency logger.debug(f"[TESTGEN] Test example {os.path.basename(file_path)}: {size:,} bytes") except (OSError, FileNotFoundError) as e: # If we can't get size, put it at the end