Fix for path translation within docker
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user