forked from JointCloud/pcm-ac
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/internal/common"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/internal/svc"
|
|
"log"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetPytorchTaskLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
const (
|
|
PYTORCH_TASK = "pytorch"
|
|
)
|
|
|
|
func NewGetPytorchTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPytorchTaskLogic {
|
|
return &GetPytorchTaskLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetPytorchTaskLogic) GetPytorchTask(in *hpcAC.GetPytorchTaskReq) (*hpcAC.GetPytorchTaskResp, error) {
|
|
resp := &hpcAC.GetPytorchTaskResp{}
|
|
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.GetTaskAi
|
|
|
|
token := common.GetToken()
|
|
if token == "" {
|
|
log.Println("获取token失败")
|
|
return nil, errors.New("获取token失败")
|
|
}
|
|
|
|
req := common.GetRestyRequest(3)
|
|
_, err := req.
|
|
SetHeader("token", token).
|
|
SetPathParam("taskGroup", PYTORCH_TASK).
|
|
SetPathParam("taskId", in.Id).
|
|
SetResult(resp).
|
|
Get(reqUrl)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|