fix test bundling bug

This commit is contained in:
2026-07-17 15:17:08 -04:00
parent b5dd611f82
commit a49772aece
5 changed files with 159 additions and 66 deletions
+24 -16
View File
@@ -16,6 +16,7 @@ os.environ.setdefault("DUT", db.DEVICE_DUT)
os.environ.setdefault("REF", db.DEVICE_REF)
from scheduler import Scheduler, Test as SchedulerTest
from scanner import resolve_runtime_path
from test_config import build_bundle_test_configs, build_config_rows
from test_window import get_shift_capacity_for_date, get_shift_sequence, is_off_day
from watcher import configure_result_watcher, stop_result_watcher
@@ -79,6 +80,28 @@ def _runtime_overrides_from_settings(settings: dict[str, Any]) -> dict[str, dict
return overrides
def _is_explicit_path(path_value: str) -> bool:
return (
path_value.startswith(("/", "\\\\", "//"))
or "\\" in path_value
or ":" in path_value
)
def _resolve_requested_csv_path(requested_path: str) -> str | Path:
received_path = str(requested_path).strip()
resolved_path = str(resolve_runtime_path(received_path)).strip()
if _is_explicit_path(received_path) or _is_explicit_path(resolved_path):
return resolved_path
data_dir_path = APP_ROOT / "data" / received_path
if data_dir_path.exists():
return data_dir_path
return APP_ROOT / received_path
class CompileScheduleRequest(BaseModel):
start_date: str | None = Field(default=None, description="YYYY-MM-DD")
rule: str = ""
@@ -314,22 +337,7 @@ def get_settings() -> dict[str, Any]:
@app.post("/api/tests/load")
def load_tests(request: LoadTestsRequest) -> dict[str, Any]:
received_path = request.csv_path
# Handle absolute paths (Windows or Unix) by extracting just the filename
if "\\" in received_path or ":" in received_path or received_path.startswith("/"):
# Absolute path (Windows with backslash or drive letter, or Unix with /)
# Extract just the filename from the path
filename = received_path.replace("\\", "/").split("/")[-1]
data_dir_path = APP_ROOT / "data" / filename
if data_dir_path.exists():
csv_path = data_dir_path
else:
csv_path = APP_ROOT / filename
else:
# Relative paths - prepend APP_ROOT
csv_path = APP_ROOT / received_path
csv_path = _resolve_requested_csv_path(request.csv_path)
settings = db.read_settings(DB_PATH)
smb_credentials = _smb_credentials_from_settings(settings)