52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/common"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
|
|
"log"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type SubmitTensorflowTaskLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewSubmitTensorflowTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitTensorflowTaskLogic {
|
|
return &SubmitTensorflowTaskLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *SubmitTensorflowTaskLogic) SubmitTensorflowTask(in *hpcAC.SubmitTensorflowTaskReq) (*hpcAC.SubmitTaskAiResp, error) {
|
|
resp := &hpcAC.SubmitTaskAiResp{}
|
|
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.SubmitTaskAi
|
|
|
|
token := common.GetToken()
|
|
if token == "" {
|
|
log.Println("获取token失败")
|
|
return nil, errors.New("获取token失败")
|
|
}
|
|
|
|
req := common.GetRestyRequest(20)
|
|
_, err := req.
|
|
SetHeader("token", token).
|
|
SetPathParam("taskGroup", TENSORFLOW_TASK).
|
|
SetBody(in.Params).
|
|
SetResult(resp).
|
|
Post(reqUrl)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|