Browse Source

提交日志显示代码,

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.10.1^2
zouap 3 years ago
parent
commit
db78cc50d7
2 changed files with 25 additions and 3 deletions
  1. +17
    -1
      routers/api/v1/repo/cloudbrain.go
  2. +8
    -2
      routers/repo/aisafety.go

+ 17
- 1
routers/api/v1/repo/cloudbrain.go View File

@@ -393,6 +393,15 @@ func ModelSafetyGetLog(ctx *context.APIContext) {
}
if job.JobType == string(models.JobTypeModelSafety) {
if job.Type == models.TypeCloudBrainOne {
result, err := cloudbrain.GetJob(job.JobID)
existStr := ""
if err == nil && result != nil {
jobRes, _ := models.ConvertToJobResultPayload(result.Payload)
taskRoles := jobRes.TaskRoles
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{}))
existStr = taskRes.TaskStatuses[0].ExitDiagnostics
}
ctx.Data["existStr"] = existStr
CloudbrainGetLog(ctx)
} else if job.Type == models.TypeCloudBrainTwo {
TrainJobForModelConvertGetLog(ctx)
@@ -487,12 +496,19 @@ func CloudbrainGetLog(ctx *context.APIContext) {
return
}
}
content := ""
if result["Content"] != nil {
content = result["Content"].(string)
}
if ctx.Data["existStr"] != nil && result["Lines"].(int) < 50 {
content = content + ctx.Data["existStr"].(string)
}
re := map[string]interface{}{
"JobID": ID,
"LogFileName": result["FileName"],
"StartLine": result["StartLine"],
"EndLine": result["EndLine"],
"Content": result["Content"],
"Content": content,
"Lines": result["Lines"],
"CanLogDownload": result["FileName"] != "",
}


+ 8
- 2
routers/repo/aisafety.go View File

@@ -853,6 +853,9 @@ func createForGPU(ctx *context.Context, jobName string) {
specId := ctx.QueryInt64("spec_id")
TrainUrl := ctx.Query("train_url")
CkptName := ctx.Query("ckpt_name")
modelName := ctx.Query("model_name")
modelVersion := ctx.Query("model_version")

ckptUrl := setting.Attachment.Minio.RealPath + TrainUrl + CkptName
log.Info("ckpt url:" + ckptUrl)
spec, err := resource.GetAndCheckSpec(ctx.User.ID, specId, models.FindSpecsOptions{
@@ -923,6 +926,9 @@ func createForGPU(ctx *context.Context, jobName string) {
BootFile: BootFile,
Params: Params,
CommitID: "",
ModelName: modelName,
ModelVersion: modelVersion,
CkptName: CkptName,
ResultPath: storage.GetMinioPath(jobName, cloudbrain.ResultPath+"/"),
Spec: spec,
LabelName: evaluationIndex,
@@ -960,9 +966,9 @@ func getGpuModelSafetyCommand(BootFile string, params string, CkptName string, D
}
}

param += " --modelname" + "=" + CkptName
param += " --ckpt_url=" + cloudbrain.ModelMountPath + "/" + CkptName

command += "python /code/" + bootFile + param + " > " + cloudbrain.ResultPath + "/" + DisplayJobName + "-" + cloudbrain.LogFile
command += "python /code/" + bootFile + param + " > " + cloudbrain.ModelMountPath + "/" + DisplayJobName + "-" + cloudbrain.LogFile

return command, nil
}


Loading…
Cancel
Save