From 26157b12c70cf5f214f2033b955c233307433da2 Mon Sep 17 00:00:00 2001 From: Diva123456 Date: Mon, 6 Mar 2023 16:51:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adaptor/AIComputing/AICore/api/AICore.api | 143 ++++++++++++++++++ .../internal/logic/createexporttasklogic.go | 42 +++++ .../api/internal/logic/createservicelogic.go | 42 +++++ .../api/internal/logic/listclusterslogic.go | 42 +++++ 4 files changed, 269 insertions(+) create mode 100644 adaptor/AIComputing/AICore/api/internal/logic/createexporttasklogic.go create mode 100644 adaptor/AIComputing/AICore/api/internal/logic/createservicelogic.go create mode 100644 adaptor/AIComputing/AICore/api/internal/logic/listclusterslogic.go diff --git a/adaptor/AIComputing/AICore/api/AICore.api b/adaptor/AIComputing/AICore/api/AICore.api index f12411b..6cb4abe 100644 --- a/adaptor/AIComputing/AICore/api/AICore.api +++ b/adaptor/AIComputing/AICore/api/AICore.api @@ -48,6 +48,25 @@ type ( } ) /******************ImportTask end*************************/ + +/******************ExportTask start*************************/ +type ( + CreateExportTaskReq { + ProjectId string `json:"project_id"` + DatasetId string `json:"dataset_id"` + ExportPath string `json:"export_path"` + // AnnotationFormat string `json:"annotation_format"` + // ExportFormat int64 `json:"export_format"` + // ExportParams ExportParams `json:"export_params"` + + } + CreateExportTaskResp { + TaskId string `json:"task_id"` + } +) + +/******************ExportTask end*************************/ + /******************taskList start*************************/ type ( ListImportTasksReq { @@ -280,6 +299,121 @@ type ( ) /******************ListTrainingJobs end*************************/ +/******************Create Service Start*************************/ +type ( + CreateServiceReq { + WorkspaceId string `json:"workspaceId"` + Schedule Scheduler `json:"schedule"` + ClusterId string `json:"clusterId"` + InferType string `json:"inferType"` + VpcId string `json:"vpcId"` + ServiceName string `json:"serviceName"` + Description string `json:"description"` + SecurityGroupId string `json:"securityGroupId"` + SubnetNetworkId string `json:"subnetNetworkId"` + Config []ServiceConfig `json:"config"` + ProjectId string `json:"projectId"` + } + CreateServiceResp { + Code uint32 `json:"code"` + ServiceId string `json:"serviceId"` + ResourceIds []string `json:"resourceIds"` + } +) + +type Scheduler { + Duration int32 `json:"duration"` + TimeUnit string `json:"timeUnit"` + Type string `json:"type"` +} + +type ServiceConfig { + CustomSpec CustomSpec `json:"customSpec"` + Envs map[string]string `json:"envs"` + Specification string `json:"specification"` + Weight int32 `json:"weight"` + ModelId string `json:"modelId"` + SrcPath string `json:"srcPath"` + ReqUri string `json:"reqUri"` + MappingType string `json:"mappingType"` + ClusterId string `json:"clusterId"` + Nodes []string `json:"nodes"` + SrcType string `json:"srcType"` + DestPath string `json:"destPath"` + InstanceCount int32 `json:"instanceCount"` +} + +type CustomSpec { + GpuP4 float64 `json:"gpuP4"` + Memory int64 `json:"memory"` + Cpu float64 `json:"cpu"` + AscendA310 int64 `json:"ascendA310"` +} +/******************Create Service End*************************/ + +/******************Delete Service Start*************************/ +type ( + deleteServiceReq { + ProjectId string `json:"projectId"` + ServiceId string `json:"serviceId"` + } + deleteServiceResp { + } +) +/******************Delete Service Start*************************/ + +/******************Show Service Start*************************/ +type ( + showServiceReq { + ProjectId string `json:"projectId"` + ServiceId string `json:"serviceId"` + } + showServiceResp { + } +) +/******************Delete Service end*************************/ + +/******************List Clusters Start*************************/ +type ( + ListClustersReq { + ProjectId string `json:"project_id"` + ClusterName string `json:"cluster_name,optional"` + Offset int64 `json:"offset,optional"` + Limit int64 `json:"limit,optional"` + SortBy string `json:"sort_by,optional"` + Order string `json:"order,optional"` + } + ListClustersResp { + Code int32 `json:"code,omitempty"` + Count int32 `json:"count,omitempty"` + Clusters []Cluster `json:"clusters,omitempty"` + } +) + +type ClusterNode { + Specification string `json:"specification,omitempty"` + Count int32 `json:"count,omitempty"` + AvailableCount int32 `json:"available_count,omitempty"` +} + +type Cluster { + ClusterId string `json:"cluster_id,omitempty"` + ClusterName string `json:"cluster_name,omitempty"` + Description string `json:"description,omitempty"` + Tenant string `json:"tenant,omitempty"` + Project string `json:"project,omitempty"` + Owner string `json:"owner,omitempty"` + CreatedAt int32 `json:"created_at,omitempty"` + Status string `json:"status,omitempty"` + Nodes ClusterNode `json:"nodes,omitempty"` + AllocatableCpuCores float64 `json:"allocatable_cpu_cores,omitempty"` + AllocatableMemory int64 `json:"allocatable_memory,omitempty"` + PeriodNum int32 `json:"period_num,omitempty"` + PeriodType string `json:"period_type,omitempty"` + OrderId string `json:"order_id,omitempty"` +} +/******************List Clusters end*************************/ + /******************CreateTrainingJob start*************************/ type ( CreateTrainingJobReq { @@ -305,4 +439,13 @@ service AICore-api { // CreateTrainingJob 创建训练作业 @handler CreateTrainingJobHandler post /CreateTrainingJob (CreateTrainingJobReq) returns (CreateTrainingJobResp) + + // creat task 创建导入任务 + @handler CreateExportTaskHandler + post /CreateExportTask (CreateExportTaskReq) returns (CreateExportTaskResp) + @handler createServiceHandler + get /createService (CreateServiceReq) returns (CreateServiceResp) + @handler ListClustersHandler + get /ListClusters (ListClustersReq) returns (ListClustersResp) + } \ No newline at end of file diff --git a/adaptor/AIComputing/AICore/api/internal/logic/createexporttasklogic.go b/adaptor/AIComputing/AICore/api/internal/logic/createexporttasklogic.go new file mode 100644 index 0000000..5999f06 --- /dev/null +++ b/adaptor/AIComputing/AICore/api/internal/logic/createexporttasklogic.go @@ -0,0 +1,42 @@ +package logic + +import ( + "PCM/adaptor/AIComputing/modelarts/rpc/modelarts" + "PCM/common/tool" + "PCM/common/xerr" + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + + "PCM/adaptor/AIComputing/AICore/api/internal/svc" + "PCM/adaptor/AIComputing/AICore/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateExportTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExportTaskLogic { + return &CreateExportTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateExportTaskLogic) CreateExportTask(req *types.CreateExportTaskReq) (resp *types.CreateExportTaskResp, err error) { + + modelartsReq := &modelarts.GetExportTasksOfDatasetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters}) + CreateExportTaskResp, err := l.svcCtx.ModelArtsRpc.GetExportTasksOfDataset(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.CreateExportTaskResp{} + err = copier.CopyWithOption(&resp, &CreateExportTaskResp, copier.Option{Converters: tool.Converters}) + return resp, nil +} diff --git a/adaptor/AIComputing/AICore/api/internal/logic/createservicelogic.go b/adaptor/AIComputing/AICore/api/internal/logic/createservicelogic.go new file mode 100644 index 0000000..607508f --- /dev/null +++ b/adaptor/AIComputing/AICore/api/internal/logic/createservicelogic.go @@ -0,0 +1,42 @@ +package logic + +import ( + "PCM/adaptor/AIComputing/modelarts/rpc/modelarts" + "PCM/common/tool" + "PCM/common/xerr" + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + + "PCM/adaptor/AIComputing/AICore/api/internal/svc" + "PCM/adaptor/AIComputing/AICore/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic { + return &CreateServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.CreateServiceResp, err error) { + // todo: add your logic here and delete this line + modelartsReq := &modelarts.CreateServiceReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters}) + CreateServiceResp, err := l.svcCtx.ModelArtsRpc.CreateService(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.CreateServiceResp{} + err = copier.CopyWithOption(&resp, &CreateServiceResp, copier.Option{Converters: tool.Converters}) + return resp, nil +} diff --git a/adaptor/AIComputing/AICore/api/internal/logic/listclusterslogic.go b/adaptor/AIComputing/AICore/api/internal/logic/listclusterslogic.go new file mode 100644 index 0000000..e73ffce --- /dev/null +++ b/adaptor/AIComputing/AICore/api/internal/logic/listclusterslogic.go @@ -0,0 +1,42 @@ +package logic + +import ( + "PCM/adaptor/AIComputing/modelarts/rpc/modelarts" + "PCM/common/tool" + "PCM/common/xerr" + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + + "PCM/adaptor/AIComputing/AICore/api/internal/svc" + "PCM/adaptor/AIComputing/AICore/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListClustersLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic { + return &ListClustersLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListClustersLogic) ListClusters(req *types.ListClustersReq) (resp *types.ListClustersResp, err error) { + // todo: add your logic here and delete this line + modelartsReq := &modelarts.ListClustersReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters}) + ListClustersResp, err := l.svcCtx.ModelArtsRpc.ListClusters(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.ListClustersResp{} + err = copier.CopyWithOption(&resp, &ListClustersResp, copier.Option{Converters: tool.Converters}) + return resp, nil +}