- Added configuration for file storage and software plugins in `software_config.yaml`. - Created core components for batch processing including `CadBatchManager`, `CadTaskRouter`, and `SerialBatchExecutor`. - Implemented plugin callback handling with `PluginCallbackRegistry` and HTTP client for task submission. - Developed API endpoint for receiving plugin callbacks in `plugin_callbacks.py`. - Enhanced data models for batch processing including `BatchJob`, `BatchItem`, and callback payloads. - Introduced WebSocket support for real-time updates on batch processing status. - Added comprehensive tests for routing, callback API, and serial executor behavior. - Documented the implementation plan and core execution rules in `cad-batch-plan.md`.
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""FastAPI entrypoint."""
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.v1 import files, plugin_callbacks, websocket
|
|
from app.core.cad_batch_manager import cad_batch_manager
|
|
from app.core.log_manager import log_manager
|
|
from app.core.software_manager import software_manager
|
|
from app.core.websocket_manager import websocket_manager
|
|
|
|
|
|
app = FastAPI(
|
|
title="CadHubManage API",
|
|
description="Backend service for managing CAD software and batch processing tasks.",
|
|
version="1.1.0",
|
|
)
|
|
|
|
software_manager.set_websocket_manager(websocket_manager)
|
|
software_manager.set_log_manager(log_manager)
|
|
|
|
cad_batch_manager.set_websocket_manager(websocket_manager)
|
|
cad_batch_manager.set_log_manager(log_manager)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
await log_manager.start()
|
|
await cad_batch_manager.start()
|
|
|
|
|
|
@app.on_event("shutdown")
|
|
async def shutdown_event():
|
|
await cad_batch_manager.stop()
|
|
await log_manager.stop()
|
|
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(websocket.router, prefix="/api/v1/ws", tags=["WebSocket"])
|
|
app.include_router(files.router, prefix="/api/v1", tags=["Files"])
|
|
app.include_router(plugin_callbacks.router, prefix="/api/v1", tags=["PluginCallbacks"])
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"message": "CadHubManage API is running",
|
|
"version": "1.1.0",
|
|
"docs": "/docs",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|