fit:增加createTrainJob接口
This commit is contained in:
parent
3b8c75fb2e
commit
e66d979ff7
|
@ -331,7 +331,6 @@ type (
|
|||
)
|
||||
/******************DeleteTrainingJob end*************************/
|
||||
|
||||
|
||||
/******************Create Service Start*************************/
|
||||
type (
|
||||
CreateServiceReq {
|
||||
|
@ -1030,6 +1029,82 @@ type (
|
|||
)
|
||||
/******************Visualization Job End*************************/
|
||||
|
||||
/******************create TrainIngJob start*************************/
|
||||
|
||||
type (
|
||||
CreateTrainingJobReq { //创建训练任务入参
|
||||
Kind string `json:"kind"`
|
||||
Metadatas MetadataS `json:"metadata"`
|
||||
Algorithms Algorithms `json:"algorithm"`
|
||||
Specs Specs `json:"spec"`
|
||||
ProjectId string `json:"projectId"`
|
||||
}
|
||||
|
||||
CreateTrainingJobResp { //创建训练任务出参
|
||||
Kind string `json:"kind"`
|
||||
Metadatas MetadataS `json:"metadata"`
|
||||
Status Status `json:"status"`
|
||||
Specs Specs `json:"spec"`
|
||||
Algorithms Algorithms `json:"algorithm"`
|
||||
}
|
||||
MetadataS {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
WorkspaceId string `json:"workspaceId"`
|
||||
}
|
||||
|
||||
EngineCreateTraining {
|
||||
EngineId string `json:"engineId"`
|
||||
EngineName string `json:"engineName"`
|
||||
EngineVersion string `json:"engineVersion"`
|
||||
}
|
||||
|
||||
ConstraintCreateTraining {
|
||||
Type string `json:"type"`
|
||||
Editable bool `json:"editable"`
|
||||
Required bool `json:"required"`
|
||||
Sensitive bool `json:"sensitive"`
|
||||
ValidType string `json:"validType"`
|
||||
}
|
||||
|
||||
ParametersTrainJob {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Value string `json:"value"`
|
||||
ConstraintCreateTraining ConstraintCreateTraining `json:"constraint"`
|
||||
}
|
||||
|
||||
PoliciesCreateTraining {
|
||||
}
|
||||
|
||||
Algorithms {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CodeDir string `json:"codeDir"`
|
||||
BootFile string `json:"bootFile"`
|
||||
EngineCreateTraining EngineCreateTraining `json:"engine"`
|
||||
ParametersTrainJob []ParametersTrainJob `json:"parameters"`
|
||||
PoliciesCreateTraining PoliciesCreateTraining `json:"policies"`
|
||||
}
|
||||
|
||||
ResourceCreateTraining {
|
||||
FlavorId string `json:"flavorId"`
|
||||
NodeCount int32 `json:"nodeCount"`
|
||||
}
|
||||
|
||||
LogExportPathCreateTrainingJob {
|
||||
}
|
||||
|
||||
Specs {
|
||||
ResourceCreateTraining ResourceCreateTraining `json:"resource"`
|
||||
LogExportPathCreateTrainingJob LogExportPathCreateTrainingJob `json:"logExportPath"`
|
||||
IsHostedLog bool `json:"isHostedLog"`
|
||||
}
|
||||
)
|
||||
|
||||
/******************create TrainIngJob end*************************/
|
||||
|
||||
/******************CreateAlgorithm end*************************/
|
||||
service AICore-api {
|
||||
|
||||
|
@ -1060,9 +1135,9 @@ service AICore-api {
|
|||
// DeleteAlgorithm 删除算法
|
||||
@handler DeleteAlgorithm
|
||||
delete /DeleteAlgorithm (DeleteAlgorithmReq) returns (DeleteAlgorithmResp)
|
||||
// // CreateTrainingJob 创建训练作业
|
||||
// @handler CreateTrainingJobHandler
|
||||
// post /CreateTrainingJob (CreateTrainingJobReq) returns (CreateTrainingJobResp)
|
||||
// CreateTrainingJob 创建训练作业
|
||||
@handler CreateTrainingJobHandler
|
||||
post /CreateTrainingJob (CreateTrainingJobReq) returns (CreateTrainingJobResp)
|
||||
|
||||
// creat export task 创建导出任务
|
||||
@handler CreateExportTaskHandler
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
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 CreateTrainingJobLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
|
||||
return &CreateTrainingJobLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
modelartsReq := &modelarts.CreateTrainingJobReq{}
|
||||
err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
||||
CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainingJob list"), "Failed to get db TrainingJob list err : %v ,req:%+v", err, req)
|
||||
}
|
||||
resp = &types.CreateTrainingJobResp{}
|
||||
|
||||
err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{Converters: tool.Converters})
|
||||
return resp, nil
|
||||
return
|
||||
}
|
|
@ -452,11 +452,11 @@ message Task_statuses{
|
|||
/******************CreateTrainingJob start*************************/
|
||||
//创建训练任务入参
|
||||
message CreateTrainingJobReq {
|
||||
string kind = 1;
|
||||
MetadataS metadata = 2;
|
||||
Algorithms algorithm = 3;
|
||||
Spec1 spec = 4;
|
||||
string project_id =5;
|
||||
string kind = 1; // @gotags: copier:"Kind"
|
||||
MetadataS metadatas = 2; // @gotags: copier:"Metadatas"
|
||||
Algorithms algorithms = 3; // @gotags: copier:"Algorithms"
|
||||
Specs specs = 4; // @gotags: copier:"Specs"
|
||||
string project_id =5; // @gotags: copier:"ProjectId"
|
||||
}
|
||||
//创建训练任务出参
|
||||
message CreateTrainingJobResp{
|
||||
|
@ -467,11 +467,10 @@ message CreateTrainingJobResp{
|
|||
Spec spec = 5;
|
||||
}
|
||||
message MetadataS {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string description = 3;
|
||||
int32 create_time = 4;
|
||||
string workspace_id = 5;
|
||||
string id = 1; // @gotags: copier:"Id"
|
||||
string name = 2; // @gotags: copier:"Name"
|
||||
string description = 3; // @gotags: copier:"Description"
|
||||
string workspace_id = 4; // @gotags: copier:"WorkspaceId"
|
||||
}
|
||||
|
||||
message EngineCreateTraining {
|
||||
|
@ -488,7 +487,7 @@ message ConstraintCreateTraining {
|
|||
string valid_type = 5;
|
||||
}
|
||||
|
||||
message Parameters {
|
||||
message ParametersTrainJob {
|
||||
string name = 1;
|
||||
string description = 2;
|
||||
string value = 3;
|
||||
|
@ -503,9 +502,9 @@ message Algorithms {
|
|||
string name = 2;
|
||||
string code_dir = 3;
|
||||
string boot_file = 4;
|
||||
EngineCreateTraining engine = 5;
|
||||
repeated Parameters parameters = 6;
|
||||
PoliciesCreateTraining policies = 7;
|
||||
EngineCreateTraining engine = 5; // @gotags: copier:"EngineCreateTraining"
|
||||
repeated ParametersTrainJob parameters = 6; // @gotags: copier:"ParametersTrainJob"
|
||||
PoliciesCreateTraining policies = 7; // @gotags: copier:"PoliciesCreateTraining"
|
||||
}
|
||||
|
||||
message ResourceCreateTraining {
|
||||
|
@ -516,7 +515,7 @@ message ResourceCreateTraining {
|
|||
message LogExportPathCreateTraining {
|
||||
}
|
||||
|
||||
message Spec1 {
|
||||
message Specs {
|
||||
ResourceCreateTraining resource = 1;
|
||||
LogExportPathCreateTraining log_export_path = 2;
|
||||
bool is_hosted_log = 3;
|
||||
|
|
Loading…
Reference in New Issue