Browse Source

#1249

update point when multi node
tags/v1.22.9.2^2
chenyifan01 3 years ago
parent
commit
762b3b1c17
3 changed files with 9 additions and 5 deletions
  1. +7
    -3
      models/cloudbrain_spec.go
  2. +1
    -1
      routers/repo/modelarts.go
  3. +1
    -1
      services/reward/cloudbrain_deduct.go

+ 7
- 3
models/cloudbrain_spec.go View File

@@ -123,10 +123,14 @@ func GetResourceSpecMapByCloudbrainIDs(ids []int64) (map[int64]*Specification, e
return r, nil return r, nil
} }


func GetCloudbrainTaskUnitPrice(cloudbrainId int64) (int, error) {
s, err := GetCloudbrainSpecByID(cloudbrainId)
func GetCloudbrainTaskUnitPrice(task Cloudbrain) (int, error) {
s, err := GetCloudbrainSpecByID(task.ID)
if err != nil { if err != nil {
return 0, err return 0, err
} }
return s.UnitPrice, nil
var n = 1
if task.WorkServerNumber > 1 {
n = task.WorkServerNumber
}
return s.UnitPrice * n, nil
} }

+ 1
- 1
routers/repo/modelarts.go View File

@@ -1216,7 +1216,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm)
ctx.RenderWithErr("Resource specification not available", tplModelArtsTrainJobNew, &form) ctx.RenderWithErr("Resource specification not available", tplModelArtsTrainJobNew, &form)
return return
} }
if !account.IsPointBalanceEnough(ctx.User.ID, spec.UnitPrice) {
if !account.IsPointBalanceEnough(ctx.User.ID, spec.UnitPrice*form.WorkServerNumber) {
log.Error("point balance is not enough,userId=%d specId=%d", ctx.User.ID, spec.ID) log.Error("point balance is not enough,userId=%d specId=%d", ctx.User.ID, spec.ID)
cloudBrainNewDataPrepare(ctx) cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr(ctx.Tr("points.insufficient_points_balance"), tplModelArtsTrainJobNew, &form) ctx.RenderWithErr(ctx.Tr("points.insufficient_points_balance"), tplModelArtsTrainJobNew, &form)


+ 1
- 1
services/reward/cloudbrain_deduct.go View File

@@ -29,7 +29,7 @@ func StartAndGetCloudBrainPointDeductTask(task models.Cloudbrain) (*models.Rewar
return nil, nil return nil, nil
} }


unitPrice, err := models.GetCloudbrainTaskUnitPrice(task.ID)
unitPrice, err := models.GetCloudbrainTaskUnitPrice(task)
if err != nil { if err != nil {
return nil, err return nil, err
} }


Loading…
Cancel
Save