|
@@ -636,6 +636,7 @@ func CloudBrainTrainJobShow(ctx *context.Context) { |
|
|
func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.JobType) { |
|
|
func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.JobType) { |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
debugListType := ctx.Query("debugListType") |
|
|
debugListType := ctx.Query("debugListType") |
|
|
|
|
|
cloudbrain.InitSpecialPool() |
|
|
|
|
|
|
|
|
var task *models.Cloudbrain |
|
|
var task *models.Cloudbrain |
|
|
var err error |
|
|
var err error |
|
@@ -647,22 +648,22 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("error:" + err.Error()) |
|
|
log.Info("error:" + err.Error()) |
|
|
ctx.Data["error"] = err.Error() |
|
|
|
|
|
|
|
|
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
result, err := cloudbrain.GetJob(task.JobID) |
|
|
result, err := cloudbrain.GetJob(task.JobID) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("error:" + err.Error()) |
|
|
log.Info("error:" + err.Error()) |
|
|
ctx.Data["error"] = err.Error() |
|
|
|
|
|
|
|
|
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hasSpec := false |
|
|
if task.JobType == string(models.JobTypeTrain) { |
|
|
if task.JobType == string(models.JobTypeTrain) { |
|
|
if cloudbrain.TrainResourceSpecs == nil { |
|
|
if cloudbrain.TrainResourceSpecs == nil { |
|
|
json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) |
|
|
json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) |
|
|
} |
|
|
} |
|
|
hasSpec := false |
|
|
|
|
|
|
|
|
|
|
|
for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { |
|
|
for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
hasSpec = true |
|
|
hasSpec = true |
|
@@ -670,24 +671,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !hasSpec && cloudbrain.SpecialPools != nil { |
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
|
|
|
|
if specialPool.ResourceSpec != nil { |
|
|
|
|
|
|
|
|
|
|
|
for _, spec := range specialPool.ResourceSpec { |
|
|
|
|
|
if task.ResourceSpecId == spec.Id { |
|
|
|
|
|
ctx.Data["GpuNum"] = spec.GpuNum |
|
|
|
|
|
ctx.Data["CpuNum"] = spec.CpuNum |
|
|
|
|
|
ctx.Data["MemMiB"] = spec.MemMiB |
|
|
|
|
|
ctx.Data["ShareMemMiB"] = spec.ShareMemMiB |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -697,10 +681,12 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
} |
|
|
} |
|
|
for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { |
|
|
for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
|
|
hasSpec = true |
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@@ -709,10 +695,32 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
} |
|
|
} |
|
|
for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { |
|
|
for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
|
|
hasSpec = true |
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !hasSpec && cloudbrain.SpecialPools != nil { |
|
|
|
|
|
|
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
|
|
|
|
if specialPool.ResourceSpec != nil { |
|
|
|
|
|
|
|
|
|
|
|
for _, spec := range specialPool.ResourceSpec { |
|
|
|
|
|
if task.ResourceSpecId == spec.Id { |
|
|
|
|
|
ctx.Data["GpuNum"] = spec.GpuNum |
|
|
|
|
|
ctx.Data["CpuNum"] = spec.CpuNum |
|
|
|
|
|
ctx.Data["MemMiB"] = spec.MemMiB |
|
|
|
|
|
ctx.Data["ShareMemMiB"] = spec.ShareMemMiB |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -731,14 +739,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
|
|
|
|
for _, resourceType := range specialPool.Pool { |
|
|
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if task.JobType == string(models.JobTypeInference) { |
|
|
} else if task.JobType == string(models.JobTypeInference) { |
|
|
if inferenceGpuInfos == nil { |
|
|
if inferenceGpuInfos == nil { |
|
@@ -770,6 +770,16 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if cloudbrain.SpecialPools != nil { |
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
for _, resourceType := range specialPool.Pool { |
|
|
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
taskRoles := jobRes.TaskRoles |
|
|
taskRoles := jobRes.TaskRoles |
|
|
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) |
|
|
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) |
|
|
ctx.Data["taskRes"] = taskRes |
|
|
ctx.Data["taskRes"] = taskRes |
|
@@ -895,6 +905,20 @@ func CloudBrainCommitImageShow(ctx *context.Context) { |
|
|
ctx.HTML(200, tplCloudBrainImageSubmit) |
|
|
ctx.HTML(200, tplCloudBrainImageSubmit) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func GetImage(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|
var ID = ctx.Params(":id") |
|
|
|
|
|
id, _ := strconv.ParseInt(ID, 10, 64) |
|
|
|
|
|
|
|
|
|
|
|
image, err := models.GetImageByID(id) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetImageByID failed:%v", err.Error()) |
|
|
|
|
|
ctx.JSON(http.StatusNotFound, nil) |
|
|
|
|
|
} |
|
|
|
|
|
ctx.JSON(http.StatusOK, image) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func CloudBrainImageEdit(ctx *context.Context) { |
|
|
func CloudBrainImageEdit(ctx *context.Context) { |
|
|
ctx.Data["PageIsImageEdit"] = true |
|
|
ctx.Data["PageIsImageEdit"] = true |
|
|
ctx.Data["PageFrom"] = ctx.Params(":from") |
|
|
ctx.Data["PageFrom"] = ctx.Params(":from") |
|
|