fix:删除训练作业和算法接口修改
Former-commit-id: bb4d627271dbfcfdf3fbca2bc8760b524be39ac9
This commit is contained in:
parent
c1bf5bee2e
commit
47b142dcec
|
@ -1,10 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
|
@ -30,7 +34,11 @@ func NewDeleteAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
|||
// DeleteAlgorithms 删除算法
|
||||
func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) {
|
||||
var resp modelarts.DeleteAlgorithmsResp
|
||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId
|
||||
//根据智算类型判断走华为智算还是南京智算
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -47,5 +55,45 @@ func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsR
|
|||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
} else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType {
|
||||
AK := l.svcCtx.Config.AK
|
||||
SK := l.svcCtx.Config.SK
|
||||
NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl
|
||||
XProjectId := l.svcCtx.Config.XProjectId
|
||||
XDomainId := l.svcCtx.Config.XDomainId
|
||||
s := core.Signer{
|
||||
Key: AK,
|
||||
Secret: SK,
|
||||
}
|
||||
r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/algorithms/"+in.AlgorithmId,
|
||||
nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
//return
|
||||
}
|
||||
r.Header.Add("content-type", "application/json;charset=UTF-8")
|
||||
r.Header.Add("X-Project-Id", XProjectId)
|
||||
r.Header.Add("X-Domain-Id", XDomainId)
|
||||
r.Header.Add("x-stage", "RELEASE")
|
||||
s.Sign(r)
|
||||
client := http.DefaultClient
|
||||
res, err := client.Do(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
statusCode := res.StatusCode
|
||||
if statusCode == 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"io/ioutil"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -28,7 +32,11 @@ func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
// DeleteTrainingJobConfig 删除训练作业
|
||||
func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) {
|
||||
var resp modelarts.DeleteTrainingJobResp
|
||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/training-jobs/" + in.TrainingJobId
|
||||
//根据智算类型判断走华为智算还是南京智算
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
url := modelArtsUrl + "v2/" + in.ProjectId + "/training-jobs/" + in.TrainingJobId
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -48,5 +56,45 @@ func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJ
|
|||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
} else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType {
|
||||
AK := l.svcCtx.Config.AK
|
||||
SK := l.svcCtx.Config.SK
|
||||
NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl
|
||||
XProjectId := l.svcCtx.Config.XProjectId
|
||||
XDomainId := l.svcCtx.Config.XDomainId
|
||||
s := core.Signer{
|
||||
Key: AK,
|
||||
Secret: SK,
|
||||
}
|
||||
r, err := http.NewRequest("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-jobs/"+in.TrainingJobId,
|
||||
nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
//return
|
||||
}
|
||||
r.Header.Add("content-type", "application/json;charset=UTF-8")
|
||||
r.Header.Add("X-Project-Id", XProjectId)
|
||||
r.Header.Add("X-Domain-Id", XDomainId)
|
||||
r.Header.Add("x-stage", "RELEASE")
|
||||
s.Sign(r)
|
||||
client := http.DefaultClient
|
||||
res, err := client.Do(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
statusCode := res.StatusCode
|
||||
if statusCode == 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue