good version for 算法注册
This commit is contained in:
@@ -72,9 +72,24 @@ class APIGateway:
|
||||
if not version_info:
|
||||
raise HTTPException(status_code=404, detail="Algorithm version not found")
|
||||
|
||||
# 在实际实现中,这里会根据version_info.url将请求转发到对应的算法服务
|
||||
# 现在我们模拟调用过程
|
||||
algorithm_url = version_info.url if hasattr(version_info, 'url') else f"http://localhost:8001/algorithms/{algorithm_id}/execute"
|
||||
# 尝试从算法版本获取URL,如果没有则尝试从服务表获取
|
||||
algorithm_url = None
|
||||
|
||||
# 首先检查版本信息中是否有URL
|
||||
if hasattr(version_info, 'url') and version_info.url:
|
||||
algorithm_url = version_info.url
|
||||
else:
|
||||
# 如果版本信息中没有URL,尝试从服务表获取
|
||||
from app.models.models import AlgorithmService
|
||||
service = db.query(AlgorithmService).filter(
|
||||
AlgorithmService.algorithm_name == algorithm_id
|
||||
).first()
|
||||
|
||||
if service and service.api_url:
|
||||
algorithm_url = service.api_url
|
||||
else:
|
||||
# 如果都没有,使用默认的本地端点
|
||||
algorithm_url = f"http://localhost:8001/algorithms/{algorithm_id}/execute"
|
||||
|
||||
# 使用httpx调用算法服务
|
||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||
|
||||
Reference in New Issue
Block a user