MCPcopy
hub / github.com/OpenBMB/ChatDev / execute_batch

Function execute_batch

server/routes/batch.py:15–61  ·  view source on GitHub ↗
(
    file: UploadFile = File(...),
    session_id: str = Form(...),
    yaml_file: str = Form(...),
    max_parallel: int = Form(5),
    log_level: str | None = Form(None),
)

Source from the content-addressed store, hash-verified

13
14@router.post("/api/workflows/batch")
15async 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 }

Callers

nothing calls this directly

Calls 5

run_batchMethod · 0.95
ensure_known_sessionFunction · 0.90
parse_batch_fileFunction · 0.90
LogLevelClass · 0.90
BatchRunServiceClass · 0.90

Tested by

no test coverage detected