| @@ -1,20 +0,0 @@ | |||||
| FROM alpine:3.16.2 | |||||
| WORKDIR /home | |||||
| # 修改alpine源为上海交通大学 | |||||
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \ | |||||
| apk update && \ | |||||
| apk upgrade && \ | |||||
| apk add --no-cache ca-certificates && update-ca-certificates && \ | |||||
| apk add --update tzdata && \ | |||||
| rm -rf /var/cache/apk/* | |||||
| COPY pcm-modelarts /home/ | |||||
| COPY etc/pcmmodelarts.yaml /home/ | |||||
| ENV TZ=Asia/Shanghai | |||||
| EXPOSE 2003 | |||||
| ENTRYPOINT ./pcm-modelarts -f pcmmodelarts.yaml | |||||
| @@ -1,2 +0,0 @@ | |||||
| rpc-gen: | |||||
| goctl rpc protoc ./pb/*.proto --go_out=./ --go-grpc_out=./ --zrpc_out=. | |||||
| @@ -1,15 +0,0 @@ | |||||
| NacosConfig: | |||||
| DataId: pcm-modelarts-rpc.yaml | |||||
| Group: DEFAULT_GROUP | |||||
| ServerConfigs: | |||||
| # - IpAddr: 127.0.0.1 | |||||
| # Port: 8848 | |||||
| - IpAddr: nacos.jcce.dev | |||||
| Port: 8848 | |||||
| ClientConfig: | |||||
| NamespaceId: test | |||||
| TimeoutMs: 5000 | |||||
| NotLoadCacheAtStart: true | |||||
| LogDir: | |||||
| CacheDir: | |||||
| LogLevel: debug | |||||
| @@ -1,68 +0,0 @@ | |||||
| package common | |||||
| import ( | |||||
| "bytes" | |||||
| "encoding/json" | |||||
| "io" | |||||
| "log" | |||||
| "net/http" | |||||
| "time" | |||||
| ) | |||||
| const ( | |||||
| IAMUser = "pcmmodelarts" | |||||
| IAMPassword = "!QAZ2wsx3edc4" | |||||
| IAMDomain = "hw_008618597947378_01" | |||||
| AuthMethod = "password" | |||||
| IAMTokenUrl = "https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens" | |||||
| ProjectName = "cn-north-4" | |||||
| TokenHeader = "X-Subject-Token" | |||||
| Status_created = 201 | |||||
| ) | |||||
| var ( | |||||
| token, expiredAt = GenerateToken() | |||||
| ) | |||||
| func GenerateToken() (string, time.Time) { | |||||
| a := Auth{} | |||||
| a.Auth.Scope.Project.Name = ProjectName | |||||
| a.Auth.Identity.Methods = append(a.Auth.Identity.Methods, AuthMethod) | |||||
| a.Auth.Identity.Password.User.Name = IAMUser | |||||
| a.Auth.Identity.Password.User.Password = IAMPassword | |||||
| a.Auth.Identity.Password.User.Domain.Name = IAMDomain | |||||
| jsonStr, _ := json.Marshal(a) | |||||
| req_url, err := http.NewRequest("POST", IAMTokenUrl, bytes.NewBuffer(jsonStr)) | |||||
| if err != nil { | |||||
| log.Fatal(err) | |||||
| } | |||||
| c := http.Client{Timeout: time.Duration(3) * time.Second} | |||||
| respUrl, err := c.Do(req_url) | |||||
| if err != nil { | |||||
| log.Fatal(err) | |||||
| } | |||||
| if respUrl.StatusCode != Status_created { | |||||
| panic("获取token失败") | |||||
| } | |||||
| defer respUrl.Body.Close() | |||||
| var t Token | |||||
| result, _ := io.ReadAll(respUrl.Body) | |||||
| json.Unmarshal(result, &t) | |||||
| return respUrl.Header.Get(TokenHeader), t.Token.ExpiresAt | |||||
| } | |||||
| func GetToken() string { | |||||
| if time.Now().After(expiredAt) { | |||||
| token, expiredAt = GenerateToken() | |||||
| } | |||||
| return token | |||||
| } | |||||
| @@ -1,71 +0,0 @@ | |||||
| package common | |||||
| import "time" | |||||
| type Token struct { | |||||
| Token struct { | |||||
| ExpiresAt time.Time `json:"expires_at"` | |||||
| Methods []string `json:"methods"` | |||||
| Catalog []struct { | |||||
| Endpoints []struct { | |||||
| Id string `json:"id"` | |||||
| Interface string `json:"interface"` | |||||
| Region string `json:"region"` | |||||
| RegionId string `json:"region_id"` | |||||
| Url string `json:"url"` | |||||
| } `json:"endpoints"` | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Type string `json:"type"` | |||||
| } `json:"catalog"` | |||||
| Roles []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } `json:"roles"` | |||||
| Project struct { | |||||
| Domain struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } `json:"domain"` | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } `json:"project"` | |||||
| IssuedAt time.Time `json:"issued_at"` | |||||
| User struct { | |||||
| Domain struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } `json:"domain"` | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| PasswordExpiresAt string `json:"password_expires_at"` | |||||
| } `json:"user"` | |||||
| } `json:"token"` | |||||
| } | |||||
| type Auth struct { | |||||
| Auth struct { | |||||
| Identity struct { | |||||
| Methods []string `json:"methods"` | |||||
| Password struct { | |||||
| User struct { | |||||
| Name string `json:"name"` | |||||
| Password string `json:"password"` | |||||
| Domain struct { | |||||
| Name string `json:"name"` | |||||
| } `json:"domain"` | |||||
| } `json:"user"` | |||||
| } `json:"password"` | |||||
| } `json:"identity"` | |||||
| Scope struct { | |||||
| Project struct { | |||||
| Name string `json:"name"` | |||||
| } `json:"project"` | |||||
| } `json:"scope"` | |||||
| } `json:"auth"` | |||||
| } | |||||
| type Error struct { | |||||
| ErrorCode string `json:"error_code"` | |||||
| ErrorMsg string `json:"error_msg"` | |||||
| } | |||||
| @@ -1,13 +0,0 @@ | |||||
| package config | |||||
| import ( | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| ) | |||||
| type Config struct { | |||||
| zrpc.RpcServerConf | |||||
| LogConf logx.LogConf | |||||
| PcmCoreRpcConf zrpc.RpcClientConf | |||||
| ModelArtsConfig | |||||
| } | |||||
| @@ -1,15 +0,0 @@ | |||||
| package config | |||||
| type ModelArtsConfig struct { | |||||
| ModelArtsUrl string `json:"ModelArtsUrl"` | |||||
| IAMUser string `json:"IAMUser"` | |||||
| NanjingModelArtsUrl string `json:"NanjingModelArtsUrl"` | |||||
| AK string `json:"AK"` | |||||
| SK string `json:"SK"` | |||||
| XProjectId string `json:"X-Project-Id"` | |||||
| XDomainId string `json:"X-Domain-Id"` | |||||
| HaweiModelArtsType string `json:"HaweiModelArtsType"` | |||||
| NanjingModelArtsType string `json:"NanjingModelArtsType"` | |||||
| HuaweiProjectId string `json:"Huawei-Project-Id"` | |||||
| NanjingProjectId string `json:"Nanjing-Project-Id"` | |||||
| } | |||||
| @@ -1,95 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| ) | |||||
| type CreateAlgorithmLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic { | |||||
| return &CreateAlgorithmLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // CreateAlgorithm 创建算法 | |||||
| func (l *CreateAlgorithmLogic) CreateAlgorithm(in *modelarts.CreateAlgorithmReq) (*modelarts.CreateAlgorithmResp, error) { | |||||
| var resp modelarts.CreateAlgorithmResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms" | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if statusCode == 201 { | |||||
| json.Unmarshal(body, &resp) | |||||
| resp.Code = 200 | |||||
| resp.Msg = "Success" | |||||
| } else if statusCode == 400 { | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| reqByte, err := json.Marshal(in) | |||||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/algorithms", | |||||
| bytes.NewBuffer(reqByte)) | |||||
| 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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,90 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateDataSetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic { | |||||
| return &CreateDataSetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // create DateSet | |||||
| func (l *CreateDataSetLogic) CreateDataSet(in *modelarts.CreateDataSetReq) (*modelarts.CreateDataSetResq, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.CreateDataSetResq | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets" | |||||
| 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) | |||||
| 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+"v2/"+in.ProjectId+"/datasets", | |||||
| bytes.NewBuffer(reqByte)) | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,91 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| ) | |||||
| type CreateModelLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateModelLogic { | |||||
| return &CreateModelLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // model management | |||||
| func (l *CreateModelLogic) CreateModel(in *modelarts.CreateModelReq) (*modelarts.CreateModelResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.CreateModelResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models" | |||||
| 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+"v1/"+in.ProjectId+"/models", | |||||
| 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 | |||||
| } | |||||
| @@ -1,105 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| ) | |||||
| type CreateNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic { | |||||
| return &CreateNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateNotebookLogic) CreateNotebook(in *modelarts.CreateNotebookReq) (*modelarts.CreateNotebookResp, error) { | |||||
| resp := &modelarts.CreateNotebookResp{} | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| createUrl := modelArtsUrl + "v1/{project_id}/notebooks" | |||||
| token := common.GetToken() | |||||
| var createResp modelarts.NotebookResp | |||||
| req := tool.GetACHttpRequest() | |||||
| res, err := req. | |||||
| SetHeader("x-auth-token", token). | |||||
| SetPathParam("project_id", in.ProjectId). | |||||
| SetBody(in.Param). | |||||
| SetResult(&createResp). | |||||
| Post(createUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if res.StatusCode() == 200 || res.StatusCode() == 201 { | |||||
| resp.NotebookResp = &createResp | |||||
| resp.Code = int32(res.StatusCode()) | |||||
| resp.Msg = "Success" | |||||
| } else { | |||||
| resp.Code = int32(res.StatusCode()) | |||||
| resp.Msg = "Failure" | |||||
| var errMsg common.Error | |||||
| err := json.Unmarshal(res.Body(), &errMsg) | |||||
| if err != nil { | |||||
| errMsg.ErrorMsg = "" | |||||
| } | |||||
| resp.ErrorMsg = errMsg.ErrorMsg | |||||
| } | |||||
| } 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+"/notebooks", | |||||
| 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 | |||||
| } | |||||
| @@ -1,92 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateProcessorTaskLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProcessorTaskLogic { | |||||
| return &CreateProcessorTaskLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // processor task | |||||
| func (l *CreateProcessorTaskLogic) CreateProcessorTask(in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.CreateProcessorTaskResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,102 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| ) | |||||
| import ( | |||||
| "context" | |||||
| ) | |||||
| type CreateServiceLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic { | |||||
| return &CreateServiceLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // service management | |||||
| func (l *CreateServiceLogic) CreateService(in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.CreateServiceResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services" | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,95 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateTaskLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTaskLogic { | |||||
| return &CreateTaskLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // creat task 创建导入任务 | |||||
| func (l *CreateTaskLogic) CreateTask(in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) { | |||||
| var resp modelarts.ImportTaskDataResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/import-tasks" | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,89 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateTrainingJobConfigLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobConfigLogic { | |||||
| return &CreateTrainingJobConfigLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // CreateTrainingJobConfig 创建训练作业参数 | |||||
| func (l *CreateTrainingJobConfigLogic) CreateTrainingJobConfig(in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) { | |||||
| var resp modelarts.CreateTrainingJobConfigResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs" | |||||
| 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) | |||||
| 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 | |||||
| } | |||||
| @@ -1,97 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateTrainingJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic { | |||||
| return &CreateTrainingJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // CreateTrainingJob 创建训练作业 | |||||
| func (l *CreateTrainingJobLogic) CreateTrainingJob(in *modelarts.CreateTrainingJobReq) (*modelarts.CreateTrainingJobResp, error) { | |||||
| var resp modelarts.CreateTrainingJobResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-jobs" | |||||
| //url := "https://modelarts.cn-north-4.myhuaweicloud.com/v2/0a62ffb0d48026c12fbfc011b8d23f0b/training-jobs" | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if statusCode == 201 { | |||||
| json.Unmarshal(body, &resp) | |||||
| resp.Code = 200 | |||||
| resp.Msg = "Success" | |||||
| } else if statusCode != 201 { | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| reqByte, err := json.Marshal(in) | |||||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-jobs", | |||||
| bytes.NewBuffer(reqByte)) | |||||
| 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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,88 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateVisualizationJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVisualizationJobLogic { | |||||
| return &CreateVisualizationJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateVisualizationJobLogic) CreateVisualizationJob(in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) { | |||||
| var resp modelarts.CreateVisualizationJobResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| 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) | |||||
| if err != nil { | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,217 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "PCM/adaptor/PCM-CORE/rpc/pcmcoreclient" | |||||
| "context" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "time" | |||||
| ) | |||||
| func InitCron(svc *svc.ServiceContext) { | |||||
| submitJobLogic := NewCreateTrainingJobLogic(context.Background(), svc) | |||||
| listLogic := NewGetListTrainingJobsLogic(context.Background(), svc) | |||||
| svc.Cron.AddFunc("*/5 * * * * ?", func() { | |||||
| syncInfoReq := pcmcoreclient.SyncInfoReq{ | |||||
| Kind: "ai", | |||||
| ServiceName: "modelArts", | |||||
| } | |||||
| // 查询core端分发下来的任务列表 | |||||
| infoList, err := queryCoreInfoList(svc) | |||||
| if err != nil { | |||||
| logx.Error(err) | |||||
| return | |||||
| } | |||||
| // 提交任务 | |||||
| submitJob(infoList, submitJobLogic) | |||||
| // 查询运行中的任务列表同步信息 | |||||
| listReq := modelarts.ListTrainingJobsreq{ | |||||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||||
| Limit: 10, | |||||
| OffSet: 0, | |||||
| ModelArtsType: "cn-north-4.myhuawei", | |||||
| } | |||||
| listJob, err := listLogic.GetListTrainingJobs(&listReq) | |||||
| if err != nil { | |||||
| logx.Error(err) | |||||
| return | |||||
| } | |||||
| for index, _ := range infoList.AiInfoList { | |||||
| for _, job := range listJob.Items { | |||||
| if job.Metadata.Name == infoList.AiInfoList[index].Name { | |||||
| infoList.AiInfoList[index].ProjectId = job.ProjectId | |||||
| infoList.AiInfoList[index].JobId = job.Metadata.Id | |||||
| createTime := time.Unix(int64(job.Metadata.CreateTime)/1000, 0) | |||||
| infoList.AiInfoList[index].CreateTime = time.Time.String(createTime) | |||||
| if job.Status.StartTime != 0 { | |||||
| startTime := time.Unix(int64(job.Status.StartTime)/1000, 0) | |||||
| infoList.AiInfoList[index].StartTime = time.Time.String(startTime) | |||||
| } | |||||
| infoList.AiInfoList[index].RunningTime = int64(job.Status.Duration) / 1000 | |||||
| infoList.AiInfoList[index].Status = job.Status.Phase | |||||
| } | |||||
| } | |||||
| } | |||||
| // 同步信息到core端 | |||||
| if len(infoList.AiInfoList) != 0 { | |||||
| syncInfoReq.AiInfoList = infoList.AiInfoList | |||||
| svc.PcmCoreRpc.SyncInfo(context.Background(), &syncInfoReq) | |||||
| } | |||||
| }) | |||||
| } | |||||
| func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *CreateTrainingJobLogic) { | |||||
| for index, _ := range infoList.AiInfoList { | |||||
| if infoList.AiInfoList[index].Status == "Saved" { | |||||
| submitReq := modelarts.CreateTrainingJobReq{ | |||||
| ModelArtsType: "cn-north-4.myhuawei", | |||||
| Kind: "job", | |||||
| ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b", | |||||
| Metadata: &modelarts.MetadataS{ | |||||
| Name: infoList.AiInfoList[index].Name, | |||||
| WorkspaceId: "0", | |||||
| Description: "This is a ModelArts Demo Job", | |||||
| }, | |||||
| Algorithm: &modelarts.Algorithms{ | |||||
| //SubscriptionId: infoList.AiInfoList[index].SubscriptionId, | |||||
| //ItemVersionId: infoList.AiInfoList[index].ItemVersionId, | |||||
| SubscriptionId: "26a0d9a9-808a-43f4-9a06-c9ea6bdc53d2", | |||||
| ItemVersionId: "2.0.0", | |||||
| //Command: infoList.AiInfoList[index].Command, | |||||
| //Engine: &modelarts.EngineCreateTraining{ | |||||
| // ImageUrl: infoList.AiInfoList[index].ImageUrl, | |||||
| //}, | |||||
| Parameters: []*modelarts.ParametersTrainJob{ | |||||
| { | |||||
| Name: "do_train", | |||||
| Value: "True", | |||||
| }, | |||||
| { | |||||
| Name: "do_eval_along_train", | |||||
| Value: "True", | |||||
| }, | |||||
| { | |||||
| Name: "lr", | |||||
| Value: "0.01", | |||||
| }, | |||||
| { | |||||
| Name: "epochs", | |||||
| Value: "60", | |||||
| }, | |||||
| { | |||||
| Name: "batch_size", | |||||
| Value: "64", | |||||
| }, | |||||
| { | |||||
| Name: "eval_batch_size", | |||||
| Value: "64", | |||||
| }, | |||||
| { | |||||
| Name: "lr_scheduler", | |||||
| Value: "cos", | |||||
| }, | |||||
| { | |||||
| Name: "lr_step", | |||||
| Value: "20", | |||||
| }, | |||||
| { | |||||
| Name: "mixup", | |||||
| Value: "0.2", | |||||
| }, | |||||
| { | |||||
| Name: "label_smoothing", | |||||
| Value: "0.1", | |||||
| }, | |||||
| { | |||||
| Name: "warmup_epochs", | |||||
| Value: "5", | |||||
| }, | |||||
| { | |||||
| Name: "rand_aug", | |||||
| Value: "True", | |||||
| }, | |||||
| { | |||||
| Name: "num_workers", | |||||
| Value: "8", | |||||
| }, | |||||
| { | |||||
| Name: "model_name", | |||||
| Value: "resnest50", | |||||
| }, | |||||
| { | |||||
| Name: "use_dali", | |||||
| Value: "False", | |||||
| }, | |||||
| { | |||||
| Name: "accumulation_steps", | |||||
| Value: "1", | |||||
| }, | |||||
| { | |||||
| Name: "do_data_cleaning", | |||||
| Value: "True", | |||||
| }, | |||||
| { | |||||
| Name: "max_to_keep", | |||||
| Value: "10", | |||||
| }, | |||||
| }, | |||||
| Inputs: []*modelarts.InputTraining{ | |||||
| { | |||||
| Name: "data_url", | |||||
| AccessMethod: "parameter", | |||||
| Remote: &modelarts.RemoteTra{ | |||||
| Dataset: &modelarts.DatasetTra{ | |||||
| Id: "L0cTaBjZF61k27w8T74", | |||||
| Name: "dataset-flower", | |||||
| VersionName: "V001", | |||||
| VersionId: "xBx4lPDk4rtf6mEex4W", | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| Outputs: []*modelarts.OutputTraining{ | |||||
| { | |||||
| Name: "train_url", | |||||
| AccessMethod: "parameter", | |||||
| Remote: &modelarts.RemoteOut{ | |||||
| Obs: &modelarts.ObsTra{ | |||||
| ObsUrl: "/jointcloud-out1/flower/", | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| Spec: &modelarts.SpecsC{ | |||||
| Resource: &modelarts.ResourceCreateTraining{ | |||||
| FlavorId: infoList.AiInfoList[index].FlavorId, | |||||
| NodeCount: 1, | |||||
| Policy: "regular", | |||||
| FlavorLabel: "[限时免费] GPU: 1*NVIDIA-V100(32GB) | CPU: 8 核 64GB 780GB", | |||||
| }, | |||||
| }, | |||||
| } | |||||
| jobResult, _ := submitJobLogic.CreateTrainingJob(&submitReq) | |||||
| if jobResult.Code == 200 { | |||||
| infoList.AiInfoList[index].Status = jobResult.Status.Phase | |||||
| infoList.AiInfoList[index].ProjectId = jobResult.Metadata.Id | |||||
| } else { | |||||
| infoList.AiInfoList[index].Result = "Failed" | |||||
| infoList.AiInfoList[index].Result = jobResult.Msg | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| func queryCoreInfoList(svc *svc.ServiceContext) (*pcmcoreclient.InfoListResp, error) { | |||||
| infoReq := pcmcoreclient.InfoListReq{ | |||||
| Kind: "ai", | |||||
| ServiceName: "modelArts", | |||||
| } | |||||
| infoList, err := svc.PcmCoreRpc.InfoList(context.Background(), &infoReq) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return infoList, nil | |||||
| } | |||||
| @@ -1,99 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteAlgorithmsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmsLogic { | |||||
| return &DeleteAlgorithmsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // DeleteAlgorithms 删除算法 | |||||
| func (l *DeleteAlgorithmsLogic) DeleteAlgorithms(in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) { | |||||
| var resp modelarts.DeleteAlgorithmsResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| 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 | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||||
| 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" | |||||
| } | |||||
| } 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,103 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteDataSetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetLogic { | |||||
| return &DeleteDataSetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // create DateSet | |||||
| func (l *DeleteDataSetLogic) DeleteDataSet(in *modelarts.DeleteDataSetReq) (*modelarts.DeleteDataSetResq, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.DeleteDataSetResq | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if statusCode == 204 { | |||||
| json.Unmarshal(body, &resp) | |||||
| resp.Code = 200 | |||||
| resp.Msg = "Success" | |||||
| } else if statusCode != 204 { | |||||
| 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("DELETE", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId, | |||||
| 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) | |||||
| 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,104 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteModelLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelLogic { | |||||
| return &DeleteModelLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteModelLogic) DeleteModel(in *modelarts.DeleteModelReq) (*modelarts.DeleteModelResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.DeleteModelResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models/" + in.ModelId | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| 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" | |||||
| } | |||||
| } 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("DELETE", NanjingModelArtsUrl+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) | |||||
| 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,97 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteServiceLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic { | |||||
| return &DeleteServiceLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteServiceLogic) DeleteService(in *modelarts.DeleteServiceReq) (*modelarts.DeleteServiceResp, error) { | |||||
| var resp modelarts.DeleteServiceResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services/" + in.ServiceId | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, 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("DELETE", NanjingModelArtsUrl+in.ProjectId+"/services/"+in.ServiceId, | |||||
| 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-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,93 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteTrainingJobConfigLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobConfigLogic { | |||||
| return &DeleteTrainingJobConfigLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业参数 | |||||
| func (l *DeleteTrainingJobConfigLogic) DeleteTrainingJobConfig(in *modelarts.DeleteTrainingJobConfigReq) (*modelarts.DeleteTrainingJobConfigResp, error) { | |||||
| var resp modelarts.DeleteTrainingJobConfigResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs/" + in.ConfigName | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, strings.NewReader(``), 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.HaweiModelArtsType { | |||||
| 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("DELETE", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs/"+in.ConfigName, | |||||
| 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) | |||||
| 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,100 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| ) | |||||
| type DeleteTrainingJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobLogic { | |||||
| return &DeleteTrainingJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业 | |||||
| func (l *DeleteTrainingJobLogic) DeleteTrainingJob(in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) { | |||||
| var resp modelarts.DeleteTrainingJobResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| 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 | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, url, payload, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| 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" | |||||
| } | |||||
| } 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 | |||||
| } | |||||
| @@ -1,82 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DescribeProcessorTaskLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDescribeProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DescribeProcessorTaskLogic { | |||||
| return &DescribeProcessorTaskLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DescribeProcessorTaskLogic) DescribeProcessorTask(in *modelarts.DescribeProcessorTaskReq) (*modelarts.DescribeProcessorTaskResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.DescribeProcessorTaskResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/processor-tasks/" + in.TaskId | |||||
| 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+"v2/"+in.ProjectId+"/processor-tasks/"+in.TaskId, | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,99 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| _ "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ExportTaskLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExportTaskLogic { | |||||
| return &ExportTaskLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // ExportTask for modelarts | |||||
| func (l *ExportTaskLogic) ExportTask(in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) { | |||||
| var resp modelarts.ExportTaskDataResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == "huawei" { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks" | |||||
| reqByte, err := json.Marshal(in) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| 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 == "nanjing" { | |||||
| 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+"/export-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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,89 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetAiEnginesListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetAiEnginesListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAiEnginesListLogic { | |||||
| return &GetAiEnginesListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // GET ai-engines 查询作业引擎规格 | |||||
| func (l *GetAiEnginesListLogic) GetAiEnginesList(in *modelarts.ListAiEnginesReq) (*modelarts.ListAiEnginesResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.ListAiEnginesResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-engines" | |||||
| token := common.GetToken() | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-job-engines", | |||||
| 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-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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,96 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| "strings" | |||||
| ) | |||||
| type GetDatasetListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetDatasetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetListLogic { | |||||
| return &GetDatasetListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // find datasetList | |||||
| func (l *GetDatasetListLogic) GetDatasetList(in *modelarts.DataSetReq) (*modelarts.DataSetResp, error) { | |||||
| projectId := in.ProjectId | |||||
| var resp modelarts.DataSetResp | |||||
| offset := strconv.Itoa(int(in.Offset)) | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, modelArtsUrl+"v2/"+projectId+"/datasets?offset="+offset+"&"+"limit="+limit, strings.NewReader(``), 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+"v2/"+in.ProjectId+"/datasets?offset="+offset+"&"+"limit="+limit, | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,106 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetExportTasksOfDatasetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTasksOfDatasetLogic { | |||||
| return &GetExportTasksOfDatasetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| //type Pppp struct { | |||||
| // TotalCount int `json:"total_count"` | |||||
| // ExportTasks []*Modelarts.ExportTaskStatus `json:"export_tasks"` | |||||
| //} | |||||
| func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(in *modelarts.GetExportTasksOfDatasetReq) (*modelarts.GetExportTasksOfDatasetResp, error) { | |||||
| var resp modelarts.GetExportTasksOfDatasetResp | |||||
| offset := strconv.Itoa(int(in.Offset)) | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.DatasetId + "/export-tasks?limit=" + limit + "&offset=" + offset | |||||
| token := common.GetToken() | |||||
| 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 != 202 { | |||||
| 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+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/export-tasks?limit="+limit+"&offset="+offset, | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,94 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetExportTaskStatusOfDatasetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTaskStatusOfDatasetLogic { | |||||
| return &GetExportTaskStatusOfDatasetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(in *modelarts.GetExportTaskStatusOfDatasetReq) (*modelarts.GetExportTaskStatusOfDatasetResp, error) { | |||||
| var resp modelarts.GetExportTaskStatusOfDatasetResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/datasets/" + in.ResourceId + "/export-tasks/" + in.TaskId | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| 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+"v2/"+in.ProjectId+"/datasets/"+in.ResourceId+"/export-tasks/"+in.TaskId, | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,99 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "log" | |||||
| "net/http" | |||||
| "strconv" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetImportTaskListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetImportTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImportTaskListLogic { | |||||
| return &GetImportTaskListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // find taskList 查询数据集导入任务列表 | |||||
| func (l *GetImportTaskListLogic) GetImportTaskList(in *modelarts.ListImportTasksReq) (*modelarts.ListImportTasksResp, error) { | |||||
| var resp modelarts.ListImportTasksResp | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| offset := strconv.Itoa(int(in.Offset)) | |||||
| token := common.GetToken() | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, modelArtsUrl+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset, strings.NewReader(``), token) | |||||
| if err != nil { | |||||
| log.Fatal(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+"v2/"+in.ProjectId+"/datasets/"+in.DatasetId+"/import-tasks?limit="+limit+"&offset="+offset, | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,103 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| "strings" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetListTrainingJobsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic { | |||||
| return &GetListTrainingJobsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // get ListTrainingJobs1 | |||||
| func (l *GetListTrainingJobsLogic) GetListTrainingJobs(in *modelarts.ListTrainingJobsreq) (*modelarts.ListTrainingJobsresp, error) { | |||||
| var resp modelarts.ListTrainingJobsresp | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| offset := strconv.Itoa(int(in.OffSet)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-searches?limit=" + limit + "&offset=" + offset | |||||
| reqByte, err := json.Marshal(in) | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| 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" | |||||
| for index, _ := range resp.Items { | |||||
| resp.Items[index].ProjectId = in.ProjectId | |||||
| } | |||||
| } 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-job-searches?offset="+offset+"&"+"limit="+limit, | |||||
| 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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,82 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetNotebookStorageLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookStorageLogic { | |||||
| return &GetNotebookStorageLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetNotebookStorageLogic) GetNotebookStorage(in *modelarts.GetNotebookStorageReq) (*modelarts.GetNotebookStorageResp, error) { | |||||
| var resp modelarts.GetNotebookStorageResp | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| getObsUrl := modelArtsUrl + "v1/{project_id}/notebooks/{instance_id}/storage" | |||||
| getObsUrl = strings.Replace(getObsUrl, "{project_id}", in.ProjectId, -1) | |||||
| getObsUrl = strings.Replace(getObsUrl, "{instance_id}", in.InstanceId, -1) | |||||
| token := common.GetToken() | |||||
| var e struct{} | |||||
| body, err := tool.HttpClientWithQueries(tool.GET, getObsUrl, nil, token, e) | |||||
| 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+"/notebooks"+in.InstanceId+"/storage", | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,68 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "io/ioutil" | |||||
| "log" | |||||
| "net/http" | |||||
| "time" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetTokenLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTokenLogic { | |||||
| return &GetTokenLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // getToken | |||||
| func (l *GetTokenLogic) GetToken(in *modelarts.TokenReq) (*modelarts.TokenResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.TokenResp | |||||
| TokenUrl := "v3/auth/tokens" | |||||
| jsonStr, _ := json.Marshal(in) | |||||
| reqUrl, err := http.NewRequest("POST", "https://iam.cn-north-4.myhuaweicloud.com/"+TokenUrl, bytes.NewBuffer(jsonStr)) | |||||
| if err != nil { | |||||
| log.Fatal(err) | |||||
| } | |||||
| defer reqUrl.Body.Close() | |||||
| c := http.Client{Timeout: time.Duration(3) * time.Second} | |||||
| respUrl, err := c.Do(reqUrl) | |||||
| print(respUrl) | |||||
| defer respUrl.Body.Close() | |||||
| if err != nil { | |||||
| log.Fatal(err) | |||||
| } | |||||
| result, _ := ioutil.ReadAll(respUrl.Body) | |||||
| json.Unmarshal([]byte(string(result)), &resp) | |||||
| //X-Auth-Token := respUrl.Header().Get("X-Subject-Token") | |||||
| //return resp, nil | |||||
| return &modelarts.TokenResp{}, nil | |||||
| } | |||||
| @@ -1,88 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetTrainingJobFlavorsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetTrainingJobFlavorsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTrainingJobFlavorsLogic { | |||||
| return &GetTrainingJobFlavorsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // training-job-flavors 获取训练作业支持的公共规格 | |||||
| func (l *GetTrainingJobFlavorsLogic) GetTrainingJobFlavors(in *modelarts.TrainingJobFlavorsReq) (*modelarts.TrainingJobFlavorsResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.TrainingJobFlavorsResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/training-job-flavors?flavor_type=" + in.FlavorType | |||||
| token := common.GetToken() | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/training-job-flavors?flavor_type="+in.FlavorType, | |||||
| 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-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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,83 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetVisualizationJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVisualizationJobLogic { | |||||
| return &GetVisualizationJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // visualization-jobs | |||||
| func (l *GetVisualizationJobLogic) GetVisualizationJob(in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) { | |||||
| var resp modelarts.GetVisualizationJobResp | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| getVisualJobUrl := modelArtsUrl + "v1/{project_id}/visualization-jobs" | |||||
| getVisualJobUrl = strings.Replace(getVisualJobUrl, "{project_id}", in.ProjectId, -1) | |||||
| token := common.GetToken() | |||||
| body, err := tool.HttpClientWithQueries(tool.GET, getVisualJobUrl, nil, token, in.Param) | |||||
| 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+"/visualization-jobs", | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,96 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| ) | |||||
| type ListAlgorithmsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAlgorithmsLogic { | |||||
| return &ListAlgorithmsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // ListAlgorithms 查询算法 | |||||
| func (l *ListAlgorithmsLogic) ListAlgorithms(in *modelarts.ListAlgorithmsReq) (*modelarts.ListAlgorithmsResp, error) { | |||||
| var resp modelarts.ListAlgorithmsResp | |||||
| offset := strconv.Itoa(int(in.Offset)) | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| modelArtsType := in.ModelArtsType | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms?offset=" + offset + "&" + "limit=" + limit | |||||
| token := common.GetToken() | |||||
| 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+"v2/"+in.ProjectId+"/algorithms?offset="+offset+"&"+"limit="+limit, | |||||
| bytes.NewBuffer([]byte("foo=bar"))) | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,98 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ListClustersLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic { | |||||
| return &ListClustersLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ListClustersLogic) ListClusters(in *modelarts.ListClustersReq) (*modelarts.ListClustersResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.ListClustersResp | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| offset := strconv.Itoa(int(in.Offset)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/clusters?limit=" + limit + "&offset=" + offset | |||||
| token := common.GetToken() | |||||
| statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, url, nil, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| if statusCode == 200 { | |||||
| json.Unmarshal(body, &resp.Resp200) | |||||
| } else { | |||||
| json.Unmarshal(body, &resp.Resp400) | |||||
| } | |||||
| } 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+"/clusters?offset="+offset+"&"+"limit="+limit, | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,88 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ListModelsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListModelsLogic { | |||||
| return &ListModelsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ListModelsLogic) ListModels(in *modelarts.ListModelReq) (*modelarts.ListModelResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.ListModelResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/models" | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/models", | |||||
| bytes.NewBuffer([]byte("foo=bar"))) | |||||
| 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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,101 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| ) | |||||
| type ListNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNotebookLogic { | |||||
| return &ListNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // notebook task | |||||
| func (l *ListNotebookLogic) ListNotebook(in *modelarts.ListNotebookReq) (*modelarts.ListNotebookResp, error) { | |||||
| resp := &modelarts.ListNotebookResp{} | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| getUrl := modelArtsUrl + "v1/{project_id}/notebooks" | |||||
| token := common.GetToken() | |||||
| queryMap := tool.ConvertStructToMap(in.Param) | |||||
| req := tool.GetACHttpRequest() | |||||
| res, err := req. | |||||
| SetHeader("x-auth-token", token). | |||||
| SetPathParam("project_id", in.ProjectId). | |||||
| SetQueryParams(queryMap). | |||||
| SetResult(resp). | |||||
| Get(getUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if res.StatusCode() != 200 { | |||||
| resp.Code = int32(res.StatusCode()) | |||||
| resp.Msg = "Failure" | |||||
| var errMsg common.Error | |||||
| err := json.Unmarshal(res.Body(), &errMsg) | |||||
| if err != nil { | |||||
| errMsg.ErrorMsg = "" | |||||
| } | |||||
| resp.ErrorMsg = errMsg.ErrorMsg | |||||
| } else { | |||||
| resp.Code = int32(res.StatusCode()) | |||||
| resp.Msg = "Success" | |||||
| } | |||||
| } 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+"/notebooks", | |||||
| 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) | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,99 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| ) | |||||
| type ListServicesLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServicesLogic { | |||||
| return &ListServicesLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ListServicesLogic) ListServices(in *modelarts.ListServicesReq) (*modelarts.ListServicesResp, error) { | |||||
| var resp modelarts.ListServicesResp | |||||
| judgeLimit := strconv.Itoa(int(in.Limit)) | |||||
| offset := strconv.Itoa(int(in.OffSet)) | |||||
| var limit string | |||||
| if judgeLimit != "0" { | |||||
| limit = strconv.Itoa(int(in.Limit)) | |||||
| } else { | |||||
| limit = "10" | |||||
| } | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services?limit=" + limit + "&offset=" + offset | |||||
| token := common.GetToken() | |||||
| 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?offset="+offset+"&"+"limit="+limit, | |||||
| bytes.NewBuffer([]byte("foo=bar"))) | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,85 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "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" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "github.com/bitly/go-simplejson" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "strconv" | |||||
| ) | |||||
| type ListTrainingJobConfigLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewListTrainingJobConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTrainingJobConfigLogic { | |||||
| return &ListTrainingJobConfigLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // ListTrainingJobConfig 查询训练作业参数 | |||||
| func (l *ListTrainingJobConfigLogic) ListTrainingJobConfig(in *modelarts.ListTrainingJobConfigReq) (*modelarts.ListTrainingJobConfigResp, error) { | |||||
| var resp modelarts.ListTrainingJobConfigResp | |||||
| perPage := strconv.Itoa(int(in.PerPage)) | |||||
| page := strconv.Itoa(int(in.Page)) | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs?" + perPage + "&" + page | |||||
| token := common.GetToken() | |||||
| body, err := tool.HttpClient(tool.GET, url, nil, token) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| jsonResult, err := simplejson.NewJson(body) | |||||
| println(&jsonResult) | |||||
| 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+"/training-job-configs?"+perPage+"&"+page, | |||||
| bytes.NewBuffer([]byte("foo=bar"))) | |||||
| 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-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 | |||||
| } | |||||
| @@ -1,87 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type MountNotebookStorageLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewMountNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MountNotebookStorageLogic { | |||||
| return &MountNotebookStorageLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *MountNotebookStorageLogic) MountNotebookStorage(in *modelarts.MountNotebookStorageReq) (*modelarts.MountNotebookStorageResp, error) { | |||||
| var resp modelarts.MountNotebookStorageResp | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| mountUrl := modelArtsUrl + "v1/{project_id}/notebooks/{instance_id}/storage" | |||||
| mountUrl = strings.Replace(mountUrl, "{project_id}", in.ProjectId, -1) | |||||
| mountUrl = strings.Replace(mountUrl, "{instance_id}", in.InstanceId, -1) | |||||
| reqByte, err := json.Marshal(in.Param) | |||||
| if err != nil { | |||||
| panic(err.Error()) | |||||
| } | |||||
| payload := strings.NewReader(string(reqByte)) | |||||
| token := common.GetToken() | |||||
| body, err := tool.HttpClient(tool.POST, mountUrl, 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+"/notebooks"+in.InstanceId+"/storage", | |||||
| 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 | |||||
| } | |||||
| @@ -1,91 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ShowAlgorithmByUuidLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewShowAlgorithmByUuidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowAlgorithmByUuidLogic { | |||||
| return &ShowAlgorithmByUuidLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // ShowAlgorithmByUuid 展示算法详情 | |||||
| func (l *ShowAlgorithmByUuidLogic) ShowAlgorithmByUuid(in *modelarts.ShowAlgorithmByUuidReq) (*modelarts.ShowAlgorithmByUuidResp, error) { | |||||
| var resp modelarts.ShowAlgorithmByUuidResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v2/" + in.ProjectId + "/algorithms/" + in.AlgorithmId | |||||
| token := common.GetToken() | |||||
| 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 | |||||
| XDomainId := l.svcCtx.Config.XDomainId | |||||
| s := core.Signer{ | |||||
| Key: AK, | |||||
| Secret: SK, | |||||
| } | |||||
| r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v2/"+in.ProjectId+"/algorithms/"+in.AlgorithmId, | |||||
| bytes.NewBuffer([]byte("foo=bar"))) | |||||
| 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) | |||||
| if err != nil { | |||||
| fmt.Println(err) | |||||
| } | |||||
| json.Unmarshal(body, &resp) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,83 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ShowModelsLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewShowModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowModelsLogic { | |||||
| return &ShowModelsLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ShowModelsLogic) ShowModels(in *modelarts.ShowModelReq) (*modelarts.ShowModelResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.ShowModelResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,91 +0,0 @@ | |||||
| package logic | |||||
| /* | |||||
| desc: "AI core微服务" | |||||
| author: "xie" | |||||
| */ | |||||
| import ( | |||||
| "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/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ShowServiceLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowServiceLogic { | |||||
| return &ShowServiceLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ShowServiceLogic) ShowService(in *modelarts.ShowServiceReq) (*modelarts.ShowServiceResp, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| var resp modelarts.ShowServiceResp | |||||
| //根据智算类型判断走华为智算还是南京智算 | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| url := modelArtsUrl + "v1/" + in.ProjectId + "/services/" + in.ServiceId | |||||
| token := common.GetToken() | |||||
| 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) | |||||
| } | |||||
| return &resp, nil | |||||
| } | |||||
| @@ -1,82 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type StartNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewStartNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartNotebookLogic { | |||||
| return &StartNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *StartNotebookLogic) StartNotebook(in *modelarts.StartNotebookReq) (*modelarts.StartNotebookResp, error) { | |||||
| var resp modelarts.StartNotebookResp | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.NanjingModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| startUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/start" | |||||
| startUrl = strings.Replace(startUrl, "{project_id}", in.ProjectId, -1) | |||||
| startUrl = strings.Replace(startUrl, "{id}", in.Id, -1) | |||||
| token := common.GetToken() | |||||
| body, err := tool.HttpClientWithQueries(tool.POST, startUrl, nil, token, in.Param) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| json.Unmarshal(body, &resp.NotebookResp) | |||||
| } else if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| 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+"/notebooks"+in.Id+"/start", | |||||
| 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 | |||||
| } | |||||
| @@ -1,83 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "fmt" | |||||
| "github.com/JCCE-nudt/apigw-go-sdk/core" | |||||
| "io/ioutil" | |||||
| "net/http" | |||||
| "strings" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type StopNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewStopNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopNotebookLogic { | |||||
| return &StopNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *StopNotebookLogic) StopNotebook(in *modelarts.StopNotebookReq) (*modelarts.StopNotebookResp, error) { | |||||
| var resp modelarts.StopNotebookResp | |||||
| modelArtsType := in.ModelArtsType | |||||
| if modelArtsType == l.svcCtx.Config.HaweiModelArtsType { | |||||
| modelArtsUrl := l.svcCtx.Config.ModelArtsUrl | |||||
| stopUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/stop" | |||||
| stopUrl = strings.Replace(stopUrl, "{project_id}", in.ProjectId, -1) | |||||
| stopUrl = strings.Replace(stopUrl, "{id}", in.Id, -1) | |||||
| token := common.GetToken() | |||||
| //empty struct | |||||
| var e struct{} | |||||
| body, err := tool.HttpClientWithQueries(tool.POST, stopUrl, nil, token, e) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| json.Unmarshal(body, &resp.NotebookResp) | |||||
| } 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+"/notebooks"+in.Id+"/stop", | |||||
| 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 | |||||
| } | |||||
| @@ -1,247 +0,0 @@ | |||||
| // Code generated by goctl. DO NOT EDIT. | |||||
| // Source: pcm-modelarts.proto | |||||
| package server | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| ) | |||||
| type ModelArtsServer struct { | |||||
| svcCtx *svc.ServiceContext | |||||
| modelarts.UnimplementedModelArtsServer | |||||
| } | |||||
| func NewModelArtsServer(svcCtx *svc.ServiceContext) *ModelArtsServer { | |||||
| return &ModelArtsServer{ | |||||
| svcCtx: svcCtx, | |||||
| } | |||||
| } | |||||
| // get modelarts Token | |||||
| func (s *ModelArtsServer) GetToken(ctx context.Context, in *modelarts.TokenReq) (*modelarts.TokenResp, error) { | |||||
| l := logic.NewGetTokenLogic(ctx, s.svcCtx) | |||||
| return l.GetToken(in) | |||||
| } | |||||
| // get modelarts Token | |||||
| func (s *ModelArtsServer) GetDatasetList(ctx context.Context, in *modelarts.DataSetReq) (*modelarts.DataSetResp, error) { | |||||
| l := logic.NewGetDatasetListLogic(ctx, s.svcCtx) | |||||
| return l.GetDatasetList(in) | |||||
| } | |||||
| // create DateSet | |||||
| func (s *ModelArtsServer) CreateDataSet(ctx context.Context, in *modelarts.CreateDataSetReq) (*modelarts.CreateDataSetResq, error) { | |||||
| l := logic.NewCreateDataSetLogic(ctx, s.svcCtx) | |||||
| return l.CreateDataSet(in) | |||||
| } | |||||
| // create DateSet | |||||
| func (s *ModelArtsServer) DeleteDataSet(ctx context.Context, in *modelarts.DeleteDataSetReq) (*modelarts.DeleteDataSetResq, error) { | |||||
| l := logic.NewDeleteDataSetLogic(ctx, s.svcCtx) | |||||
| return l.DeleteDataSet(in) | |||||
| } | |||||
| // creat task 创建导入任务 | |||||
| func (s *ModelArtsServer) CreateTask(ctx context.Context, in *modelarts.ImportTaskDataReq) (*modelarts.ImportTaskDataResp, error) { | |||||
| l := logic.NewCreateTaskLogic(ctx, s.svcCtx) | |||||
| return l.CreateTask(in) | |||||
| } | |||||
| // get taskList 查询数据集导入任务列表 | |||||
| func (s *ModelArtsServer) GetImportTaskList(ctx context.Context, in *modelarts.ListImportTasksReq) (*modelarts.ListImportTasksResp, error) { | |||||
| l := logic.NewGetImportTaskListLogic(ctx, s.svcCtx) | |||||
| return l.GetImportTaskList(in) | |||||
| } | |||||
| // ListTrainingJobs 查询训练作业列表 | |||||
| func (s *ModelArtsServer) GetListTrainingJobs(ctx context.Context, in *modelarts.ListTrainingJobsreq) (*modelarts.ListTrainingJobsresp, error) { | |||||
| l := logic.NewGetListTrainingJobsLogic(ctx, s.svcCtx) | |||||
| return l.GetListTrainingJobs(in) | |||||
| } | |||||
| // CreateTrainingJob 创建训练作业 | |||||
| func (s *ModelArtsServer) CreateTrainingJob(ctx context.Context, in *modelarts.CreateTrainingJobReq) (*modelarts.CreateTrainingJobResp, error) { | |||||
| l := logic.NewCreateTrainingJobLogic(ctx, s.svcCtx) | |||||
| return l.CreateTrainingJob(in) | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业 | |||||
| func (s *ModelArtsServer) DeleteTrainingJob(ctx context.Context, in *modelarts.DeleteTrainingJobReq) (*modelarts.DeleteTrainingJobResp, error) { | |||||
| l := logic.NewDeleteTrainingJobLogic(ctx, s.svcCtx) | |||||
| return l.DeleteTrainingJob(in) | |||||
| } | |||||
| // CreateTrainingJobConfig 创建训练作业参数 | |||||
| func (s *ModelArtsServer) CreateTrainingJobConfig(ctx context.Context, in *modelarts.CreateTrainingJobConfigReq) (*modelarts.CreateTrainingJobConfigResp, error) { | |||||
| l := logic.NewCreateTrainingJobConfigLogic(ctx, s.svcCtx) | |||||
| return l.CreateTrainingJobConfig(in) | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业参数 | |||||
| func (s *ModelArtsServer) DeleteTrainingJobConfig(ctx context.Context, in *modelarts.DeleteTrainingJobConfigReq) (*modelarts.DeleteTrainingJobConfigResp, error) { | |||||
| l := logic.NewDeleteTrainingJobConfigLogic(ctx, s.svcCtx) | |||||
| return l.DeleteTrainingJobConfig(in) | |||||
| } | |||||
| // ListTrainingJobConfig 查询训练作业参数 | |||||
| func (s *ModelArtsServer) ListTrainingJobConfig(ctx context.Context, in *modelarts.ListTrainingJobConfigReq) (*modelarts.ListTrainingJobConfigResp, error) { | |||||
| l := logic.NewListTrainingJobConfigLogic(ctx, s.svcCtx) | |||||
| return l.ListTrainingJobConfig(in) | |||||
| } | |||||
| // CreateAlgorithm 创建算法 | |||||
| func (s *ModelArtsServer) CreateAlgorithm(ctx context.Context, in *modelarts.CreateAlgorithmReq) (*modelarts.CreateAlgorithmResp, error) { | |||||
| l := logic.NewCreateAlgorithmLogic(ctx, s.svcCtx) | |||||
| return l.CreateAlgorithm(in) | |||||
| } | |||||
| // ListAlgorithms 查询算法 | |||||
| func (s *ModelArtsServer) ListAlgorithms(ctx context.Context, in *modelarts.ListAlgorithmsReq) (*modelarts.ListAlgorithmsResp, error) { | |||||
| l := logic.NewListAlgorithmsLogic(ctx, s.svcCtx) | |||||
| return l.ListAlgorithms(in) | |||||
| } | |||||
| // DeleteAlgorithms 删除算法 | |||||
| func (s *ModelArtsServer) DeleteAlgorithms(ctx context.Context, in *modelarts.DeleteAlgorithmsReq) (*modelarts.DeleteAlgorithmsResp, error) { | |||||
| l := logic.NewDeleteAlgorithmsLogic(ctx, s.svcCtx) | |||||
| return l.DeleteAlgorithms(in) | |||||
| } | |||||
| // ShowAlgorithmByUuid 展示算法详情 | |||||
| func (s *ModelArtsServer) ShowAlgorithmByUuid(ctx context.Context, in *modelarts.ShowAlgorithmByUuidReq) (*modelarts.ShowAlgorithmByUuidResp, error) { | |||||
| l := logic.NewShowAlgorithmByUuidLogic(ctx, s.svcCtx) | |||||
| return l.ShowAlgorithmByUuid(in) | |||||
| } | |||||
| // training-job-flavors 获取训练作业支持的公共规格 | |||||
| func (s *ModelArtsServer) GetTrainingJobFlavors(ctx context.Context, in *modelarts.TrainingJobFlavorsReq) (*modelarts.TrainingJobFlavorsResp, error) { | |||||
| l := logic.NewGetTrainingJobFlavorsLogic(ctx, s.svcCtx) | |||||
| return l.GetTrainingJobFlavors(in) | |||||
| } | |||||
| // GET ai-engines 查询作业引擎规格 | |||||
| func (s *ModelArtsServer) GetAiEnginesList(ctx context.Context, in *modelarts.ListAiEnginesReq) (*modelarts.ListAiEnginesResp, error) { | |||||
| l := logic.NewGetAiEnginesListLogic(ctx, s.svcCtx) | |||||
| return l.GetAiEnginesList(in) | |||||
| } | |||||
| // export task | |||||
| func (s *ModelArtsServer) ExportTask(ctx context.Context, in *modelarts.ExportTaskReq) (*modelarts.ExportTaskDataResp, error) { | |||||
| l := logic.NewExportTaskLogic(ctx, s.svcCtx) | |||||
| return l.ExportTask(in) | |||||
| } | |||||
| func (s *ModelArtsServer) GetExportTasksOfDataset(ctx context.Context, in *modelarts.GetExportTasksOfDatasetReq) (*modelarts.GetExportTasksOfDatasetResp, error) { | |||||
| l := logic.NewGetExportTasksOfDatasetLogic(ctx, s.svcCtx) | |||||
| return l.GetExportTasksOfDataset(in) | |||||
| } | |||||
| func (s *ModelArtsServer) GetExportTaskStatusOfDataset(ctx context.Context, in *modelarts.GetExportTaskStatusOfDatasetReq) (*modelarts.GetExportTaskStatusOfDatasetResp, error) { | |||||
| l := logic.NewGetExportTaskStatusOfDatasetLogic(ctx, s.svcCtx) | |||||
| return l.GetExportTaskStatusOfDataset(in) | |||||
| } | |||||
| // processor task | |||||
| func (s *ModelArtsServer) CreateProcessorTask(ctx context.Context, in *modelarts.CreateProcessorTaskReq) (*modelarts.CreateProcessorTaskResp, error) { | |||||
| l := logic.NewCreateProcessorTaskLogic(ctx, s.svcCtx) | |||||
| return l.CreateProcessorTask(in) | |||||
| } | |||||
| func (s *ModelArtsServer) DescribeProcessorTask(ctx context.Context, in *modelarts.DescribeProcessorTaskReq) (*modelarts.DescribeProcessorTaskResp, error) { | |||||
| l := logic.NewDescribeProcessorTaskLogic(ctx, s.svcCtx) | |||||
| return l.DescribeProcessorTask(in) | |||||
| } | |||||
| // model management | |||||
| func (s *ModelArtsServer) CreateModel(ctx context.Context, in *modelarts.CreateModelReq) (*modelarts.CreateModelResp, error) { | |||||
| l := logic.NewCreateModelLogic(ctx, s.svcCtx) | |||||
| return l.CreateModel(in) | |||||
| } | |||||
| func (s *ModelArtsServer) DeleteModel(ctx context.Context, in *modelarts.DeleteModelReq) (*modelarts.DeleteModelResp, error) { | |||||
| l := logic.NewDeleteModelLogic(ctx, s.svcCtx) | |||||
| return l.DeleteModel(in) | |||||
| } | |||||
| func (s *ModelArtsServer) ListModels(ctx context.Context, in *modelarts.ListModelReq) (*modelarts.ListModelResp, error) { | |||||
| l := logic.NewListModelsLogic(ctx, s.svcCtx) | |||||
| return l.ListModels(in) | |||||
| } | |||||
| func (s *ModelArtsServer) ShowModels(ctx context.Context, in *modelarts.ShowModelReq) (*modelarts.ShowModelResp, error) { | |||||
| l := logic.NewShowModelsLogic(ctx, s.svcCtx) | |||||
| return l.ShowModels(in) | |||||
| } | |||||
| // service management | |||||
| func (s *ModelArtsServer) CreateService(ctx context.Context, in *modelarts.CreateServiceReq) (*modelarts.CreateServiceResp, error) { | |||||
| l := logic.NewCreateServiceLogic(ctx, s.svcCtx) | |||||
| return l.CreateService(in) | |||||
| } | |||||
| func (s *ModelArtsServer) ListServices(ctx context.Context, in *modelarts.ListServicesReq) (*modelarts.ListServicesResp, error) { | |||||
| l := logic.NewListServicesLogic(ctx, s.svcCtx) | |||||
| return l.ListServices(in) | |||||
| } | |||||
| func (s *ModelArtsServer) ShowService(ctx context.Context, in *modelarts.ShowServiceReq) (*modelarts.ShowServiceResp, error) { | |||||
| l := logic.NewShowServiceLogic(ctx, s.svcCtx) | |||||
| return l.ShowService(in) | |||||
| } | |||||
| func (s *ModelArtsServer) DeleteService(ctx context.Context, in *modelarts.DeleteServiceReq) (*modelarts.DeleteServiceResp, error) { | |||||
| l := logic.NewDeleteServiceLogic(ctx, s.svcCtx) | |||||
| return l.DeleteService(in) | |||||
| } | |||||
| func (s *ModelArtsServer) ListClusters(ctx context.Context, in *modelarts.ListClustersReq) (*modelarts.ListClustersResp, error) { | |||||
| l := logic.NewListClustersLogic(ctx, s.svcCtx) | |||||
| return l.ListClusters(in) | |||||
| } | |||||
| // notebook task | |||||
| func (s *ModelArtsServer) ListNotebook(ctx context.Context, in *modelarts.ListNotebookReq) (*modelarts.ListNotebookResp, error) { | |||||
| l := logic.NewListNotebookLogic(ctx, s.svcCtx) | |||||
| return l.ListNotebook(in) | |||||
| } | |||||
| func (s *ModelArtsServer) CreateNotebook(ctx context.Context, in *modelarts.CreateNotebookReq) (*modelarts.CreateNotebookResp, error) { | |||||
| l := logic.NewCreateNotebookLogic(ctx, s.svcCtx) | |||||
| return l.CreateNotebook(in) | |||||
| } | |||||
| func (s *ModelArtsServer) StartNotebook(ctx context.Context, in *modelarts.StartNotebookReq) (*modelarts.StartNotebookResp, error) { | |||||
| l := logic.NewStartNotebookLogic(ctx, s.svcCtx) | |||||
| return l.StartNotebook(in) | |||||
| } | |||||
| func (s *ModelArtsServer) StopNotebook(ctx context.Context, in *modelarts.StopNotebookReq) (*modelarts.StopNotebookResp, error) { | |||||
| l := logic.NewStopNotebookLogic(ctx, s.svcCtx) | |||||
| return l.StopNotebook(in) | |||||
| } | |||||
| func (s *ModelArtsServer) GetNotebookStorage(ctx context.Context, in *modelarts.GetNotebookStorageReq) (*modelarts.GetNotebookStorageResp, error) { | |||||
| l := logic.NewGetNotebookStorageLogic(ctx, s.svcCtx) | |||||
| return l.GetNotebookStorage(in) | |||||
| } | |||||
| func (s *ModelArtsServer) MountNotebookStorage(ctx context.Context, in *modelarts.MountNotebookStorageReq) (*modelarts.MountNotebookStorageResp, error) { | |||||
| l := logic.NewMountNotebookStorageLogic(ctx, s.svcCtx) | |||||
| return l.MountNotebookStorage(in) | |||||
| } | |||||
| // visualization-jobs | |||||
| func (s *ModelArtsServer) GetVisualizationJob(ctx context.Context, in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) { | |||||
| l := logic.NewGetVisualizationJobLogic(ctx, s.svcCtx) | |||||
| return l.GetVisualizationJob(in) | |||||
| } | |||||
| func (s *ModelArtsServer) CreateVisualizationJob(ctx context.Context, in *modelarts.CreateVisualizationJobReq) (*modelarts.CreateVisualizationJobResp, error) { | |||||
| l := logic.NewCreateVisualizationJobLogic(ctx, s.svcCtx) | |||||
| return l.CreateVisualizationJob(in) | |||||
| } | |||||
| @@ -1,22 +0,0 @@ | |||||
| package svc | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/config" | |||||
| "PCM/adaptor/PCM-CORE/rpc/pcmcoreclient" | |||||
| "github.com/robfig/cron/v3" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| ) | |||||
| type ServiceContext struct { | |||||
| Config config.Config | |||||
| Cron *cron.Cron | |||||
| PcmCoreRpc pcmcoreclient.PcmCore | |||||
| } | |||||
| func NewServiceContext(c config.Config) *ServiceContext { | |||||
| return &ServiceContext{ | |||||
| Config: c, | |||||
| Cron: cron.New(cron.WithSeconds()), | |||||
| PcmCoreRpc: pcmcoreclient.NewPcmCore(zrpc.MustNewClient(c.PcmCoreRpcConf)), | |||||
| } | |||||
| } | |||||
| @@ -1,565 +0,0 @@ | |||||
| // Code generated by goctl. DO NOT EDIT. | |||||
| // Source: pcm-modelarts.proto | |||||
| package modelartsclient | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| "google.golang.org/grpc" | |||||
| ) | |||||
| type ( | |||||
| ActionProgress = modelarts.ActionProgress | |||||
| AdvancedConfigAl = modelarts.AdvancedConfigAl | |||||
| AlgoConfigs = modelarts.AlgoConfigs | |||||
| Algorithm = modelarts.Algorithm | |||||
| AlgorithmResponse = modelarts.AlgorithmResponse | |||||
| Algorithms = modelarts.Algorithms | |||||
| AnnotationFormatConfig = modelarts.AnnotationFormatConfig | |||||
| AttributesAlRq = modelarts.AttributesAlRq | |||||
| Auth = modelarts.Auth | |||||
| AutoSearch = modelarts.AutoSearch | |||||
| AutoSearchAlgoConfigParameter = modelarts.AutoSearchAlgoConfigParameter | |||||
| Billing = modelarts.Billing | |||||
| Children = modelarts.Children | |||||
| Cluster = modelarts.Cluster | |||||
| ClusterNode = modelarts.ClusterNode | |||||
| CodeTree = modelarts.CodeTree | |||||
| Config = modelarts.Config | |||||
| ConfigResponse = modelarts.ConfigResponse | |||||
| Constraint = modelarts.Constraint | |||||
| ConstraintAlRp = modelarts.ConstraintAlRp | |||||
| ConstraintAlRq = modelarts.ConstraintAlRq | |||||
| ConstraintCreateTraining = modelarts.ConstraintCreateTraining | |||||
| ContainerHooks = modelarts.ContainerHooks | |||||
| ContainerHooksResp = modelarts.ContainerHooksResp | |||||
| Cpu = modelarts.Cpu | |||||
| CreateAlgorithmReq = modelarts.CreateAlgorithmReq | |||||
| CreateAlgorithmResp = modelarts.CreateAlgorithmResp | |||||
| CreateDataSetReq = modelarts.CreateDataSetReq | |||||
| CreateDataSetResq = modelarts.CreateDataSetResq | |||||
| CreateModelReq = modelarts.CreateModelReq | |||||
| CreateModelRequestInferParams = modelarts.CreateModelRequestInferParams | |||||
| CreateModelRequestModelApis = modelarts.CreateModelRequestModelApis | |||||
| CreateModelRequestTemplateInput = modelarts.CreateModelRequestTemplateInput | |||||
| CreateModelResp = modelarts.CreateModelResp | |||||
| CreateNotebookParam = modelarts.CreateNotebookParam | |||||
| CreateNotebookReq = modelarts.CreateNotebookReq | |||||
| CreateNotebookResp = modelarts.CreateNotebookResp | |||||
| CreateProcessorTaskReq = modelarts.CreateProcessorTaskReq | |||||
| CreateProcessorTaskResp = modelarts.CreateProcessorTaskResp | |||||
| CreateServiceReq = modelarts.CreateServiceReq | |||||
| CreateServiceResp = modelarts.CreateServiceResp | |||||
| CreateTrainingJobConfigReq = modelarts.CreateTrainingJobConfigReq | |||||
| CreateTrainingJobConfigResp = modelarts.CreateTrainingJobConfigResp | |||||
| CreateTrainingJobReq = modelarts.CreateTrainingJobReq | |||||
| CreateTrainingJobResp = modelarts.CreateTrainingJobResp | |||||
| CreateTrainingJobResp400 = modelarts.CreateTrainingJobResp400 | |||||
| CreateVisualizationJobParam = modelarts.CreateVisualizationJobParam | |||||
| CreateVisualizationJobReq = modelarts.CreateVisualizationJobReq | |||||
| CreateVisualizationJobResp = modelarts.CreateVisualizationJobResp | |||||
| CustomHooks = modelarts.CustomHooks | |||||
| CustomSpec = modelarts.CustomSpec | |||||
| DataSetReq = modelarts.DataSetReq | |||||
| DataSetResp = modelarts.DataSetResp | |||||
| DataSets = modelarts.DataSets | |||||
| DataSource = modelarts.DataSource | |||||
| DataSources = modelarts.DataSources | |||||
| DataVolumesRes = modelarts.DataVolumesRes | |||||
| Dataset = modelarts.Dataset | |||||
| DatasetTra = modelarts.DatasetTra | |||||
| DeleteAlgorithmsReq = modelarts.DeleteAlgorithmsReq | |||||
| DeleteAlgorithmsResp = modelarts.DeleteAlgorithmsResp | |||||
| DeleteDataSetReq = modelarts.DeleteDataSetReq | |||||
| DeleteDataSetResq = modelarts.DeleteDataSetResq | |||||
| DeleteModelReq = modelarts.DeleteModelReq | |||||
| DeleteModelResp = modelarts.DeleteModelResp | |||||
| DeleteModelResponseFailedList = modelarts.DeleteModelResponseFailedList | |||||
| DeleteServiceReq = modelarts.DeleteServiceReq | |||||
| DeleteServiceResp = modelarts.DeleteServiceResp | |||||
| DeleteTrainingJobConfigReq = modelarts.DeleteTrainingJobConfigReq | |||||
| DeleteTrainingJobConfigResp = modelarts.DeleteTrainingJobConfigResp | |||||
| DeleteTrainingJobReq = modelarts.DeleteTrainingJobReq | |||||
| DeleteTrainingJobResp = modelarts.DeleteTrainingJobResp | |||||
| DescribeProcessorTaskReq = modelarts.DescribeProcessorTaskReq | |||||
| DescribeProcessorTaskResp = modelarts.DescribeProcessorTaskResp | |||||
| Disk = modelarts.Disk | |||||
| Domain = modelarts.Domain | |||||
| EndpointsReq = modelarts.EndpointsReq | |||||
| EndpointsRes = modelarts.EndpointsRes | |||||
| Engine = modelarts.Engine | |||||
| EngineAlRp = modelarts.EngineAlRp | |||||
| EngineAlRq = modelarts.EngineAlRq | |||||
| EngineCreateTraining = modelarts.EngineCreateTraining | |||||
| Environments = modelarts.Environments | |||||
| ExportParams = modelarts.ExportParams | |||||
| ExportTaskDataResp = modelarts.ExportTaskDataResp | |||||
| ExportTaskReq = modelarts.ExportTaskReq | |||||
| ExportTaskStatus = modelarts.ExportTaskStatus | |||||
| FileStatistics = modelarts.FileStatistics | |||||
| Flavor = modelarts.Flavor | |||||
| FlavorDetail = modelarts.FlavorDetail | |||||
| FlavorInfo = modelarts.FlavorInfo | |||||
| FlavorResponse = modelarts.FlavorResponse | |||||
| GetExportTaskStatusOfDatasetReq = modelarts.GetExportTaskStatusOfDatasetReq | |||||
| GetExportTaskStatusOfDatasetResp = modelarts.GetExportTaskStatusOfDatasetResp | |||||
| GetExportTasksOfDatasetReq = modelarts.GetExportTasksOfDatasetReq | |||||
| GetExportTasksOfDatasetResp = modelarts.GetExportTasksOfDatasetResp | |||||
| GetNotebookStorageReq = modelarts.GetNotebookStorageReq | |||||
| GetNotebookStorageResp = modelarts.GetNotebookStorageResp | |||||
| GetVisualizationJobParam = modelarts.GetVisualizationJobParam | |||||
| GetVisualizationJobReq = modelarts.GetVisualizationJobReq | |||||
| GetVisualizationJobResp = modelarts.GetVisualizationJobResp | |||||
| Gpu = modelarts.Gpu | |||||
| GuideDoc = modelarts.GuideDoc | |||||
| Hooks = modelarts.Hooks | |||||
| I18NDescription = modelarts.I18NDescription | |||||
| Identity = modelarts.Identity | |||||
| Image = modelarts.Image | |||||
| ImageInfo = modelarts.ImageInfo | |||||
| ImportTaskDataReq = modelarts.ImportTaskDataReq | |||||
| ImportTaskDataResp = modelarts.ImportTaskDataResp | |||||
| ImportTasks = modelarts.ImportTasks | |||||
| Input = modelarts.Input | |||||
| InputDataInfo = modelarts.InputDataInfo | |||||
| InputTraining = modelarts.InputTraining | |||||
| Inputs = modelarts.Inputs | |||||
| InputsAlRp = modelarts.InputsAlRp | |||||
| InputsAlRq = modelarts.InputsAlRq | |||||
| Items = modelarts.Items | |||||
| JobAlgorithmResponse = modelarts.JobAlgorithmResponse | |||||
| JobConfigAl = modelarts.JobConfigAl | |||||
| JobConfigAlRq = modelarts.JobConfigAlRq | |||||
| JobMetadata = modelarts.JobMetadata | |||||
| JobProgress = modelarts.JobProgress | |||||
| JobResponse = modelarts.JobResponse | |||||
| Jobs = modelarts.Jobs | |||||
| Lease = modelarts.Lease | |||||
| LeaseReq = modelarts.LeaseReq | |||||
| ListAiEnginesReq = modelarts.ListAiEnginesReq | |||||
| ListAiEnginesResp = modelarts.ListAiEnginesResp | |||||
| ListAlgorithmsReq = modelarts.ListAlgorithmsReq | |||||
| ListAlgorithmsResp = modelarts.ListAlgorithmsResp | |||||
| ListClustersReq = modelarts.ListClustersReq | |||||
| ListClustersResp = modelarts.ListClustersResp | |||||
| ListClustersResp200 = modelarts.ListClustersResp200 | |||||
| ListClustersResp400 = modelarts.ListClustersResp400 | |||||
| ListImportTasksReq = modelarts.ListImportTasksReq | |||||
| ListImportTasksResp = modelarts.ListImportTasksResp | |||||
| ListModelReq = modelarts.ListModelReq | |||||
| ListModelResp = modelarts.ListModelResp | |||||
| ListNotebookParam = modelarts.ListNotebookParam | |||||
| ListNotebookReq = modelarts.ListNotebookReq | |||||
| ListNotebookResp = modelarts.ListNotebookResp | |||||
| ListServices = modelarts.ListServices | |||||
| ListServicesReq = modelarts.ListServicesReq | |||||
| ListServicesResp = modelarts.ListServicesResp | |||||
| ListTrainingJobConfigReq = modelarts.ListTrainingJobConfigReq | |||||
| ListTrainingJobConfigResp = modelarts.ListTrainingJobConfigResp | |||||
| ListTrainingJobsreq = modelarts.ListTrainingJobsreq | |||||
| ListTrainingJobsresp = modelarts.ListTrainingJobsresp | |||||
| LogExportPath = modelarts.LogExportPath | |||||
| LogExportPathCreateTraining = modelarts.LogExportPathCreateTraining | |||||
| Memory = modelarts.Memory | |||||
| MetadataAlRp = modelarts.MetadataAlRp | |||||
| MetadataAlRq = modelarts.MetadataAlRq | |||||
| MetadataCrAl = modelarts.MetadataCrAl | |||||
| MetadataS = modelarts.MetadataS | |||||
| Methods = modelarts.Methods | |||||
| ModelDependencies = modelarts.ModelDependencies | |||||
| ModelHealth = modelarts.ModelHealth | |||||
| ModelInOutputParams = modelarts.ModelInOutputParams | |||||
| ModelListItem = modelarts.ModelListItem | |||||
| ModelParamsInfo = modelarts.ModelParamsInfo | |||||
| ModelSpecification = modelarts.ModelSpecification | |||||
| MountNotebookStorageParam = modelarts.MountNotebookStorageParam | |||||
| MountNotebookStorageReq = modelarts.MountNotebookStorageReq | |||||
| MountNotebookStorageResp = modelarts.MountNotebookStorageResp | |||||
| Nfs = modelarts.Nfs | |||||
| NotebookResp = modelarts.NotebookResp | |||||
| Npu = modelarts.Npu | |||||
| Obs = modelarts.Obs | |||||
| Obs1 = modelarts.Obs1 | |||||
| ObsTra = modelarts.ObsTra | |||||
| OperatorParam = modelarts.OperatorParam | |||||
| Output = modelarts.Output | |||||
| OutputTraining = modelarts.OutputTraining | |||||
| Outputs = modelarts.Outputs | |||||
| OutputsAl = modelarts.OutputsAl | |||||
| OutputsAlRp = modelarts.OutputsAlRp | |||||
| Packages = modelarts.Packages | |||||
| Parameter = modelarts.Parameter | |||||
| ParameterS = modelarts.ParameterS | |||||
| ParametersAlRp = modelarts.ParametersAlRp | |||||
| ParametersAlRq = modelarts.ParametersAlRq | |||||
| ParametersTrainJob = modelarts.ParametersTrainJob | |||||
| Password = modelarts.Password | |||||
| Policies = modelarts.Policies | |||||
| PoliciesCreateTraining = modelarts.PoliciesCreateTraining | |||||
| Pool = modelarts.Pool | |||||
| PostStart = modelarts.PostStart | |||||
| PreStart = modelarts.PreStart | |||||
| ProcessorDataSource = modelarts.ProcessorDataSource | |||||
| Project = modelarts.Project | |||||
| QueryServiceConfig = modelarts.QueryServiceConfig | |||||
| Remote = modelarts.Remote | |||||
| RemoteConstraint = modelarts.RemoteConstraint | |||||
| RemoteConstraints = modelarts.RemoteConstraints | |||||
| RemoteOut = modelarts.RemoteOut | |||||
| RemoteTra = modelarts.RemoteTra | |||||
| Resource = modelarts.Resource | |||||
| ResourceCreateTraining = modelarts.ResourceCreateTraining | |||||
| ResourceRequirements = modelarts.ResourceRequirements | |||||
| RewardAttrs = modelarts.RewardAttrs | |||||
| Schedule = modelarts.Schedule | |||||
| Scheduler = modelarts.Scheduler | |||||
| SchemaMaps = modelarts.SchemaMaps | |||||
| Scope = modelarts.Scope | |||||
| SearchCondition = modelarts.SearchCondition | |||||
| SearchLabel = modelarts.SearchLabel | |||||
| SearchLabels = modelarts.SearchLabels | |||||
| SearchParams = modelarts.SearchParams | |||||
| SearchProp = modelarts.SearchProp | |||||
| ServiceConfig = modelarts.ServiceConfig | |||||
| ShareInfo = modelarts.ShareInfo | |||||
| ShareInfoAlRp = modelarts.ShareInfoAlRp | |||||
| ShowAlgorithmByUuidReq = modelarts.ShowAlgorithmByUuidReq | |||||
| ShowAlgorithmByUuidResp = modelarts.ShowAlgorithmByUuidResp | |||||
| ShowModelReq = modelarts.ShowModelReq | |||||
| ShowModelResp = modelarts.ShowModelResp | |||||
| ShowServiceReq = modelarts.ShowServiceReq | |||||
| ShowServiceResp = modelarts.ShowServiceResp | |||||
| SourceInfo = modelarts.SourceInfo | |||||
| Spec = modelarts.Spec | |||||
| Specs = modelarts.Specs | |||||
| SpecsC = modelarts.SpecsC | |||||
| StartNotebookParam = modelarts.StartNotebookParam | |||||
| StartNotebookReq = modelarts.StartNotebookReq | |||||
| StartNotebookResp = modelarts.StartNotebookResp | |||||
| Status = modelarts.Status | |||||
| StopNotebookReq = modelarts.StopNotebookReq | |||||
| StopNotebookResp = modelarts.StopNotebookResp | |||||
| Tags = modelarts.Tags | |||||
| TagsAlRp = modelarts.TagsAlRp | |||||
| TaskResponse = modelarts.TaskResponse | |||||
| TaskStatuses = modelarts.TaskStatuses | |||||
| Template = modelarts.Template | |||||
| TemplateParam = modelarts.TemplateParam | |||||
| TokenReq = modelarts.TokenReq | |||||
| TokenResp = modelarts.TokenResp | |||||
| TrainingJobFlavorsReq = modelarts.TrainingJobFlavorsReq | |||||
| TrainingJobFlavorsResp = modelarts.TrainingJobFlavorsResp | |||||
| User = modelarts.User | |||||
| UserNotebookDomain = modelarts.UserNotebookDomain | |||||
| UserNotebookResp = modelarts.UserNotebookResp | |||||
| VolumeReq = modelarts.VolumeReq | |||||
| VolumeRes = modelarts.VolumeRes | |||||
| Volumes = modelarts.Volumes | |||||
| Weigou = modelarts.Weigou | |||||
| WorkPath = modelarts.WorkPath | |||||
| ModelArts interface { | |||||
| // get modelarts Token | |||||
| GetToken(ctx context.Context, in *TokenReq, opts ...grpc.CallOption) (*TokenResp, error) | |||||
| // get modelarts Token | |||||
| GetDatasetList(ctx context.Context, in *DataSetReq, opts ...grpc.CallOption) (*DataSetResp, error) | |||||
| // create DateSet | |||||
| CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) | |||||
| // create DateSet | |||||
| DeleteDataSet(ctx context.Context, in *DeleteDataSetReq, opts ...grpc.CallOption) (*DeleteDataSetResq, error) | |||||
| // creat task 创建导入任务 | |||||
| CreateTask(ctx context.Context, in *ImportTaskDataReq, opts ...grpc.CallOption) (*ImportTaskDataResp, error) | |||||
| // get taskList 查询数据集导入任务列表 | |||||
| GetImportTaskList(ctx context.Context, in *ListImportTasksReq, opts ...grpc.CallOption) (*ListImportTasksResp, error) | |||||
| // ListTrainingJobs 查询训练作业列表 | |||||
| GetListTrainingJobs(ctx context.Context, in *ListTrainingJobsreq, opts ...grpc.CallOption) (*ListTrainingJobsresp, error) | |||||
| // CreateTrainingJob 创建训练作业 | |||||
| CreateTrainingJob(ctx context.Context, in *CreateTrainingJobReq, opts ...grpc.CallOption) (*CreateTrainingJobResp, error) | |||||
| // DeleteTrainingJobConfig 删除训练作业 | |||||
| DeleteTrainingJob(ctx context.Context, in *DeleteTrainingJobReq, opts ...grpc.CallOption) (*DeleteTrainingJobResp, error) | |||||
| // CreateTrainingJobConfig 创建训练作业参数 | |||||
| CreateTrainingJobConfig(ctx context.Context, in *CreateTrainingJobConfigReq, opts ...grpc.CallOption) (*CreateTrainingJobConfigResp, error) | |||||
| // DeleteTrainingJobConfig 删除训练作业参数 | |||||
| DeleteTrainingJobConfig(ctx context.Context, in *DeleteTrainingJobConfigReq, opts ...grpc.CallOption) (*DeleteTrainingJobConfigResp, error) | |||||
| // ListTrainingJobConfig 查询训练作业参数 | |||||
| ListTrainingJobConfig(ctx context.Context, in *ListTrainingJobConfigReq, opts ...grpc.CallOption) (*ListTrainingJobConfigResp, error) | |||||
| // CreateAlgorithm 创建算法 | |||||
| CreateAlgorithm(ctx context.Context, in *CreateAlgorithmReq, opts ...grpc.CallOption) (*CreateAlgorithmResp, error) | |||||
| // ListAlgorithms 查询算法 | |||||
| ListAlgorithms(ctx context.Context, in *ListAlgorithmsReq, opts ...grpc.CallOption) (*ListAlgorithmsResp, error) | |||||
| // DeleteAlgorithms 删除算法 | |||||
| DeleteAlgorithms(ctx context.Context, in *DeleteAlgorithmsReq, opts ...grpc.CallOption) (*DeleteAlgorithmsResp, error) | |||||
| // ShowAlgorithmByUuid 展示算法详情 | |||||
| ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgorithmByUuidReq, opts ...grpc.CallOption) (*ShowAlgorithmByUuidResp, error) | |||||
| // training-job-flavors 获取训练作业支持的公共规格 | |||||
| GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) | |||||
| // GET ai-engines 查询作业引擎规格 | |||||
| GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) | |||||
| // export task | |||||
| ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) | |||||
| GetExportTasksOfDataset(ctx context.Context, in *GetExportTasksOfDatasetReq, opts ...grpc.CallOption) (*GetExportTasksOfDatasetResp, error) | |||||
| GetExportTaskStatusOfDataset(ctx context.Context, in *GetExportTaskStatusOfDatasetReq, opts ...grpc.CallOption) (*GetExportTaskStatusOfDatasetResp, error) | |||||
| // processor task | |||||
| CreateProcessorTask(ctx context.Context, in *CreateProcessorTaskReq, opts ...grpc.CallOption) (*CreateProcessorTaskResp, error) | |||||
| DescribeProcessorTask(ctx context.Context, in *DescribeProcessorTaskReq, opts ...grpc.CallOption) (*DescribeProcessorTaskResp, error) | |||||
| // model management | |||||
| CreateModel(ctx context.Context, in *CreateModelReq, opts ...grpc.CallOption) (*CreateModelResp, error) | |||||
| DeleteModel(ctx context.Context, in *DeleteModelReq, opts ...grpc.CallOption) (*DeleteModelResp, error) | |||||
| ListModels(ctx context.Context, in *ListModelReq, opts ...grpc.CallOption) (*ListModelResp, error) | |||||
| ShowModels(ctx context.Context, in *ShowModelReq, opts ...grpc.CallOption) (*ShowModelResp, error) | |||||
| // service management | |||||
| CreateService(ctx context.Context, in *CreateServiceReq, opts ...grpc.CallOption) (*CreateServiceResp, error) | |||||
| ListServices(ctx context.Context, in *ListServicesReq, opts ...grpc.CallOption) (*ListServicesResp, error) | |||||
| ShowService(ctx context.Context, in *ShowServiceReq, opts ...grpc.CallOption) (*ShowServiceResp, error) | |||||
| DeleteService(ctx context.Context, in *DeleteServiceReq, opts ...grpc.CallOption) (*DeleteServiceResp, error) | |||||
| ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error) | |||||
| // notebook task | |||||
| ListNotebook(ctx context.Context, in *ListNotebookReq, opts ...grpc.CallOption) (*ListNotebookResp, error) | |||||
| CreateNotebook(ctx context.Context, in *CreateNotebookReq, opts ...grpc.CallOption) (*CreateNotebookResp, error) | |||||
| StartNotebook(ctx context.Context, in *StartNotebookReq, opts ...grpc.CallOption) (*StartNotebookResp, error) | |||||
| StopNotebook(ctx context.Context, in *StopNotebookReq, opts ...grpc.CallOption) (*StopNotebookResp, error) | |||||
| GetNotebookStorage(ctx context.Context, in *GetNotebookStorageReq, opts ...grpc.CallOption) (*GetNotebookStorageResp, error) | |||||
| MountNotebookStorage(ctx context.Context, in *MountNotebookStorageReq, opts ...grpc.CallOption) (*MountNotebookStorageResp, error) | |||||
| // visualization-jobs | |||||
| GetVisualizationJob(ctx context.Context, in *GetVisualizationJobReq, opts ...grpc.CallOption) (*GetVisualizationJobResp, error) | |||||
| CreateVisualizationJob(ctx context.Context, in *CreateVisualizationJobReq, opts ...grpc.CallOption) (*CreateVisualizationJobResp, error) | |||||
| } | |||||
| defaultModelArts struct { | |||||
| cli zrpc.Client | |||||
| } | |||||
| ) | |||||
| func NewModelArts(cli zrpc.Client) ModelArts { | |||||
| return &defaultModelArts{ | |||||
| cli: cli, | |||||
| } | |||||
| } | |||||
| // get modelarts Token | |||||
| func (m *defaultModelArts) GetToken(ctx context.Context, in *TokenReq, opts ...grpc.CallOption) (*TokenResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetToken(ctx, in, opts...) | |||||
| } | |||||
| // get modelarts Token | |||||
| func (m *defaultModelArts) GetDatasetList(ctx context.Context, in *DataSetReq, opts ...grpc.CallOption) (*DataSetResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetDatasetList(ctx, in, opts...) | |||||
| } | |||||
| // create DateSet | |||||
| func (m *defaultModelArts) CreateDataSet(ctx context.Context, in *CreateDataSetReq, opts ...grpc.CallOption) (*CreateDataSetResq, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateDataSet(ctx, in, opts...) | |||||
| } | |||||
| // create DateSet | |||||
| func (m *defaultModelArts) DeleteDataSet(ctx context.Context, in *DeleteDataSetReq, opts ...grpc.CallOption) (*DeleteDataSetResq, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteDataSet(ctx, in, opts...) | |||||
| } | |||||
| // creat task 创建导入任务 | |||||
| func (m *defaultModelArts) CreateTask(ctx context.Context, in *ImportTaskDataReq, opts ...grpc.CallOption) (*ImportTaskDataResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateTask(ctx, in, opts...) | |||||
| } | |||||
| // get taskList 查询数据集导入任务列表 | |||||
| func (m *defaultModelArts) GetImportTaskList(ctx context.Context, in *ListImportTasksReq, opts ...grpc.CallOption) (*ListImportTasksResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetImportTaskList(ctx, in, opts...) | |||||
| } | |||||
| // ListTrainingJobs 查询训练作业列表 | |||||
| func (m *defaultModelArts) GetListTrainingJobs(ctx context.Context, in *ListTrainingJobsreq, opts ...grpc.CallOption) (*ListTrainingJobsresp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetListTrainingJobs(ctx, in, opts...) | |||||
| } | |||||
| // CreateTrainingJob 创建训练作业 | |||||
| func (m *defaultModelArts) CreateTrainingJob(ctx context.Context, in *CreateTrainingJobReq, opts ...grpc.CallOption) (*CreateTrainingJobResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateTrainingJob(ctx, in, opts...) | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业 | |||||
| func (m *defaultModelArts) DeleteTrainingJob(ctx context.Context, in *DeleteTrainingJobReq, opts ...grpc.CallOption) (*DeleteTrainingJobResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteTrainingJob(ctx, in, opts...) | |||||
| } | |||||
| // CreateTrainingJobConfig 创建训练作业参数 | |||||
| func (m *defaultModelArts) CreateTrainingJobConfig(ctx context.Context, in *CreateTrainingJobConfigReq, opts ...grpc.CallOption) (*CreateTrainingJobConfigResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateTrainingJobConfig(ctx, in, opts...) | |||||
| } | |||||
| // DeleteTrainingJobConfig 删除训练作业参数 | |||||
| func (m *defaultModelArts) DeleteTrainingJobConfig(ctx context.Context, in *DeleteTrainingJobConfigReq, opts ...grpc.CallOption) (*DeleteTrainingJobConfigResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteTrainingJobConfig(ctx, in, opts...) | |||||
| } | |||||
| // ListTrainingJobConfig 查询训练作业参数 | |||||
| func (m *defaultModelArts) ListTrainingJobConfig(ctx context.Context, in *ListTrainingJobConfigReq, opts ...grpc.CallOption) (*ListTrainingJobConfigResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListTrainingJobConfig(ctx, in, opts...) | |||||
| } | |||||
| // CreateAlgorithm 创建算法 | |||||
| func (m *defaultModelArts) CreateAlgorithm(ctx context.Context, in *CreateAlgorithmReq, opts ...grpc.CallOption) (*CreateAlgorithmResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateAlgorithm(ctx, in, opts...) | |||||
| } | |||||
| // ListAlgorithms 查询算法 | |||||
| func (m *defaultModelArts) ListAlgorithms(ctx context.Context, in *ListAlgorithmsReq, opts ...grpc.CallOption) (*ListAlgorithmsResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListAlgorithms(ctx, in, opts...) | |||||
| } | |||||
| // DeleteAlgorithms 删除算法 | |||||
| func (m *defaultModelArts) DeleteAlgorithms(ctx context.Context, in *DeleteAlgorithmsReq, opts ...grpc.CallOption) (*DeleteAlgorithmsResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteAlgorithms(ctx, in, opts...) | |||||
| } | |||||
| // ShowAlgorithmByUuid 展示算法详情 | |||||
| func (m *defaultModelArts) ShowAlgorithmByUuid(ctx context.Context, in *ShowAlgorithmByUuidReq, opts ...grpc.CallOption) (*ShowAlgorithmByUuidResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ShowAlgorithmByUuid(ctx, in, opts...) | |||||
| } | |||||
| // training-job-flavors 获取训练作业支持的公共规格 | |||||
| func (m *defaultModelArts) GetTrainingJobFlavors(ctx context.Context, in *TrainingJobFlavorsReq, opts ...grpc.CallOption) (*TrainingJobFlavorsResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetTrainingJobFlavors(ctx, in, opts...) | |||||
| } | |||||
| // GET ai-engines 查询作业引擎规格 | |||||
| func (m *defaultModelArts) GetAiEnginesList(ctx context.Context, in *ListAiEnginesReq, opts ...grpc.CallOption) (*ListAiEnginesResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetAiEnginesList(ctx, in, opts...) | |||||
| } | |||||
| // export task | |||||
| func (m *defaultModelArts) ExportTask(ctx context.Context, in *ExportTaskReq, opts ...grpc.CallOption) (*ExportTaskDataResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ExportTask(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) GetExportTasksOfDataset(ctx context.Context, in *GetExportTasksOfDatasetReq, opts ...grpc.CallOption) (*GetExportTasksOfDatasetResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetExportTasksOfDataset(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) GetExportTaskStatusOfDataset(ctx context.Context, in *GetExportTaskStatusOfDatasetReq, opts ...grpc.CallOption) (*GetExportTaskStatusOfDatasetResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetExportTaskStatusOfDataset(ctx, in, opts...) | |||||
| } | |||||
| // processor task | |||||
| func (m *defaultModelArts) CreateProcessorTask(ctx context.Context, in *CreateProcessorTaskReq, opts ...grpc.CallOption) (*CreateProcessorTaskResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateProcessorTask(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) DescribeProcessorTask(ctx context.Context, in *DescribeProcessorTaskReq, opts ...grpc.CallOption) (*DescribeProcessorTaskResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DescribeProcessorTask(ctx, in, opts...) | |||||
| } | |||||
| // model management | |||||
| func (m *defaultModelArts) CreateModel(ctx context.Context, in *CreateModelReq, opts ...grpc.CallOption) (*CreateModelResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateModel(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) DeleteModel(ctx context.Context, in *DeleteModelReq, opts ...grpc.CallOption) (*DeleteModelResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteModel(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) ListModels(ctx context.Context, in *ListModelReq, opts ...grpc.CallOption) (*ListModelResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListModels(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) ShowModels(ctx context.Context, in *ShowModelReq, opts ...grpc.CallOption) (*ShowModelResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ShowModels(ctx, in, opts...) | |||||
| } | |||||
| // service management | |||||
| func (m *defaultModelArts) CreateService(ctx context.Context, in *CreateServiceReq, opts ...grpc.CallOption) (*CreateServiceResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateService(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) ListServices(ctx context.Context, in *ListServicesReq, opts ...grpc.CallOption) (*ListServicesResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListServices(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) ShowService(ctx context.Context, in *ShowServiceReq, opts ...grpc.CallOption) (*ShowServiceResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ShowService(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) DeleteService(ctx context.Context, in *DeleteServiceReq, opts ...grpc.CallOption) (*DeleteServiceResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.DeleteService(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListClusters(ctx, in, opts...) | |||||
| } | |||||
| // notebook task | |||||
| func (m *defaultModelArts) ListNotebook(ctx context.Context, in *ListNotebookReq, opts ...grpc.CallOption) (*ListNotebookResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.ListNotebook(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) CreateNotebook(ctx context.Context, in *CreateNotebookReq, opts ...grpc.CallOption) (*CreateNotebookResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateNotebook(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) StartNotebook(ctx context.Context, in *StartNotebookReq, opts ...grpc.CallOption) (*StartNotebookResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.StartNotebook(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) StopNotebook(ctx context.Context, in *StopNotebookReq, opts ...grpc.CallOption) (*StopNotebookResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.StopNotebook(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) GetNotebookStorage(ctx context.Context, in *GetNotebookStorageReq, opts ...grpc.CallOption) (*GetNotebookStorageResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetNotebookStorage(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) MountNotebookStorage(ctx context.Context, in *MountNotebookStorageReq, opts ...grpc.CallOption) (*MountNotebookStorageResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.MountNotebookStorage(ctx, in, opts...) | |||||
| } | |||||
| // visualization-jobs | |||||
| func (m *defaultModelArts) GetVisualizationJob(ctx context.Context, in *GetVisualizationJobReq, opts ...grpc.CallOption) (*GetVisualizationJobResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.GetVisualizationJob(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultModelArts) CreateVisualizationJob(ctx context.Context, in *CreateVisualizationJobReq, opts ...grpc.CallOption) (*CreateVisualizationJobResp, error) { | |||||
| client := modelarts.NewModelArtsClient(m.cli.Conn()) | |||||
| return client.CreateVisualizationJob(ctx, in, opts...) | |||||
| } | |||||
| @@ -1,67 +0,0 @@ | |||||
| package main | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/config" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/logic" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/server" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts" | |||||
| commonConfig "PCM/common/config" | |||||
| "PCM/common/interceptor/rpcserver" | |||||
| "flag" | |||||
| "github.com/zeromicro/go-zero/core/conf" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "github.com/zeromicro/go-zero/core/service" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| "google.golang.org/grpc" | |||||
| "google.golang.org/grpc/reflection" | |||||
| ) | |||||
| var configFile = flag.String("f", "adaptor/PCM-AI/PCM-MODELARTS/rpc/etc/pcmmodelarts.yaml", "the config file") | |||||
| func main() { | |||||
| flag.Parse() | |||||
| var bootstrapConfig commonConfig.BootstrapConfig | |||||
| conf.MustLoad(*configFile, &bootstrapConfig) | |||||
| //解析业务配置 | |||||
| var c config.Config | |||||
| nacosConfig := bootstrapConfig.NacosConfig | |||||
| serviceConfigContent := nacosConfig.InitConfig(func(data string) { | |||||
| err := conf.LoadFromYamlBytes([]byte(data), &c) | |||||
| if err != nil { | |||||
| panic(err) | |||||
| } | |||||
| }) | |||||
| err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c) | |||||
| if err != nil { | |||||
| panic(err) | |||||
| } | |||||
| // start log component | |||||
| logx.MustSetup(c.LogConf) | |||||
| // 注册到nacos | |||||
| nacosConfig.Discovery(&c.RpcServerConf) | |||||
| ctx := svc.NewServiceContext(c) | |||||
| ctx.Cron.Start() | |||||
| s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { | |||||
| modelarts.RegisterModelArtsServer(grpcServer, server.NewModelArtsServer(ctx)) | |||||
| if c.Mode == service.DevMode || c.Mode == service.TestMode { | |||||
| reflection.Register(grpcServer) | |||||
| } | |||||
| }) | |||||
| //rpc log | |||||
| s.AddUnaryInterceptors(rpcserver.LoggerInterceptor) | |||||
| defer s.Stop() | |||||
| logx.Infof("Starting rpc server at %s...\n", c.ListenOn) | |||||
| logic.InitCron(ctx) | |||||
| s.Start() | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| // Code generated by goctl. DO NOT EDIT. | |||||
| // Source: pcm-ms.proto | |||||
| package agentservice | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| "google.golang.org/grpc" | |||||
| ) | |||||
| type ( | |||||
| ClusterReRegisterMessageProto = ms.ClusterReRegisterMessageProto | |||||
| ClusterRegisterAckMessageProto = ms.ClusterRegisterAckMessageProto | |||||
| ClusterStateChangeMessageProto = ms.ClusterStateChangeMessageProto | |||||
| MessageProducerProto = ms.MessageProducerProto | |||||
| MessageResponseProto = ms.MessageResponseProto | |||||
| StringStringMapProto = ms.StringStringMapProto | |||||
| AgentService interface { | |||||
| RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| } | |||||
| defaultAgentService struct { | |||||
| cli zrpc.Client | |||||
| } | |||||
| ) | |||||
| func NewAgentService(cli zrpc.Client) AgentService { | |||||
| return &defaultAgentService{ | |||||
| cli: cli, | |||||
| } | |||||
| } | |||||
| func (m *defaultAgentService) RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||||
| return client.RequireReRegister(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultAgentService) RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||||
| return client.RegisterAck(ctx, in, opts...) | |||||
| } | |||||
| func (m *defaultAgentService) ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| client := ms.NewAgentServiceClient(m.cli.Conn()) | |||||
| return client.ChangeClusterState(ctx, in, opts...) | |||||
| } | |||||
| @@ -1,6 +0,0 @@ | |||||
| Name: pcmms.rpc | |||||
| ListenOn: 0.0.0.0:8080 | |||||
| Etcd: | |||||
| Hosts: | |||||
| - 127.0.0.1:2379 | |||||
| Key: pcmms.rpc | |||||
| @@ -1,7 +0,0 @@ | |||||
| package config | |||||
| import "github.com/zeromicro/go-zero/zrpc" | |||||
| type Config struct { | |||||
| zrpc.RpcServerConf | |||||
| } | |||||
| @@ -1,30 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ChangeClusterStateLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewChangeClusterStateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChangeClusterStateLogic { | |||||
| return &ChangeClusterStateLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *ChangeClusterStateLogic) ChangeClusterState(in *ms.ClusterStateChangeMessageProto) (*ms.MessageResponseProto, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| return &ms.MessageResponseProto{}, nil | |||||
| } | |||||
| @@ -1,30 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type RegisterAckLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewRegisterAckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterAckLogic { | |||||
| return &RegisterAckLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *RegisterAckLogic) RegisterAck(in *ms.ClusterRegisterAckMessageProto) (*ms.MessageResponseProto, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| return &ms.MessageResponseProto{}, nil | |||||
| } | |||||
| @@ -1,30 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type RequireReRegisterLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewRequireReRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RequireReRegisterLogic { | |||||
| return &RequireReRegisterLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *RequireReRegisterLogic) RequireReRegister(in *ms.ClusterReRegisterMessageProto) (*ms.MessageResponseProto, error) { | |||||
| // todo: add your logic here and delete this line | |||||
| return &ms.MessageResponseProto{}, nil | |||||
| } | |||||
| @@ -1,38 +0,0 @@ | |||||
| // Code generated by goctl. DO NOT EDIT. | |||||
| // Source: pcm-ms.proto | |||||
| package server | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/logic" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| ) | |||||
| type AgentServiceServer struct { | |||||
| svcCtx *svc.ServiceContext | |||||
| ms.UnimplementedAgentServiceServer | |||||
| } | |||||
| func NewAgentServiceServer(svcCtx *svc.ServiceContext) *AgentServiceServer { | |||||
| return &AgentServiceServer{ | |||||
| svcCtx: svcCtx, | |||||
| } | |||||
| } | |||||
| func (s *AgentServiceServer) RequireReRegister(ctx context.Context, in *ms.ClusterReRegisterMessageProto) (*ms.MessageResponseProto, error) { | |||||
| l := logic.NewRequireReRegisterLogic(ctx, s.svcCtx) | |||||
| return l.RequireReRegister(in) | |||||
| } | |||||
| func (s *AgentServiceServer) RegisterAck(ctx context.Context, in *ms.ClusterRegisterAckMessageProto) (*ms.MessageResponseProto, error) { | |||||
| l := logic.NewRegisterAckLogic(ctx, s.svcCtx) | |||||
| return l.RegisterAck(in) | |||||
| } | |||||
| func (s *AgentServiceServer) ChangeClusterState(ctx context.Context, in *ms.ClusterStateChangeMessageProto) (*ms.MessageResponseProto, error) { | |||||
| l := logic.NewChangeClusterStateLogic(ctx, s.svcCtx) | |||||
| return l.ChangeClusterState(in) | |||||
| } | |||||
| @@ -1,13 +0,0 @@ | |||||
| package svc | |||||
| import "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/config" | |||||
| type ServiceContext struct { | |||||
| Config config.Config | |||||
| } | |||||
| func NewServiceContext(c config.Config) *ServiceContext { | |||||
| return &ServiceContext{ | |||||
| Config: c, | |||||
| } | |||||
| } | |||||
| @@ -1,613 +0,0 @@ | |||||
| // Code generated by protoc-gen-go. DO NOT EDIT. | |||||
| // versions: | |||||
| // protoc-gen-go v1.28.1 | |||||
| // protoc v3.19.4 | |||||
| // source: pcm-ms.proto | |||||
| package ms | |||||
| import ( | |||||
| protoreflect "google.golang.org/protobuf/reflect/protoreflect" | |||||
| protoimpl "google.golang.org/protobuf/runtime/protoimpl" | |||||
| reflect "reflect" | |||||
| sync "sync" | |||||
| ) | |||||
| const ( | |||||
| // Verify that this generated code is sufficiently up-to-date. | |||||
| _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) | |||||
| // Verify that runtime/protoimpl is sufficiently up-to-date. | |||||
| _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) | |||||
| ) | |||||
| type MessageStatus int32 | |||||
| const ( | |||||
| MessageStatus_FAIL MessageStatus = 0 | |||||
| MessageStatus_SUCCESS MessageStatus = 1 | |||||
| MessageStatus_UNKNOWN MessageStatus = 2 | |||||
| ) | |||||
| // Enum value maps for MessageStatus. | |||||
| var ( | |||||
| MessageStatus_name = map[int32]string{ | |||||
| 0: "FAIL", | |||||
| 1: "SUCCESS", | |||||
| 2: "UNKNOWN", | |||||
| } | |||||
| MessageStatus_value = map[string]int32{ | |||||
| "FAIL": 0, | |||||
| "SUCCESS": 1, | |||||
| "UNKNOWN": 2, | |||||
| } | |||||
| ) | |||||
| func (x MessageStatus) Enum() *MessageStatus { | |||||
| p := new(MessageStatus) | |||||
| *p = x | |||||
| return p | |||||
| } | |||||
| func (x MessageStatus) String() string { | |||||
| return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) | |||||
| } | |||||
| func (MessageStatus) Descriptor() protoreflect.EnumDescriptor { | |||||
| return file_pcm_ms_proto_enumTypes[0].Descriptor() | |||||
| } | |||||
| func (MessageStatus) Type() protoreflect.EnumType { | |||||
| return &file_pcm_ms_proto_enumTypes[0] | |||||
| } | |||||
| func (x MessageStatus) Number() protoreflect.EnumNumber { | |||||
| return protoreflect.EnumNumber(x) | |||||
| } | |||||
| // Deprecated: Use MessageStatus.Descriptor instead. | |||||
| func (MessageStatus) EnumDescriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{0} | |||||
| } | |||||
| type ClusterReRegisterMessageProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||||
| } | |||||
| func (x *ClusterReRegisterMessageProto) Reset() { | |||||
| *x = ClusterReRegisterMessageProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[0] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *ClusterReRegisterMessageProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*ClusterReRegisterMessageProto) ProtoMessage() {} | |||||
| func (x *ClusterReRegisterMessageProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[0] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use ClusterReRegisterMessageProto.ProtoReflect.Descriptor instead. | |||||
| func (*ClusterReRegisterMessageProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{0} | |||||
| } | |||||
| func (x *ClusterReRegisterMessageProto) GetMsgProducer() *MessageProducerProto { | |||||
| if x != nil { | |||||
| return x.MsgProducer | |||||
| } | |||||
| return nil | |||||
| } | |||||
| type MessageProducerProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| MsNetId string `protobuf:"bytes,1,opt,name=ms_net_id,json=msNetId,proto3" json:"ms_net_id,omitempty"` | |||||
| ClusterId string `protobuf:"bytes,2,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"` | |||||
| AgentServiceHost string `protobuf:"bytes,3,opt,name=agent_service_host,json=agentServiceHost,proto3" json:"agent_service_host,omitempty"` | |||||
| AgentServicePort int32 `protobuf:"varint,4,opt,name=agent_service_port,json=agentServicePort,proto3" json:"agent_service_port,omitempty"` | |||||
| } | |||||
| func (x *MessageProducerProto) Reset() { | |||||
| *x = MessageProducerProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[1] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *MessageProducerProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*MessageProducerProto) ProtoMessage() {} | |||||
| func (x *MessageProducerProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[1] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use MessageProducerProto.ProtoReflect.Descriptor instead. | |||||
| func (*MessageProducerProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{1} | |||||
| } | |||||
| func (x *MessageProducerProto) GetMsNetId() string { | |||||
| if x != nil { | |||||
| return x.MsNetId | |||||
| } | |||||
| return "" | |||||
| } | |||||
| func (x *MessageProducerProto) GetClusterId() string { | |||||
| if x != nil { | |||||
| return x.ClusterId | |||||
| } | |||||
| return "" | |||||
| } | |||||
| func (x *MessageProducerProto) GetAgentServiceHost() string { | |||||
| if x != nil { | |||||
| return x.AgentServiceHost | |||||
| } | |||||
| return "" | |||||
| } | |||||
| func (x *MessageProducerProto) GetAgentServicePort() int32 { | |||||
| if x != nil { | |||||
| return x.AgentServicePort | |||||
| } | |||||
| return 0 | |||||
| } | |||||
| type ClusterRegisterAckMessageProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||||
| Configs []*StringStringMapProto `protobuf:"bytes,3,rep,name=configs,proto3" json:"configs,omitempty"` | |||||
| } | |||||
| func (x *ClusterRegisterAckMessageProto) Reset() { | |||||
| *x = ClusterRegisterAckMessageProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[2] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *ClusterRegisterAckMessageProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*ClusterRegisterAckMessageProto) ProtoMessage() {} | |||||
| func (x *ClusterRegisterAckMessageProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[2] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use ClusterRegisterAckMessageProto.ProtoReflect.Descriptor instead. | |||||
| func (*ClusterRegisterAckMessageProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{2} | |||||
| } | |||||
| func (x *ClusterRegisterAckMessageProto) GetMsgProducer() *MessageProducerProto { | |||||
| if x != nil { | |||||
| return x.MsgProducer | |||||
| } | |||||
| return nil | |||||
| } | |||||
| func (x *ClusterRegisterAckMessageProto) GetConfigs() []*StringStringMapProto { | |||||
| if x != nil { | |||||
| return x.Configs | |||||
| } | |||||
| return nil | |||||
| } | |||||
| type StringStringMapProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` | |||||
| Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` | |||||
| } | |||||
| func (x *StringStringMapProto) Reset() { | |||||
| *x = StringStringMapProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[3] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *StringStringMapProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*StringStringMapProto) ProtoMessage() {} | |||||
| func (x *StringStringMapProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[3] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use StringStringMapProto.ProtoReflect.Descriptor instead. | |||||
| func (*StringStringMapProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{3} | |||||
| } | |||||
| func (x *StringStringMapProto) GetKey() string { | |||||
| if x != nil { | |||||
| return x.Key | |||||
| } | |||||
| return "" | |||||
| } | |||||
| func (x *StringStringMapProto) GetValue() string { | |||||
| if x != nil { | |||||
| return x.Value | |||||
| } | |||||
| return "" | |||||
| } | |||||
| type ClusterStateChangeMessageProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| MsgProducer *MessageProducerProto `protobuf:"bytes,1,opt,name=msg_producer,json=msgProducer,proto3" json:"msg_producer,omitempty"` | |||||
| ClusterState int32 `protobuf:"varint,2,opt,name=cluster_state,json=clusterState,proto3" json:"cluster_state,omitempty"` | |||||
| } | |||||
| func (x *ClusterStateChangeMessageProto) Reset() { | |||||
| *x = ClusterStateChangeMessageProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[4] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *ClusterStateChangeMessageProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*ClusterStateChangeMessageProto) ProtoMessage() {} | |||||
| func (x *ClusterStateChangeMessageProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[4] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use ClusterStateChangeMessageProto.ProtoReflect.Descriptor instead. | |||||
| func (*ClusterStateChangeMessageProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{4} | |||||
| } | |||||
| func (x *ClusterStateChangeMessageProto) GetMsgProducer() *MessageProducerProto { | |||||
| if x != nil { | |||||
| return x.MsgProducer | |||||
| } | |||||
| return nil | |||||
| } | |||||
| func (x *ClusterStateChangeMessageProto) GetClusterState() int32 { | |||||
| if x != nil { | |||||
| return x.ClusterState | |||||
| } | |||||
| return 0 | |||||
| } | |||||
| type MessageResponseProto struct { | |||||
| state protoimpl.MessageState | |||||
| sizeCache protoimpl.SizeCache | |||||
| unknownFields protoimpl.UnknownFields | |||||
| MessageStatus MessageStatus `protobuf:"varint,1,opt,name=message_status,json=messageStatus,proto3,enum=ms.MessageStatus" json:"message_status,omitempty"` | |||||
| } | |||||
| func (x *MessageResponseProto) Reset() { | |||||
| *x = MessageResponseProto{} | |||||
| if protoimpl.UnsafeEnabled { | |||||
| mi := &file_pcm_ms_proto_msgTypes[5] | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| } | |||||
| func (x *MessageResponseProto) String() string { | |||||
| return protoimpl.X.MessageStringOf(x) | |||||
| } | |||||
| func (*MessageResponseProto) ProtoMessage() {} | |||||
| func (x *MessageResponseProto) ProtoReflect() protoreflect.Message { | |||||
| mi := &file_pcm_ms_proto_msgTypes[5] | |||||
| if protoimpl.UnsafeEnabled && x != nil { | |||||
| ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |||||
| if ms.LoadMessageInfo() == nil { | |||||
| ms.StoreMessageInfo(mi) | |||||
| } | |||||
| return ms | |||||
| } | |||||
| return mi.MessageOf(x) | |||||
| } | |||||
| // Deprecated: Use MessageResponseProto.ProtoReflect.Descriptor instead. | |||||
| func (*MessageResponseProto) Descriptor() ([]byte, []int) { | |||||
| return file_pcm_ms_proto_rawDescGZIP(), []int{5} | |||||
| } | |||||
| func (x *MessageResponseProto) GetMessageStatus() MessageStatus { | |||||
| if x != nil { | |||||
| return x.MessageStatus | |||||
| } | |||||
| return MessageStatus_FAIL | |||||
| } | |||||
| var File_pcm_ms_proto protoreflect.FileDescriptor | |||||
| var file_pcm_ms_proto_rawDesc = []byte{ | |||||
| 0x0a, 0x0c, 0x70, 0x63, 0x6d, 0x2d, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, | |||||
| 0x6d, 0x73, 0x22, 0x5c, 0x0a, 0x1d, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x52, | |||||
| 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, | |||||
| 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x64, 0x75, | |||||
| 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, | |||||
| 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, | |||||
| 0x22, 0xad, 0x01, 0x0a, 0x14, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, | |||||
| 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x0a, 0x09, 0x6d, 0x73, 0x5f, | |||||
| 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x73, | |||||
| 0x4e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, | |||||
| 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, | |||||
| 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, | |||||
| 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, | |||||
| 0x52, 0x10, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48, 0x6f, | |||||
| 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, | |||||
| 0x69, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, | |||||
| 0x61, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, | |||||
| 0x22, 0x91, 0x01, 0x0a, 0x1e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, | |||||
| 0x73, 0x74, 0x65, 0x72, 0x41, 0x63, 0x6b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, | |||||
| 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x64, 0x75, | |||||
| 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x50, 0x72, | |||||
| 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, | |||||
| 0x12, 0x32, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, | |||||
| 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, | |||||
| 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x07, 0x63, 0x6f, 0x6e, | |||||
| 0x66, 0x69, 0x67, 0x73, 0x22, 0x3e, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x74, | |||||
| 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x0a, 0x03, | |||||
| 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, | |||||
| 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, | |||||
| 0x61, 0x6c, 0x75, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x1e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, | |||||
| 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, | |||||
| 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x70, | |||||
| 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, | |||||
| 0x6d, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, | |||||
| 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x64, | |||||
| 0x75, 0x63, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, | |||||
| 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6c, 0x75, | |||||
| 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x50, 0x0a, 0x14, 0x4d, 0x65, 0x73, | |||||
| 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, | |||||
| 0x6f, 0x12, 0x38, 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x74, 0x61, | |||||
| 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x6d, 0x65, | |||||
| 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x33, 0x0a, 0x0d, 0x4d, | |||||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, | |||||
| 0x46, 0x41, 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, | |||||
| 0x53, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, | |||||
| 0x32, 0x87, 0x02, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, | |||||
| 0x65, 0x12, 0x52, 0x0a, 0x11, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x52, 0x65, | |||||
| 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x21, 0x2e, 0x6d, 0x73, 0x2e, 0x43, 0x6c, 0x75, 0x73, | |||||
| 0x74, 0x65, 0x72, 0x52, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x73, | |||||
| 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, | |||||
| 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, | |||||
| 0x6f, 0x74, 0x6f, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, | |||||
| 0x72, 0x41, 0x63, 0x6b, 0x12, 0x22, 0x2e, 0x6d, 0x73, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, | |||||
| 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x63, 0x6b, 0x4d, 0x65, 0x73, 0x73, | |||||
| 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x2e, 0x6d, 0x73, 0x2e, 0x4d, 0x65, | |||||
| 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, | |||||
| 0x74, 0x6f, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x12, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6c, | |||||
| 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, 0x2e, 0x6d, 0x73, 0x2e, | |||||
| 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, | |||||
| 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, | |||||
| 0x2e, 0x6d, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, | |||||
| 0x6e, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x00, 0x42, 0x05, 0x5a, 0x03, 0x2f, 0x6d, | |||||
| 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |||||
| } | |||||
| var ( | |||||
| file_pcm_ms_proto_rawDescOnce sync.Once | |||||
| file_pcm_ms_proto_rawDescData = file_pcm_ms_proto_rawDesc | |||||
| ) | |||||
| func file_pcm_ms_proto_rawDescGZIP() []byte { | |||||
| file_pcm_ms_proto_rawDescOnce.Do(func() { | |||||
| file_pcm_ms_proto_rawDescData = protoimpl.X.CompressGZIP(file_pcm_ms_proto_rawDescData) | |||||
| }) | |||||
| return file_pcm_ms_proto_rawDescData | |||||
| } | |||||
| var file_pcm_ms_proto_enumTypes = make([]protoimpl.EnumInfo, 1) | |||||
| var file_pcm_ms_proto_msgTypes = make([]protoimpl.MessageInfo, 6) | |||||
| var file_pcm_ms_proto_goTypes = []interface{}{ | |||||
| (MessageStatus)(0), // 0: ms.MessageStatus | |||||
| (*ClusterReRegisterMessageProto)(nil), // 1: ms.ClusterReRegisterMessageProto | |||||
| (*MessageProducerProto)(nil), // 2: ms.MessageProducerProto | |||||
| (*ClusterRegisterAckMessageProto)(nil), // 3: ms.ClusterRegisterAckMessageProto | |||||
| (*StringStringMapProto)(nil), // 4: ms.StringStringMapProto | |||||
| (*ClusterStateChangeMessageProto)(nil), // 5: ms.ClusterStateChangeMessageProto | |||||
| (*MessageResponseProto)(nil), // 6: ms.MessageResponseProto | |||||
| } | |||||
| var file_pcm_ms_proto_depIdxs = []int32{ | |||||
| 2, // 0: ms.ClusterReRegisterMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||||
| 2, // 1: ms.ClusterRegisterAckMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||||
| 4, // 2: ms.ClusterRegisterAckMessageProto.configs:type_name -> ms.StringStringMapProto | |||||
| 2, // 3: ms.ClusterStateChangeMessageProto.msg_producer:type_name -> ms.MessageProducerProto | |||||
| 0, // 4: ms.MessageResponseProto.message_status:type_name -> ms.MessageStatus | |||||
| 1, // 5: ms.AgentService.requireReRegister:input_type -> ms.ClusterReRegisterMessageProto | |||||
| 3, // 6: ms.AgentService.registerAck:input_type -> ms.ClusterRegisterAckMessageProto | |||||
| 5, // 7: ms.AgentService.changeClusterState:input_type -> ms.ClusterStateChangeMessageProto | |||||
| 6, // 8: ms.AgentService.requireReRegister:output_type -> ms.MessageResponseProto | |||||
| 6, // 9: ms.AgentService.registerAck:output_type -> ms.MessageResponseProto | |||||
| 6, // 10: ms.AgentService.changeClusterState:output_type -> ms.MessageResponseProto | |||||
| 8, // [8:11] is the sub-list for method output_type | |||||
| 5, // [5:8] is the sub-list for method input_type | |||||
| 5, // [5:5] is the sub-list for extension type_name | |||||
| 5, // [5:5] is the sub-list for extension extendee | |||||
| 0, // [0:5] is the sub-list for field type_name | |||||
| } | |||||
| func init() { file_pcm_ms_proto_init() } | |||||
| func file_pcm_ms_proto_init() { | |||||
| if File_pcm_ms_proto != nil { | |||||
| return | |||||
| } | |||||
| if !protoimpl.UnsafeEnabled { | |||||
| file_pcm_ms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*ClusterReRegisterMessageProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| file_pcm_ms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*MessageProducerProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| file_pcm_ms_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*ClusterRegisterAckMessageProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| file_pcm_ms_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*StringStringMapProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| file_pcm_ms_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*ClusterStateChangeMessageProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| file_pcm_ms_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { | |||||
| switch v := v.(*MessageResponseProto); i { | |||||
| case 0: | |||||
| return &v.state | |||||
| case 1: | |||||
| return &v.sizeCache | |||||
| case 2: | |||||
| return &v.unknownFields | |||||
| default: | |||||
| return nil | |||||
| } | |||||
| } | |||||
| } | |||||
| type x struct{} | |||||
| out := protoimpl.TypeBuilder{ | |||||
| File: protoimpl.DescBuilder{ | |||||
| GoPackagePath: reflect.TypeOf(x{}).PkgPath(), | |||||
| RawDescriptor: file_pcm_ms_proto_rawDesc, | |||||
| NumEnums: 1, | |||||
| NumMessages: 6, | |||||
| NumExtensions: 0, | |||||
| NumServices: 1, | |||||
| }, | |||||
| GoTypes: file_pcm_ms_proto_goTypes, | |||||
| DependencyIndexes: file_pcm_ms_proto_depIdxs, | |||||
| EnumInfos: file_pcm_ms_proto_enumTypes, | |||||
| MessageInfos: file_pcm_ms_proto_msgTypes, | |||||
| }.Build() | |||||
| File_pcm_ms_proto = out.File | |||||
| file_pcm_ms_proto_rawDesc = nil | |||||
| file_pcm_ms_proto_goTypes = nil | |||||
| file_pcm_ms_proto_depIdxs = nil | |||||
| } | |||||
| @@ -1,177 +0,0 @@ | |||||
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT. | |||||
| // versions: | |||||
| // - protoc-gen-go-grpc v1.2.0 | |||||
| // - protoc v3.19.4 | |||||
| // source: pcm-ms.proto | |||||
| package ms | |||||
| import ( | |||||
| context "context" | |||||
| grpc "google.golang.org/grpc" | |||||
| codes "google.golang.org/grpc/codes" | |||||
| status "google.golang.org/grpc/status" | |||||
| ) | |||||
| // This is a compile-time assertion to ensure that this generated file | |||||
| // is compatible with the grpc package it is being compiled against. | |||||
| // Requires gRPC-Go v1.32.0 or later. | |||||
| const _ = grpc.SupportPackageIsVersion7 | |||||
| // AgentServiceClient is the client API for AgentService service. | |||||
| // | |||||
| // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. | |||||
| type AgentServiceClient interface { | |||||
| RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) | |||||
| } | |||||
| type agentServiceClient struct { | |||||
| cc grpc.ClientConnInterface | |||||
| } | |||||
| func NewAgentServiceClient(cc grpc.ClientConnInterface) AgentServiceClient { | |||||
| return &agentServiceClient{cc} | |||||
| } | |||||
| func (c *agentServiceClient) RequireReRegister(ctx context.Context, in *ClusterReRegisterMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| out := new(MessageResponseProto) | |||||
| err := c.cc.Invoke(ctx, "/ms.AgentService/requireReRegister", in, out, opts...) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return out, nil | |||||
| } | |||||
| func (c *agentServiceClient) RegisterAck(ctx context.Context, in *ClusterRegisterAckMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| out := new(MessageResponseProto) | |||||
| err := c.cc.Invoke(ctx, "/ms.AgentService/registerAck", in, out, opts...) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return out, nil | |||||
| } | |||||
| func (c *agentServiceClient) ChangeClusterState(ctx context.Context, in *ClusterStateChangeMessageProto, opts ...grpc.CallOption) (*MessageResponseProto, error) { | |||||
| out := new(MessageResponseProto) | |||||
| err := c.cc.Invoke(ctx, "/ms.AgentService/changeClusterState", in, out, opts...) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return out, nil | |||||
| } | |||||
| // AgentServiceServer is the server API for AgentService service. | |||||
| // All implementations must embed UnimplementedAgentServiceServer | |||||
| // for forward compatibility | |||||
| type AgentServiceServer interface { | |||||
| RequireReRegister(context.Context, *ClusterReRegisterMessageProto) (*MessageResponseProto, error) | |||||
| RegisterAck(context.Context, *ClusterRegisterAckMessageProto) (*MessageResponseProto, error) | |||||
| ChangeClusterState(context.Context, *ClusterStateChangeMessageProto) (*MessageResponseProto, error) | |||||
| mustEmbedUnimplementedAgentServiceServer() | |||||
| } | |||||
| // UnimplementedAgentServiceServer must be embedded to have forward compatible implementations. | |||||
| type UnimplementedAgentServiceServer struct { | |||||
| } | |||||
| func (UnimplementedAgentServiceServer) RequireReRegister(context.Context, *ClusterReRegisterMessageProto) (*MessageResponseProto, error) { | |||||
| return nil, status.Errorf(codes.Unimplemented, "method RequireReRegister not implemented") | |||||
| } | |||||
| func (UnimplementedAgentServiceServer) RegisterAck(context.Context, *ClusterRegisterAckMessageProto) (*MessageResponseProto, error) { | |||||
| return nil, status.Errorf(codes.Unimplemented, "method RegisterAck not implemented") | |||||
| } | |||||
| func (UnimplementedAgentServiceServer) ChangeClusterState(context.Context, *ClusterStateChangeMessageProto) (*MessageResponseProto, error) { | |||||
| return nil, status.Errorf(codes.Unimplemented, "method ChangeClusterState not implemented") | |||||
| } | |||||
| func (UnimplementedAgentServiceServer) mustEmbedUnimplementedAgentServiceServer() {} | |||||
| // UnsafeAgentServiceServer may be embedded to opt out of forward compatibility for this service. | |||||
| // Use of this interface is not recommended, as added methods to AgentServiceServer will | |||||
| // result in compilation errors. | |||||
| type UnsafeAgentServiceServer interface { | |||||
| mustEmbedUnimplementedAgentServiceServer() | |||||
| } | |||||
| func RegisterAgentServiceServer(s grpc.ServiceRegistrar, srv AgentServiceServer) { | |||||
| s.RegisterService(&AgentService_ServiceDesc, srv) | |||||
| } | |||||
| func _AgentService_RequireReRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||||
| in := new(ClusterReRegisterMessageProto) | |||||
| if err := dec(in); err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if interceptor == nil { | |||||
| return srv.(AgentServiceServer).RequireReRegister(ctx, in) | |||||
| } | |||||
| info := &grpc.UnaryServerInfo{ | |||||
| Server: srv, | |||||
| FullMethod: "/ms.AgentService/requireReRegister", | |||||
| } | |||||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||||
| return srv.(AgentServiceServer).RequireReRegister(ctx, req.(*ClusterReRegisterMessageProto)) | |||||
| } | |||||
| return interceptor(ctx, in, info, handler) | |||||
| } | |||||
| func _AgentService_RegisterAck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||||
| in := new(ClusterRegisterAckMessageProto) | |||||
| if err := dec(in); err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if interceptor == nil { | |||||
| return srv.(AgentServiceServer).RegisterAck(ctx, in) | |||||
| } | |||||
| info := &grpc.UnaryServerInfo{ | |||||
| Server: srv, | |||||
| FullMethod: "/ms.AgentService/registerAck", | |||||
| } | |||||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||||
| return srv.(AgentServiceServer).RegisterAck(ctx, req.(*ClusterRegisterAckMessageProto)) | |||||
| } | |||||
| return interceptor(ctx, in, info, handler) | |||||
| } | |||||
| func _AgentService_ChangeClusterState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||||
| in := new(ClusterStateChangeMessageProto) | |||||
| if err := dec(in); err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if interceptor == nil { | |||||
| return srv.(AgentServiceServer).ChangeClusterState(ctx, in) | |||||
| } | |||||
| info := &grpc.UnaryServerInfo{ | |||||
| Server: srv, | |||||
| FullMethod: "/ms.AgentService/changeClusterState", | |||||
| } | |||||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||||
| return srv.(AgentServiceServer).ChangeClusterState(ctx, req.(*ClusterStateChangeMessageProto)) | |||||
| } | |||||
| return interceptor(ctx, in, info, handler) | |||||
| } | |||||
| // AgentService_ServiceDesc is the grpc.ServiceDesc for AgentService service. | |||||
| // It's only intended for direct use with grpc.RegisterService, | |||||
| // and not to be introspected or modified (even as a copy) | |||||
| var AgentService_ServiceDesc = grpc.ServiceDesc{ | |||||
| ServiceName: "ms.AgentService", | |||||
| HandlerType: (*AgentServiceServer)(nil), | |||||
| Methods: []grpc.MethodDesc{ | |||||
| { | |||||
| MethodName: "requireReRegister", | |||||
| Handler: _AgentService_RequireReRegister_Handler, | |||||
| }, | |||||
| { | |||||
| MethodName: "registerAck", | |||||
| Handler: _AgentService_RegisterAck_Handler, | |||||
| }, | |||||
| { | |||||
| MethodName: "changeClusterState", | |||||
| Handler: _AgentService_ChangeClusterState_Handler, | |||||
| }, | |||||
| }, | |||||
| Streams: []grpc.StreamDesc{}, | |||||
| Metadata: "pcm-ms.proto", | |||||
| } | |||||
| @@ -1,47 +0,0 @@ | |||||
| syntax = "proto3"; | |||||
| package ms; | |||||
| option go_package = "/ms"; | |||||
| message ClusterReRegisterMessageProto { | |||||
| MessageProducerProto msg_producer = 1; | |||||
| } | |||||
| message MessageProducerProto { | |||||
| string ms_net_id = 1; | |||||
| string cluster_id = 2; | |||||
| string agent_service_host = 3; | |||||
| int32 agent_service_port = 4; | |||||
| } | |||||
| message ClusterRegisterAckMessageProto { | |||||
| MessageProducerProto msg_producer = 1; | |||||
| repeated StringStringMapProto configs = 3; | |||||
| } | |||||
| message StringStringMapProto { | |||||
| string key = 1; | |||||
| string value = 2; | |||||
| } | |||||
| message ClusterStateChangeMessageProto { | |||||
| MessageProducerProto msg_producer = 1; | |||||
| int32 cluster_state = 2; | |||||
| } | |||||
| enum MessageStatus { | |||||
| FAIL = 0; | |||||
| SUCCESS = 1; | |||||
| UNKNOWN = 2; | |||||
| } | |||||
| message MessageResponseProto { | |||||
| MessageStatus message_status = 1; | |||||
| } | |||||
| service AgentService { | |||||
| rpc requireReRegister (ClusterReRegisterMessageProto) returns (MessageResponseProto) {}; | |||||
| rpc registerAck (ClusterRegisterAckMessageProto) returns (MessageResponseProto) {}; | |||||
| rpc changeClusterState (ClusterStateChangeMessageProto) returns (MessageResponseProto) {}; | |||||
| } | |||||
| @@ -1,39 +0,0 @@ | |||||
| package main | |||||
| import ( | |||||
| "flag" | |||||
| "fmt" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/config" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/server" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-MS/rpc/ms" | |||||
| "github.com/zeromicro/go-zero/core/conf" | |||||
| "github.com/zeromicro/go-zero/core/service" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| "google.golang.org/grpc" | |||||
| "google.golang.org/grpc/reflection" | |||||
| ) | |||||
| var configFile = flag.String("f", "etc/pcmms.yaml", "the config file") | |||||
| func main() { | |||||
| flag.Parse() | |||||
| var c config.Config | |||||
| conf.MustLoad(*configFile, &c) | |||||
| ctx := svc.NewServiceContext(c) | |||||
| s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { | |||||
| ms.RegisterAgentServiceServer(grpcServer, server.NewAgentServiceServer(ctx)) | |||||
| if c.Mode == service.DevMode || c.Mode == service.TestMode { | |||||
| reflection.Register(grpcServer) | |||||
| } | |||||
| }) | |||||
| defer s.Stop() | |||||
| fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) | |||||
| s.Start() | |||||
| } | |||||
| @@ -1,2 +0,0 @@ | |||||
| rpc-gen: | |||||
| goctl rpc protoc ./pb/*.proto --go_out=./ --go-grpc_out=./ --zrpc_out=. | |||||
| @@ -1,16 +0,0 @@ | |||||
| NacosConfig: | |||||
| DataId: pcm-octopus-rpc.yaml | |||||
| Group: DEFAULT_GROUP | |||||
| ServerConfigs: | |||||
| - IpAddr: nacos.jcce.dev | |||||
| Port: 8848 | |||||
| # - IpAddr: nacos-headless | |||||
| # Port: 8848 | |||||
| ClientConfig: | |||||
| NamespaceId: test | |||||
| TimeoutMs: 5000 | |||||
| NotLoadCacheAtStart: true | |||||
| LogDir: | |||||
| CacheDir: | |||||
| LogLevel: debug | |||||
| @@ -1,110 +0,0 @@ | |||||
| package common | |||||
| type TokenResp struct { | |||||
| Success bool `json:"success"` | |||||
| Payload struct { | |||||
| Token string `json:"token"` | |||||
| Expiration int `json:"expiration"` | |||||
| } `json:"payload"` | |||||
| Error interface{} `json:"error"` | |||||
| } | |||||
| type SuiyuanResp struct { | |||||
| Success bool `json:"success"` | |||||
| Payload struct { | |||||
| MapResourceSpecIdList struct { | |||||
| Debug struct { | |||||
| ResourceSpecs []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Price int `json:"price"` | |||||
| ResourceQuantity struct { | |||||
| Cpu string `json:"cpu,omitempty"` | |||||
| EnflameComDtu string `json:"enflame.com/dtu,omitempty"` | |||||
| Memory string `json:"memory"` | |||||
| Shm string `json:"shm,omitempty"` | |||||
| CpuCpu string `json:"cpu_cpu,omitempty"` | |||||
| } `json:"resourceQuantity"` | |||||
| } `json:"resourceSpecs"` | |||||
| } `json:"debug"` | |||||
| Deploy struct { | |||||
| ResourceSpecs []interface{} `json:"resourceSpecs"` | |||||
| } `json:"deploy"` | |||||
| Train struct { | |||||
| ResourceSpecs []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Price int `json:"price"` | |||||
| ResourceQuantity struct { | |||||
| Cpu string `json:"cpu"` | |||||
| EnflameComDtu string `json:"enflame.com/dtu"` | |||||
| Memory string `json:"memory"` | |||||
| Shm string `json:"shm"` | |||||
| } `json:"resourceQuantity"` | |||||
| } `json:"resourceSpecs"` | |||||
| } `json:"train"` | |||||
| } `json:"mapResourceSpecIdList"` | |||||
| } `json:"payload"` | |||||
| Error interface{} `json:"error"` | |||||
| } | |||||
| type HanwujiResp struct { | |||||
| Success bool `json:"success"` | |||||
| Payload struct { | |||||
| MapResourceSpecIdList struct { | |||||
| Debug struct { | |||||
| ResourceSpecs []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Price int `json:"price"` | |||||
| ResourceQuantity struct { | |||||
| CambriconComMlu string `json:"cambricon.com/mlu,omitempty"` | |||||
| Cpu string `json:"cpu"` | |||||
| Memory string `json:"memory"` | |||||
| Shm string `json:"shm,omitempty"` | |||||
| } `json:"resourceQuantity"` | |||||
| } `json:"resourceSpecs"` | |||||
| } `json:"debug"` | |||||
| Deploy struct { | |||||
| ResourceSpecs []interface{} `json:"resourceSpecs"` | |||||
| } `json:"deploy"` | |||||
| Train struct { | |||||
| ResourceSpecs []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Price int `json:"price"` | |||||
| ResourceQuantity struct { | |||||
| CambriconComMlu string `json:"cambricon.com/mlu,omitempty"` | |||||
| Cpu string `json:"cpu"` | |||||
| Memory string `json:"memory"` | |||||
| Shm string `json:"shm,omitempty"` | |||||
| } `json:"resourceQuantity"` | |||||
| } `json:"resourceSpecs"` | |||||
| } `json:"train"` | |||||
| } `json:"mapResourceSpecIdList"` | |||||
| } `json:"payload"` | |||||
| Error interface{} `json:"error"` | |||||
| } | |||||
| type SailingsiResp struct { | |||||
| Success bool `json:"success"` | |||||
| Payload struct { | |||||
| MapResourceSpecIdList struct { | |||||
| Debug struct { | |||||
| ResourceSpecs []interface{} `json:"resourceSpecs"` | |||||
| } `json:"debug"` | |||||
| Deploy struct { | |||||
| ResourceSpecs []interface{} `json:"resourceSpecs"` | |||||
| } `json:"deploy"` | |||||
| Train struct { | |||||
| ResourceSpecs []interface{} `json:"resourceSpecs"` | |||||
| } `json:"train"` | |||||
| } `json:"mapResourceSpecIdList"` | |||||
| } `json:"payload"` | |||||
| Error interface{} `json:"error"` | |||||
| } | |||||
| type Login struct { | |||||
| Username string `json:"username"` | |||||
| Password string `json:"password"` | |||||
| } | |||||
| @@ -1,36 +0,0 @@ | |||||
| package common | |||||
| import ( | |||||
| "io" | |||||
| "log" | |||||
| "net/http" | |||||
| "os" | |||||
| "time" | |||||
| ) | |||||
| func OctopusHttpClient(method string, url string, payload io.Reader, token string) ([]byte, error) { | |||||
| request, err := http.NewRequest(method, url, payload) | |||||
| if token != "" { | |||||
| request.Header.Set("Authorization", "Bearer "+token) | |||||
| } else { | |||||
| request.Header.Set("Content-Type", "application/json") | |||||
| } | |||||
| client := http.Client{Timeout: time.Duration(2) * time.Second} | |||||
| res, err := client.Do(request) | |||||
| if err != nil { | |||||
| if os.IsTimeout(err) { | |||||
| log.Println("接口调用超时 : ", err) | |||||
| request.Body.Close() | |||||
| return nil, err | |||||
| } | |||||
| log.Println(err) | |||||
| } | |||||
| defer res.Body.Close() | |||||
| body, err := io.ReadAll(res.Body) | |||||
| if err != nil { | |||||
| log.Println("body转换错误: ", err) | |||||
| return nil, err | |||||
| } | |||||
| return body, err | |||||
| } | |||||
| @@ -1,99 +0,0 @@ | |||||
| package common | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/config" | |||||
| "PCM/common/tool" | |||||
| "bytes" | |||||
| "encoding/json" | |||||
| "log" | |||||
| "time" | |||||
| ) | |||||
| const ( | |||||
| Hanwuji = "hanwuji" | |||||
| Suiyuan = "suiyuan" | |||||
| Sailingsi = "sailingsi" | |||||
| ) | |||||
| type TokenTimePair struct { | |||||
| Token string | |||||
| ExpiredAt time.Time | |||||
| } | |||||
| var ( | |||||
| tokenMap = generateTokenMap() | |||||
| OctopusUrls = getOctopusUrls() | |||||
| ) | |||||
| func generateTokenMap() map[string]TokenTimePair { | |||||
| var tokenMap = make(map[string]TokenTimePair) | |||||
| octopusConfig := config.Cfg | |||||
| login := Login{ | |||||
| Username: octopusConfig.OctopusConfig.Username, | |||||
| Password: octopusConfig.OctopusConfig.Password, | |||||
| } | |||||
| jsonStr, _ := json.Marshal(login) | |||||
| urlMap := map[string]string{ | |||||
| Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||||
| Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||||
| Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusConfig.OctopusTokenUrl, | |||||
| } | |||||
| for k, v := range urlMap { | |||||
| token, expiredAt := generateToken(jsonStr, v) | |||||
| if token == "" { | |||||
| continue | |||||
| } | |||||
| tokenTimePair := TokenTimePair{ | |||||
| Token: token, | |||||
| ExpiredAt: expiredAt, | |||||
| } | |||||
| tokenMap[k] = tokenTimePair | |||||
| } | |||||
| return tokenMap | |||||
| } | |||||
| func generateToken(jsonStr []byte, tokenUrl string) (string, time.Time) { | |||||
| body, err := OctopusHttpClient(tool.POST, tokenUrl, bytes.NewBuffer(jsonStr), "") | |||||
| var tokenResp TokenResp | |||||
| err = json.Unmarshal(body, &tokenResp) | |||||
| if err != nil { | |||||
| log.Println("token json转换失败 : ", err) | |||||
| return "", time.Time{} | |||||
| } | |||||
| var d time.Duration | |||||
| d = time.Second * time.Duration(tokenResp.Payload.Expiration) | |||||
| return tokenResp.Payload.Token, time.Now().Add(d) | |||||
| } | |||||
| func GetToken(kForToken string) string { | |||||
| if tokenMap[kForToken].Token == "" { | |||||
| return "" | |||||
| } | |||||
| tokenTimePair := tokenMap[kForToken] | |||||
| if time.Now().After(tokenTimePair.ExpiredAt) { | |||||
| tokenMap = generateTokenMap() | |||||
| if tokenMap[kForToken].Token == "" { | |||||
| return "" | |||||
| } else { | |||||
| return tokenMap[kForToken].Token | |||||
| } | |||||
| } | |||||
| return tokenTimePair.Token | |||||
| } | |||||
| func getOctopusUrls() map[string]string { | |||||
| octopusConfig := config.Cfg | |||||
| urlMap := map[string]string{ | |||||
| Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl, | |||||
| Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl, | |||||
| Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl, | |||||
| } | |||||
| return urlMap | |||||
| } | |||||
| @@ -1,49 +0,0 @@ | |||||
| package config | |||||
| import ( | |||||
| commonConfig "PCM/common/config" | |||||
| "flag" | |||||
| "github.com/zeromicro/go-zero/core/conf" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "github.com/zeromicro/go-zero/core/stores/redis" | |||||
| "github.com/zeromicro/go-zero/zrpc" | |||||
| ) | |||||
| type Config struct { | |||||
| zrpc.RpcServerConf | |||||
| OctopusConfig OctopusConfig | |||||
| OctopusApi OctopusApi | |||||
| PcmCoreRpcConf zrpc.RpcClientConf | |||||
| LogConf logx.LogConf | |||||
| RedisConf redis.RedisConf | |||||
| } | |||||
| var configFile = flag.String("f", "adaptor/PCM-AI/PCM-OCTOPUS/rpc/etc/octopus.yaml", "the config file") | |||||
| var Cfg = getConfig() | |||||
| func getConfig() Config { | |||||
| var bootstrapConfig commonConfig.BootstrapConfig | |||||
| conf.MustLoad(*configFile, &bootstrapConfig) | |||||
| //解析业务配置 | |||||
| var c Config | |||||
| nacosConfig := bootstrapConfig.NacosConfig | |||||
| serviceConfigContent := nacosConfig.InitConfig(func(data string) { | |||||
| err := conf.LoadFromYamlBytes([]byte(data), &c) | |||||
| if err != nil { | |||||
| panic(err) | |||||
| } | |||||
| }) | |||||
| err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c) | |||||
| if err != nil { | |||||
| panic(err) | |||||
| } | |||||
| // start log component | |||||
| logx.MustSetup(c.LogConf) | |||||
| // 注册到nacos | |||||
| nacosConfig.Discovery(&c.RpcServerConf) | |||||
| return c | |||||
| } | |||||
| @@ -1,67 +0,0 @@ | |||||
| package config | |||||
| type OctopusConfig struct { | |||||
| Username string | |||||
| Password string | |||||
| HanwujiUrl string | |||||
| SuiyuanUrl string | |||||
| SailingsiUrl string | |||||
| OctopusResouceSpec string | |||||
| OctopusTokenUrl string | |||||
| CambriconMLU290 int32 | |||||
| EnflameT20 int32 | |||||
| OctopusCp string | |||||
| } | |||||
| type OctopusApi struct { | |||||
| GetUserImageList string | |||||
| GetMyAlgorithmList string | |||||
| GetNotebookList string | |||||
| GetMydatasetList string | |||||
| CreateImage string | |||||
| DeleteImage string | |||||
| CreateDataSet string | |||||
| DeleteDataSet string | |||||
| GetAlgorithmApplyList string | |||||
| GetAlgorithmFrameworkList string | |||||
| DeleteMyAlgorithm string | |||||
| CreateMyAlgorithm string | |||||
| GetAlgorithmList string | |||||
| GetAlgorithm string | |||||
| DownloadAlgorithm string | |||||
| UploadAlgorithm string | |||||
| UploadAlgorithmConfirm string | |||||
| UploadImage string | |||||
| UploadImageConfirm string | |||||
| UploadDataSet string | |||||
| UploadDataSetConfirm string | |||||
| CreateDataSetVersion string | |||||
| DeleteDataSetVersion string | |||||
| GetDatasetVersionList string | |||||
| DeleteNotebook string | |||||
| StartNotebook string | |||||
| StopNotebook string | |||||
| CreateNotebook string | |||||
| GetNotebook string | |||||
| CreateTrainJob string | |||||
| GetDatasetApplyList string | |||||
| GetDatasetTypeList string | |||||
| GetTrainJobList string | |||||
| GetMyModelList string | |||||
| GetModelVersionList string | |||||
| DeleteMyModel string | |||||
| DeleteModelVersion string | |||||
| DownloadModelVersion string | |||||
| GetTrainJob string | |||||
| DeleteTrainJob string | |||||
| StopTrainJob string | |||||
| GetTrainJobEvent string | |||||
| GetTrainJobMetric string | |||||
| CreateModelDeploy string | |||||
| GetModelDeployList string | |||||
| GetModelDeploy string | |||||
| GetModelDeployEvent string | |||||
| StopModelDeploy string | |||||
| DeleteModelDeploy string | |||||
| InferModelDeploy string | |||||
| } | |||||
| @@ -1,51 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "log" | |||||
| ) | |||||
| type CreateDataSetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic { | |||||
| return &CreateDataSetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateDataSetLogic) CreateDataSet(in *octopus.CreateDataSetReq) (*octopus.CreateDataSetResp, error) { | |||||
| resp := &octopus.CreateDataSetResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateDataSet | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.CreateDataSet). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateDataSetVersionLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateDataSetVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetVersionLogic { | |||||
| return &CreateDataSetVersionLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateDataSetVersionLogic) CreateDataSetVersion(in *octopus.CreateDataSetVersionReq) (*octopus.CreateDataSetVersionResp, error) { | |||||
| resp := &octopus.CreateDataSetVersionResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateDataSetVersion | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("datasetId", in.DatasetId). | |||||
| SetBody(in.Params). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,52 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateImageLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateImageLogic { | |||||
| return &CreateImageLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateImageLogic) CreateImage(in *octopus.CreateImageReq) (*octopus.CreateImageResp, error) { | |||||
| resp := &octopus.CreateImageResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateImage | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.CreateImage). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateModelDeployLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateModelDeployLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateModelDeployLogic { | |||||
| return &CreateModelDeployLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // ModelDeployService | |||||
| func (l *CreateModelDeployLogic) CreateModelDeploy(in *octopus.CreateModelDeployReq) (*octopus.CreateModelDeployResp, error) { | |||||
| resp := &octopus.CreateModelDeployResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateModelDeploy | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.Params). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateMyAlgorithmLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateMyAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMyAlgorithmLogic { | |||||
| return &CreateMyAlgorithmLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateMyAlgorithmLogic) CreateMyAlgorithm(in *octopus.CreateMyAlgorithmReq) (*octopus.CreateMyAlgorithmResp, error) { | |||||
| resp := &octopus.CreateMyAlgorithmResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateMyAlgorithm | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.CreateMyAlgorithm). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic { | |||||
| return &CreateNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *CreateNotebookLogic) CreateNotebook(in *octopus.CreateNotebookReq) (*octopus.CreateNotebookResp, error) { | |||||
| resp := &octopus.CreateNotebookResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateNotebook | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.Params). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type CreateTrainJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewCreateTrainJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainJobLogic { | |||||
| return &CreateTrainJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| // TrainJobService | |||||
| func (l *CreateTrainJobLogic) CreateTrainJob(in *octopus.CreateTrainJobReq) (*octopus.CreateTrainJobResp, error) { | |||||
| resp := &octopus.CreateTrainJobResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.CreateTrainJob | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetBody(in.Params). | |||||
| SetResult(resp). | |||||
| Post(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteDataSetLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetLogic { | |||||
| return &DeleteDataSetLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteDataSetLogic) DeleteDataSet(in *octopus.DeleteDataSetReq) (*octopus.DeleteDataSetResp, error) { | |||||
| resp := &octopus.DeleteDataSetResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteDataSet | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("id", in.Id). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteDataSetVersionLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteDataSetVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetVersionLogic { | |||||
| return &DeleteDataSetVersionLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteDataSetVersionLogic) DeleteDataSetVersion(in *octopus.DeleteDataSetVersionReq) (*octopus.DeleteDataSetVersionResp, error) { | |||||
| resp := &octopus.DeleteDataSetVersionResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteDataSetVersion | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("datasetId", in.DatasetId). | |||||
| SetPathParam("version", in.Version). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteImageLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteImageLogic { | |||||
| return &DeleteImageLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteImageLogic) DeleteImage(in *octopus.DeleteImageReq) (*octopus.DeleteImageResp, error) { | |||||
| resp := &octopus.DeleteImageResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteImage | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("imageId", in.ImageId). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,58 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteModelDeployLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteModelDeployLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelDeployLogic { | |||||
| return &DeleteModelDeployLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteModelDeployLogic) DeleteModelDeploy(in *octopus.DeleteModelDeployReq) (*octopus.DeleteModelDeployResp, error) { | |||||
| resp := &octopus.DeleteModelDeployResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteModelDeploy | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| var queryStr string | |||||
| for _, s := range in.GetJobIds() { | |||||
| queryStr += "jobIds=" + s + "&" | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString(queryStr). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteModelVersionLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteModelVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteModelVersionLogic { | |||||
| return &DeleteModelVersionLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteModelVersionLogic) DeleteModelVersion(in *octopus.DeleteModelVersionReq) (*octopus.DeleteModelVersionResp, error) { | |||||
| resp := &octopus.DeleteModelVersionResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteModelVersion | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("modelId", in.ModelId). | |||||
| SetPathParam("version", in.Version). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteMyAlgorithmLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteMyAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMyAlgorithmLogic { | |||||
| return &DeleteMyAlgorithmLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteMyAlgorithmLogic) DeleteMyAlgorithm(in *octopus.DeleteMyAlgorithmReq) (*octopus.DeleteMyAlgorithmResp, error) { | |||||
| resp := &octopus.DeleteMyAlgorithmResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteMyAlgorithm | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("algorithmId", in.AlgorithmId). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteMyModelLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteMyModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMyModelLogic { | |||||
| return &DeleteMyModelLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteMyModelLogic) DeleteMyModel(in *octopus.DeleteMyModelReq) (*octopus.DeleteMyModelResp, error) { | |||||
| resp := &octopus.DeleteMyModelResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteMyModel | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("modelId", in.ModelId). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteNotebookLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNotebookLogic { | |||||
| return &DeleteNotebookLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteNotebookLogic) DeleteNotebook(in *octopus.DeleteNotebookReq) (*octopus.DeleteNotebookResp, error) { | |||||
| resp := &octopus.DeleteNotebookResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteNotebook | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("id", in.Id). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,59 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DeleteTrainJobLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDeleteTrainJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainJobLogic { | |||||
| return &DeleteTrainJobLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DeleteTrainJobLogic) DeleteTrainJob(in *octopus.DeleteTrainJobReq) (*octopus.DeleteTrainJobResp, error) { | |||||
| resp := &octopus.DeleteTrainJobResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DeleteTrainJob | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| var queryStr string | |||||
| for _, s := range in.GetJobIds() { | |||||
| queryStr += "jobIds=" + s + "&" | |||||
| } | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString(queryStr). | |||||
| SetResult(resp). | |||||
| Delete(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DownloadAlgorithmLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDownloadAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadAlgorithmLogic { | |||||
| return &DownloadAlgorithmLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DownloadAlgorithmLogic) DownloadAlgorithm(in *octopus.DownloadAlgorithmReq) (*octopus.DownloadAlgorithmResp, error) { | |||||
| resp := &octopus.DownloadAlgorithmResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DownloadAlgorithm | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("algorithmId", in.AlgorithmId). | |||||
| SetPathParam("version", in.Version). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type DownloadModelVersionLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewDownloadModelVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadModelVersionLogic { | |||||
| return &DownloadModelVersionLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *DownloadModelVersionLogic) DownloadModelVersion(in *octopus.DownloadModelVersionReq) (*octopus.DownloadModelVersionResp, error) { | |||||
| resp := &octopus.DownloadModelVersionResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.DownloadModelVersion | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("modelId", in.ModelId). | |||||
| SetPathParam("version", in.Version). | |||||
| SetQueryString("domain=" + in.Domain). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,56 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetAlgorithmApplyListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetAlgorithmApplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmApplyListLogic { | |||||
| return &GetAlgorithmApplyListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetAlgorithmApplyListLogic) GetAlgorithmApplyList(in *octopus.GetAlgorithmApplyListReq) (*octopus.GetAlgorithmApplyListResp, error) { | |||||
| resp := &octopus.GetAlgorithmApplyListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmApplyList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,56 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetAlgorithmFrameworkListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetAlgorithmFrameworkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmFrameworkListLogic { | |||||
| return &GetAlgorithmFrameworkListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetAlgorithmFrameworkListLogic) GetAlgorithmFrameworkList(in *octopus.GetAlgorithmFrameworkListReq) (*octopus.GetAlgorithmFrameworkListResp, error) { | |||||
| resp := &octopus.GetAlgorithmFrameworkListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmFrameworkList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,57 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetAlgorithmListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetAlgorithmListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmListLogic { | |||||
| return &GetAlgorithmListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetAlgorithmListLogic) GetAlgorithmList(in *octopus.GetAlgorithmListReq) (*octopus.GetAlgorithmListResp, error) { | |||||
| resp := &octopus.GetAlgorithmListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithmList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString("pageIndex="+strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize="+strconv.Itoa(int(in.PageSize))). | |||||
| SetPathParam("algorithmId", in.AlgorithmId). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,54 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetAlgorithmLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAlgorithmLogic { | |||||
| return &GetAlgorithmLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetAlgorithmLogic) GetAlgorithm(in *octopus.GetAlgorithmReq) (*octopus.GetAlgorithmResp, error) { | |||||
| resp := &octopus.GetAlgorithmResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetAlgorithm | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("algorithmId", in.AlgorithmId). | |||||
| SetPathParam("version", in.Version). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,128 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/config" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "context" | |||||
| "encoding/json" | |||||
| "github.com/go-redis/redis" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| "log" | |||||
| "strconv" | |||||
| "time" | |||||
| ) | |||||
| type GetComputingPowerLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputingPowerLogic { | |||||
| return &GetComputingPowerLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetComputingPowerLogic) GetComputingPower(in *octopus.ResourceReq) (*octopus.CpResp, error) { | |||||
| var resp octopus.CpResp | |||||
| var cp float32 | |||||
| redisClient := redis.NewClient(&redis.Options{ | |||||
| Addr: l.svcCtx.Config.RedisConf.Host, | |||||
| Password: l.svcCtx.Config.RedisConf.Pass, | |||||
| }) | |||||
| defer redisClient.Close() | |||||
| _, err := redisClient.Ping().Result() | |||||
| if err != nil { | |||||
| log.Println("redis连接失败", err) | |||||
| cp = getCPFromOctopus() | |||||
| redisClient.Set(l.svcCtx.Config.OctopusConfig.OctopusCp, cp, 168*time.Hour) | |||||
| } else { | |||||
| res, err := redisClient.Get(l.svcCtx.Config.OctopusConfig.OctopusCp).Float32() | |||||
| if err == redis.Nil { | |||||
| log.Println("redis key未找到或已过期,重新请求") | |||||
| cp = getCPFromOctopus() | |||||
| redisClient.Set(l.svcCtx.Config.OctopusConfig.OctopusCp, cp, 168*time.Hour) | |||||
| } else { | |||||
| cp = res | |||||
| } | |||||
| } | |||||
| resp.POpsAtFp16 = cp | |||||
| return &resp, nil | |||||
| } | |||||
| func getCPFromOctopus() float32 { | |||||
| octopusConfig := config.Cfg | |||||
| urlMap := map[string]string{ | |||||
| common.Hanwuji: octopusConfig.OctopusConfig.HanwujiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||||
| common.Suiyuan: octopusConfig.OctopusConfig.SuiyuanUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||||
| common.Sailingsi: octopusConfig.OctopusConfig.SailingsiUrl + octopusConfig.OctopusConfig.OctopusResouceSpec, | |||||
| } | |||||
| var computingPowerInTops int32 | |||||
| for k, v := range urlMap { | |||||
| token := common.GetToken(k) | |||||
| if token == "" { | |||||
| continue | |||||
| } | |||||
| body, err := common.OctopusHttpClient("GET", v, nil, token) | |||||
| if err != nil { | |||||
| continue | |||||
| } | |||||
| //获取训练资源算力 | |||||
| switch k { | |||||
| case common.Hanwuji: | |||||
| resourceSpec := common.HanwujiResp{} | |||||
| err := json.Unmarshal(body, &resourceSpec) | |||||
| if err != nil { | |||||
| log.Println("Hanwuji json转换失败 : ", err) | |||||
| continue | |||||
| } | |||||
| if !resourceSpec.Success { | |||||
| log.Println("Hanwuji 获取训练资源失败 : ", resourceSpec.Error) | |||||
| continue | |||||
| } | |||||
| for _, spec := range resourceSpec.Payload.MapResourceSpecIdList.Train.ResourceSpecs { | |||||
| numOfCards, err := strconv.ParseInt(spec.ResourceQuantity.CambriconComMlu, 10, 32) | |||||
| if err != nil { | |||||
| continue | |||||
| } | |||||
| computingPowerInTops += octopusConfig.OctopusConfig.CambriconMLU290 * int32(numOfCards) | |||||
| } | |||||
| case common.Suiyuan: | |||||
| resourceSpec := common.SuiyuanResp{} | |||||
| err := json.Unmarshal(body, &resourceSpec) | |||||
| if err != nil { | |||||
| log.Println("Suiyuan json转换失败 : ", err) | |||||
| continue | |||||
| } | |||||
| if !resourceSpec.Success { | |||||
| log.Println("Suiyuan 获取训练资源失败 : ", resourceSpec.Error) | |||||
| continue | |||||
| } | |||||
| for _, spec := range resourceSpec.Payload.MapResourceSpecIdList.Train.ResourceSpecs { | |||||
| numOfCards, err := strconv.ParseInt(spec.ResourceQuantity.EnflameComDtu, 10, 32) | |||||
| if err != nil { | |||||
| continue | |||||
| } | |||||
| computingPowerInTops += octopusConfig.OctopusConfig.EnflameT20 * int32(numOfCards) | |||||
| } | |||||
| } | |||||
| } | |||||
| if computingPowerInTops == 0 { | |||||
| return 0 | |||||
| } | |||||
| return float32(computingPowerInTops) / 1024 | |||||
| } | |||||
| @@ -1,56 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetDatasetApplyListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetDatasetApplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetApplyListLogic { | |||||
| return &GetDatasetApplyListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetDatasetApplyListLogic) GetDatasetApplyList(in *octopus.GetDatasetApplyListReq) (*octopus.GetDatasetApplyListResp, error) { | |||||
| resp := &octopus.GetDatasetApplyListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetApplyList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,56 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetDatasetTypeListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetDatasetTypeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetTypeListLogic { | |||||
| return &GetDatasetTypeListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetDatasetTypeListLogic) GetDatasetTypeList(in *octopus.GetDatasetTypeListRep) (*octopus.GetDatasetTypeListResp, error) { | |||||
| resp := &octopus.GetDatasetTypeListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetTypeList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||
| @@ -1,57 +0,0 @@ | |||||
| package logic | |||||
| import ( | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/common" | |||||
| "PCM/common/tool" | |||||
| "context" | |||||
| "errors" | |||||
| "log" | |||||
| "strconv" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/internal/svc" | |||||
| "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type GetDatasetVersionListLogic struct { | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| logx.Logger | |||||
| } | |||||
| func NewGetDatasetVersionListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDatasetVersionListLogic { | |||||
| return &GetDatasetVersionListLogic{ | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| Logger: logx.WithContext(ctx), | |||||
| } | |||||
| } | |||||
| func (l *GetDatasetVersionListLogic) GetDatasetVersionList(in *octopus.GetDatasetVersionListReq) (*octopus.GetDatasetVersionListResp, error) { | |||||
| resp := &octopus.GetDatasetVersionListResp{} | |||||
| var url_prefix = common.OctopusUrls[in.Platform] | |||||
| var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetDatasetVersionList | |||||
| token := common.GetToken(in.Platform) | |||||
| if token == "" { | |||||
| log.Println("获取token失败, platform : ", in.Platform) | |||||
| return nil, errors.New("获取token失败") | |||||
| } | |||||
| req := tool.GetACHttpRequest() | |||||
| _, err := req. | |||||
| SetHeader("Authorization", "Bearer "+token). | |||||
| SetPathParam("datasetId", in.DatasetId). | |||||
| SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))). | |||||
| SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))). | |||||
| SetResult(resp). | |||||
| Get(reqUrl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return resp, nil | |||||
| } | |||||