fix:显示详情接口修改
Former-commit-id: 81391f54c3862bc8be46fafd3867e39eeddd4bdb
This commit is contained in:
parent
44c1836d0c
commit
85bfc35a25
|
@ -6,12 +6,16 @@ package logic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"APIGW-go-sdk/core"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
"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/internal/svc"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
||||||
"PCM/common/tool"
|
"PCM/common/tool"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -33,12 +37,47 @@ func NewShowModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowMo
|
||||||
func (l *ShowModelsLogic) ShowModels(in *modelarts.ShowModelReq) (*modelarts.ShowModelResp, error) {
|
func (l *ShowModelsLogic) ShowModels(in *modelarts.ShowModelReq) (*modelarts.ShowModelResp, error) {
|
||||||
// todo: add your logic here and delete this line
|
// todo: add your logic here and delete this line
|
||||||
var resp modelarts.ShowModelResp
|
var resp modelarts.ShowModelResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/models/" + in.ModelId
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
token := common.GetToken()
|
modelArtsType := in.ModelArtsType
|
||||||
body, err := tool.HttpClient(tool.GET, url, nil, token)
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
if err != nil {
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
return nil, err
|
url := modelArtsUrl + "v1/" + in.ProjectId + "/models/" + in.ModelId
|
||||||
|
token := common.GetToken()
|
||||||
|
body, err := tool.HttpClient(tool.GET, url, nil, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
} 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
|
||||||
|
s := core.Signer{
|
||||||
|
Key: AK,
|
||||||
|
Secret: SK,
|
||||||
|
}
|
||||||
|
r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/models/"+in.ModelId,
|
||||||
|
nil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
r.Header.Add("content-type", "application/json;charset=UTF-8")
|
||||||
|
r.Header.Add("X-Project-Id", XProjectId)
|
||||||
|
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)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
}
|
}
|
||||||
json.Unmarshal(body, &resp)
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,16 @@ package logic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"APIGW-go-sdk/core"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
"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/internal/svc"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
||||||
"PCM/common/tool"
|
"PCM/common/tool"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -33,20 +37,55 @@ func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowS
|
||||||
func (l *ShowServiceLogic) ShowService(in *modelarts.ShowServiceReq) (*modelarts.ShowServiceResp, error) {
|
func (l *ShowServiceLogic) ShowService(in *modelarts.ShowServiceReq) (*modelarts.ShowServiceResp, error) {
|
||||||
// todo: add your logic here and delete this line
|
// todo: add your logic here and delete this line
|
||||||
var resp modelarts.ShowServiceResp
|
var resp modelarts.ShowServiceResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services/" + in.ServiceId
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
token := common.GetToken()
|
modelArtsType := in.ModelArtsType
|
||||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token)
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
if err != nil {
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
return nil, err
|
url := modelArtsUrl + "v1/" + in.ProjectId + "/services/" + in.ServiceId
|
||||||
}
|
token := common.GetToken()
|
||||||
if statusCode == 200 {
|
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if statusCode == 200 {
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Msg = "Success"
|
||||||
|
} else if statusCode != 200 {
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
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
|
||||||
|
s := core.Signer{
|
||||||
|
Key: AK,
|
||||||
|
Secret: SK,
|
||||||
|
}
|
||||||
|
r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/services/"+in.ServiceId,
|
||||||
|
nil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
r.Header.Add("content-type", "application/json;charset=UTF-8")
|
||||||
|
r.Header.Add("X-Project-Id", XProjectId)
|
||||||
|
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)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
json.Unmarshal(body, &resp)
|
json.Unmarshal(body, &resp)
|
||||||
resp.Code = 200
|
|
||||||
resp.Msg = "Success"
|
|
||||||
} else if statusCode != 200 {
|
|
||||||
json.Unmarshal(body, &resp)
|
|
||||||
resp.Code = 400
|
|
||||||
resp.Msg = "Failure"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,6 +617,8 @@ message DeleteTrainingJobConfigResp{
|
||||||
bool is_success =1;
|
bool is_success =1;
|
||||||
string error_message =2;
|
string error_message =2;
|
||||||
string error_code =3;
|
string error_code =3;
|
||||||
|
int32 code =4; //@gotags: copier:"Code"
|
||||||
|
string msg =5; //@gotags: copier:"Msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************DeleteTrainingJobConfig end*************************/
|
/******************DeleteTrainingJobConfig end*************************/
|
||||||
|
|
Loading…
Reference in New Issue