fix:创建接口修改
Former-commit-id: 80349a101566d63deeaecf56589ce4ab49ce028c
This commit is contained in:
parent
8fc3939653
commit
1efe5406e5
|
@ -6,10 +6,15 @@ 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/common/tool"
|
"PCM/common/tool"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||||
|
@ -36,17 +41,52 @@ func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||||
func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) {
|
func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) {
|
||||||
// todo: add your logic here and delete this line
|
// todo: add your logic here and delete this line
|
||||||
var resp modelarts.CreateProcessorTaskResp
|
var resp modelarts.CreateProcessorTaskResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/processor-tasks/"
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
reqByte, err := json.Marshal(in)
|
modelArtsType := in.ModelArtsType
|
||||||
if err != nil {
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
return nil, err
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
|
url := modelArtsUrl + "v2/" + in.ProjectId + "/processor-tasks/"
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
payload := strings.NewReader(string(reqByte))
|
||||||
|
token := common.GetToken()
|
||||||
|
body, err := tool.HttpClient(tool.POST, url, payload, 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,
|
||||||
|
}
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/processor-tasks/",
|
||||||
|
bytes.NewBuffer(reqByte))
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
payload := strings.NewReader(string(reqByte))
|
|
||||||
token := common.GetToken()
|
|
||||||
body, err := tool.HttpClient(tool.POST, url, payload, token)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
json.Unmarshal(body, &resp)
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,17 @@ 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"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,25 +42,61 @@ func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
|
||||||
func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) {
|
func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) {
|
||||||
// todo: add your logic here and delete this line
|
// todo: add your logic here and delete this line
|
||||||
var resp modelarts.CreateServiceResp
|
var resp modelarts.CreateServiceResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/services"
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
reqByte, err := json.Marshal(in)
|
modelArtsType := in.ModelArtsType
|
||||||
if err != nil {
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
return nil, err
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
}
|
url := modelArtsUrl + "v1/" + in.ProjectId + "/services"
|
||||||
payload := strings.NewReader(string(reqByte))
|
reqByte, err := json.Marshal(in)
|
||||||
token := common.GetToken()
|
if err != nil {
|
||||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token)
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
payload := strings.NewReader(string(reqByte))
|
||||||
}
|
token := common.GetToken()
|
||||||
if statusCode == 200 {
|
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, 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,
|
||||||
|
}
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/services",
|
||||||
|
bytes.NewBuffer(reqByte))
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package logic
|
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/common/tool"
|
"PCM/common/tool"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||||
|
@ -30,25 +35,61 @@ func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
||||||
// creat task 创建导入任务
|
// creat task 创建导入任务
|
||||||
func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) {
|
func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) {
|
||||||
var resp modelarts.ImportTaskDataResp
|
var resp modelarts.ImportTaskDataResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/import-tasks"
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
reqByte, err := json.Marshal(in)
|
modelArtsType := in.ModelArtsType
|
||||||
if err != nil {
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
return nil, err
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
}
|
url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/import-tasks"
|
||||||
payload := strings.NewReader(string(reqByte))
|
reqByte, err := json.Marshal(in)
|
||||||
token := common.GetToken()
|
if err != nil {
|
||||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token)
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
payload := strings.NewReader(string(reqByte))
|
||||||
}
|
token := common.GetToken()
|
||||||
if statusCode == 200 {
|
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, 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,
|
||||||
|
}
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets"+in.DatasetId+"/import-tasks",
|
||||||
|
bytes.NewBuffer(reqByte))
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package logic
|
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/common/tool"
|
"PCM/common/tool"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||||
|
@ -30,20 +35,55 @@ func NewCreateTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
||||||
// CreateTrainingJobConfig 创建训练作业参数
|
// CreateTrainingJobConfig 创建训练作业参数
|
||||||
func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) {
|
func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) {
|
||||||
var resp modelarts.CreateTrainingJobConfigResp
|
var resp modelarts.CreateTrainingJobConfigResp
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/training-job-configs"
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
reqByte, err := json.Marshal(in)
|
modelArtsType := in.ModelArtsType
|
||||||
if err != nil {
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
return nil, err
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
}
|
url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs"
|
||||||
payload := strings.NewReader(string(reqByte))
|
reqByte, err := json.Marshal(in)
|
||||||
token := common.GetToken()
|
if err != nil {
|
||||||
body, err := tool.HttpClient(tool.POST, url, payload, token)
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
payload := strings.NewReader(string(reqByte))
|
||||||
}
|
token := common.GetToken()
|
||||||
json.Unmarshal(body, &resp)
|
body, err := tool.HttpClient(tool.POST, url, payload, token)
|
||||||
if &resp == nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
}
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
if &resp == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} 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,
|
||||||
|
}
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs",
|
||||||
|
bytes.NewBuffer(reqByte))
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package logic
|
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/common/tool"
|
"PCM/common/tool"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||||
|
@ -29,19 +34,55 @@ func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||||
|
|
||||||
func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) {
|
func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) {
|
||||||
var resp modelarts.CreateVisualizationJobResp
|
var resp modelarts.CreateVisualizationJobResp
|
||||||
createVisualJobUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/visualization-jobs"
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
createVisualJobUrl = strings.Replace(createVisualJobUrl, "{project_id}", in.ProjectId, -1)
|
modelArtsType := in.ModelArtsType
|
||||||
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
|
createVisualJobUrl := modelArtsUrl + "/v1/{project_id}/visualization-jobs"
|
||||||
|
createVisualJobUrl = strings.Replace(createVisualJobUrl, "{project_id}", in.ProjectId, -1)
|
||||||
|
|
||||||
reqByte, err := json.Marshal(in.Param)
|
reqByte, err := json.Marshal(in.Param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
payload := strings.NewReader(string(reqByte))
|
||||||
|
token := common.GetToken()
|
||||||
|
body, err := tool.HttpClient(tool.POST, createVisualJobUrl, payload, 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,
|
||||||
|
}
|
||||||
|
reqByte, err := json.Marshal(in)
|
||||||
|
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/visualization-jobs",
|
||||||
|
bytes.NewBuffer(reqByte))
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
payload := strings.NewReader(string(reqByte))
|
|
||||||
token := common.GetToken()
|
|
||||||
body, err := tool.HttpClient(tool.POST, createVisualJobUrl, payload, token)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
json.Unmarshal(body, &resp)
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue