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 config import TEMPERATURE_ANALYTICAL
|
||||||
from systemprompts import TESTGEN_PROMPT
|
from systemprompts import TESTGEN_PROMPT
|
||||||
|
from utils.file_utils import translate_file_paths
|
||||||
|
|
||||||
from .base import BaseTool, ToolRequest
|
from .base import BaseTool, ToolRequest
|
||||||
from .models import ToolOutput
|
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")
|
logger.info(f"[TESTGEN] All {len(test_examples)} test examples already in conversation history")
|
||||||
return "", ""
|
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)
|
# Calculate token budget for test examples (25% of available tokens, or fallback)
|
||||||
if available_tokens:
|
if available_tokens:
|
||||||
test_examples_budget = int(available_tokens * 0.25) # 25% for test examples
|
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
|
# 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 = []
|
file_sizes = []
|
||||||
for file_path in examples_to_process:
|
for i, file_path in enumerate(examples_to_process):
|
||||||
|
translated_path = translated_examples[i]
|
||||||
try:
|
try:
|
||||||
size = os.path.getsize(file_path)
|
size = os.path.getsize(translated_path)
|
||||||
file_sizes.append((file_path, size))
|
file_sizes.append((file_path, size)) # Keep original path for consistency
|
||||||
logger.debug(f"[TESTGEN] Test example {os.path.basename(file_path)}: {size:,} bytes")
|
logger.debug(f"[TESTGEN] Test example {os.path.basename(file_path)}: {size:,} bytes")
|
||||||
except (OSError, FileNotFoundError) as e:
|
except (OSError, FileNotFoundError) as e:
|
||||||
# If we can't get size, put it at the end
|
# If we can't get size, put it at the end
|
||||||
|
|||||||
Reference in New Issue
Block a user