forked from JointCloud/pcm-coordinator
Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator
This commit is contained in:
commit
cdf8f986b6
|
@ -902,6 +902,8 @@ type (
|
||||||
RegionDict string `json:"regionDict,optional"`
|
RegionDict string `json:"regionDict,optional"`
|
||||||
RegionName string `json:"regionName,optional"`
|
RegionName string `json:"regionName,optional"`
|
||||||
Environment map[string]string `json:"environment,optional"`
|
Environment map[string]string `json:"environment,optional"`
|
||||||
|
CostType string `json:"costType,optional"`
|
||||||
|
Price int `json:"price,optional"`
|
||||||
}
|
}
|
||||||
ClusterInfo {
|
ClusterInfo {
|
||||||
Id string `json:"id,omitempty" db:"id"`
|
Id string `json:"id,omitempty" db:"id"`
|
||||||
|
@ -1366,7 +1368,7 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResourcePrice struct {
|
type ResourcePrice {
|
||||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
||||||
ResourceID int64 `json:"resourceId" gorm:"column:resource_id"`
|
ResourceID int64 `json:"resourceId" gorm:"column:resource_id"`
|
||||||
Price int `json:"price" gorm:"column:price"`
|
Price int `json:"price" gorm:"column:price"`
|
||||||
|
@ -1374,7 +1376,7 @@ type ResourcePrice struct {
|
||||||
ResourceType string `json:"resourceType" gorm:"column:resource_type"`
|
ResourceType string `json:"resourceType" gorm:"column:resource_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourceCostRecord struct {
|
type ResourceCostRecord {
|
||||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
||||||
ResourcePriceID int64 `json:"resourcePriceId" gorm:"column:resource_price_id"`
|
ResourcePriceID int64 `json:"resourcePriceId" gorm:"column:resource_price_id"`
|
||||||
UserId int64 `json:"userId" gorm:"column:user_id"`
|
UserId int64 `json:"userId" gorm:"column:user_id"`
|
||||||
|
|
|
@ -30,8 +30,9 @@ type (
|
||||||
StdInput string `json:"stdInput,optional"`
|
StdInput string `json:"stdInput,optional"`
|
||||||
ClusterType string `json:"clusterType,optional"`
|
ClusterType string `json:"clusterType,optional"`
|
||||||
Partition string `json:"partition"`
|
Partition string `json:"partition"`
|
||||||
UserId int64 `json:"userId,optional"`
|
UserId int64 `json:"userId,optional"`
|
||||||
Token string `json:"token,optional"`
|
Token string `json:"token,optional"`
|
||||||
|
UserIp string `json:"userIp,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
commitHpcTaskResp {
|
commitHpcTaskResp {
|
||||||
|
@ -155,24 +156,24 @@ type QueueAsset {
|
||||||
|
|
||||||
type (
|
type (
|
||||||
/******************instance center*************************/
|
/******************instance center*************************/
|
||||||
HpcInstanceCenterReq{
|
HpcInstanceCenterReq {
|
||||||
InstanceType int32 `form:"instanceType,optional"`
|
InstanceType int32 `form:"instanceType,optional"`
|
||||||
InstanceClass string `form:"instanceClass,optional"`
|
InstanceClass string `form:"instanceClass,optional"`
|
||||||
InstanceName string `form:"instanceName,optional"`
|
InstanceName string `form:"instanceName,optional"`
|
||||||
PageInfo
|
PageInfo
|
||||||
}
|
}
|
||||||
HpcInstanceCenterResp {
|
HpcInstanceCenterResp {
|
||||||
InstanceCenterList []HpcInstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"`
|
InstanceCenterList []HpcInstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"`
|
||||||
TotalCount int `json:"totalCount"`
|
TotalCount int `json:"totalCount"`
|
||||||
}
|
}
|
||||||
HpcInstanceCenterList {
|
HpcInstanceCenterList {
|
||||||
LogoPath string `json:"logo_path"`
|
LogoPath string `json:"logo_path"`
|
||||||
InstanceName string `json:"instance_name"`
|
InstanceName string `json:"instance_name"`
|
||||||
InstanceType int32 `json:"instance_type"`
|
InstanceType int32 `json:"instance_type"`
|
||||||
InstanceClass string `json:"instance_class"`
|
InstanceClass string `json:"instance_class"`
|
||||||
InstanceClassChinese string `json:"instance_class_chinese"`
|
InstanceClassChinese string `json:"instance_class_chinese"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************instance center*************************/
|
/******************instance center*************************/
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -18,6 +19,9 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
result.ParamErrorResult(r, w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 获取ip信息
|
||||||
|
ip := utils.GetClientIP(r)
|
||||||
|
req.UserIp = ip
|
||||||
// 获取token信息
|
// 获取token信息
|
||||||
token := r.Header.Get("Authorization")
|
token := r.Header.Get("Authorization")
|
||||||
req.Token = token
|
req.Token = token
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||||
tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -63,7 +64,13 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t
|
||||||
logx.Errorf(tx.Error.Error())
|
logx.Errorf(tx.Error.Error())
|
||||||
return nil, errors.New("cluster create failed")
|
return nil, errors.New("cluster create failed")
|
||||||
}
|
}
|
||||||
|
// 创建资源价格信息
|
||||||
|
resourcePrice := &types.ResourcePrice{
|
||||||
|
Price: req.Price,
|
||||||
|
ResourceType: constants.CLUSTER,
|
||||||
|
CostType: req.CostType,
|
||||||
|
}
|
||||||
|
tx = l.svcCtx.DbEngin.Table("resource_cost").Create(resourcePrice)
|
||||||
// push cluster info to adapter
|
// push cluster info to adapter
|
||||||
go func() {
|
go func() {
|
||||||
var adapterServer string
|
var adapterServer string
|
||||||
|
|
|
@ -134,8 +134,13 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
||||||
db := tx.Table("task").Create(&taskModel)
|
db := tx.Table("task").Create(&taskModel)
|
||||||
db = tx.Table("task_cloud").Create(&taskClouds)
|
db = tx.Table("task_cloud").Create(&taskClouds)
|
||||||
db = tx.Table("t_notice").Create(¬iceInfo)
|
db = tx.Table("t_notice").Create(¬iceInfo)
|
||||||
|
|
||||||
|
if db.Error != nil {
|
||||||
|
logx.Errorf("Task creation failure, err: %v", db.Error)
|
||||||
|
return errors.New("task creation failure")
|
||||||
|
}
|
||||||
// 数据上链
|
// 数据上链
|
||||||
bytes, err := json.Marshal(taskModel)
|
bytes, _ := json.Marshal(taskModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -148,10 +153,6 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
||||||
Token: req.Token,
|
Token: req.Token,
|
||||||
Args: []string{strconv.FormatInt(taskModel.Id, 10), string(bytes)},
|
Args: []string{strconv.FormatInt(taskModel.Id, 10), string(bytes)},
|
||||||
})
|
})
|
||||||
if db.Error != nil {
|
|
||||||
logx.Errorf("Task creation failure, err: %v", db.Error)
|
|
||||||
return errors.New("task creation failure")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
|
||||||
logx.Info("提交job到指定集群")
|
logx.Info("提交job到指定集群")
|
||||||
jobId, err := submitJob(&hpcInfo, &clusterInfo, server)
|
jobId, err := submitJob(&hpcInfo, &clusterInfo, server)
|
||||||
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
//}
|
|
||||||
//logx.Info("提交job到指定集群完成")
|
|
||||||
// 保存操作记录
|
// 保存操作记录
|
||||||
noticeInfo := clientCore.NoticeInfo{
|
noticeInfo := clientCore.NoticeInfo{
|
||||||
AdapterId: clusterInfo.AdapterId,
|
AdapterId: clusterInfo.AdapterId,
|
||||||
|
@ -122,6 +118,7 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
|
||||||
// 数据上链
|
// 数据上链
|
||||||
bytes, _ := json.Marshal(taskModel)
|
bytes, _ := json.Marshal(taskModel)
|
||||||
remoteUtil.Evidence(remoteUtil.EvidenceParam{
|
remoteUtil.Evidence(remoteUtil.EvidenceParam{
|
||||||
|
UserIp: req.UserIp,
|
||||||
Url: l.svcCtx.Config.BlockChain.Url,
|
Url: l.svcCtx.Config.BlockChain.Url,
|
||||||
ContractAddress: l.svcCtx.Config.BlockChain.ContractAddress,
|
ContractAddress: l.svcCtx.Config.BlockChain.ContractAddress,
|
||||||
FunctionName: l.svcCtx.Config.BlockChain.FunctionName,
|
FunctionName: l.svcCtx.Config.BlockChain.FunctionName,
|
||||||
|
|
|
@ -204,7 +204,7 @@ func (m *ModelArtsLink) SubmitTask(ctx context.Context, imageId string, cmd stri
|
||||||
},
|
},
|
||||||
Spec: &modelarts.SpecsC{
|
Spec: &modelarts.SpecsC{
|
||||||
Resource: &modelarts.ResourceCreateTraining{
|
Resource: &modelarts.ResourceCreateTraining{
|
||||||
FlavorId: "modelarts.kat1.xlarge",
|
FlavorId: resourceId,
|
||||||
NodeCount: 1,
|
NodeCount: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -647,7 +647,13 @@ func (m *ModelArtsLink) Execute(ctx context.Context, option *option.AiOption, mo
|
||||||
if ascendNum == v.FlavorInfo.Npu.UnitNum {
|
if ascendNum == v.FlavorInfo.Npu.UnitNum {
|
||||||
option.ResourceId = v.FlavorId
|
option.ResourceId = v.FlavorId
|
||||||
break
|
break
|
||||||
} else if ascendNum == 3 {
|
} else if ascendNum <= 1 {
|
||||||
|
option.ResourceId = "modelarts.kat1.xlarge"
|
||||||
|
break
|
||||||
|
} else if ascendNum == 2 {
|
||||||
|
option.ResourceId = "modelarts.kat1.2xlarge"
|
||||||
|
break
|
||||||
|
} else if ascendNum > 2 && ascendNum <= 4 {
|
||||||
option.ResourceId = "modelarts.kat1.4xlarge"
|
option.ResourceId = "modelarts.kat1.4xlarge"
|
||||||
break
|
break
|
||||||
} else if ascendNum >= 5 && ascendNum <= 8 {
|
} else if ascendNum >= 5 && ascendNum <= 8 {
|
||||||
|
|
|
@ -835,6 +835,8 @@ type ClusterCreateReq struct {
|
||||||
RegionDict string `json:"regionDict,optional"`
|
RegionDict string `json:"regionDict,optional"`
|
||||||
RegionName string `json:"regionName,optional"`
|
RegionName string `json:"regionName,optional"`
|
||||||
Environment map[string]string `json:"environment,optional"`
|
Environment map[string]string `json:"environment,optional"`
|
||||||
|
CostType string `json:"costType,optional"`
|
||||||
|
Price int `json:"price,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInfo struct {
|
type ClusterInfo struct {
|
||||||
|
@ -1323,6 +1325,7 @@ type CommitHpcTaskReq struct {
|
||||||
Partition string `json:"partition"`
|
Partition string `json:"partition"`
|
||||||
UserId int64 `json:"userId,optional"`
|
UserId int64 `json:"userId,optional"`
|
||||||
Token string `json:"token,optional"`
|
Token string `json:"token,optional"`
|
||||||
|
UserIp string `json:"userIp,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommitHpcTaskResp struct {
|
type CommitHpcTaskResp struct {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package constants
|
||||||
|
|
||||||
|
const (
|
||||||
|
CLUSTER = "0"
|
||||||
|
)
|
Loading…
Reference in New Issue