fix: Modify models.TaskAi of the Ai task_ai
This commit is contained in:
parent
1bd8315e13
commit
32103a1bfe
|
@ -135,6 +135,7 @@ type CloudInfo struct {
|
|||
}
|
||||
|
||||
type AiInfo struct {
|
||||
Id int64 `json:"id"` // id
|
||||
AdapterId int64 `json:"adapterId,omitempty,optional"`
|
||||
AdapterName string `json:"adapterName,omitempty,optional"`
|
||||
ClusterId int64 `json:"clusterId,omitempty,optional"`
|
||||
|
@ -155,17 +156,21 @@ type AiInfo struct {
|
|||
ClusterName string `json:"clusterName,omitempty,optional"`
|
||||
ModelName string `json:"ModelName,omitempty,optional"`
|
||||
AlgorithmName string `json:"algorithmName,omitempty,optional"`
|
||||
Strategy string `json:"strategy,omitempty"`
|
||||
|
||||
ImageId string `json:"imageId,omitempty"`
|
||||
SpecId string `json:"specId,omitempty"`
|
||||
DatasetsId string `json:"datasetsId,omitempty"`
|
||||
CodeId string `json:"codeId,omitempty"`
|
||||
ResourceId string `json:"resourceId,omitempty"`
|
||||
AlgorithmId string `json:"algorithmId,omitempty"`
|
||||
ImageId string `json:"imageId,omitempty"`
|
||||
SpecId string `json:"specId,omitempty"`
|
||||
DatasetsId string `json:"datasetsId,omitempty"`
|
||||
CodeId string `json:"codeId,omitempty"`
|
||||
ResourceId string `json:"resourceId,omitempty"`
|
||||
AlgorithmId string `json:"algorithmId,omitempty"`
|
||||
MetadataName string `json:"metadataName,omitempty"`
|
||||
|
||||
Cmd string `json:"cmd,omitempty"`
|
||||
Envs []string `json:"envs,omitempty"`
|
||||
Params []string `json:"params,omitempty"`
|
||||
Cmd string `json:"cmd,omitempty"`
|
||||
Envs []string `json:"envs,omitempty"`
|
||||
Params []string `json:"params,omitempty"`
|
||||
Environments []string `json:"environments,omitempty"`
|
||||
Parameters []string `json:"parameters,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
|
||||
modelartsclient "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
|
@ -54,6 +55,7 @@ type ModelArtsLink struct {
|
|||
Version string
|
||||
ModelId string
|
||||
ModelType string
|
||||
DbEngin *gorm.DB
|
||||
}
|
||||
|
||||
// Version 结构体表示版本号
|
||||
|
@ -61,6 +63,10 @@ type Version struct {
|
|||
Major, Minor, Patch int
|
||||
}
|
||||
|
||||
type AiStorage struct {
|
||||
DbEngin *gorm.DB
|
||||
}
|
||||
|
||||
// ParseVersion 从字符串解析版本号
|
||||
func ParseVersion(versionStr string) (*Version, error) {
|
||||
parts := strings.Split(versionStr, ".")
|
||||
|
@ -174,6 +180,11 @@ func (m *ModelArtsLink) SubmitTask(ctx context.Context, imageId string, cmd stri
|
|||
Platform: m.platform,
|
||||
}
|
||||
resp, err := m.modelArtsRpc.CreateTrainingJob(ctx, req)
|
||||
//tx := m.DbEngin.Create(adapterId)
|
||||
/*if tx.Error != nil {
|
||||
return tx.Error, nil
|
||||
}*/
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
@ -36,26 +35,34 @@ type (
|
|||
}
|
||||
|
||||
TaskAi struct {
|
||||
Id int64 `db:"id"` // id
|
||||
TaskId int64 `db:"task_id"` // 任务id
|
||||
AdapterId int64 `db:"adapter_id"` // 适配器id
|
||||
AdapterName string `db:"adapter_name"` // 适配器名称
|
||||
ClusterId int64 `db:"cluster_id"` // 集群id
|
||||
ClusterName string `db:"cluster_name"` // 集群名称
|
||||
Name string `db:"name"` // 任务名
|
||||
Replica int64 `db:"replica"` // 执行数
|
||||
JobId string `db:"job_id"` // 集群返回任务id
|
||||
Strategy string `db:"strategy"` // 主任务使用策略
|
||||
Status string `db:"status"` // 任务状态
|
||||
Msg string `db:"msg"` // 集群返回任务信息
|
||||
CommitTime time.Time `db:"commit_time"` // 提交时间
|
||||
StartTime string `db:"start_time"` // 开始时间
|
||||
EndTime string `db:"end_time"` // 结束时间
|
||||
TaskType string `db:"task_type"`
|
||||
DeletedAt *time.Time `db:"deleted_at"`
|
||||
Card string `db:"card"`
|
||||
InferUrl string `db:"infer_url"`
|
||||
ModelName string `db:"model_name"`
|
||||
Id int64 `db:"id"` // id
|
||||
TaskId int64 `db:"task_id"` // 任务id
|
||||
AdapterId int64 `db:"adapter_id"` // 适配器id
|
||||
AdapterName string `db:"adapter_name"` // 适配器名称
|
||||
ClusterId int64 `db:"cluster_id"` // 集群id
|
||||
ClusterName string `db:"cluster_name"` // 集群名称
|
||||
Name string `db:"name"` // 任务名
|
||||
Replica int64 `db:"replica"` // 执行数
|
||||
JobId string `db:"job_id"` // 集群返回任务id
|
||||
Strategy string `db:"strategy"` // 主任务使用策略
|
||||
Status string `db:"status"` // 任务状态
|
||||
Msg string `db:"msg"` // 集群返回任务信息
|
||||
CommitTime time.Time `db:"commit_time"` // 提交时间
|
||||
StartTime string `db:"start_time"` // 开始时间
|
||||
EndTime string `db:"end_time"` // 结束时间
|
||||
TaskType string `db:"task_type"`
|
||||
DeletedAt time.Time `db:"deleted_at"`
|
||||
Card string `db:"card"`
|
||||
Remark string `db:"remark"` // 备注
|
||||
InferUrl string `db:"infer_url"`
|
||||
ModelName string `db:"model_name"`
|
||||
AlgorithmId string `db:"algorithm_id"` // 算法id
|
||||
ImageId string `db:"image_id"` // 镜像id
|
||||
Command string `db:"command"` // 启动命令
|
||||
Environments string `db:"environments"` // 训练作业的环境变量
|
||||
Parameters string `db:"parameters"` // 训练作业的运行参数
|
||||
FlavorId string `db:"flavor_id"` // 规格id
|
||||
MetadataName string `db:"metadata_name"` // 训练作业名称
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -66,13 +73,6 @@ func newTaskAiModel(conn sqlx.SqlConn) *defaultTaskAiModel {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *defaultTaskAiModel) withSession(session sqlx.Session) *defaultTaskAiModel {
|
||||
return &defaultTaskAiModel{
|
||||
conn: sqlx.NewSqlConnFromSession(session),
|
||||
table: "`task_ai`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultTaskAiModel) Delete(ctx context.Context, id int64) error {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||
|
@ -86,7 +86,7 @@ func (m *defaultTaskAiModel) FindOne(ctx context.Context, id int64) (*TaskAi, er
|
|||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
case sqlx.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
|
@ -94,14 +94,14 @@ func (m *defaultTaskAiModel) FindOne(ctx context.Context, id int64) (*TaskAi, er
|
|||
}
|
||||
|
||||
func (m *defaultTaskAiModel) Insert(ctx context.Context, data *TaskAi) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, taskAiRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.Name, data.Replica, data.JobId, data.Strategy, data.Status, data.Msg, data.CommitTime, data.StartTime, data.EndTime, data.TaskType, data.DeletedAt, data.Card)
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, taskAiRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.Name, data.Replica, data.JobId, data.Strategy, data.Status, data.Msg, data.CommitTime, data.StartTime, data.EndTime, data.TaskType, data.DeletedAt, data.Card, data.Remark, data.InferUrl, data.ModelName, data.AlgorithmId, data.ImageId, data.Command, data.Environments, data.Parameters, data.FlavorId, data.MetadataName)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultTaskAiModel) Update(ctx context.Context, data *TaskAi) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, taskAiRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.Name, data.Replica, data.JobId, data.Strategy, data.Status, data.Msg, data.CommitTime, data.StartTime, data.EndTime, data.TaskType, data.DeletedAt, data.Card, data.Id)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.Name, data.Replica, data.JobId, data.Strategy, data.Status, data.Msg, data.CommitTime, data.StartTime, data.EndTime, data.TaskType, data.DeletedAt, data.Card, data.Remark, data.InferUrl, data.ModelName, data.AlgorithmId, data.ImageId, data.Command, data.Environments, data.Parameters, data.FlavorId, data.MetadataName, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue