(
file: UploadFile = File(...),
session_id: str = Form(...),
yaml_file: str = Form(...),
max_parallel: int = Form(5),
log_level: str | None = Form(None),
)
| 13 | |
| 14 | @router.post("/api/workflows/batch") |
| 15 | async def execute_batch( |
| 16 | file: UploadFile = File(...), |
| 17 | session_id: str = Form(...), |
| 18 | yaml_file: str = Form(...), |
| 19 | max_parallel: int = Form(5), |
| 20 | log_level: str | None = Form(None), |
| 21 | ): |
| 22 | try: |
| 23 | manager = ensure_known_session(session_id, require_connection=True) |
| 24 | except ValidationError as exc: |
| 25 | raise HTTPException(status_code=400, detail=str(exc)) |
| 26 | |
| 27 | if max_parallel < 1: |
| 28 | raise HTTPException(status_code=400, detail="max_parallel must be >= 1") |
| 29 | |
| 30 | try: |
| 31 | content = await file.read() |
| 32 | tasks, file_base = parse_batch_file(content, file.filename or "batch.csv") |
| 33 | except ValidationError as exc: |
| 34 | raise HTTPException(status_code=400, detail=str(exc)) |
| 35 | |
| 36 | resolved_level = None |
| 37 | if log_level: |
| 38 | try: |
| 39 | resolved_level = LogLevel(log_level) |
| 40 | except ValueError: |
| 41 | raise HTTPException(status_code=400, detail="log_level must be either DEBUG or INFO") |
| 42 | |
| 43 | service = BatchRunService() |
| 44 | asyncio.create_task( |
| 45 | service.run_batch( |
| 46 | session_id, |
| 47 | yaml_file, |
| 48 | tasks, |
| 49 | manager, |
| 50 | max_parallel=max_parallel, |
| 51 | file_base=file_base, |
| 52 | log_level=resolved_level, |
| 53 | ) |
| 54 | ) |
| 55 | |
| 56 | return { |
| 57 | "status": "accepted", |
| 58 | "session_id": session_id, |
| 59 | "batch_id": session_id, |
| 60 | "task_count": len(tasks), |
| 61 | } |
nothing calls this directly
no test coverage detected