SIENTIAPDE-1579: Fixed data preprocessor
This commit is contained in:
@@ -105,6 +105,19 @@ def load_scenario(scenario_name: str) -> dict:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def _resolve_csv_path(csv_path: Path) -> Path:
|
||||
"""Resolve CSV path; if not found in project root, try docs/."""
|
||||
if csv_path.is_absolute():
|
||||
return csv_path
|
||||
resolved = PROJECT_ROOT / csv_path
|
||||
if resolved.exists():
|
||||
return resolved
|
||||
docs_path = PROJECT_ROOT / 'docs' / csv_path.name
|
||||
if docs_path.exists():
|
||||
return docs_path
|
||||
return resolved
|
||||
|
||||
|
||||
def _ensure_source_file(path: Path) -> None:
|
||||
if not path.exists():
|
||||
raise FileNotFoundError(f'Test dataset not found at {path.resolve()}')
|
||||
@@ -206,6 +219,7 @@ def build_workflow_payload(
|
||||
'end_date': request_data.get('endDate'),
|
||||
'scaler_name': request_data.get('scalerName', 'None'),
|
||||
'support_filters': request_data.get('supportFilters', {}),
|
||||
'static_threshold': request_data.get('staticThreshold'),
|
||||
}
|
||||
|
||||
|
||||
@@ -292,8 +306,7 @@ def run_local_pipeline(
|
||||
result['error'] = str(exc)
|
||||
return result
|
||||
|
||||
if not csv_path.is_absolute():
|
||||
csv_path = PROJECT_ROOT / csv_path
|
||||
csv_path = _resolve_csv_path(csv_path)
|
||||
_ensure_source_file(csv_path)
|
||||
payload = _build_local_payload(request_data, csv_path)
|
||||
try:
|
||||
@@ -439,6 +452,8 @@ def run_single_scenario(scenario_name: str, csv_path: Path) -> dict:
|
||||
result['error'] = str(exc)
|
||||
return result
|
||||
|
||||
csv_path = _resolve_csv_path(csv_path)
|
||||
|
||||
# Upload CSV to MinIO
|
||||
try:
|
||||
uploaded_file_name = upload_to_minio(csv_path)
|
||||
|
||||
Reference in New Issue
Block a user